akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    int k, x;
    cin>>k>>x;

    int start = max(-1000000, x-k+1);
    int end = min(10000000, k+x-1);

    for(int i=start; i<=end; i++){
        cout<<i<<" ";
    }
}

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

using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/

#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second

#define what_is(x)     cerr << #x << " is " << x << endl;

///*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)
{
    cout << endl ;
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
int ini()
{
    int x;
    scanf("%d",&x);
    return x;
}
long long inl()
{
    long long x;
    scanf("%lld",&x);
    return x;
}

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);

int main()
{
  int a,b;

  cin>>a>>b;

  if(a>=13){
    cout<<b<<endl;
  }
  else if(a>=6 and a<=12){
    cout<<b/2<<endl;
  }
  else{
    cout<<0<<endl;
  }


    return 0;
}


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

#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;
ll const mxn = 1e5+1;
ll n;
ll dp[mxn];
ll arr[mxn];

ll solve(int pos){
    if(pos==0)return 0;
    if(pos==1)return abs(arr[1]-arr[0]);
    if(dp[pos]>-1){
        return dp[pos];
    }
    ll dif = solve(pos-2)+(abs(arr[pos]-arr[pos-2]));
    ll dif1 = solve(pos-1)+(abs(arr[pos]-arr[pos-1]));
    dp[pos] = min(dif,dif1);
    return dp[pos];
}

int main() {FIN;

    cin>>n;arr[n];
    fore(i,0,n)cin>>arr[i];
    fill(dp,-1);
    cout<<solve(n-1)<<"\n";


    return 0;
}




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

int main() {
	long long N, D;
	cin >> N >> D;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		long long X, Y;
		cin >> X >> Y;
		if (X * X + Y * Y <= D * D) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3672
#include <cstdio>
int max;
int n;
void dfs(int a,int b){
    int num=0;
 //   printf("----a=%d b=%d\n",a,b);
    while(a){
        num+=a%10;
        a/=10;
    }
  //  printf("num1==%d\n",num);
    while(b){
        num+=b%10;
        b/=10;
    }
  //  printf("num2==%d\n",num);
    if(num<max){
      max=num;
    //  printf("max=%d a=%d b=%d\n",max,a,b);
      return;
    }
    else
        return;

}
int main(){
    int n;
    while(~scanf("%d",&n)){
        max=100000;
        for(int i=1;i<=n/2+1;i++){

            dfs(i,n-i);
    }
        printf("%d\n",max);
    }
}


Measured memory_bytes: 128
class BIT:
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)
        self.bisect_K = [1 << k for k in reversed(range(N.bit_length()))]

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def bisect(self, w):
        bit, N = self.tree, self.size
        i = 0
        for k in self.bisect_K:
            if i + k <= N and bit[i + k] < w:
                i += k
                w -= bit[i]
        return i + 1

N, *A = map(int, open(0).read().split())

memo = {a: i for i, a in enumerate(sorted(set(A)), 1)}
M = len(memo)

bit = BIT(M)
for b in (memo[a] for a in A):
    s = bit.sum(b - 1)
    if s > 0:
        i = bit.bisect(s)
        bit.add(i, -1)
    bit.add(b, 1)

print(bit.sum(M))


Measured memory_bytes: 71228
n = int(input())
w = [input() for i in range(n)]
se = set()
for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
        break
    else:
        se.add(w[i])
        se.add(w[i+1])
print('Yes') if len(se) == n else print('No')

Measured memory_bytes: 3064
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

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

const int N = 5000 + 20 , mod = 1e9 + 7 ;
int n , dp[N][N] , ans ;
string s ;

inline void rel (int &a) {
	if (a >= mod) a -= mod ;
}

inline void add (int &a , int b) {
	rel(b) ;
	a += b ;
	rel(a) ;
}

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

	cin >> n ;
	cin >> s ;

	dp[0][0] = 1 ;
	for (int i = 0 ; i < n ; i ++) {
		for (int j = 0 ; j <= i ; j ++) {
			add(dp[i + 1][j + 1] , 2 * dp[i][j]) ;
			add(dp[i + 1][max(0 , j - 1)] , dp[i][j]) ;
		}
	}

	ans = dp[n][_sz(s)] ;

	for (int i = 0 ; i < _sz(s) ; i ++) ans = 1ll * ans * (mod + 1) / 2 % mod ;

	cout << ans << '\n' ;
}


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

