akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		int max = Math.max(a + b, a - b);
		max = Math.max(max, a * b);

		System.out.println(max);
	}
}


Measured memory_bytes: 23892
function Main(input) {
  input = input.split('\n').map(num => Number(num));
  payment = input[0];
  sheets = input[1];
  if (payment % 500 <= sheets) {
    console.log('Yes');
  } else {
    console.log('No');
  }
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <cstdio>

const int N = 200000 + 10;

int n, p[N], q[N], t[N], f[N];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &p[i]), q[p[i]] = i;
  for (int i = n - 1; i > 0; --i) {
    if (t[i + 1]) {
      int cnt = (q[f[i + 1]] < q[i]) + (q[i] < q[i + 1]) + (q[i + 1] < q[f[i + 1]]);
      if (cnt == 2) {
        t[i] = t[i + 1];
        f[i] = f[i + 1];
      } else {
        t[i] = t[i + 1] + 1;
        f[i] = i + 1;
      }
    } else if (q[i] > q[i + 1]) {
      t[i] = 1;
      f[i] = i + 1;
    }
  }
  printf("%d\n", t[1]);
  return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;


public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int n=sc.nextInt();
		int c[]=new int[n];
		int v[]=new int[n];
		int total=0;
		for(int i=0;i<n;++i){
			v[i]=sc.nextInt();
		}

		for(int i=0;i<n;++i){
			c[i]=sc.nextInt();
			if(v[i]>=c[i])total=total+v[i]-c[i];
		}



		System.out.println(total);
	}
}

Measured memory_bytes: 23124
t = int(input())
for i in range(t):
    n, k = map(int, input().split())
    position_array = list(map(int, input().split()))

    # ??????????????????????????£????£?????????¢??????????????????
    distance_array = []
    for j in range(n-1):
        distance_array.append(position_array[j+1] - position_array[j])

    # ??????????????????
    distance_array.sort(reverse=True)
    print(sum(distance_array[k-1:])) # ?????§??????k-1????????????????¨?

Measured memory_bytes: 23208
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int n,d[200100],t[200100],m;
int main(){
    cin >> n;
    for(int i=0;i<n;i++) cin >> d[i];
    cin >> m;
    for(int i=0;i<m;i++) cin >> t[i];
    sort(d,d+n);
    sort(t,t+m);
    int l = 0, r = 0;
    int cnt = 0;
    while(l<n && r<m){
        if(d[l]==t[r]){
            cnt++;
            l++, r++;
        }
        else if(d[l]>t[r]){
            r++;
        }
        else {
            l++;
        }
    }
    if(cnt==m){
        printf("YES\n");
    }
    else printf("NO\n");

    return 0;
}


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

