akhauriyash/Code-Regression huggingface dataset:
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;
 
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  f              first                 
#define  s              second
#define  endl           "\n"
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;            
          
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;
 
const ll   N     =  1e6+5;
const ll   mod   =  998244353;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;

ll test=1, n, a[N];
set <ll> s;

void solve(){
    cin>>n;
    for(int i = 0; i < n; i++) cin>>a[i];
    sort(a,a+n);
    a[n] = 0;
    int ct = 0;
    for(int i = 0; i < n; i++){
        if(a[i] == a[i+1]){
            s.insert(a[i]);
            continue;
        }
        int flag = 1;
        for(int j = 1; j*j <= a[i]; j++){
            if(a[i]%j == 0){
                if(s.find(j) != s.end()){
                    flag = 0; break;
                }
                if(s.find(a[i]/j) != s.end()){
                    flag = 0; break;
                }
            }
        }
        ct += flag;
        s.insert(a[i]);
    }
    deb1(ct)
}

int main(){
    fastio;
    //cin>>test;
    for(int i = 1; i <= test; i++){
        solve();
    }
}

Measured memory_bytes: 14572
MOD = 10**9 + 7
N, M = map(int, input().split())
dp = [0]*(N+1)
for _ in range(M):
  dp[int(input())] = -1
dp[0] = 1

for i in range(N+1):
  if dp[i] == -1:
    continue
  if i+1 <= N and dp[i+1] != -1:
    dp[i+1] = (dp[i+1] + dp[i]) % MOD
  if i+2 <= N and dp[i+2] != -1:
    dp[i+2] = (dp[i+2] + dp[i]) % MOD
print(dp[N])

Measured memory_bytes: 12560
#include<bits/stdc++.h>
namespace ZDY{
#define ll long long
#define Fur(i,x,y) for(int i=x;i<=y;i++)
#define Fdr(i,x,y) for(int i=x;i>=y;i--)
#define in2(x,y) in(x);in(y)
#define in3(x,y,z) in2(x,y);in(z)
#define in4(a,b,c,d) in2(a,b);in2(c,d)
#define clr(x,y) memset(x,y,sizeof(x))
#define cpy(x,y) memcpy(x,y,sizeof(x))
#define fl(i,x) for(ll i=head[x],to;to=e[i].to,i;i=e[i].next)
#define inf 999999999
}
namespace FAST{
#define pob (fwrite(fob::b,sizeof(char),fob::f-fob::b,stdout),fob::f=fob::b,0)
#define pc(x) (*(fob::f++)=(x),(fob::f==fob::g)?pob:0)
#define gc ((*fib::f)?(*(fib ::f++)):(fgets(fib::b,sizeof(fib::b),stdin)?(fib::f=fib::b,*(fib::f++)):-1))
namespace fib{char b[300000]= {},*f=b;}
inline void in(ll &x){x=0;char c;bool f=0;while((c=gc)>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=gc)<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;}
inline void in(int &x){x=0;char c;bool f=0;while((c=gc)>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=gc)<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;}
namespace fob{char b[300000]= {},*f=b,*g=b+300000-2;}struct foce{~foce(){pob;fflush(stdout);}} _foce;namespace ib{char b[100];}
inline void out(ll x){if(x==0){pc(48);return;}if(x<0){pc('-');x=-x;}char *s=ib::b;while(x) *(++s)=x%10,x/=10;while(s!=ib::b) pc((*(s--))+48);}inline void outn(ll x){out(x);pc('\n');}
inline void out(int x){if(x==0){pc(48);return;}if(x<0){pc('-');x=-x;}char *s=ib::b;while(x) *(++s)=x%10,x/=10;while(s!=ib::b) pc((*(s--))+48);}inline void outn(int x){out(x);pc('\n');}
inline char sc(){char c=gc;while(!(('A'<=c&&c<='Z')||('a'<=c&&c<='z')))c=gc;return c;}
}using namespace FAST;using namespace ZDY;using namespace std;
#define N 1001
ll a,b;
int main(){
	in2(a,b);
	if(a+b==15)pc('+');
	else if(a*b==15)pc('*');
	else pc('x');
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int taro=0, hanako=0;
		for (int i = 0; i < n; i++) {
			String a = sc.next();
			String b = sc.next();
			if (a.compareTo(b) < 0) {
				taro += 3;
			} else if (a.compareTo(b) > 0) {
				hanako += 3;
			} else {
				taro += 1;
				hanako += 1;
			}
		}
		System.out.println(hanako + " " + taro);
	}
}



Measured memory_bytes: 30012
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
long long n,l[100010],ans;
int main(){
	scanf("%lld",&n);
	for(int i=1;i<=n<<1;i++)scanf("%lld",&l[i]);
	sort(l+1,l+n*2+1);
	for(int i=1;i<=n;i++)ans+=l[(i<<1)-1];
	printf("%lld",ans);
	return 0;
}

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