int main(){
    int n,q;

    
    cin >>n>>q;
    vector<vector<int>> adj(n+1);
    bool visit[n+1];
    int px[n+1]={};

    for (int i = 0; i < n-1; i++){
        visit[i]=false;
        
        int a,b;
        cin>>a>>b;

        adj[a].push_back(b);
    }

    visit[n-1]=false;visit[n]=false;
    
    for (int i = 0; i < q; i++){
        int p,x;
        cin >>p>>x;
        px[p] += x;
    }
    

    queue<int> que;
    que.push(1);

    while(que.size()){
        int cur=que.front();
        visit[cur]=true;
        que.pop();

        //cout << cur<<"::"<<px[cur]<< endl;//

        for (int j = 0; j < (int)adj[cur].size(); j++){
            int nex=adj[cur][j];

            px[nex] += px[cur];

            que.push(nex);

            //cout << cur<<"--"<<nex<< endl;//
        }
        

    }


    for (int i = 1; i <= n; i++){
        cout << px[i] << " ";
    }
    std::cout << '\n';


    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

signed main(void)
{
	int k, ans;
	ll num;
	set<int> st;
	bool ok;
	cin >> k;
	num = 7;
	ans = 1;
	ok = true;
	while (num % k != 0)
	{
		ans++;
		num %= k;
		if (!st.count(num))
			st.insert(num);
		else
		{
			ok = false;
			break;
		}
		num = num * 10 + 7;
	}
	if (ok)
		cout << ans << endl;
	else
		cout << -1 << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    int x,y,z;
    cin>>x>>y>>z;
    x-=y+2*z;
    cout<<x/(y+z)+1<<endl;
    return 0;
}

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

typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n), es(n), os(n);
    
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    es[0]=os[0]=a[0];
    ll ecnt=0, ocnt=0;
    // 偶数番目を+,奇数番目を-にする
    for(int i=0; i<n; i++){
        if(i!=0) es[i] = es[i-1]+a[i];
        if(i%2==0 && es[i]<=0){
            ecnt += abs(1-es[i]);
            es[i] = 1;
        }
        else if(i%2!=0 && es[i]>=0){
            ecnt += abs(-1-es[i]);
            es[i] = -1;
        }
    }
    // 偶数番目を-,奇数番目を+にする
    for(int i=0; i<n; i++){
        if(i!=0) os[i] = os[i-1]+a[i];
        if(i%2==0 && os[i]>=0){
            ocnt += abs(-1-os[i]);
            os[i] = -1;
        }
        else if(i%2!=0 && os[i]<=0){
            ocnt += abs(1-os[i]);
            os[i] = 1;
        }
    }
    
    cout << (ecnt<ocnt?ecnt:ocnt) << endl;
}


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

using std::cin;
using std::cout;
using std::endl;

int factorial(int n)
{
  int fact = 1;
  for (int i = n; i > 0;i--) fact *= i;
  return fact;
}


void count_order()
{
  int n;
  cin >> n;

  std::vector<int> p(n);
  std::vector<int> q(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int i = 0; i < n; i++) cin >> q[i];


  int p_cnt = 0, q_cnt = 0;
  for (int i = 0; i < n; i++)
  {
    p_cnt += (p[i]-1) * factorial(n - 1 - i);
    for (int j = i + 1; j < n; j++) {
      if (p[j] > p[i]) p[j]--;
    }
  }
  for (int i = 0; i < n; i++)
  {
    q_cnt += (q[i] - 1) * factorial(n - 1 - i);
    for (int j = i + 1; j < n; j++) {
      if (q[j] > q[i]) q[j]--;
    }
  }
  cout << std::abs(p_cnt - q_cnt);
}


void welcome_atcoder()
{
  int n, m;
  cin >> n >> m;
  int pena = 0;
  std::vector<int> ac(n + 1, 0);//インデックスを無理やりpに合わせた
  std::vector<int> wa(n + 1, 0);

  for (int i = 0; i < m; i++) 
  {
    int p; 
    std::string s;
    cin >> p >> s;

    if (s == "WA") wa[p]++;
    if (ac[p] == 1) continue;
    if (ac[p] == 0 && s == "AC")
    {
      ac[p] = 1;
      pena += wa[p];
    }
  }

  int ans = 0;
  for (int i = 0; i < n + 1; i++) if (ac[i] == 1) ans++;
  cout << ans << " " << pena << endl;
}


void low_elements()
{
  int n;
  cin >> n;
  std::vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i]; 
  int min = 1000000;
  int cnt = 0;

  for (int i = 0; i < n; i++)
  {
    if (p[i] < min)
    {
      cnt++;
      min = p[i];
    }
  }
  cout << cnt << endl;
}


void fennec_vs_monster()
{
  int n, k;
  cin >> n >> k;
  std::vector<long> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];

  std::sort(h.begin(), h.end());
  long long int sum = 0;
  for (int i = 0; i < n - k; i++) sum += h[i];
  cout << sum << endl;
}
int main() 
{
  //count_order();
  //welcome_atcoder();
  //low_elements();
  fennec_vs_monster();
}

Measured memory_bytes: 1792
#include <iostream>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int a,b,c;
  cin >> a;
  cin >> b;
  cin >> c;
  if(a-b>=c)
  {
    cout << 0;
  }
  else
  {
    cout << (c - a + b);
  }
  return 0;
}


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