int main() {
  int n,x,y;
  cin>>n>>x>>y;

  int ans[n];
  ans[0]=0;
  for(int i=1; i<n; i++) ans[i]=0;

  // cout<<"OK"<<endl;

  for(int i=1; i<n; i++) {
    for(int j=i+1; j<=n; j++) {
      if(i<=x) {
        if(j<=x) ans[j-i]++;
        else if(y<=j) ans[j-i+1+x-y]++;
        else {
          int m = min(j-i, x+y+1-i-j);
          ans[m]++;
        }
      }

      else if(i<y) {
        if(j<=y) {
          int m = min(j-i, i-j+1-x+y);
          ans[m]++;
        }
        else {
          int m = min(j-i, i+j+1-x-y);
          ans[m]++;
        }
      }

      else {
        ans[j-i]++;
      }
    }
  }

  for(int i=1; i<n; i++) cout<<ans[i]<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

#define for1(n) for (int i = 0 ; i < n ; i++)
#define for2(n) for (int j = 0 ; j < n ; j++)
#define for3(n) for (int k = 0 ; k < n ; k++)
#define for4(n) for (int l = 0 ; l < n ; l++)
#define forl(n) for (ll i = 0 ; i < n ; i++)

int main() {
    ios::sync_with_stdio(false);
 	int n;
 	cin >> n;
 	int a[n];
 	for1(n) cin >> a[i];
 	sort(a, a + n);
 	cout << a[n - 1] - a[0];
}

Measured memory_bytes: 3640
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main(){
	double r;
	cin >> r;

	double area = r * r * M_PI;
	double circle = 2 * r * M_PI;

	printf("%lf %lf", area, circle);

}

Measured memory_bytes: 1232
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n, h, w;
	scanf("%d %d %d", &n, &h, &w);
	printf("%d\n", (n-h+1)*(n-w+1));
	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=[]
b=[]
c=[]
for i in range(n):
    A,B=map(int,input().split())
    a.append(A)
    b.append(B)
c=list(zip(a,b))
c.sort()
a,b=zip(*c)
a=list(a)
b=list(b)
#sprint(a,b)
M=m
for i in range(n):
    if m>=0:
        m=m-b[i]
        #print(i)
        I=i
    else:
        b[i]=0

#print(b)
b[I]=b[I]-(sum(b)-M)
#print(b)

ans=0
for i in range(n):
    ans+=a[i]*b[i]

print(ans)



Measured memory_bytes: 26888
#coding:utf-8

n = int(input())

dic = {}
for _ in range(n):
    key = input()
    if key in dic:
        dic[key] += 1
    else:
        dic[key] = 1
        

max_v = max(dic.values())
li = []


for key in dic:
    if max_v == dic[key]:
        li.append(key)
        
li = sorted(li)
for v in li:
    print(v)

Measured memory_bytes: 32988
public class Main {
    public static void main(String[] args) {

         java.util.Scanner sc = new java.util.Scanner(System.in);
        String s = sc.next();
        String p = sc.next();

         boolean tf = false;
        String x = "";
        for (int i = 0; i < s.length(); i ++) {
            x = "";
            for (int j = 0; j < p.length(); j ++) { x += s.charAt((i + j) % s.length()); }
            if (x.equals(p)) {
                System.out.println("Yes");
                tf = true;
                break;
            }
        }
        if (tf == false) { System.out.println("No"); }
    }
}

Measured memory_bytes: 26396
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

long N,K;
long R,S,P;
string T;
long ans = 0;

//手rspを筐体が出力して、かつそれに勝ったときの点数を出力する関数
long get_score_by_rsp(char rsp){
	switch(rsp){
	case 'r':
		return P;
	case 's':
		return R;
	case 'p':
		return S;
	}
	return 0;
}

void solve(){
	bool used_draw[100000];//i回目であいこになっているならused_draw[i]=1
	memset(used_draw,0,sizeof(used_draw));
	for(int i=0;i<N;i++){
		if(i<K){
			ans+=get_score_by_rsp(T[i]);
		}else{
			if(T[i]!=T[i-K] || used_draw[i-K]==true){
				ans+=get_score_by_rsp(T[i]);
			}else{
				used_draw[i] = true;
			}
		}
	}
}

int main(){
	cin >> N >> K;
	cin >> R >> S >> P;
	cin >> T;

	solve();

	cout << ans;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define ios; ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef double db;
mt19937 rnd(random_device{}());
const int mod = 998244353;
const int N = 1e6 + 5;
const int M = 1e3 + 5;
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
inline ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
int n, m, k;
char s[N];
int a[N];
ll qsm(ll x,ll y, ll MOD){ ll res=1; while(y){if(y&1) res=res*x%MOD;
x=x*x%MOD; y>>=1;} return res; }

int main(){
    ios;
    cin>>n;
    cin>>s+1;
    int res=0, cnt=0;
    rep(i,1,n){
        if(s[i]=='1') ++cnt;
        a[n-i+1]=s[i]-'0';
    }
    int res1=res, res2=res;
    int cnt1=cnt-1, cnt2=cnt+1;
    rep(i,1,n){
        if(a[i]){
            if(cnt1>0) res1=(res1+qsm(2,i-1,cnt1))%cnt1;
            res2=(res2+qsm(2,i-1,cnt2))%cnt2;
        }
    }
    per(i,n,1){
        int tmp;
        if(a[i]){
            if(cnt1==0){
                cout<<"0\n";
                continue;
            }
            tmp=(res1-qsm(2,i-1,cnt1)+cnt1)%cnt1;
        }
        else{
            tmp=(res2+qsm(2,i-1,cnt2)+cnt2)%cnt2;
        }
        int ans=1;
        while(tmp){
            cnt=__builtin_popcount(tmp);
            tmp%=cnt;
            ++ans;
        }
        cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 4676
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
const int N = 2e3+ 2, mod = 1e9 + 7;


void solve() {
     int n;
     cin >> n;
     vector<int> cnt(n + 1);
     for(int i = 1; i < n; i++) {
          for(int j = 1; j < n && i*j < n; j++) {
               cnt[i*j]++;
          }
     }
     int ans = 0;
     for(int i = 1; i < n; i++) {
          ans += cnt[n - i];
     }
     cout << ans;
}    


int main() {
	int tt = 1;
	// cin >> tt;
	for (int tc = 1; tc <= tt; tc++) {
		// cout << "Case #:" << tc << " ";
		solve();
	}
}

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int x[3][3];
	for (int i=0; i<3; i++)
		for (int j=0; j<3; j++)
			cin>>x[i][j];
	for (int i=1; i<3; i++) {
		set<int> st;
		for (int j=0; j<3; j++)
			st.insert(x[i][j]-x[i-1][j]);
		if(st.size()!=1) {
			cout<<"No\n";
			return 0;
		}
	}

	for (int j=1; j<3; j++) {
		set<int> st;
		for (int i=0; i<3; i++)
			st.insert(x[i][j]-x[i][j-1]);
		if(st.size()!=1) {
			cout<<"No\n";	
			return 0;
		}
	}
	cout<<"Yes\n";
	return 0;
}

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

using namespace std;

long long num[200005], L[200005], R[200005];

int main(){
    int N;
    cin >> N;
    
    for(int i=1; i<=N; i++) cin >> num[i];
    
    vector<long long> stack;
    for(int i=1; i<=N; i++){
        L[num[i]] = 1;
        while(!stack.empty() && stack.back() > num[i]){
            L[num[i]] += L[stack.back()];
            stack.pop_back();
        }
        stack.push_back(num[i]);
    }

    stack.clear();
    for(int i=N; i>=1; i--){
        R[num[i]] = 1;
        while(!stack.empty() && stack.back()> num[i]){
            R[num[i]] += R[stack.back()];
            stack.pop_back();
        }
        stack.push_back(num[i]);
    }

    long long ans = 0;
    for(int i=1; i<=N; i++){
        ans += L[i]*R[i]*i;
    }

    cout << ans << endl;

}

Measured memory_bytes: 9464
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
print(n//min(a,b,c,d,e)+4) if n%min(a,b,c,d,e)==0 else print((n//min(a,b,c,d,e)+1)+4)



Measured memory_bytes: 9076
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nk[0];
        var k = nk[1];
        var seqP = Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray();

        var es = new double[seqP.Length + 1];
        for (int i = 1; i < es.Length; ++i)
        {
            var x = (1 + seqP[i - 1]) * seqP[i - 1] / 2 / seqP[i - 1];
            es[i] = x < es[i - 1] ? x + es[i - 1] : es[i - 1] + x;
        }

        var max = new Transitive<double>(0);
        for (int i = k; i < es.Length; ++i)
        {
            max += es[i] - es[i - k];
        }

        Console.WriteLine($"{max}");
    }

    struct Transitive<T>
    where T : IComparable<T>
    {
        public T Value;
        public Transitive(T value)
        {
            Value = value;
        }

        public override string ToString() => Value.ToString();

        public static implicit operator Transitive<T>(T value) => new Transitive<T>(value);
        public static Transitive<T> operator -(Transitive<T> x, Transitive<T> y) => x.Value.CompareTo(y.Value) < 0 ? x : y;
        public static Transitive<T> operator +(Transitive<T> x, Transitive<T> y) => x.Value.CompareTo(y.Value) > 0 ? x : y;
    }
}


Measured memory_bytes: 35932
n, k = map(int, input().split())
min = [0] * (n + 1)
max = [0] * (n + 1)
min[0] = 0
max[0] = n
for i in range(1, n + 1):
    min[i] = min[i - 1] + i
    max[i] = max[i - 1] + n - i

# print(min)
# print(max)
sum = 0
for i in range(k - 1, n + 1):
    sum = sum + max[i] - min[i] + 1
print(sum % (pow(10, 9) + 7))

Measured memory_bytes: 27228
n, a = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]

dp=[[0 for i in range(a*n+1)] for j in range(n+1)]
dp[0][0]=1
ans=0
f=0

for k in range(1,n+1):
  kx=x[k-1]
  f+=kx
  for i in range(k,0,-1):
    for j in range(kx,a*n+1):
      dp[i][j] += dp[i-1][j-kx]
      if j > f:
        break
      
for i in range(1,n+1):
  ans+=dp[i][a*i]

print(ans)


Measured memory_bytes: 4468
main = interact $ unlines . map (show . uncurry hanafuda) . read' . lines
 where
  read' ("0 0":_) = []
  read' (nr:xs) = (reverse [1..n], map (map read . words) xs1) : read' xs2 
   where
    [n,r] = map read (words nr)
    (xs1,xs2) = splitAt r xs

hanafuda d [] = head d
hanafuda d ([p,c]:pcs) = hanafuda (dm ++ dt ++ db) pcs
 where
  dt = take (p-1) d
  dm = take c (drop (p-1) d)
  db = drop (p+c-1) d

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

// void fun(){
//   ll x,y,n;
//   cin>>x>>y>>n;
//
//   ll r=n%x;
//   ll q=n/x;
//
// if(r==y){
// cout<<n<<endl;return;
// }
//   if(y>r){
//     ll ans=q*x;
//     ans=ans-(x-y);
//     cout<<ans<<endl;return;
//   }
//   if(r>y){
//       ll ans;
//       ans=n-(r-y);
//       cout<<ans<<endl;
//   }
//
//
// }
//
//
//
// void solve(){
//   ll n;
//   cin>>n;
//   int th=0,tw=0;
//   ll m=n;
//   ll k=n;
//
//   while(k%3==0)k/=3;
//   while(k%2==0)k/=2;
//   if(k!=1){
//     cout<<"-1\n";return;
//   }
//   while(m%3==0){th++;m/=3;}
//   m=n;
//   while(m%2==0){tw++;m/=2;}
//   if(tw>th){
//     cout<<"-1\n";return;
//   }
//   ll ans=th+(th-tw);
//
//   cout<<ans<<endl;
// }
//
//
// void solveit(){
//   ll a,b,n,m;
//   cin>>a>>b>>n>>m;
//   if(a>b){
//     n=n-(a-b);
//     a=b;
//     if(n<0){
//       a=a-n;
//     }
//     if(a>b)
//   }
//   else{
//     n=n-(b-a);
//     b=a;
//     if(n<0){
//       b=b-n;
//     }
//   }
//
//   if((n+m)<=(a+b)){
//     cout<<"Yes\n";
//
//   }
//   else cout<<"No\n";
//
//
//
// }





// void Aprob(){
// ll n;
// cin>>n;
// ll ans=0;
// ll arr[n];
// for(int i=0;i<n;i++)cin>>arr[i];
// for(int i=1;i<n;i++){
//   ll f=min(arr[i],arr[i-1]);
//   ll s=max(arr[i],arr[i-1]);
//   ans+=s-f-1;
// }
// cout<<ans<<endl;
// }
//
//
// ll sum(ll n){
//   ll val=0;
//   while(n){
//     val+=(n%10);
//     n/=10;
//   }
//   return val;
// }
// void Bprob(){
//   ll n;
//   cin>>n;
//   ll c=0,m=0;
//   while(n--){
//     ll a,b;
//     cin>>a>>b;
//     ll csum=sum(a);
//     ll msum=sum(b);
//     if(csum>msum)c++;
//     else if(msum>csum)m++;
//     else {c++;m++;}
//   }
//   if(c>m){
//     cout<<"0 "<<c<<"\n";
//   }
//   else if(m>c){
//     cout<<"1 "<<m<<"\n";
//   }
//   else {
//     cout<<"2 "<<c<<endl;
//   }
// }
// void Cprob(){
//   int k;
//   cin>>k;
//   vector<vector<char>>v (8,vector<char>(8,'X'));
//
//   int c=1;
//   for(int i=0;i<8;i++){
//     for(int j=0;j<8;j++){
//       if(c>k){break;}
//       v[i][j]='.';c++;
//     }
//     if(c>k)break;
//   }
//   v[0][0]='O';
//   for(int i=0;i<8;i++){
//     for(int j=0;j<8;j++){
//       cout<<v[i][j];
//     }
//     cout<<endl;
//   }
//   cout<<endl;
// }


// void Dprob(){
//
// }

void abc(){
  ll n;
  cin>>n;
  ll arr[n];
  for(int i=0;i<n;i++){
    cin>>arr[i];
  }
  if(n==1){
    cout<<"0\n";return;
  }

  sort(arr,arr+n);
  ll ans=arr[n-1];
ll dp [n]={0};
dp[n-2]=dp[n-1];
int j=n-3;
int p=n-2;
while(j>=0){
  dp[j]=arr[p];
  j--;
  if(j<0){break;}
  dp[j]=arr[p];
  j--;
  p--;
}
for(int i=0;i<n;i++){
  ans+=dp[i];
}
cout<<ans<<endl;


}


int main(){
  #ifndef ONLINE_JUDGE
 freopen("inp.txt","r",stdin);
 freopen("out.txt","w",stdout);
 #endif
  int t=1;
  // cin>>t;
  while(t--){
    abc();
  }
  return 0;
}


Measured memory_bytes: 6720
#include <bits/stdc++.h>
using namespace std;
int main()
{
    bool chk=true;
    string S;
    cin >> S;
    if(S.at(0)==S.at(1)) chk=false;
    if(S.at(2)==S.at(1)) chk=false;
    if(S.at(2)==S.at(3)) chk=false;
    if(chk) cout << "Good" << endl; else cout << "Bad" << endl;
}


Measured memory_bytes: 256
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cassert>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll n;cin>>n;
    map<ll,ll> mp;
    priority_queue<ll> pq;
    rep(i,n){
        ll a;cin>>a;
        mp[a]++;
        if(mp[a]%2==0){
            pq.push(a);
        }
    }

    if(pq.size()<=1) cout<<0<<endl;
    else{
        ll h=pq.top();
        pq.pop();
        ll w=pq.top();
        pq.pop();
        cout<<h*w<<endl;
    }

}