#define int long long
int pw(int n,int k){
  assert(k>=0);
  int res=1;
  while(k){
    if(k&1)res*=n;
    n*=n;
    k>>=1;
  }
  return res;
}
void fin(int a,int b){
  cout<<a<<" "<<b<<endl;
  exit(0);
}

signed main(){
  int x;cin>>x;
  for(int a=-1000;a<=1000;a++){
    for(int b=-1000;b<=1000;b++){
      if(pw(a,5)-pw(b,5)==x)fin(a,b);
    }
  }
}


Measured memory_bytes: 3636
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H, N, *A = map(int, read().split())

    if H <= sum(A):
        print('Yes')
    else:
        print('No')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 89072
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(){
  int n, i;
  int* stones;
  int* result;
  int cost1, cost2;
  scanf("%d", &n);
  //cin >> n;
  stones = new int[n];
  result = new int[n];
  for(i=0; i<n; i++){
    scanf("%d", &stones[i]);
    //cin >> stones[i];
    result[i] = 0;
  }
  cost1 = abs(stones[0]-stones[1]);
  result[1] = cost1;
  for(i=2; i<n; i++){
    cost1 = abs(stones[i-1]-stones[i]);
    cost2 = abs(stones[i-2]-stones[i]);
    result[i] = min(cost1 + result[i-1], cost2 + result[i-2]);
  }
  printf("%d", result[n-1]);
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    for(int i=1; i<=9; i++){
        for(int j=1; j<=9; j++){
            cout<<i<<'x'<<j<<'='<<i*j<<'\n';
        }
    }
    return 0;
}



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

#define rep(i, a, n) for (int i = a; i < n; i++)
#define asc(v) sort(v.begin(), v.end())
#define desc(v) sort(v.begin(), v.end(), greater<int>())

using namespace std;

int main() {
  string s;
  cin >> s;
  s[5] = ' ';
  s[13] = ' ';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
        while(scan.hasNext()){
            int N = scan.nextInt();
            int[] S = new int[N];
            for(int i = 0; i < N;i++)
                S[i] = scan.nextInt();
            
            int Q = scan.nextInt();
            int[] T = new int[Q];
            for(int i = 0; i < Q; i++)
                T[i] = scan.nextInt();
            
            int count = 0;
            for(int i = 0;i < Q;i++){
                for(int j = 0;j < N;j++){
                    if(T[i] == S[j]){
                        count++;
                        break;
                    }
                }
            }
            System.out.println(count);
        }
        scan.close();
       
    }
}



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

using namespace std;

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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

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

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