int main()
{
	int n;
	string s;

	cin >> n;
	cin >> s;
	if (n % 2 != 0) {
		cout << "No" << endl;
	}
	else
	{
		if (s.substr(0, n / 2) == s.substr(n / 2, n / 2)) {
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int N;

int main() {
  cin >> N;
  if (N % 1000 == 0)
    cout << "0" << endl;
  else
    cout << 1000 - (N % 1000) << endl;

  return 0;
}


Measured memory_bytes: 3632
order = [int(input()) for _ in range(5)]
min_digit = 9
time = 0
for i in range(len(order)):
  if order[i]%10!=0:
    time+=(order[i]//10+1)*10
  else:
    time+=order[i]

for i in range(len(order)):
  digit = order[i]%10
  if min_digit>=digit and digit!=0:
    min_digit=digit
    
order_digit = [i%10 for i in order]
if order_digit == [0,0,0,0,0]:
  print (time)
else:
  print (time-10+min_digit)

Measured memory_bytes: 3064
#include <cstdlib>
#include <iterator>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <functional>
using namespace std;

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

    int ans = 0;
    for(int i = 0; s[i]; i++) {
        if(s[i] == '1') ans++;
    }
    cout << ans << endl;
}


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

const int N = (int) 5e5 + 5;

int n, q;
char s[N];
int fw[N][26];

void upd(int id, int i, int v) {
	for (; i <= n; i += i & -i) fw[i][id] += v;
}

int get(int l, int r) {
	int cnt[26];
	for (int id = 0; id < 26; id++) cnt[id] = 0;
	for (int id = 0; id < 26; id++) 
		for (int j = r; j >= 1; j -= j & -j) cnt[id] += fw[j][id];
	for (int id = 0; id < 26; id++)
		for (int j = l; j >= 1; j -= j & -j) cnt[id] -= fw[j][id];
	int res = 0;
	for (int id = 0; id < 26; id++) res += (cnt[id] > 0);		
	return res;
}

int main() {
	ios_base :: sync_with_stdio(false); cin.tie(NULL);
	cin >> n;
	cin >> s + 1;
	for (int i = 1; i <= n; i++) {
		upd(s[i] - 'a', i, 1);
	}
	cin >> q;
	for (int i = 1; i <= q; i++) {
		int t; cin >> t;
		if (t == 1) {
			int j; char c; cin >> j >> c;
			upd(s[j] - 'a', j, -1);
			s[j] = c;
			upd(s[j] - 'a', j, +1);
		} else {
			int l, r; cin >> l >> r;
			cout << get(l - 1, r) << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 51584
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <stack>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    string s;
    while(cin>>s && s!="."){
        int n=s.size();
        string t;
        rep(i,n){
            if(s[i]=='+'||s[i]=='-'||s[i]=='?'){
                int d=0;
                int j=i;
                for(; !isalpha(s[j]) && s[j]!='?'; j++){
                    if(s[j]=='+') d++;
                    else d--;
                }
                i=j;
                if(s[j]=='?'){
                    t.push_back('A');
                }else{
                    int x=s[j]-'A'+2600;
                    x+=d;
                    x%=26;
                    t.push_back('A'+x);
                }
            }else{
                t.push_back(s[i]);
            }
        }
        int m=t.size();
        stack<int> st;
        rep(i,m){
            if(t[i]=='[') st.push(i);
            else if(t[i]==']'){
                int l=st.top(); st.pop();
                reverse(t.begin()+l,t.begin()+i+1);
                t[l]=' ';
                t[i]=' ';
            }
        }
        rep(i,t.size()){
            if(isalpha(t[i])) cout<<t[i];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1192
// 挿入ソートアルゴリズム

#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;


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

    int N;
    cin >> N;
    int array[N];
    REP(i,N){
        cin >> array[i];
    }
     REP(k,N){
            cout << array[k];
            if(k != N-1) cout << " ";
        }
        cout << endl;

    REPP(i,1,N){
        int tmpArray = array[i];
        int j = i-1;
        while(j >= 0 && tmpArray < array[j]){
            array[j+1] = array[j];
            j--;
        }
        array[j+1] = tmpArray;

        //アルゴリズム確認の表示用
        REP(k,N){
            cout << array[k];
            if(k != N-1) cout << " ";
        }
        cout << endl;
    }

    return 0;
}


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

using namespace std;

int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}

int main()
{
   int a, X;
   a = 360;
   cin >> X;
   int b = lcm(a, X);
   int k = b / X;

   cout << k << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

// 最大公約数
ll gcd(ll a, ll b)
{
   if (a%b == 0) {
       return(b);
   } else {
       return(gcd(b, a%b));
   }
}

// 最小公倍数
ll lcm(ll a, ll b){
   return a * b / gcd(a, b);
}

void solve() {
    ll n, m; cin >> n >> m;
    Vl x(m);
    rep(i, 0, m) cin >> x[i];
    sort(ALL(x));
    Vl dis(m-1);
    rep(i, 0, m-1) dis[i] = x[i+1] - x[i];
    sort(ALL(dis), greater<ll>());
    ll ans = 0;
    rep(i, n-1, m-1) ans += dis[i];
    cout << ans << endl;
}

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

    solve();
    return 0;
}

Measured memory_bytes: 1792
X,Y,Z,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
ans=[]
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1)>K:
                break
            else:
                ans.append(A[i]+B[j]+C[k])
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Measured memory_bytes: 8708
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int n, a[100001];
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	sort(a, a+n);
	if(a[n-1]-a[0]>1){
		printf("%s\n", "No");
	}else if(a[n-1]-a[0]==1){
		int k=0;
		for(int i=0; i<n; i++){
			if(a[i]==a[0]) k++;
		}
		if(n-a[n-1]+1<=n-k && n-k<=2*(n-a[n-1])){
			printf("%s\n", "Yes");
		}else{
			printf("%s\n", "No");
		}
	}else{
		if(2*a[0]<=n || a[0]==n-1){
			printf("%s\n", "Yes");
		}else{
			printf("%s\n", "No");
		}
	}
	return 0;
}

Measured memory_bytes: 512
Mod = 10**9+7
X, Y = map(int, input().split())
ans1 = (2*X-Y)//3
ans2 = (2*Y-X)//3
if (2*X-Y)%3!=0 or (2*Y-X)%3!=0:
  print(0)
  exit()
fac = [1, 1]
finv = [1, 1]
inv = [0, 1]
def COMinit():
    for i in range(2, ans1+ans2+111):
        fac.append(fac[-1]*i%Mod)
        inv.append((-inv[Mod%i] * (Mod//i)) % Mod)
        finv.append(finv[-1] * inv[-1] % Mod)
    

def COM(n, k):
    if n < 0 or k < 0 or n < k:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % Mod) % Mod

COMinit()
print(COM(ans1+ans2, ans1))



Measured memory_bytes: 82244
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

void rsortr_u32(void *base, const int count){
	uint32_t *a=base;
	uint32_t *b=malloc(count*sizeof(uint32_t));
	int c[0x100];
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(0<<3))&0xFF]++; } for(int i=0xFE; i>=0; i--) c[i]+=c[i+1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(0<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(1<<3))&0xFF]++; } for(int i=0xFE; i>=0; i--) c[i]+=c[i+1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(1<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(2<<3))&0xFF]++; } for(int i=0xFE; i>=0; i--) c[i]+=c[i+1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(2<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(3<<3))&0xFF]++; } for(int i=0xFE; i>=0; i--) c[i]+=c[i+1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(3<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	free(b);
}

int a[1000];
int b[1000];
int bs(int *a, int s, int k){
	int l=0, r=s-1;
	while(l<=r){
		int m=(l+r)/2;
		if(a[m]<k) r=m-1; else l=m+1;
	}
	return l;
}

#define P 1000000007

int main(void){
	int n=nextint();
	int m=nextint();
	for(int i=0; i<n; i++){
		a[i]=nextint();
	}
	for(int j=0; j<m; j++){
		b[j]=nextint();
	}
	rsortr_u32(a, n);
	rsortr_u32(b, m);
	for(int i=0; i<n-1; i++){
		if(a[i]==a[i+1]){
			puts("0");
			return 0;
		}
	}
	for(int j=0; j<m-1; j++){
		if(b[j]==b[j+1]){
			puts("0");
			return 0;
		}
	}
	long ans=1;
	for(int x=m*n; x>0; x--){
		int i=bs(a, n, x);
		int j=bs(b, m, x);
		if(a[i-1]==x && b[j-1]==x){
		}else if(i>0 && a[i-1]==x){
			ans=ans*j%P;
		}else if(j>0 && b[j-1]==x){
			ans=ans*i%P;
		}else{
			ans=ans*(i*j-n*m+x)%P;
		}
	}
	printf("%ld\n", ans);
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(int argc, char const *argv[]) {
	int a, b; cin >> a >> b;
	printf("%d\n", a - 1 + ((a <= b) ? 1 : 0));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int X, Y, Z;
	cin >> X >> Y >> Z;

	pair<int, int> BA[100000];
	int CA[100000];
	int CB[100000];

	ll goukeiA = 0;
	rep(i, X + Y + Z) {
		int a, b, c;
		cin >> a >> b >> c;
		BA[i] = mp(b - a, i);
		CA[i] = c - a;
		CB[i] = c - b;
		goukeiA += a;
	}

	sort(BA, BA + X + Y + Z);

	ll C[100000] = {};
	multiset<int> MS;
	rep(i, X) {
		MS.insert(CA[BA[i].second]);
	}
	rep(i, Z) {
		MS.insert(CA[BA[X + i].second]);
		C[i + 1] = C[i] + *(--MS.end());
		MS.erase(--MS.end());
	}

	MS.clear();
	reverse(BA, BA + X + Y + Z);
	ll B[100000] = {};
	rep(i, Y) {
		B[0] += BA[i].first;
		MS.insert(CB[BA[i].second]);
	}
	rep(i, Z) {
		MS.insert(CB[BA[Y + i].second]);
		B[i + 1] = B[i] + BA[Y + i].first + *(--MS.end());
		MS.erase(--MS.end());
	}

	ll saidai = 0;
	rep(i, Z + 1) saidai = max(saidai, goukeiA + B[i] + C[Z - i]);

	co(saidai);

	Would you please return 0;
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int n, num[105];
    while(cin >> n){
        rep(i,n){
            cin >> num[i];
        }
        for(int i = n - 1; i >= 0; i--){
            if(i != n - 1) cout << ' ';
             cout << num[i];
        }
        cout << endl;
    }
}



Measured memory_bytes: 3100
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int K = sc.nextInt();
    int ans = 0;
    for(int a=1;a<=K;a++){
      for(int b=1;b<=K;b++){
        for(int c=1;c<=K;c++){
          ans=ans+gcd(gcd(a,b),c);
        }
      }
    }
    System.out.println(ans);
    }
    

  //最大公約数・最小公倍数（セットで使う）
  static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
  static int lcm (int a, int b) {return a*b/gcd(a,b);}
  
}


Measured memory_bytes: 35888
#include <stdio.h>

int main(void)
{
	long i, n,max,min,sum;
	scanf("%d",&n);
	
	long a[10000];
	
	for ( i = 0; i < n ; i++ )
	{
		scanf("%ld",&a[i]);
	}
	max=-1000000;
	min=1000000;
	sum=0;

//max????????????
	for ( i = 0; i < n ; i++ )
	{
		if(a[i]>=max)
		{
			max=a[i];
		}
	}
	
//min????????????
	for ( i = 0; i < n ; i++ )
	{
		if(a[i]<=min)
		{
			min=a[i];
		}
	}
//sum????????????
	for ( i = 0; i < n ; i++ )
	{
		sum+=a[i];
	}

printf("%ld %ld %ld\n",min,max,sum);

	return 0;
}

Measured memory_bytes: 676
import sys
readline = sys.stdin.readline

def main():
    D, G = map(int, readline().rstrip().split())
    G //= 100
    PC = [tuple(map(int, readline().rstrip().split())) for _ in range(D)]
    ans = 10 ** 4
    for i in range(2**D):
        b = bin(i)[2:].zfill(D)
        score = 0
        cost = 0
        for i, e in enumerate(b):
            if e == '1':
                score += PC[i][0] * (i+1) + PC[i][1] // 100
                cost += PC[i][0]
        
        if '0' in b:
            m = D - b[::-1].index('0') - 1
            for _ in range(PC[m][0]-1):
                if score >= G:
                    break
                score += m + 1
                cost += 1
        
        if score >= G:
            ans = min(ans, cost)
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
from collections import deque
import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
table = [[] for i in range(N)]
for i in range(N-1):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  table[a].append(b)
task = [0]*N
count = [0]*N
for i in range(Q):
  p,x = map(int,input().split())
  p -= 1
  task[p] += x
H = deque()
H.append(0)
while H:
  y = H.popleft()
  count[y] += task[y]
  for ny in table[y]:
    H.append(ny)
    count[ny] = count[y]
print(" ".join(map(str,count)))
    

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

int main() {
	string A,B,C;
    cin >> A >> B >> C;
    int a = A.size()-1;
    int b = B.size()-1;
    if(A.at(a) == B.at(0) && B.at(b) == C.at(0)){
      cout << "YES" << endl;
    }
    else{
      cout << "NO" << endl;
    }
}


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


int main(void) {
    using namespace std;

    long n;
    cin >> n;
    vector<long> a(n);
    for(auto &x: a) cin >> x;

    long r = 0;
    long l = n-1;
    for(int i=n-1; i>=0; i--) {
        if(a[i] == max(0l, i-l))
            continue;
        if(a[i] < max(0l, i-l) || a[i] > i) {
            cout << -1 << endl;
            return 0;
        }

        r += a[i];
        l = i - a[i];
    }
    cout << r << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int maxn=100;
char s[2];
int n;
int main()
{
    scanf("%d",&n);
    bool flag=0;
    for(int i=1;i<=n;++i)
    {
        scanf("%s",s);
        if(s[0]=='Y') flag=1;
    }
    if(!flag) printf("Three");else printf("Four");
}


Measured memory_bytes: 256
x_1, y_1, x_2, y_2 = gets.chomp.split.map(&:to_i)
dx = x_2 - x_1
dy = y_2 - y_1
x_3 = x_2 - dy
y_3 = y_2 + dx
x_4 = x_3 - dx
y_4 = y_3 - dy
print "#{x_3} #{y_3} #{x_4} #{y_4}\n"


Measured memory_bytes: 3836
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<time.h>
#include<vector>
#define ll long long
using namespace std;

int n;
int main()
{
    cin >> n;
    if(n>=30)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(ll i = 0; i < (ll)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(ll i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
//const ll MOD = 998244353ll;
const dou pi=3.141592653589793*2;

int main(){
    int n;
    std::cin >> n;
    string s,t;
    std::cin >> s>>t;
    rep(i,n){
        if(s.substr(i,n-i)==t.substr(0,n-i)){
            std::cout << 2*n-(n-i) << std::endl;
            exit(0);
        }
    }
    std::cout << 2*n << std::endl;
}

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

int main() {
  string s;
  cin >> s;
  ll q;
  cin >> q;
  int count = 0;
  for(ll i = 0; i < q; i++) {
    int t;
    cin >> t;
    if(t==1) count++;
    if(t==2) {
      int f;
      cin >> f;
      char c;
      cin >> c;
      if(((f==1)&&(count%2==0)) || ((f==2)&&(count%2==1))) {
        string u;
        u.push_back(c);
        s.insert(0, u);
      }
      if(((f==2)&&(count%2==0)) || ((f==1)&&(count%2==1))) s.push_back(c);
    }
  }
  if(count%2==0) cout << s << endl;
  else {
    reverse(s.begin(), s.end());
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 900
#include<stdio.h>

//线性搜索
int search(int A[],int n, int key)
{
	int i = 0;
	A[n] = key;//key为另一数组的元素
	while (A[i] != key) i++;
	return i != n;//判断是否结尾，不结尾返回真
}
int main()
{
	int i, n, A[10001], q, key, sum = 0;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", & A[i]);

	scanf("%d", &q);
	for (i = 0; i < q; i++)
	{
		scanf("%d", &key);
		if (search(A, n, key)) sum++;
	}
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 2112
import java.util.Scanner;

public class Main {

	static final boolean debugMode = false;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = readInt(sc);
		int b = readInt(sc);
		int c = readInt(sc);

		System.out.println(c + " " + a + " " + b);

	}

	static int readInt(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	static void log(String s) {
		if (debugMode) {
			System.out.println(s);
		}
		return;
	}
}

class Pair {
	private int x;
	private int y;

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public Pair() {

	}

	public Pair(int x, int y) {
		this.x = x;
		this.y = y;
	}

}

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

int main(){
    int a,b,c,x;
    int cnt = 0;
    cin >> a >> b >> c >> x;
    rep(i,a+1)rep(j,b+1)rep(k,c+1){
        if((i * 500 + j * 100 + k * 50) == x) cnt++;
    }
    cout << cnt << endl;
}


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

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

int main() {
  int n, k, disp = 1;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    disp = min(disp*2, disp+k);
  }
  cout << disp << endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
base = 127
mask = (1 << 32) - 1
def calc_hash(f, pl, tl):
    dl = tl - pl
    tmp = set()
    t = 1
    for _ in range(pl):
        t = (t * base) & mask
    e = 0
    for i in range(pl):
        e = (e * base + f[i]) & mask
    for i in range(dl):
        tmp.add(e)
        e = (e * base - t * f[i] + f[i + pl]) & mask
    tmp.add(e)
    return tmp
t = tuple(ord(c) for c in input())
tl = len(t)
q = int(input())
h = dict()
c = dict()
a = []
for _ in range(q):
    p = readline().strip()
    if p in c:
        a.append(c[p])
        continue
    p = tuple(ord(c) for c in p)
    pl = len(p)
    if pl > tl:
        a.append(0)
        continue
    bs = min(19, pl)
    keys = calc_hash(p, bs, pl)
    if bs not in h:
        h[bs] = calc_hash(t, bs, tl)
    a.append(1 if keys.issubset(h[bs]) else 0)
print('\n'.join(map(str, a)))



Measured memory_bytes: 1073696
n = int(input())
btc = 380000.0
a = 0
# 単位毎に加算する。
for _ in range(n):
    x, u = input().split()
    if u == 'JPY':
        a += int(x)
    elif u == 'BTC':
        a += float(x)*btc
print(a)


Measured memory_bytes: 9112
n = int(input())
a = [-1]+list(map(int, input().split()))
cnt = n//2
b = [-1]+[0] *(n//2)+a[n//2+1:]

for i in reversed(range(1,n//2+1)):
    b[i] = abs((sum([b[i*j] for j in range(2,n//i+1)])%2) - a[i])

m = len([b[i] for i in range(n+1) if b[i] == 1])
bb = list(map(str,[i for i in range(n+1) if b[i] == 1]))
print(m)
print(" ".join(bb))

Measured memory_bytes: 20140
import sys 
sys.setrecursionlimit(10**8)

def dfs(i,sum,count,nokori):
  global ans
  if i==d:
    if sum<g:
      use=max(nokori)
      n=min(pc[use-1][0],-(-(g-sum)//(100*use)))
      count +=n
      sum +=n*100*use

    if sum>=g:
      ans=min(ans,count)

  else:
    dfs(i+1,sum,count,nokori)
    dfs(i+1,sum+pc[i][0]*100*(i+1)+pc[i][1],count+pc[i][0],nokori-{i+1})

d,g=map(int,input().split())
pc=[list(map(int,input().split())) for i in range(d)]
ans=float('inf')

dfs(0,0,0,set(range(1,d+1)))

print(ans)  

Measured memory_bytes: 3064
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <cmath>         // sqrt
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
typedef tuple<ll, ll, string> Tlls;

// Greatest Common Divisor (最大公約数)
ll gcd(ll a, ll b)
{
  // Eucledean algorithm
  while (a)
  {
    if (a < b)
    {
      std::swap(a, b);
    }
    a %= b;
  }
  return b;
}

// Least Common Multiple 最小公倍数
ll lcm(ll a, ll b)
{
  return a / gcd(a, b) * b;
}

// key: value of prime factor素因数分解
// value: number of prime factor
map<ll, ll> prime_factorization(ll n)
{
  map<ll, ll> prime_factors;
  for (ll i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      prime_factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    prime_factors[n] = 1;
  return prime_factors;
}

// 約数リスト約数の列挙
vector<ll> get_divisors(const ll n)
{
  vector<ll> divs;
  for (ll i = 1; i < (ll)sqrt((ld)n) + 1; i++)
  {
    if (n % i == 0)
    {
      divs.push_back(i);
      if (i != n / i)
      {
        divs.push_back(n / i);
      }
    }
  }

  // 必要に応じてソート
  // sort(divs.begin(), divs.end());

  return divs;
}

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

int main()
{
  ll N, K;
  // int INF = 100000000;
  cin >> N >> K;
  const long long INF = 1LL << 60;

  // 入力
  // int N;
  // long long h[110000];

  // DP テーブル
  // long long dp[110000];

  // for (int i = 0; i < N; ++i)
  //   cin >> h[i];

  // 初期化 (最小化問題なので INF に初期化)
  // for (int i = 0; i < 110000; ++i)
  //   dp[i] = INF;
  vector<ll> h(N + K + 1);
  vector<ll> dp(N + K + 1, INF);
  rep(i, N)
  {
    cin >> h.at(i);
  }
  dp[0] = 0;
  for (int i = 0; i < N; ++i)
  {
    for (int j = 1; j <= K; ++j)
    {
      chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }
  }
  // 答え
  cout << dp[N - 1] << endl;
  return 0;
}


Measured memory_bytes: 1792
import numpy as np,math,itertools

n,m,x,y=map(int,input().split())

xs=list(map(int,input().split()))
ys=list(map(int,input().split()))
rs=False

for i in range(-100,100):
   if not x<i<=y:continue
   if all([I<i for I in xs])and all([I>=i for I in ys]):rs=True;break

print(["War","No War"][int(rs)])

Measured memory_bytes: 12504
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
using namespace std;
typedef pair<int,int>p;
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
vector<long long> divisor(long long n) {
	vector< long long> ret;
	for (long long i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return (ret);
}
long long mod = 1e9 + 7;
vector<int> graph[100004];
int used[100005] = { 0 };
void dfs(int now) {
	used[now] = 1;
	for (int i = 0; i < graph[now].size(); i++) {
		int to = graph[now][i];
		if (used[to] == 0) {
			used[to] = 1;
			dfs(to);
		}
	}
}
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout <<fixed<< setprecision(16);
	int m, k;
	cin >> m >> k;
	if (k >=(1<<m) || (m == 1 && k == 1)) {
		cout << -1;
		return 0;
	}
	if (k == 0) {
		for (int i = 0; i < (1 << m); i++) {
			cout << i << " " << i;
			if (i != (1 << m) - 1)cout << " ";
		}
	}
	else {
		for (int i = 0; i < (1 << m); i++) {
			if (i != k) {
				cout << i << " ";
			}
		}
		cout << k << " ";
		for (int i = (1 << m) - 1; i >= 0; i--) {
			if (i != k)cout << i << " ";
		}
		cout << k;
	}
}

Measured memory_bytes: 4224
n=int(input())
happy=list(map(int,input().split(' ')))
for i in range(1,n):
    h=list(map(int,input().split(' ')))
    x=max(happy[1]+h[0],happy[2]+h[0])
    y=max(happy[2]+h[1],happy[0]+h[1])
    z=max(happy[0]+h[2],happy[1]+h[2])
    happy=[x,y,z]
print(max(happy))

Measured memory_bytes: 47960
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;

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

signed main() {
    int h, w, k;
    cin >> h >> w >> k;

    vector<string> vs;

    rep(i, h) {
        string s;
        cin >> s;

        vs.push_back(s);
    }

    int ans = 0;

    rep(xh, 1 << h) {
        rep(xw, 1 << w) {
            int res = 0;
            rep(i, h) {
                rep(j, w) {
                    if ((xh >> i & 1) == 0 && (xw >> j & 1) == 0 && vs[i][j] == '#') {
                        res += 1;
                    }
                }
            }

            if (res == k) ++ans;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 3124
def gen_ordinary_lists(n):
    up_lis = list(range(1, n * 20001, 20001))
    return up_lis, up_lis[::-1]


def argsort(lis):
    tpls = [(l, i) for i, l in enumerate(lis)]
    return sorted(tpls)


def solve(N, lis):
    up_list, down_list = gen_ordinary_lists(N)
    arg_tpls = argsort(lis)
    for val, idx in arg_tpls:
        up_list[val - 1] += idx
    print(*up_list)
    print(*down_list)
    

N = int(input())
lis = list(map(int, input().split()))

solve(N, lis)

Measured memory_bytes: 8440
import kotlin.math.*
import java.util.*

fun main(args: Array<String>) {
  var (a, b, c, k) = readLine()!!.split(' ').map(String::toInt)
  var x = min(k, a)
  k -= a + b
  if (0 < k) {
    x -= min(k, c)
  }
  println(x)
}


Measured memory_bytes: 36312
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll N;
    ll M;
    cin >> N >> M;
    ll A[N];
    for(ll i = 0; i < N; i++){
        cin >> A[i];
    }
    ll B[N + 1];
    B[0] = 0;
    for(ll i = 1; i <= N; i++){
        B[i] = (B[i - 1] + A[i - 1]) % M;
    }
    map<ll,ll> bucket = map<ll,ll>();
    for(ll i = 0; i <= N; i++){
        ll m = B[i];

        if(bucket.count(m) == 0){
            bucket[m] = 0;
        }
        bucket[m] += 1;
    }
    ll count = 0;
    auto begin = bucket.begin(), end = bucket.end();
    for (auto iter = begin; iter != end; iter++) {
        // first: key, second: value
        ll k = iter ->second;
        count += k * (k - 1) / 2;
    }
    cout << count << endl;
}


Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int frek[100001] = {0};
    int n;
    long long sum = 0;
    cin >> n;
    for (int i = 0 , a ; i < n ; i++)
        cin >> a, sum += a ,
        frek[a]++;
    int Q;
    cin >> Q;
    for (int i = 0 , prev , to ; i < Q ; i++){
        cin >> prev >> to;
        sum += (to - prev) * (long long)frek[prev];
        frek[to] += frek[prev];
        frek[prev] = 0;
        cout << sum << endl;
    }

}


Measured memory_bytes: 4032
/**< Winter is Coming - Game Of Thrones */
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = 1e9 + 7;
const ll mode = 1e6 + 3;

ll min(ll a, ll b)
{
    if(a > b) return b;
    else return a;
}
ll min_third(ll a, ll b ,ll c)
{
    return min(min(a,b),c);
}
ll GCD(ll A, ll B) {
    if(B == 0)
        return A;
    else
        return GCD(B, A % B);
}

ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
int fun(int x, int y)
{
    return x*y;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll a = 0,b = 0,c = 0;cin >> a >> b >> c;
    if((a+b+c) >= 22) cout << "bust";
    else cout << "win";


    return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF= 1e20;

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);

int main() {
	LL n;
	cin >> n;
	if (isEven(n)) {
		COUT(n);
	}
	else {
		COUT(n * 2);
	}
	return 0;
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string ans;
    rep(i, tx-sx)ans+="R";
    rep(i, ty-sy)ans+="U";
    rep(i, tx-sx)ans+="L";
    rep(i, ty-sy)ans+="D";
    ans+="D";
    rep(i, tx-sx)ans+="R";
    ans+="RU";
    rep(i, ty-sy)ans+="U";
    ans+="LU";
    rep(i, tx-sx)ans+="L";
    ans+="LD";
    rep(i, ty-sy)ans+="D";
    ans+="R";
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
        int n,a[3000],i,s=0;
        scanf("%d",&n);
        for(i=0;i<n;i++){
                scanf("%d",&a[i]);
                s+=a[i];
        }
        printf("%d\n",s-n);
        return 0;
}


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

using namespace std;

int n, m;

int main()
{
    cin>>n>>m;
    int k = 0;
    for (int i=1;i<=m;i++)
    {
        int x; cin>>x;
        k+=x;
    }
    if (k>n) cout<<-1; else cout<<n - k;
    return 0;
}


Measured memory_bytes: 3580
#include<stdio.h>

int main()

{

    int A,N,i,temp;

    scanf("%d %d",&A,&N);

    temp = A;

    if(N>0)
    {
        while(temp>500)
        {
            temp = temp - 500;
        }

        if(temp<=N)
        {

            printf("Yes\n");

        }

        else
        {

            printf("No\n");

        }
    }

    else
    {
       if(temp%500==0)
       {
          printf("Yes\n");
       }

       else
       {
          printf("No\n");
       }
    }

    return 0;

}


Measured memory_bytes: 1624