Measured memory_bytes: 9776
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n, a, b, c, d;
  scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);
  b -= a, b = (b > 0 ? b : -b);
  for(i = 0; i < n ; ++i) if(c * (n - i - 1) - d * i <= b && d * (n - i - 1) - c * i >= b) {
    printf("YES");
    return 0;
  }
  printf("NO");
  return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Endl endl
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    int2(a, b);
    if (!(a % 3) || !(b % 3) || !((a+b)%3)) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }

    return 0;
}



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>;
//vector<> vec(n);

int main(){
  int n=0;
  long long y=0,ans=0;

  cin >> n >> y;
  
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      int z = n-i-j;
      	if(y==10000*i + 5000*j + 1000*z && z>=0){
        	cout << i << " " << j << " " << z << endl;
          	return 0;
        }
    }
  }
  
  cout << "-1 -1 -1" << endl;
  return 0;
}

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

int main(){
    string s;
    int q;
    cin >> s;
    cin >> q;
    deque<char> ds;
    for(int i=0; i<s.size(); i++){
        ds.push_back(s.at(i));
    }
    int rev=0;
    for(int i=0; i<q; i++){
        int t;
        cin >> t;
        if(t==1){
            rev = 1 - rev;
        }
        else{
            int f;
            char c;
            cin >> f;
            f--;
            cin >> c;
            if(f == rev){
                ds.push_front(c);
            }
            else{
                ds.push_back(c);
            }
        }
    }
    if(rev){
        while(!ds.empty()){
            cout << ds.back();
            ds.pop_back();
        }
    }
    else{
        while(!ds.empty()){
            cout << ds.front();
            ds.pop_front();
        }
    }
    cout << endl;
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	int m, n;
	while (cin >> m >> n, m || n) {
		vector<bool>v(7368797, false);
		for (int i = m; n; i++) {
			if (!v[i]) {
				for (int j = i; j < v.size(); j += i) {
					v[j] = true;
				}
				n--;
			}
		}
		for (int i = m;; i++) {
			if (!v[i]) {
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3952
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >>n;
  while(n!=0){
    int na=0;
    int zeroc=0;
    int k[n];
    for(int i=0;i<n;i++){
      cin>>k[i];
    }
    for(int i=0;i<n;i++){
      if(k[i]>=2){
        na++;
      }
      if(k[i]==0) zeroc++;
    }
    if(na==0){
      cout <<"NA"<<endl;
    }else{
      cout <<n+1-zeroc<<endl;
    }
  cin >>n;
}
  return 0;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define endl            "\n"
#define forn(i,n)       for(int i=0; i<n; i++)
#define forit(it, m)    for(decltype(m)::iterator it = m.begin(); it!=m.end(); ++it)
#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 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 zeus()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
    zeus();

    int n; cin >> n;

    int a[n];
    int num = pow(10, 18);
    int mult = 1;
    int flag = 1;

    forn(i, n) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    forn(i, n) {
        if ( num / mult >= a[i]) {
            mult = mult * a[i];
        }
        else {
            flag = 0;
            break;
        }
    }
    if (flag == 0) {
        cout << -1 << endl;
    }
    else {
        cout << mult << endl;
    }




}





Measured memory_bytes: 4424
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define mod 1000000007

using namespace std;

int main()
{
    IOS;
    int n;
    cin>>n;
    int l = n%100;
    n=n/100;
    int flag1=0,flag2=0;
    if(l<=12 && l>=1)
        flag1++;
    if(n<=12 && n>=1)
        flag2++;
    if(flag1&&flag2)
        cout<<"AMBIGUOUS";
    else if(flag1)
        cout<<"YYMM";
    else if(flag2)
        cout<<"MMYY";
    else
        cout<<"NA";
    //cout<<s1;
    return 0;
}


Measured memory_bytes: 256
use proconio::input;
use std::collections::HashMap;

fn main() {
  input! {
    N: usize,
    arr: [String;N]
  }

  let mut map: HashMap<String, bool> = HashMap::new();

  for v in arr {
    map.insert(v, true);
  }
  
  println!("{}", map.keys().len());
}

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

int main(){
  int n,l;cin >> n >> l;
  vector<int> a(n);
  for(int i=1;i<=n;i++){
    a[i-1]=l+i-1;
  }
  int sum=0;
  rep(i,n) sum+=a[i];
  int ans=1e9;
  rep(i,n){
    int t=sum-a[i];
    if(abs(sum-t)<abs(sum-ans)) ans=t;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
while 1:
	n,a,b = map(int,raw_input().split())
	if n == 0: break
	dp = [0]*(n+max(a,b)+1)
	dp[a] = dp[b] = 1
	for i in range(n+1):
		if dp[i]:
			dp[i+a] = dp[i+b] = 1
	print n - sum(dp[:n+1])

Measured memory_bytes: 43784
def main():
    S = input()
    A = [ 0 for i in range(len(S) + 1)]

    idx_list = list([0])
    part = list()

    for i in range(len(S) - 1):
        if S[i] == ">" and S[i+1] == "<":
            idx_list.append(i+1)

    idx_list.append(len(S))

    if len(idx_list) == 1:
        part.append(S)
    else:
        for i in range(len(idx_list) - 1):
            part.append(S[idx_list[i]:idx_list[i+1]])

    ans = 0
    for p in part:
        G, L = 0, 0

        for j in range(len(p)):
            if p[j] == "<":
                G += 1
            else:
                L += 1

        tmp = 0
        if G < L:
            tmp += L*(L+1)//2 + G*(G-1)//2
        elif G > L:
            tmp += G*(G+1)//2 + L*(L-1)//2
        else:
            tmp += G*(G+1)//2 + L*(L-1)//2

        ans += tmp
        
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>

ll INF = 1000000007;


//-----------------//
  #define amin main
//-----------------//


int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i,j;
	ll n;
	cin>>n;
	ll a =1;
	ll b= 1;
	ll c =1;

	for(i=1;i<=n;i++)
	{
		a = (a*10)%INF;
		b = (b*9)%INF;
		c = (c*8)%INF;
	}
	 
	a = (a-(2*b)%INF + c + INF)%INF;
	//ans = (ans-b-(2*c)%INF+INF)%INF;
	cout<<a<<endl;

	
	
	


	
	return 0;
}

Measured memory_bytes: 3608
m=int(input())
a=[list(map(int, input().split())) for i in range(m)]
x=0
y=0

for i in range(m):
    x+=a[i][1]
    y+=a[i][0]*a[i][1]



print(x-1+(y-1)//9)
    
    


    
    


    
    
    
    
    
    
    

    

    
    


    
    
    
    
    
    
    

    

    
    


    
    
    
    
    
    
    





    
    
    
    
    
    
    

    

    
    


    
    
    
    
    
    
    

    

    
    


    
    
    
    
    
    
    

    
    
    
    
    
    

    

    
    


    
    
    
    
    
    
    

    

    
    


    
    
    
    
    
    
    





    
    
    
    
    
    
    

    

    
    


    
    
    
    
    
    
    

    

    
    


    
    
    
    
    
    
    

    

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

int main() {
	int a, b;
	scanf("%d", &a);
	scanf("%d", &b);

	printf("%s", "a");
	if (a < b) {
		printf(" < ");
	} else if(a == b) {
		printf(" == ");
	}
	else {
		printf(" > ");
	}
	printf("%s", "b");

	cout << endl;
	return 0;
}

Measured memory_bytes: 3176
#include<iostream>
#define int long long

using namespace std;

int m[55][5500];
int n,p,a[11111];
int dp(int i,int j){
	if(i==n){
		if(j%2==p)return 1;
		else return 0;
	}
	if(m[i][j]!=-1)return m[i][j];
	int sum=0;
	sum+=dp(i+1,j+a[i]);
	sum+=dp(i+1,j);
	
	return m[i][j]=sum;
	
}


signed main(){
	cin>>n>>p;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n*100;j++){
			m[i][j]=-1;
		}
	}
	for(int i=0;i<n;i++)cin>>a[i];
	cout<<dp(0,0)<<endl;

}

Measured memory_bytes: 2432
#include <iostream>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <iomanip>

using namespace std;
using ll = long long;

#define endl "\n"
#define pb push_back

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

	int a, b, c, k;
	cin >> a >> b >> c >> k;
	if(k <= a) {
		cout << k;
	} else if(k > a && k <= a + b) {
		cout << a;
	} else if(k > a && k > a + b && k <= a + b + c) {
		cout << a - (k - a - b);
	}
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1000000007;

bool isSmall(char x){
  if('a'<=x && x<='z'){
    return true;
  }
  return false;
}

int main(){
  string S;
  cin >> S;
  int N = S.size();
  if(S[0]!='A'){
    cout <<"WA" << endl;
    return 0;
  }
  int count=0;
  for(int i=2;i<N-1;i++){
    if(S[i]=='C'){
      count ++;
    }
  }
  if(count!=1){
    cout << "WA" << endl;
    return 0;
  }
  for(int i=1;i<N;i++){
    if((!(S[i]=='C'))&&(!(isSmall(S[i])))){
      cout << "WA" << endl;
      return 0;
    }
  }
  cout << "AC" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
 
const int maxn = 5e3 + 10, maxm = 210;
 
int n, m, c[maxm][maxn], sz[maxm];
long long dp[maxn][maxn], b[maxm][maxn], ans, a[maxn];
 
void chkmax(long long &x, long long y) {
//	printf("\t%lld %lld\n", x, y);
	(x < y) && (x = y);
}
 
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 2; i <= n; ++i) {
		#ifdef DEBUG
		scanf("%I64d", a + i);
		#else
		scanf("%lld", a + i);
		#endif
		a[i] += a[i - 1];
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			long long x, lst;
			#ifdef DEBUG
			scanf("%I64d", &x);
			#else
			scanf("%lld", &x);
			#endif
			dp[i][i] += x;
			lst = x;
			while(sz[j] && b[j][sz[j] - 1] <= x) {
				--sz[j];
				dp[c[j][sz[j]]][i] += lst - b[j][sz[j]];
				lst = b[j][sz[j]];
			}
			if(sz[j]) {
//				printf("[%d]\n", c[j][sz[j] - 1]);
				dp[c[j][sz[j] - 1]][i] += lst - x;
			}
			b[j][sz[j]] = x;
			c[j][sz[j]] = i;
			++sz[j];
		}
		for (int j = i - 2; j >= 1; --j) {
//			printf("fuck\t\t%lld\n", dp[j][i]);
			dp[j][i] += dp[j + 1][i];
		}
		for (int j = 1; j <= i; ++j) {
//			printf("\t%lld %lld %lld\t", dp[j][i], a[i], a[j]);
			dp[j][i] += dp[j][i - 1];
//			printf("\t%lld %lld %lld\n", dp[j][i], a[i], a[j]);
			chkmax(ans, dp[j][i] - a[i] + a[j]);
		}
		/*
		for (int j = 1; j <= m; ++j) {
			for (int i = 0; i < sz[j]; ++i) {
				printf("(%lld, %d)\t", b[j][i], c[j][i]);
			}
			puts("");
		}
		printf("%lld\n", dp[1][i]);
		puts("");
		*/
	}
	#ifdef DEBUG
	printf("%I64d\n", ans);
	#else
	printf("%lld\n", ans);
	#endif
	return 0;
}
/*
7 2
1 1 1 1 1 1
100 1
2 1
2 3
1 3
1 2
3 2
3 100
 */

Measured memory_bytes: 205440
#include<bits/stdc++.h>
int dp[20005];
using namespace std;
int main()
{
	int h, n;
	int a, b;
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> h >> n;
	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a >> b;
		for (int j = 0; j < h + 10000; j++)
			if (j - a >= 0)
				dp[j] = min(dp[j], dp[j - a] + b);
	}
	int ans = 0x3f3f3f3f;
	for (int i = h; i < h + 10000; i++)
		ans = min(ans, dp[i]);
	cout << ans << endl;
	return 0;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;



int main(){
    int n; cin >> n;
    vi p(n);
    vi ids(n);
    for(int i=0; i<n; i++){
        cin >> p[i];
        p[i]--;
        ids[p[i]]=i;
    }

    multiset<int> S;
    S.insert(-1), S.insert(-1);
    S.insert(n), S.insert(n);
    ll ans=0;
    for(int i=n-1; i>=0; i--){
        int w, x, y, z;
        auto it1=S.upper_bound(ids[i]);
        auto it2=it1;
        y=*it1, z=*(++it1);
        --it2, x=*it2, w=*(--it2);
        ans+=(ll)(i+1)*((x-w)*(y-ids[i])+(ids[i]-x)*(z-y));
        S.insert(ids[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8772
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;
const int MOD=1e9+7;
const int MAXN=1000000;

int n,m,a,b;
ll fac[MAXN+5],inv[MAXN+5];

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

ll C(int x,int y){
    if(x<y) return 0;
    return (1ll*fac[x]*((1ll*inv[y]*inv[x-y])%MOD))%MOD;
}

int main(){
    Init();
    scanf("%d%d%d%d",&n,&m,&a,&b);
    ll ans=C(n+m-2,m-1);
    //printf("#%lld\n",ans);
    int u=n-a+1;
    for(int j=1;j<=b;j++){
        //printf("%d %d---%d %d\n",u,j,n-u+1,m-j+1);
        //printf("%lld\n",C(n+m-u-j,m-j));
        ans-=(1ll*(C(u+j-2,j-1)-C(u+j-3,j-2))*C(n+m-u-j,m-j))%MOD;
        ans=(ans+MOD)%MOD;
        //printf("%lld\n",ans);
    }
    printf("%lld",ans);
}


Measured memory_bytes: 15744
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int a;cin >> a;
  cout << a + a*a + a*a*a << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>
#include<cmath>
using namespace std;
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int findGCD(int arr[], int n) 
{ 
    int result = arr[0]; 
    for (int i = 1; i < n; i++) 
        result = gcd(arr[i], result); 
  
    return result; 
} 
int main()
{
    int t,x,arr[100002],temp;
    cin>>t>>x;
    for (int i = 0; i < t; ++i)
    {
        cin>>temp;
        arr[i]=abs(temp-x);
    }
    cout<<findGCD(arr,t);

}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N;cin>>N;
    int ans=0;
    rep(i,N){
        int a;cin>>a;
        while(a%2==0){
            a/=2;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
#define n_max 200002



llong beki(llong a,llong x){
    llong res = 1;
    llong tmp = a;
    while(x > 0){
        if(x & 1) res *= tmp; res %= MOD;
        tmp *= tmp;
        tmp %= MOD;
        x >>=1;
    }
    return res;
}

llong fac[n_max];  /// fac[n] = n!
llong finv[n_max]; /// (fac[n] * finv[n]) % MOD = 1
llong inv[n_max];  /// (n * inv[n]) % MOD = 1
 
void init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  FOR (i, 2, n_max) {
    fac[i] = fac[i-1]*i % MOD;
    inv[i] = MOD - inv[MOD%i]*(MOD/i) % MOD;
    finv[i] = finv[i-1]*inv[i] % MOD;
  }
}
 
llong nCk (int n, int k) {
  if (n < k || k < 0 || n < 0) return 0;
  return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}


signed main(){
    init();
    int n,a,b,c;
    cin >> n >> a >> b >> c;
    int cplus = 100 * beki(100 - c , MOD - 2) % MOD;
    int awari = a * beki(a + b,MOD-2) % MOD;
    int bwari = b * beki(a + b,MOD-2) % MOD;

    int res = 0;
    int pn = 0;
    int an = 1;
    int bn = 1;
    REP(i,n){
        pn += cplus;
        pn %= MOD;
        an *= awari;
        an %= MOD;
        bn *= bwari;
        bn %= MOD;

    }

    int now_an = 1;
    int now_bn = 1;
    FOR(i,n,2 * n){
        int tasu = pn * (nCk(i-1 , i - n ));
        tasu %= MOD;
        int hoge = an * now_bn;
        hoge %= MOD;
        int hoge2 = bn * now_an;
        hoge2 %= MOD;
        hoge += hoge2;
        hoge %= MOD;
        tasu *= hoge;
        tasu %= MOD;
        res +=  tasu;
        res %= MOD;
        pn += cplus;
        pn %= MOD;
        now_an *= awari;
        now_an %= MOD;
        now_bn *= bwari;
        now_bn %= MOD;
    }
    cout << res << endl;
}


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

void solve()
{
   int x;
   cin>>x;
   if(x==0) x=1;
   else x=0;
   cout<<x<<endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

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


Measured memory_bytes: 3608
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int one = in.nextInt();
		int two = in.nextInt();
		for(int i = 1; i < 4; i++) {
			if((i * one * two) % 2 != 0) {
				System.out.println("Yes");
				return;
			}
				
		}
		System.out.println("No");
		}
}


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

int main()
{
  int h1, h2, m1, m2, k, ans;

  cin >> h1 >> m1 >> h2 >> m2 >> k;

  m1 += h1 * 60;
  m2 += h2 * 60;
  ans = m2 - m1;
  cout << ans-k << endl;
}

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

typedef long long ll;
typedef pair<int, int> ii;

const int N = 2e5 + 5; 
int n, a[N], nxt[N], vis[N]; 
ll sum[N][60], k; 
int jump[N][60]; 

int main() {
  scanf("%d %lld", &n, &k); 
  for(int i = 0; i < n; ++i) {
    scanf("%d", &a[i]); 
  }

  for(int i = n - 1; i >= 0; --i) {
    nxt[a[i]] = n + i; 
  }
  for(int i = n - 1; i >= 0; --i) {
    jump[i][0] = (nxt[a[i]] + 1) % n;
    if(nxt[a[i]] + 1 >= n) sum[i][0] = 1; 
    if(nxt[a[i]] + 1 >= 2 * n) sum[i][0] = 2;
    nxt[a[i]] = i;
  }

  int lg = log2(n * k);
  for(int j = 1; j <= lg; ++j) {
    for(int i = 0; i < n; ++i) {
      jump[i][j] = jump[jump[i][j - 1]][j - 1]; 
      sum[i][j] = sum[i][j - 1] + sum[jump[i][j - 1]][j - 1]; 
    }
  }

  int idx = 0;
  ll tot = 1; 
  for(int i = lg; i >= 0; --i) {
    if(tot + sum[idx][i] <= k) {
      tot += sum[idx][i]; 
      idx = jump[idx][i];
    }
  }

  vector<int> v;

  if(tot != k && idx == n - 1) {
    v.push_back(a[idx]); 
    vis[a[idx]] = 1; 
    idx = 0; 
  }

  for(int i = idx; i < n; ++i) {
    if(!vis[a[i]]) {
      vis[a[i]] = 1; 
      v.push_back(a[i]); 
    } else {
      while(vis[a[i]]) {
        vis[v.back()] = 0; 
        v.pop_back();
      }
    }
  }


  for(int x : v) printf("%d ", x); 
  puts("");
}



Measured memory_bytes: 145396
class in{struct myIterator{int it;const bool rev;explicit constexpr myIterator(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(myIterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const myIterator i,n;public:explicit constexpr in(int n):i(0),n(n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const myIterator& begin(){return i;}const myIterator& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;

using i64 = long long;
const i64 INF = 1e16;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<i64> a(2 * n + 2, 0LL);
    for(int i : in(n)) {
        cin >> a[i + 1];
        a[i + n + 1] = a[i + 1];
    }
    a.back() = INF;
    for(int i : in(2 * n + 1)) a[i + 1] += a[i];
    i64 ans = 0LL;
    for(int i : in(n)) {
        i64 lb = ans, ub = a[n] / 3LL + 1LL;
        while(ub - lb > 1LL) {
            i64 mid = (ub + lb) / 2LL;
            bool ok = [&]() {
                int cur = i;
                for(int _ : in(2)) {
                    int it = lower_bound(a.begin(), a.end(), a[cur] + mid) - a.begin();
                    cur = it;
                }
                i64 rest = a[i + n] - a[cur];
                return rest >= mid;
            }();
            if(ok) lb = mid;
            else ub = mid;
        }
        ans = max(ans, lb);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4356
x,k,d=map(int,input().split())
x=abs(x)
temp=x%d
move_t=k-(x//d)
after_1=abs(temp-d)
if move_t>0:
    if temp<=abs(temp-d):
        if move_t%2==0:
            print(temp)
        else:
            print(after_1)
    else:
        if (move_t-1)%2==0:
            print(after_1)
        else:
            print(temp)
else:
    print(x-k*d)


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 55;

int n, m;
char a[N][N];
int vis[N][N], dist[N][N], ways[N][N];
int dx[4]={-1, +1, 0, 0};
int dy[4]={0, 0, +1, -1};

int bfs(int x, int y, int n, int m)
{
	memset(vis, 0, sizeof(vis));
	queue<pair<int, int> > q;
	q.push({x, y});
	ways[x][y]=1;
	vis[x][y]=1;
	dist[x][y]=0;
	int mx = 0;
	while(!q.empty())
	{
		int x=q.front().first;
		int y=q.front().second;
		q.pop();
		for(int dir=0;dir<4;dir++)
		{
			int nx=x+dx[dir];
			int ny=y+dy[dir];
			if(nx<1 || ny<1 || nx>n || ny>m || a[nx][ny] == '#')
				continue;
			if(!vis[nx][ny])
			{
				dist[nx][ny]=dist[x][y]+1;
				mx = max(mx, dist[nx][ny]);
				vis[nx][ny]=1;
				ways[nx][ny]+=ways[x][y];
				q.push({nx, ny});
			}
			else
			{
				if(dist[x][y] + 1 == dist[nx][ny])
					ways[nx][ny]+=ways[x][y];
			}
		}
	}
	return mx;
}


int32_t main()
{
	IOS;
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			cin >> a[i][j];
	int ans = 0;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(a[i][j] == '.')
				ans = max(ans, bfs(i, j, n, m));
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
    int a, b, c;
    int x;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if(a > b) {
        x = b;
        b = a;
        a = x;
    }
    
    if(b > c) {
        x = c;
        c = b;
        b = x;
    }
    
    if(a > b) {
        x = b;
        b = a;
        a = x;
    }
    
    printf("%d %d %d\n", a, b, c);
    
    return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
void solve()
{
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	int t1 = 60*h1+m1,t2 = 60*h2+m2;
	cout<< t2 - t1 - k<<'\n';
}
int main()
{
	int t= 1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


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


int main(){
  string s;
  vector<char> ans(s.size());
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0') ans.push_back('0');
    else if (s[i]=='1') ans.push_back('1');
    else{
      if (ans.empty()) continue;
      else ans.pop_back();
    }
  }
  for(int k=0;k<ans.size();k++){
    cout << ans[k];
  }
  cout << endl;
}

Measured memory_bytes: 256
n , x = map(int,(input().split()))
a , b = n-x , x

ans = n
while True:
    c = max(a,b)
    d = min(a,b)
    if c % d != 0:
        ans += (c // d) * 2 * d
    else:
        ans += ((c // d) * 2 - 1) * d 
        break
    
    a = d
    b = c%d
    
print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,c;
    cin >> n >> c;
    int ans=1;
    pair<pair<int,int>,int> p[n];
    for(int i=0;i<n;i++)cin >> p[i].first.first >> p[i].first.second >> p[i].second;
    sort(p,p+n);
    priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q;
    q.push(make_pair(p[0].first.second,p[0].second));
    for(int i=1;i<n;i++){
        vector<pair<int,int> > tmp;
        while(q.top().first<p[i].first.first && !q.empty())q.pop();
        while((q.top().first==p[i].first.first && q.top().second<=p[i].second) && !q.empty()){
            if(q.top().second<p[i].second)tmp.push_back(make_pair(q.top().first,q.top().second));
            q.pop();
        }
        for(auto u:tmp)q.push(u);
        q.push(make_pair(p[i].first.second,p[i].second));
        ans=max(ans,(int)q.size());
    }
    cout << ans;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const ll inf = 1e18 + 5;
typedef pair<int, bool> pib;
bool cmp(vector<int> one, vector<int> two){
    for (int i = 0; i < one.size(); i++){
        if (one[i] != two[i]){
            return false;
        }
    }
    return true;
}
int main() {
    int m1,d1,m2,d2; cin >> m1 >> d1 >> m2 >> d2;
    if (m2 == m1){
        cout << 0;
    }
    else{
        cout << 1;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;

int main(){
  int K, S; cin >> K >> S;
  int res = 0;
  for(int X = 0; X <= K; X++){
    for(int Y = 0; Y <= K; Y++){
      int Z = S - X - Y;
      if(Z >= 0 && Z <= K) res++;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256