ll powmod(ll x, ll n) { // like pow(x, n)
  ll r = 1;
  while (n) {
    if (n & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return r;
}

ll dp[1000100][2];  // dp[i][s] .. i: position, s: equal or lower

int main(int argc, char** argv) {
  string L;
  cin >> L;
  int N = L.size();
  dp[0][0] = 1;
  rep(i, N) {
    rep(s, 2) { // s = 0: equal, s = 1: lower
      rep(l, 2) rep(r, 2) {
        if (l == 1 && r == 1) { continue; }

        int ns = s | (L[i] == '1' && l == 0 && r == 0);
        if (L[i] == '1') {
          dp[i+1][ns] += dp[i][s];
          dp[i+1][ns] %= MOD;
        } else { // L[i] == '0'
          if (s > 0) {
            dp[i+1][ns] += dp[i][s];
            dp[i+1][ns] %= MOD;
          } else {
            if (l == 0 && r == 0) { // if s == 0 and L[i] == '0', then l and r must be 0.
              dp[i+1][ns] += dp[i][s];
              dp[i+1][ns] %= MOD;
            }
          }
        }
      }
    }
  }

  cout << (dp[N][0] + dp[N][1]) % MOD << endl;
}


Measured memory_bytes: 2048
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		//		new Main().solveB();
		new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		char[] wk;

		try {
			scanner = new Scanner(System.in);
			wk = scanner.nextLine().toCharArray();

			int res = 0;
			for (int i = 0; i < wk.length; i++) {
				if (wk[i] == '1') {
					res++;
				}
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private int divide(int[] wk) {
		boolean divide = true;
		int res = 0;
		for (int i = 0; i < wk.length && divide; i++) {
			if (wk[i] % 2 == 0 && wk[i] > 0) {
				wk[i] = wk[i] / 2;
			} else {
				divide = false;
			}
		}
		if (divide) {
			res = divide(wk) + 1;
		}
		return res;
	}

	private void solveB() {
		Scanner scanner = null;
		int n = 0;

		try {
			scanner = new Scanner(System.in);
			n = scanner.nextInt();

			int[] wk = new int[n];

			for (int i = 0; i < wk.length; i++) {
				wk[i] = scanner.nextInt();
			}

			System.out.println(divide(wk));

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private List<Integer> getSortedKeyArray(Map<Integer, Integer> wk) {
		List<Integer> wkList = new ArrayList<Integer>();

		for (Iterator<Integer> itr = wk.values().iterator(); itr.hasNext();) {
			wkList.add(itr.next());
		}

		Collections.sort(wkList);
		return wkList;
	}

	private void solveC() {
		Scanner scanner = null;
		int n = 0;
		int k = 0;

		try {
			scanner = new Scanner(System.in);
			n = scanner.nextInt();
			k = scanner.nextInt();

			Map<Integer, Integer> wk = new HashMap<Integer, Integer>();
			for (int i = 0; i < n; i++) {
				int wkKey = scanner.nextInt();
				if (!wk.containsKey(wkKey)) {
					wk.put(wkKey, 1);
				} else {
					wk.put(wkKey, wk.get(wkKey) + 1);
				}
			}

			List<Integer> wkList = getSortedKeyArray(wk);

			int res = 0;
			for (int i = 0; i < wkList.size() - k; i++) {
				res += wkList.get(i);
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 104732
#include<iostream>
using namespace std;
int main(){
	int r,c,a[101][101],b=0,d[101],e=0,f[101];
	int sumx=0,sumy[101]={0},all=0;
	cin>>r>>c;
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			cin>>a[i][j];
			all+=a[i][j];
		}
	}
	for(int i=0;i<c;++i){
		for(int j=0;j<r;++j){
			sumy[i]+=a[j][i];
		}
	}
	for(int i=0;i<r;++i){
		for(int j=0;j<c;++j){
			cout<<a[i][j]<<" ";
			sumx+=a[i][j];
		}
		cout<<sumx<<endl;
		sumx=0;
	}
	for(int i=0;i<c;++i){
		cout<<sumy[i]<<" ";
	}
	cout<<all<<endl;
	return 0;
}


Measured memory_bytes: 3156
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 100001

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    // int T;cin>>T;while(T--) 
    {
        ll n,m;
        cin>>n>>m;
        ll ans = (n*(n-1))/2;
        ans += (m*(m-1))/2;
        cout<<ans<<endl;
    }
    return 0;
}

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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	cin>>n>>m;
	ll dp[n+1],a[m];
	memset(dp,0,sizeof(dp));
	rep(i,0,m) cin>>a[i];
	j=0;
	dp[0]=1;
	rep(i,1,n+1){
		if(j<m && i==a[j]){
			j++;
			continue;
		}
		if(i-1>=0){
			dp[i]=(dp[i]+dp[i-1])%hell;
		}
		if(i-2>=0){
			dp[i]=(dp[i-2]+dp[i])%hell;
		}
	}	
	ret(dp[n])
	
	return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  set<int> s;
  s.insert(a);
  s.insert(b);
  s.insert(c);
  cout << (s.size() == 2 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))

dic={}

for i in range(n):
    if not a[i] in dic:
        dic[a[i]]=0
    dic[a[i]]+=1

keys=list(dic.keys())
list=[]

for i in range(len(keys)):
    list.append(dic[keys[i]])

list.sort(reverse=True)
count=0
for i in range(k,len(list)):
    count+=list[i]
print(count)

Measured memory_bytes: 102344
#include <bits/stdc++.h>
#define int long long
#define boost() ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cout << fixed; cout << setprecision(15); srand(time(NULL))
#define all(x) x.begin(), x.end()
using namespace std;

const int mod = 1000000007;

int n, res = 0;
int a[300010];
int b[300010][60];

int mul (int x, int y) {
  return ((x % mod) * (y % mod)) % mod;
}

signed main() {
  boost();
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < 60; j++) {
      b[i][j] = b[i + 1][j] + ((a[i] & (1LL << j)) > 0);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 60; j++) {
      if (a[i] & (1LL << j)) {
        res = (res + mul(1LL << j, n - i - 1 - b[i + 1][j])) % mod;
      } else {
        res = (res + mul(1LL << j, b[i + 1][j])) % mod;
      }
    }
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 143232
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    long n;
    string s, t;
    cin >> n >> s >> t;
    long pos = s.length();
    for(int i = 0; i < s.length(); i++){
        string u = s.substr(i), v = t.substr(0, u.length());
        if(u == v){
            pos = i;
            break;
        }
    }
    cout << pos + t.length() << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast","unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define F first
#define S second
#define setpre(a) cout.precision(a),cout<<fixed;
#define ALL(a) a.begin(),a.end()
#define MEM(a,b) memset(a,b,sizeof a)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll x,l,r,m;

int main()
{Tie
	cin>>x;
	l=0,r=100000;
	while(l!=r)
	{
		m=l+r>>1;
		if((1+m)*m/2<=x)
			l=m+1;
		else
			r=m;
	}
	m=l-1;
	if((1+m)*m/2>=x)
		l--;
	cout << l<<'\n';
}

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

int main() {
	vector<int> da(5);
	for (int i = 0;i < 5;i++) {
		cin >> da[i];
	}
	int ans = 0;
	for (int i = 0;i < 5;i++) {
		if (da[i] % 10 == 0)
			ans += da[i];
		else
			ans += (da[i]+10)/10*10;
	}
	int gg = 10;
	for (int i = 0;i < 5;i++) {
		int x;
		if (da[i] % 10 == 0) {
			x = 10;
		}
		else
			x = da[i] % 10;
		gg = min(x, gg);
	}
	if (gg != 10)
		ans -= 10 - gg;
	cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define rreps(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) (1 + (int)((a) - 1)/(int)(b))
//#define int long long

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a;
  int b;
  cin >> a;
  cin >> b;
	if(a % 2 == 1 && b % 2 == 1){
        cout << "Odd";
    }
      else{
        cout << "Even";
      }
}

Measured memory_bytes: 256
N=int(input())
S=input()

R=S.count('R')
G=S.count('G')
B=S.count('B')

ans = R*G*B

for i in range(N):
    for k in range(((N+1-i)//2) +2):
        if i+2*k < N:
            if S[i]!=S[i+k] and S[i+k]!=S[i+2*k] and S[i]!=S[i+2*k]:
                ans -=1

print(ans)

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

const int inf = 0x3f3f3f3f;

struct node{
	int a,b,c,d;
}t[60]; 

int n,m,q,ans,s[20];

void dfs(int nw,int st){
	if(nw > n){
		int res = 0;
		for(int i = 1;i <= q;++i){
			if(s[t[i].b] - s[t[i].a] == t[i].c)
				res += t[i].d;
		}
		ans = max(ans,res);
		return ;
	}
	for(int i = st;i <= m;++i){
		s[nw] = i;
		dfs(nw+1,i);
	}
	return ;
}
int main(){
	cin >> n >> m >> q;
	for(int i = 1;i <= q;i++){
		scanf("%d %d %d %d",&t[i].a,&t[i].b,&t[i].c,&t[i].d);
	}
	ans = -inf;
	
	dfs(1,1);
	
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long a,b,n;
   cin>>a>>b>>n;
   long long ans=0,x=0;
   x=min(n,b-1);
   ans=a*x/b;
   long long ans1=x/b;
   ans1*=a;
   cout<<ans-ans1;
   return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rnd;
#define F first
#define S second
#define pb push_back
#define pii pair<int,int>
#define go_precise cout << fixed << setprecision(18);

const int maxn = 3e3 + 10;
ll dp[maxn][maxn];
ll pref[maxn];
ll a[maxn];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);  cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n;
    cin >> n;

    for (int i=1; i<=n; i++) cin >> a[i];
    for (int i=1; i<=n; i++) pref[i] = pref[i-1] + a[i];

    for (int i=1; i<=n; i++) dp[i][i] = a[i];
    for (int len=2; len<=n; len++) {
        for (int l=1; l+len-1<=n; l++) {
            int r = l+len-1;
            dp[l][r] = max(a[l] + pref[r] - pref[l] - dp[l+1][r], a[r] + pref[r-1] - pref[l-1] - dp[l][r-1]);
        }
    }
    cout << 2 * dp[1][n] - pref[n];

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif // LOCAL
    return 0;
}


Measured memory_bytes: 70016
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    int N;
    cin>>N;
    vector<int> A(N),B(N),C(N-1);
    rep(i,N){
        int a;
        cin>>a;
        a--;
        A.at(i)=a;
    }
    rep(i,N) cin>>B.at(i);
    rep(i,N-1) cin>>C.at(i);
    int ans=0;
    rep(i,N){
        ans+=B.at(A.at(i));
        if(i+1<N && A.at(i+1)-A.at(i)==1) ans+=C.at(A.at(i));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// }}}
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;

const int mod = 1e9 + 7;

// WARN : use H with larger N
/// --- Modulo Factorial {{{ ///
template < int N, int mod = (int) 1e9 + 7 >
struct Factorial {
  constexpr ll extgcd(ll a, ll b, ll &x, ll &y) {
    ll d = 0;
    return b == 0 ? (x = 1, y = 0, a) : (d = extgcd(b, a % b, y, x), y -= a / b * x, d);
  }
  constexpr ll modinv(ll a) {
    ll x = 0, y = 0;
    extgcd(a, mod, x, y);
    return (x + mod) % mod;
  }
  int arr[N + 1], inv[N + 1];
  ll operator[](int i) const { return arr[i]; }
#if !defined(DEBUG)
  constexpr
#endif
    Factorial()
    : arr(), inv() {
      arr[0] = 1;
      for(int i = 1; i <= N; i++) {
        arr[i] = (ll) i * arr[i - 1] % mod;
      }
      inv[N] = modinv(arr[N]);
      for(int i = N - 1; i >= 0; i--) {
        inv[i] = (ll)(i + 1) * inv[i + 1] % mod;
      }
    }
  ll C(int n, int r) const {
    if(n < 0 || r < 0 || n < r) return 0;
    return (ll) arr[n] * inv[r] % mod * inv[n - r] % mod;
  }
  ll H(int n, int r) const { return C(n + r - 1, r); }
};
/// }}}--- ///

const int N = 30;
Factorial < N, mod > fact;

int h, w, k;

int main() {
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  cin >> h >> w >> k;
  
  vector<ll> x(w + 1); // x[i] := when there's i vertical-lines, how many ways to make pairs?
  // O(W^2)
  for(int i = 0; i <= w; i++) {
    for(int j = 0; j * 2 <= i; j++) { // make j pairs
      // C(i - j, j)
      x[i] += fact.C(i - j, j);
    }
    x[i] %= mod;
  }
  vector<ll> dp(w);
  dp[0] = 1;

  vector<ll> dp2(w);
  // O(WH)
  for(int i = 0; i < h; i++) {
    dp2.assign(w, 0);
    for(int a = 0; a < w; a++) { // before
      // no. of RIGHT-side free vertical-lines = w - 1 - a
      // no. of LEFT-side  free vertical-lines = a
      // after = a
      dp2[a] += dp[a] * x[w - 1 - a] % mod * x[a] % mod;
      // after = a - 1
      if(a - 1 >= 0) dp2[a-1] += dp[a] * x[w - 1 - a] % mod * x[a - 1] % mod;
      // after = a + 1
      if(a + 1 < w) dp2[a+1] += dp[a] * x[w - 1 - a - 1] % mod * x[a] % mod;
    }
    for(auto &e : dp2) e %= mod;
    swap(dp, dp2);
  }

  // dp[k-1]

  cout << dp[k-1] << endl;
  
  return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"s=input()\n"
"g=p=a=0\n"
"for t in s:\n"
"  if t=='g':\n"
"    g+=1\n"
"  else:\n"
"    if p<g:\n"
"      p+=1\n"
"    else:\n"
"      g+=1\n"
"      a-=1\n"
"print(a+(g-p)//2)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3536
import java.util.Scanner;

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

			if(op.equals("?")) {
				break;
			}

			switch(op) {
			case "+" :
				System.out.println(a + b);
				break;
			case "-" :
				System.out.println(a - b);
				break;
			case "*" :
				System.out.println(a * b);
				break;
			case "/" :
				System.out.println(a / b);
				break;
			}
		}
		scan.close();
	}
}


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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 100000

int N;
long long T;
long long A[MAX];

long long b[MAX];

int main() {
	cin >> N >> T;
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}

	long long bmax = 0;
	long long mi = INF;
	for( int i = 0; i < N; i++ ) {
		mi = min( mi, A[i] );
		if( A[i] <= mi ) {
			continue;
		}
		long long ben = A[i] - mi;
		bmax = max( bmax, ben );
		b[i] = max( b[i], ben );
	}
	int ans = 0;
	for( int i = 0; i < N; i++ ) {
		if( b[i] >= bmax ) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		priority_queue<int, vector<int>, greater<int> > PQue;
		for(int i = 0; i < n; ++i)
		{
			int input;
			cin >>input;
			PQue.push(input);
		}
		vector<unsigned long long int> wait_time(n + 1);
		wait_time[0] = 0;
		int pos = 0;
		while(!PQue.empty())
		{
			wait_time[pos + 1] = PQue.top() + wait_time[pos];
			PQue.pop();
			pos++;
		}
		unsigned long long int sum = 0;
		for(int i = 0; i < n; ++i)
		{
			sum += wait_time[i];
		}
		cout << sum << endl;
	}
}

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

Measured memory_bytes: 0
import sys

input = sys.stdin.readline

def main():
    N = int(input())
    a = int(input())
    if a != 0:
        print(-1)
        return
    ans = 0
    flag = False
    for _ in range(N-1):
        tmp = int(input())
        if tmp == a + 1:
            ans += tmp
            ans -= a
        elif tmp < a + 1:
            ans += tmp
        else:
            print(-1)
            return
        a = tmp
    print(ans)    

if __name__ == "__main__":
    main()


Measured memory_bytes: 9016
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		n = n % 10;
		if(n==3){
			System.out.println("bon");
		}else if(n==0||n==1||n==6||n==8){
			System.out.println("pon");
		}else{
			System.out.println("hon");
		}
	}
}


Measured memory_bytes: 35756
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define lld long double
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli a,b,k;
	cin>>a>>b>>k;

	REP(i,0,k){
		if(a%2)a--;
		lli tmp = a/2;
		a-=tmp;
		b+=tmp;
		i++;

		if(i>=k)continue;

		if(b%2)b--;
		tmp = b/2;
		b-=tmp;
		a+=tmp;
	}
	cout<<a<<" "<<b<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main() {
    cin.tie(0);

    int n;cin>>n;
    vector<string> s(n);
    vector<int> p(n);
    vector<int>ans(n);

    for(int i=0;i<n;i++){
        cin>>s[i]>>p[i];
        ans[i]=i+1;
    }

    for(int i =0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(s[j] < s[j-1]) {
                swap(s[j],s[j-1]);
                swap(p[j],p[j-1]);
                swap(ans[j],ans[j-1]);
            }else if(s[j] == s[j-1]){
                if(p[j] > p[j-1]){
                    swap(s[j],s[j-1]);
                    swap(p[j],p[j-1]);
                    swap(ans[j],ans[j-1]);
                }
            }
        }
    }

    for(int i = 0;i<n;i++){
        cout<<ans[i]<<endl;
    }
}

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

int main() {
    int n;
    
    while (cin >> n) {
        int ans = 0;
        for (int a = 0; a < 10; a++) {
            for (int b = 0; b < 10; b++) {
                for (int c = 0; c < 10; c++) {
                    for (int d = 0; d < 10; d++) {
                        if (a + b + c + d == n) ans++;
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int x;
	cin >> x;
	const int g = __gcd(x, 360);
	const int answer = 360 / g;
	cout << answer << endl;
	return 0;
}



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

using namespace std;


int main() 
{
   


                
        
        


    int n;
    cin>>n;
    n=n%10;
    if(n==3)cout<<"bon"<<endl;
    else if(n==0||n==1||n==6||n==8)cout<<"pon"<<endl;
    else cout<<"hon"<<endl;
        
        
           
    




}

Measured memory_bytes: 3636
from sys import stdin
from math import ceil, floor
n,a,b=[int(x) for x in stdin.readline().rstrip().split()]
s=list(stdin.readline().rstrip())
c=a+b
d=e=m=0
for i in range(n):
    if d<c and s[i]=="a":
        print("Yes")
        d+=1
    elif d<c and e<b and s[i]=="b":
        print("Yes")
        d+=1
        e+=1
    else:
        print("No")
    if d>=c:
        m=i+1
        break
if m != 0:
    for i in range(n-m):
        print("No")

Measured memory_bytes: 9960
import java.util.*;
import java.io.*;
import static java.lang.System.*;

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
      if (ptr < buflen) {
          return true;
      }else{
          ptr = 0;
          try {
              buflen = in.read(buffer);
          } catch (IOException e) {
              e.printStackTrace();
          }
          if (buflen <= 0) {
              return false;
          }
      }
      return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)) {
          sb.appendCodePoint(b);
          b = readByte();
      }
      return sb.toString();
  }
  public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
          minus = true;
          b = readByte();
      }
      if (b < '0' || '9' < b) {
          throw new NumberFormatException();
      }
      while(true){
          if ('0' <= b && b <= '9') {
              n *= 10;
              n += b - '0';
          }else if(b == -1 || !isPrintableChar(b)){
              return minus ? -n : n;
          }else{
              throw new NumberFormatException();
          }
          b = readByte();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    String S = sc.next();
    if(S.equals("Sunny") ) out.println("Cloudy");
    if(S.equals("Cloudy") ) out.println("Rainy");
    if(S.equals("Rainy") ) out.println("Sunny");
    
  }
}

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

main(){
	int r,a ;
	while( cin >> r >> a ){
		if( !r && !a ) break ;
		
		int k=1000,p[4],q[4] ;
		for( int i=0 ; i<4 ; i++ ){
			p[i] = r/k ;
			q[i] = a/k ;
			r -= p[i]*k ;
			a -= q[i]*k ;
			k /= 10 ;
		}
		
		int cnt=0 , cnt2=0 ;
		for( int i=0 ; i<4 ; i++ ){
			if( p[i] == q[i] ){
				cnt++ ;
				continue ;
			}
			for( int j=0 ; j<4 ; j++ ){
				if( p[i] == q[j] ){
					cnt2++;
					continue ;
				}
			}
		}
		
		cout << cnt << " " << cnt2 << endl ;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define X first
#define Y second
#define vsort(v) sort(v.begin(), v.end())
#define vrev(v) reverse(v.begin(), v.end())
#define vmax_p(v) max_element(v.begin(), v.end())
#define vmin_p(v) min_element(v.begin(), v.end())
#define vmax_idx(v) distance(v.begin(), vmax_p(v))
#define vmin_idx(v) distance(v.begin(), vmin_p(v))
#define vcopy(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define P pair

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

// floor(x): truncate

// 2進数変換
// string s = bitset<20>(x).to_string();

using namespace std;
using ll = long long;

int main(int argc, const char *argv[])
{
    int a, b, t;
    cin >> a >> b >> t;
    cout << floor((t + 0.5) / a) * b << endl;
}


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

int main()
{
	int n;
	while (cin >> n, n) {
		string ga, de;
		vector<string> al(n), be(n);
		for (int i = 0; i < n; i++) {
			cin >> al[i] >> be[i];
		}
		cin >> ga >> de;
		map<string, int> re;
		queue<string> q;
		re[ga] = 1;
		q.push(ga);
		while (!q.empty()) {
			auto p = q.front(); q.pop();
			int sz = p.size();
			for (int j = 0; j < n; j++) {
				string t;
				for (int i = 0; i < sz; i++) {
					if (i + (int)al[j].size() <= sz && p.compare(i, al[j].size(), al[j]) == 0) {
						t += be[j];
						i += al[j].size() - 1;
					}
					else {
						t.push_back(p[i]);
					}
				}
				if (t.size() <= de.size() && re[t] == 0) {
					q.push(t);
					re[t] = re[p] + 1;
				}
			}
		}
		cout << re[de] - 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3388
from collections import deque

N, M = map(int, input().split())
l = [[] for _ in range(N)]
reached = [-1] * N
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    l[a].append(b)
    l[b].append(a)

def bfs():
    d = deque()
    d.append(0)
    while d:
        now = d.popleft()
        for i in l[now]:
            if reached[i] == -1:
                reached[i] = now
                d.append(i)

bfs()
print("Yes")
for i in range(1, N):
    print(reached[i]+1)
        
        



Measured memory_bytes: 34192
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define endl '\n'
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 <<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* coma = strchr(names + 1, ',');cerr.write(names, coma - names) << " : " << arg1<<" | ";__f(coma+1, args...);
}
#else
#define trace(...)
#endif
 
void file() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
}

int n, m;
std::vector<int> v[100005];
int dp[100005];
int solve(int idx)
{
   int & ret = dp[idx];
   if(~ret)return ret;
   int sum = 0;
   if(v[idx].size() == 0)return ret = 0;

   for(auto i : v[idx])
        sum = max(sum, solve(i));
    return ret = sum + 1;
}
int main(int argc, char const *argv[])
{
    // file();
    fast();
    cin>>n>>m;

    for (int i = 0; i < m; ++i)
    {
        int x,y;cin>>x>>y;
        v[x].push_back(y);
    }
    int ans = 0;
    clr(dp,  -1);
    for (int i = 1; i <= n; ++i)
    {
        ans = max(ans, solve(i));
    }
    cout<<ans;

}

Measured memory_bytes: 8192
import java.lang.Math.max

fun main(args: Array<String>) {
    val (K, N) = readLine()!!.split(" ").map(String::toInt)
    val houseList = readLine()!!.split(" ").map(String::toInt).toMutableList()
    houseList.add(houseList.first() + K)
    var m = 0
    for (i in 0 until (houseList.size - 1)) {
        m = m.coerceAtLeast(houseList[i + 1] - houseList[i])
    }

    println(K - m)
}


Measured memory_bytes: 83024
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////
int main() {
	ll N, K;
	cin >> N >> K;

	mint ans = 0;
	for (ll i = K; i <= N + 1; i++) {
		ans += i * (N - i + 1) + 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]

X, Y, A, B, C = mi()
pp = sorted(li())[-X:]
q = sorted(li())[-Y:]
r = sorted(li())

p = sorted(pp+q)

#len_r = len(r)-1
a_p = p.pop(-1)
a_r = r.pop(-1)
cnt = 0

for i in range(X+Y):
    if a_p >= a_r:
        cnt += a_p
        if p!=[]:
            a_p = p.pop(-1)
        else:
            break
    else:
        cnt += a_r
        if r==[]:
            a_r = 0
        else:
            a_r = r.pop(-1)
        
'''
a_q = q.pop(-1)

for i in range(Y):
    if a_q >= a_r:
        cnt += a_q
        if q!=[]:
            a_q = q.pop(-1)
        else:
            break
    else:
        cnt += a_r
        if r==[]:
            a_r = 0
        else:
            a_r = r.pop(-1)
'''
print(cnt)

Measured memory_bytes: 22412
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n, m;
  cin >> n >> m;

  vector<P> hambai(n);
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    hambai[i] = make_pair(a, b);
  }
  sort(all(hambai));
  ll ans = 0;
  rep(i, n) {
    if(m <= 0) break;
    ll kounyu = min(m, hambai[i].second);
    ans += hambai[i].first * kounyu;
    m -= kounyu;
  }
  cout << ans << endl;

  return 0;
}

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

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

    auto s = unordered_set<string>();
    auto s_i = string();
    for (int i = 0; i < n; i++) {
        cin >> s_i;
        s.emplace(std::move(s_i));
    }

    cout << s.size() << std::endl;
    return 0;
}


Measured memory_bytes: 17688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c, k, d;
  in3(a, b, c);
  in(k);
  d = max(a, b);
  d = max(d, c);
  if(a == d)
    a = 0;
  else if(b == d)
    b = 0;
  else
    c = 0;
  rep(i, k)
    d = d * 2;
  out(a + b + c + d);
  memi;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1e12;
ll dp[2005][2005];

int main() {
    // 貪欲ではダメそう、右に移動するものと左に移動するもの、DP
    // dp[i][j] 左はi個決めて、右はj個決める
    // 大きい活発度から左右に入れる場合、O(N^2)でも大丈夫
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<P> que;
    rep(i, N) que.emplace_back(A[i], i);
    sort(que.begin(), que.end());
    rep(i, N+2) rep(j, N+2) dp[i][j] = INF;
    dp[0][0] = 0;
    int people = 0;
    while (!que.empty()) {
        people++;
        auto p = que.back(); que.pop_back();
        int move = p.first, ind = p.second;
        // 左に入れる
        {
            for (int i = 1; i <= N; i++) {
                int right = people - i; // 右にいる人
                if (right < 0) break;
                int left = i-1; // 左にいた人
                if (dp[left][right] == INF) break; // 不可能
                if (dp[i][right] == INF) {
                    dp[i][right] = dp[left][right] + (ll)move * abs(ind - (i-1));
                } else {
                    dp[i][right] = max(dp[i][right], dp[left][right] + (ll)move * abs(ind - (i-1)));
                }
            }
        }
        // 右に入れる
        {
            for (int i = 1; i <= N; i++) {
                int left = people - i; // 左にいる人
                if (left < 0) break;
                int right = i-1; // 右にいた人
                if (dp[left][right] == INF) break; // 不可能
                if (dp[left][i] == INF) {
                    dp[left][i] = dp[left][right] + (ll)move * abs(ind - ((N-1)-(i-1)));
                } else {
                    dp[left][i] = max(dp[left][i], dp[left][right] + (ll)move * abs(ind - ((N-1)-(i-1))));
                }
            }
        }
    }
    ll ans = 0;
    rep(i, N) ans = max(ans, dp[i][N-i]);
    cout << ans << '\n';
    return 0;
    // ll, 0, -, 1i, for s&g, debug
}

Measured memory_bytes: 34992
#include <cstdio>
#define MAX 500000
#define SENTINEL 2e9

int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	for(int i=0;i<n1;i++){
		L[i]=A[left+i];
	}
	for(int i=0;i<n2;i++){
		R[i]=A[mid+i];
	}
	L[n1]=R[n2]=SENTINEL;
	int i=0,j=0;
	for(int k=left;k<right;k++){
		cnt++;
		if(L[i]<=R[j]){
			A[k]=L[i++];
		}else{
			A[k]=R[j++];
		}
	}
}

void mergeSort(int A[],int n,int left,int right){
	if(left+1<right){
		int mid=(left+right)/2;
		mergeSort(A,n,left,mid);
		mergeSort(A,n,mid,right);
		merge(A,n,left,mid,right);
	}
}

int main(void){
	int A[MAX],n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	mergeSort(A,n,0,n);
	for(int i=0;i<n;i++){
		printf("%d%c",A[i],i==n-1?'\n':' ');
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 4932
<?php
$input_line = fgets(STDIN);
$array = explode(" ", $input_line);
$W = $array[0];
$a = $array[1];
$b = $array[2];
//fscanf(STDIN, "%d %d %d", $W $a $b);
if ($a + $W >= $b && $a <= $b or $b + $W >= $a && $b <= $a) {
  echo 0;
} elseif ($a <= $b) {
  echo $b - ($a + $W);
} else {
  echo $a - ($b + $W);
}
?>


Measured memory_bytes: 4856
S = int(input())
K = int(input())
S_list = [int(x) for x in list(str(S))]
 
def saiki(i):
  if i == len(S_list):
    print("1")
    exit()
  if K == i:
    print("1")
    exit()
  if S_list[i] > 1:
    print(S_list[i])
    exit()
  if S_list[i] == 1:
    saiki(i+1)
 
print(saiki(0))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    ll n,p,b,c;
    string ans="";
    cin>>n;
    n--;
    while(n>25){
        b=n/26;
        c=n%26;
        ans=(char)(c+97)+ans;
        n=b-1;
    }
    ans=(char)(n+97)+ans;
    cout<<ans<<endl;
}

Measured memory_bytes: 3616