akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int main() {
	int N, x; cin >> N >> x;
	if (x == 1 || x == 2 * N - 1)
		cout << "No\n";
	else if (N == 2)
		cout << "Yes\n1\n2\n3\n";
	else if (x < 2 * N - 2) {
		vector<int> res(2 * N - 1, 0);
		res[N - 3] = x + 2;
		res[N - 2] = x - 1;
		res[N - 1] = x;
		res[N] = x + 1;
		int ptr = 0, nx = 1;
		while (ptr < 2 * N - 1) {
			while (res[ptr]) ptr++;
			while (x - 1 <= nx && nx <= x + 2) ++nx;
			res[ptr++] = nx++;
		}
		cout << "Yes\n";
		for (auto resi : res)
			cout << resi << "\n";
	}
	else { // x = 2 * N - 2
		vector<int> res(2 * N - 1,0);
		res[N - 3] = x - 2;
		res[N - 2] = x + 1;
		res[N - 1] = x;
		res[N] = x - 1;
		int ptr = 0, nx = 1;
		while (ptr < 2 * N - 1) {
			while (res[ptr]) ptr++;
			while (x - 2 <= nx && nx <= x + 1) ++nx;
			res[ptr++] = nx++;
		}
		cout << "Yes\n";
		for (auto resi : res)
			cout << resi << "\n";
	}
	return 0;
}

Measured memory_bytes: 2304
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {
            String n;

            n = Console.ReadLine();

            if (n[0] == '9' || n[1] == '9')
                Console.WriteLine("Yes");

                else
                Console.WriteLine("No");

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#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, ll>;
vector<P> distance;

int main()
{
    ll K, N;
    cin >> K >> N;
    vector<ll> A(N, 0);
    rep(i, N)
    {
        cin >> A[i];
    }

    ll max_distance = A[0];
    int start = 0;
    rep(i, N - 1)
    {
        if (max_distance < A[i + 1] - A[i])
        {
            max_distance = A[i + 1] - A[i];
            start = i + 1;
        }
    }
    if (max_distance < K - A[N - 1])
    {
        max_distance = K - A[N - 1];
        start = -1;
    }

    // start以外ー>全体引く最大
    ll ans = 0;
    // cout << start << endl;
    // cout << max_distance << endl;
    // 最大がA[0](start = 0)
    if (start == 0)
    {
        ans = K - A[0] - (K - A[N - 1]);
    }
    // 最大がA[N-1](start = -1)
    else if (start == -1)
    {
        ans = K - max_distance - A[0];
    }
    // 最大が途中(else)
    else
    {
        ans = K - max_distance;
    }

    if (max_distance < A[0] + (K - A[N - 1]))
    {
        ans = K - A[0] - (K - A[N - 1]);
    }

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

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

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

string s;

int solve(bool flag) {
  int res = 0;
  for (char c : s) {
    if (flag && c == '0') res++;
    if (!flag && c == '1') res++;
    flag = !flag; 
  }

  return res;
}

int main() {
  cin >> s;

  cout << min(solve(true), solve(false)) << endl;
  return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int H, W;
	string smap[51];

	cin >> H >> W;
	rep(i, 0, H)
	{
		cin >> smap[i];
	}

	const int dx[] = { 1,0,-1,0 };
	const int dy[] = { 0,1,0,-1 };
	rep(i, 0, H)rep(j, 0, W)
	{
		if (smap[i][j] == '#')
		{
			bool ok = false;
			rep(k, 0, 4)
			{
				int nx = j + dx[k];
				int ny = i + dy[k];
				if (0 <= nx && nx < W && 0 <= ny && ny < H)
				{
					if (smap[ny][nx] == '#')
					{
						ok = true;
						break;
					}
				}
			}
			if (!ok)
			{
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define All(x) (x).begin(),(x).end()
#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))
#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    ll c;

    cin >> n >> c;

    int len = n + 1;

    ll xLeft[len], xRight[len];
    ll vLeft[len], vRight[len];
    ll cumSumLeft[len], cumSumRight[len];
    ll maxLeft[len], maxRight[len];
    ll ans = 0;

    xLeft[0] = xRight[0] = vLeft[0] = vRight[0] = cumSumLeft[0] = cumSumRight[0] = maxLeft[0] = maxRight[0] = 0;

    int i;

    repiin(i, n, 1) {
        cin >> xLeft[i] >> vLeft[i];

        xRight[n - i + 1] = c - xLeft[i];
        vRight[n - i + 1] = vLeft[i];
    }

    repiin(i, n, 1) {
        cumSumLeft[i] = cumSumLeft[i - 1] - xLeft[i] + xLeft[i - 1] + vLeft[i];
        cumSumRight[i] = cumSumRight[i - 1] - xRight[i] + xRight[i - 1] + vRight[i];
        maxLeft[i] = max(maxLeft[i - 1], cumSumLeft[i]);
        maxRight[i] = max(maxRight[i - 1], cumSumRight[i]);
    }

    repin(i, n) {
        Max(ans, max(cumSumLeft[i], cumSumLeft[i] - xLeft[i] + maxRight[n - i]));
        Max(ans, max(cumSumRight[i], cumSumRight[i] - xRight[i] + maxLeft[n - i]));
    }

    Out(ans);

    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <numeric>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(int argc, char** argv) {
  unsigned long long n;
  unsigned long long a[5]{};
  cin >> n;
  for (int i = 0; i < 5; ++i) cin >> a[i];
  
  unsigned long long m = *min_element(a, a + 5);
  unsigned long long d = (n + m - 1) / m;
  cout << (d + 4) << endl;
}

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


void Main(){
    int N, R;
    cin >> N >> R;
    if(N<10){
        R += 100*(10-N);
    }
    cout << R << el;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>
#include <fstream>
using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
const double pi = 3.14159265359;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, n) for (int i = (int)(n-1); i >= 0; i--)
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    int n = (int)s.size();
    vector<vector<ll>> dp(100005, vector<ll>(13));
    dp[0][0] = 1;
    rep(i, n) {
        int c=0;
        if (s[i] == '?')c = -1;
        else c = s[i] - '0';

        rep(j, 10) {
            if (c != -1 && c != j)continue;
            rep(k, 13) {
                dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
            }
        }
        rep(j, 13)dp[i + 1][j] %= MOD;
    }
    cout << dp[n][5] << endl;
    return 0;
}

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

int n;
int ans = 1010101;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=1; i<n; ++i){
		int a = i;
		int b = n - i;
		int tmp = 0;
		while(a > 0){
			tmp += a % 10;
			a /= 10;
		}
		while(b > 0){
			tmp += b % 10;
			b /= 10;
		}
		ans = min(ans, tmp);
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
a,b = map(int,input().split())
count = 0
for i in range(a + 1):
    if (i * 2 + (a - i) * 4) == b:
        count += 1
if count == 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9172
#include<bits/stdc++.h>
#define ll long long
#define N 300005
using namespace std;
int f[N],k,n,top;
ll g[N];
int main(){
	scanf("%d %d",&k,&n);
	if (k%2==0){
		printf("%d ",k/2);
		for (int i=2;i<=n;i++)
			printf("%d ",k);
	}
	else{
		f[1]=k&1; g[1]=k;
		for (int i=2;i<=n;i++)
			f[i]=((f[i-1]+1)*k)&1;
		for (top=2;;){
			g[top]=(g[top-1]+1)*k;
			if (g[top]>1e12) break;
			if (top>n) break;
			top++;
		}
		int move=0;
		for (int i=n;i>=top;i--){
			printf("%d ",(k+1)/2);
			if (f[i]==1&&i!=n) move++;
		}
		top=min(top-1,n);
		ll rk=(g[top]+(top!=n)+1)/2-move;
		//printf("%d %lld\n",top,rk);
		for (int i=top;i;i--){
			//printf("%lld %lld %lld\n",rk,g[i]+(i!=n),(g[i]+(i!=n)+1)/2-rk);
			if (i!=n) rk--;	
			if (!rk) return 0;
			for (int j=1;j<=k;j++)
				if (rk<=g[i-1]+1){
					printf("%d ",j);
					break;
				}
				else rk-=g[i-1]+1;
		}
	}
}

Measured memory_bytes: 4096
if __name__ == "__main__":
    node_num = int(input())
    heap = list(map(lambda x: int(x), input().split()))

    for idx in range(len(heap)):
        idx += 1  # Change index to start from one.
        print(f"node {idx}: key = {heap[idx - 1]}, ", end="")

        parent_idx = idx // 2
        left_idx = 2 * idx
        right_idx = (2 * idx) + 1

        if 0 != parent_idx:
            print(f"parent key = {heap[parent_idx - 1]}, ", end="")
        if len(heap) >= left_idx:
            print(f"left key = {heap[left_idx - 1]}, ", end="")
        if len(heap) >= right_idx:
            print(f"right key = {heap[right_idx - 1]}, ", end="")

        print()


Measured memory_bytes: 5688
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int n;
  int nn = 0;
  while(cin>>n, n) {
    nn++;
    map<string ,string> mp;
    REP(i, n) {
      string a, b;
      cin >> a >> b;
      mp[a] = b;
    }
    string s, t;
    cin >> s >> t;
    map<string, int> dist;
    queue<string> Q;
    dist[s] = 0;
    Q.push(s);
    int res = -1;
    while(!Q.empty()) {
      string now =Q.front();
      Q.pop();
      //cout << dist[now] << " " << now << endl;

      if (now == t) {
        res = dist[now];
        break;
      }
      if (now.size() >= t.size()) continue;
      FOR(it, mp) {
        string a = it->first;
        string b = it->second;
        string tmp = now;
        for (int i=0; i<(int)tmp.size()-(int)a.size()+1; ++i) {
          //cout << ":" << tmp.substr(i, a.size()) << endl;
          if (tmp.substr(i, a.size()) == a) {
            string hoge;
            if (i+a.size()<tmp.size())
              hoge = tmp.substr(i+a.size());
            tmp = tmp.substr(0, i) + b + hoge;
            //cout << i << " " <<tmp.substr(0, i) << " " << b << " "  << hoge << endl;
            i += b.size()-1;
          }
        }
        if (dist.count(tmp)) continue;
        dist[tmp] = dist[now] + 1;
        Q.push(tmp);
      }
    }
    cout << res << endl;
    //if (res == 2) cout << " " << nn << endl;
  }
}

Measured memory_bytes: 1116
#include<cstdio>
#include<algorithm>
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	long long int x[n], y[n], z[n], ans, anss;
	for(int i=0;i<n;i++){
		scanf("%lld%lld%lld",&x[i],&y[i],&z[i]);
	}
	long long int d[n]={};
	ans=0;
	
	anss=0;
	for(int i=0;i<n;i++){
		d[i]=x[i]+y[i]+z[i];
	}
	std::sort(d,d+n);
	for(int i=n-1;i>=n-m;i--){
		anss+=d[i];
	}
	ans=std::max(ans, anss);
	
	anss=0;
	for(int i=0;i<n;i++){
		d[i]=x[i]+y[i]-z[i];
	}
	std::sort(d,d+n);
	for(int i=n-1;i>=n-m;i--){
		anss+=d[i];
	}
	ans=std::max(ans, anss);
	
	anss=0;
	for(int i=0;i<n;i++){
		d[i]=x[i]-y[i]+z[i];
	}
	std::sort(d,d+n);
	for(int i=n-1;i>=n-m;i--){
		anss+=d[i];
	}
	ans=std::max(ans, anss);
	
	anss=0;
	for(int i=0;i<n;i++){
		d[i]=x[i]-y[i]-z[i];
	}
	std::sort(d,d+n);
	for(int i=n-1;i>=n-m;i--){
		anss+=d[i];
	}
	ans=std::max(ans, anss);
	
	anss=0;
	for(int i=0;i<n;i++){
		d[i]=-x[i]+y[i]+z[i];
	}
	std::sort(d,d+n);
	for(int i=n-1;i>=n-m;i--){
		anss+=d[i];
	}
	ans=std::max(ans, anss);
	
	anss=0;
	for(int i=0;i<n;i++){
		d[i]=-x[i]+y[i]-z[i];
	}
	std::sort(d,d+n);
	for(int i=n-1;i>=n-m;i--){
		anss+=d[i];
	}
	ans=std::max(ans, anss);
	
	anss=0;
	for(int i=0;i<n;i++){
		d[i]=-x[i]-y[i]+z[i];
	}
	std::sort(d,d+n);
	for(int i=n-1;i>=n-m;i--){
		anss+=d[i];
	}
	ans=std::max(ans, anss);
	
	anss=0;
	for(int i=0;i<n;i++){
		d[i]=-x[i]-y[i]-z[i];
	}
	std::sort(d,d+n);
	for(int i=n-1;i>=n-m;i--){
		anss+=d[i];
	}
	ans=std::max(ans, anss);
	
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))


def main():
    S=["D"] + list(input())
    N=len(S)
    MOD=10**9+7

    A = [0] * (N+1)
    C = [0] * (N+1)
    Q = [0] * (N+1)

    for i in range(1,N+1):
        s = S[i-1]
        A[i] = A[i-1]
        C[i] = C[i-1]
        Q[i] = Q[i-1]
        if s == "A":
            A[i] += 1
        elif s == "C":
            C[i] += 1
        elif s == "?":
            Q[i] += 1
    
    # print(A,C,Q)
    ans = 0
    for i in range(1,N+1):
        s = S[i-1]
        if s == "?" or s == "B":
            l_A = A[i-1]
            l_Q = Q[i-1]
            r_Q = Q[-1] - Q[i]
            r_C = C[-1] - C[i]

    
            left = pow(2,l_Q,MOD) * l_A % MOD # 一個も使わないとき
            if l_Q > 0:
                left += l_Q * pow((1+pow(2,MOD-2,MOD)), l_Q-1,MOD) * pow(2,l_Q-1,MOD) % MOD # 1個以上使うとき
                left %= MOD
                left += l_A * (pow(3,l_Q,MOD)-pow(2,l_Q,MOD)) % MOD 


            right = pow(2,r_Q,MOD) * r_C % MOD # 一個も使わないとき
            if r_Q > 0:
                right += r_Q * pow((1+pow(2,MOD-2,MOD)), r_Q-1,MOD) * pow(2,r_Q-1,MOD) % MOD # 1個以上使うとき
                right %= MOD
                right += r_C * (pow(3,r_Q,MOD)-pow(2,r_Q,MOD)) % MOD 

            ans += left * right % MOD
            ans %= MOD


            
    ans %= MOD
    print(ans)






if __name__ == "__main__":
    main()

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

int main() {
  int N,k,S;
  cin >>N;
  S=0;
  k=N;
  for(int i=0; i<9;i++){
    if(k>0){
     S+=k%10;
     k/=10;
    }
    else{
      break;
    }
  }
  if(N%S==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
#define N 100012
int n,ans=0,s[N];
struct sec{int l,r;}a[N],ri;
inline bool cmp(sec x,sec y){return (x.l<y.l);}
int main(){
	scanf("%d",&n);int i;for(i=1;i<=n;i++)scanf("%d%d",&a[i].l,&a[i].r);s[0]=1e9;
	sort(a+1,a+n+1,cmp);for(i=1;i<=n;i++)s[i]=min(s[i-1],a[i].r);ri=a[n];
	for(i=n-1;i>=1;i--)
	{
		ans=max(ans,max(max(min(s[i-1],a[i].r)-a[i].l+1,0)+max(ri.r-ri.l+1,0),a[i].r-a[i].l+1+max(min(s[i-1],ri.r)-ri.l+1,0)));
		ri.r=min(ri.r,a[i].r);ri.l=max(ri.l,a[i].l);
	}printf("%d",ans);return 0;
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main(){
        int n,counter=0,min=1000000000;
        cin >> n;
        int x;
        for(int i=0 ; i<n ; i++ ){
                cin >> x;
                while(!(x%2)){
                        x/=2;
                        counter++;
                }
                if(counter==0){
                        cout <<'0'<<endl;
                        return 0;
                }
                if(min>counter){
                        min=counter;
                }
                counter=0;
        }
        cout << min << endl;
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
  ll n, m;
  cin >> n >> m;
  ll ans = 0;
  rep(i,m) {
    ll x;
    cin >> x;
    ans += x;
  }
  if(n < ans){
    cout << -1 << endl;
  }else{
    cout << n - ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3624
n = int(input())
b = [10**6] + list(map(int, input().split()))
a = [0] * n
a[0] = b[1]
a[n-1] = b[n-1]

for i in range(1, n-1):
    a[i] = min(b[i], b[i+1])

print(sum(a))


Measured memory_bytes: 3060
/* AtCoder コピペ */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repEq(i, n) for (int i = 0; i <= (int)(n); i++)
#define repVector(i, v) for (auto i = v.begin(); i != v.end(); ++i)

#define ifBetween(n, a, b) if (n > a && n < b)
#define ifBetweenEq(n, a, b) if (n >= a && n <= b)

int main() {
	int a, b, h;

  	cin >> a;
  	cin >> b;
  	cin >> h; 

  	cout << ((a + b) * h / 2) << endl;
}


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

dp = [10 ** 5 for i in range(N)]

for i in range(N):
    if i == 0:
        dp[0] = 0
    elif i == 1:
        dp[1] = dp[0] + abs(h_array[1] - h_array[0])
    else:
        dp[i] = min(dp[i - 1] + abs(h_array[i] - h_array[i - 1]), dp[i - 2] + abs(h_array[i] - h_array[i - 2]))
print(dp[N - 1])


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

int main(){
	ll n,s,m=998244353,ans=0;
	cin >> n >> s;
	vector<ll> a(n),dp(3001,0);
	for(auto &&x:a)cin >> x;
	for(auto &&x:a){
		vector<ll> t(3001,0);
		for(int i=0;i<3001;i++){
			( t[i] += dp[i] ) %= m;
			if(i+x<=3000)( t[i+x] += dp[i] ) %= m;
		}
		t[0]++;
		t[x]++;
		dp = t;
		( ans += dp[s] ) %= m;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
int par[114514], rrank[114514];//親、木の深さ
void init(int n) {
	rep(i, n) {
		par[i] = i;
		rrank[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rrank[x] < rrank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rrank[x] == rrank[y])rrank[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
string s;
int dight(int i, int j) {
	int ans = 0;
	for (int k = i; k <= j; k++) {
		ans += (s[k] - '0') * mod_pow(10, j - k, inf);
	}
	return ans;
}
signed main() {
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a + b) * h / 2 << endl;
	ggr
}


Measured memory_bytes: 256
#include <cstdio>
int A, B, C, R;
int main()
{
	scanf("%d%d%d", &A, &B, &C);
	if (!(A & 1) && A == B && B == C)
		puts("-1");
	else
	{
		while (!(A & 1) && !(B & 1) && !(C & 1))
		{
			int _A = B + C >> 1, _B = A + C >> 1, _C = A + B >> 1;
			A = _A;
			B = _B;
			C = _C;
			R++;
		}
		printf("%d\n", R);
	}
	return 0;
}


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


int main() {
    ll n; cin>>n;
    vector<ll> a(n);
    constexpr ll max=1e18;
    ll ans=1;
    rep(i,n){
        cin>>a.at(i);
        if(a.at(i)==0){
            cout<<0<<endl;
            return 0;
        }
    }
    rep(i,n){
        if(a.at(i)>max/ans){
            cout<<-1<<endl;
            return 0;
        }
        else{
            ans*=a.at(i);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3980
#include <cstdio>
#include <algorithm>

bool cell[9];

int main()
{
	int a[9];
	for (int i = 0; i < 9; ++i)
	{
		scanf("%d", a + i);
	}
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		int b;
		scanf("%d", &b);
		for (int j = 0; j < 9; ++j)
		{
			if (a[j] == b) cell[j] = true;
		}
	}
	bool ok = false;
	for (int i = 0; i < 3; ++i)
	{
		ok |= (cell[i * 3] && cell[i * 3 + 1] && cell[i * 3 + 2]);
		ok |= (cell[i] && cell[3 + i] && cell[6 + i]);
	}
	ok |= (cell[0] && cell[4] && cell[8]) || (cell[2] && cell[4] && cell[6]);
	puts(ok ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 128
def partition(a, m, p, r)
	x = a[r]
	i = p - 1
	for j in p..r-1
		if a[j] <= x
			i += 1
			a[j],a[i] = a[i],a[j]
			m[j],m[i] = m[i],m[j]
		end
	end
	a[r],a[i+1] = a[i+1],a[r]
	m[r],m[i+1] = m[i+1],m[r]
	return i+1
end

def quicksort(a, m, p, r)
	if p < r
		q = partition(a, m, p, r)
		quicksort(a, m, p, q-1)
		quicksort(a, m, q+1, r)
	end
end

n = gets.to_i
a = Array.new
m = Array.new
num_cnt = Hash.new
n.times { |i|
	m[i],a[i] = gets.split(" ")
	a[i] = a[i].to_i
	j = a[i]
	if num_cnt[j] == nil
		num_cnt[j] = Array.new
	end
	num_cnt[j].push(m[i])
}

quicksort(a,m,0,n-1)

i = n - 1
f = 0
while i >= 0
	j = a[i]
	if m[i] != num_cnt[j].pop
		f = 1
		break
	end
	i -= 1
end

if f == 1
	puts "Not stable"
else
	puts "Stable"
end

i = 0
while i < n
	puts m[i] + " " + a[i].to_s
	i += 1
end

Measured memory_bytes: 27808
/*siddharth goyal*/
#include<bits/stdc++.h>
using namespace std;
#define   pb              push_back
#define   REP(i,n)        for(int i=1;i<=n;i++)
#define   FOR(i,a,b)      for(int i=a;i<=b;i++)
#define   all(v)          v.begin(),v.end()
#define   F               first
#define   S               second
#define   vl              vector<LL>
#define   itr             ::iterator it
#define   lb              lower_bound
#define   ub              upper_bound
#define   LL              long long
#define   ULL             unsigned long long
#define   ret             return 
#define   sz(x)           (LL)x.size()
LL n,i,j,ans = 0;
string s ; 
LL dp[1000000] ; 
LL a[1000000] ; 
int main()
{   // Read the constraints,highlights,Time Limit,Test Cases
    cin>>n ; 
    REP(i,n) cin>>a[i] ; 
    dp[1] = 0 ; 
    dp[2] = abs(a[2] - a[1]) ; 
    for(int i=3;i<=n;i++) dp[i] = min(dp[i-2] + abs(a[i-2] - a[i]),dp[i-1] + abs(a[i-1] - a[i])) ; 
    
    cout<<dp[n] ; 

}
//Check for 0,1 and other corner cases.

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;

char s[200005];int n;
ll q[32];

int main(){
	scanf("%s",s);n=strlen(s);
	fore(i,0,n)q[s[i]-'a']++;
	ll r=1LL*n*(n-1)/2+1;
	fore(i,0,26)r-=1LL*q[i]*(q[i]-1)/2;
	printf("%lld\n",r);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C,res;
    cin>>A>>B>>C;
    res=C-(A-B);
    if(res<0){
        cout<<"0"<<endl;
    }
    else{
        cout<<res<<endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
  ll n;
  cin>>n;
  V<ll> a(n),b(n);
  priority_queue<P> pq;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++){
    cin>>b[i];
    pq.emplace(b[i]-a[i],i);
  }
  ll ans=0;
  while(pq.size()){
    auto p=pq.top();
    pq.pop();
    if(p.fi==0)continue;
    if(0<=p.fi-b[(p.se+n-1)%n]-b[(p.se+1)%n]){
      ll s=b[(p.se+n-1)%n],t=b[(p.se+1)%n];
      ans+=(p.fi)/(s+t);
      if((p.fi)/(s+t)==0){
          cout<<-1<<"\n";
          return 0;
      }
      b[p.se]-=(p.fi)/(s+t)*(s+t);
      p.fi%=(s+t);
      if(p.fi)pq.emplace(p.fi,p.se);
    }else{
      cout<<-1<<"\n";
      return 0;
    }
  }
  cout<<ans<<"\n";
}


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

void solve(long long A)
{
    string Bstr;
    cin >> Bstr;
    ll B;
    if (Bstr.size() == 1) {
        B = stoll(Bstr);
    } else {
        B = (Bstr[0] - '0') * 100 + (Bstr[2] - '0') * 10;
        if (Bstr.size() == 4) {
            B += Bstr[3] - '0';
        }
    }

    ll ans = A * B / 100;
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
int main(){
    long long A;
    scanf("%lld",&A);
    solve(A);
    return 0;
}


Measured memory_bytes: 3668
import heapq

N, M, S = map(int, input().split())
Map = [[] for _ in range(N)]
Ans = [[float('inf')] * 2500 for _ in range(N)]
for _ in range(M):
    u, v, a, b = map(int, input().split())
    u -= 1
    v -= 1
    Map[u].append((v, a, b))
    Map[v].append((u, a, b))

for i in range(N):
    c, d = map(int, input().split())
    Map[i].append((i, -c, d))

Q = []
heapq.heappush(Q, (0, 0, min(2499, S))) # 今の時間、場所、持っているお金
Ans[0][min(2499, S)] = 0
while Q:
    time, where, money = heapq.heappop(Q)
    for nex, cost, take in Map[where]:
        if cost > money:
            continue
        if Ans[nex][min(2499, money - cost)] > time + take:
            Ans[nex][min(2499, money - cost)] = time + take
            heapq.heappush(Q, (time + take, nex, money - cost))

for a in Ans[1:]:
    print(min(a))

Measured memory_bytes: 101916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> l(n+1);
    l[0]=0;
    rep(i,n){
        int x;
        cin >> x;
        l[i+1]=l[i]+x;
    }

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

Measured memory_bytes: 3624
n,m = map(int, input().split())
X = [int(x) for x in input().split()]
Y = [int(x) for x in input().split()]
def f(a, n):
    return sum([(n - 1 - 2*i) * x for i, x in enumerate(reversed(a))])
print(f(X, n) * f(Y, m) % (10**9 + 7))

Measured memory_bytes: 19580
from numpy import*
n,m=map(int,input().split())
l=[]
for i in range(m):
    *a,=map(int,input().split())
    l.append(a[1:])
*p,=map(int,input().split())
 
ans=0
for t in range(2**n):
    tmp=array([t>>s&1 for s in range(n)])
    if p==[sum(tmp[array(i)-1])%2for i in l]:
        ans+=1
print(ans)

Measured memory_bytes: 12448
// Last Change: 05/19/2019 21:04:58.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  char c = S[K - 1];
  if (c >= 'A' and c <= 'Z') {
    c += 0x20;
  }
  S[K - 1] = c;

  cout << S;

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 888
#include <algorithm>
#include <iostream>
#include <cstring>
#include <bitset>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>

int n, k, u, v;
int c[100010], d[100010];
std::vector <int> g[100010];

void getD(int x, int fr)
{
    for (auto i : g[x])
        if (i != fr)
            d[i] = d[x] + 1, getD(i, x);
}

void dfs(int x, int fr)
{
    int cnt = 0;
    for (auto i : g[x])
        if (i != fr)
        {
            c[i] = k - 2 - (cnt++);
            dfs(i, x);
        }
}

int main()
{
    std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);
    std::cin >> n >> k;
    for (int i = 1; i < n; ++i)
        std::cin >> u >> v,
        g[u].push_back(v), g[v].push_back(u);
    c[1] = k;
    for (int i = 0, lim = g[1].size(); i < lim; ++i)
        c[g[1][i]] = k - (i + 1), dfs(g[1][i], 1);
    long long ans = 1;
    for (int i = 1; i <= n; ++i)
    {
        (ans *= 1ll * c[i]) %= 1000000007;
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 9600
import java.util.Scanner;
import java.util.HashMap;
import java.util.Collections;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      HashMap<String, Integer> list = new HashMap<String, Integer>();
      int count;
      int max=0;
      for(int i=0;i<n;i++){
        String s = sc.next();
        if(list.containsKey(s)) {
          count=list.get(s)+1;
        }else{
          count=1;
        }
        max=Math.max(max,count);
        list.put(s,count); 
      }
      ArrayList<String> strlist = new ArrayList<>();
      for(String Key : list.keySet()){
        if(list.get(Key)==max){
           strlist.add(Key);
        }
      }
      Collections.sort(strlist);
      for(String i : strlist) {
            System.out.println(i);
      }
    }
}


Measured memory_bytes: 82048
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

using namespace std;

int f[1 << 13];

int main() {

  int n, m; cin >> n >> m;
  memset(f, 0x7f, sizeof(f));
  f[0] = 0;
  int all = 1 << n;
  for (RI i = 1; i <= m; ++i) {
    int cost, cnt; cin >> cost >> cnt;
    int s = 0;
    for (RI j = 1, x; j <= cnt; ++j)
      cin >> x, s |= (1 << (x - 1));
    for (RI j = 0; j < all; ++j)
      f[j | s] = min(f[j | s], f[j] + cost);
  }
  if (f[all - 1] == 0x7f7f7f7f) puts("-1");
  else printf("%d\n", f[all - 1]);
  
  return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input!(a: usize, b: usize);
    let n = 100;
    let mut ans = vec![vec![0; n]; n];
    for i in 0..n {
        for j in 0..n {
            ans[i][j] = match (i, j) {
                (0, _) => 0,
                (i, _) if i == n - 1 => 1,
                (_, j) => 1 - j % 2,
            }
        }
    }

    for k in 0..b - 1 {
        let q = k / (n / 2);
        let r = k % (n / 2);
        ans[2 * (q + 1)][2 * r] ^= 1;
    }

    for k in 0..a - 1 {
        let q = k / (n / 2);
        let r = k % (n / 2);
        ans[n - 1 - (2 * (q + 1))][n - 1 - (2 * r)] ^= 1;
    }

    println!("{} {}", n, n);
    for v in ans {
        println!(
            "{}",
            String::from_utf8(
                v.into_iter()
                    .map(|i| match i {
                        0 => b'.',
                        1 => b'#',
                        _ => panic!(),
                    })
                    .collect::<Vec<u8>>()
            )
            .unwrap()
        );
    }
}


Measured memory_bytes: 2276
while line=gets
  hit = 0
  blow = 0
  cs = []
  as = line.chomp.split(' ').map(&:to_i)
  bs = readline.chomp.split(' ').map(&:to_i)
  if as[0] == bs[0]
    hit += 1 
  else
    cs << as[0]
  end
  if as[1] == bs[1]
    hit += 1 
  else
    cs << as[1]
  end
  if as[2] == bs[2]
    hit += 1 
  else
    cs << as[2]
  end
  if as[3] == bs[3]
    hit += 1 
  else
    cs << as[3]
  end
  cs.each do |c|
    blow += 1 if bs.include?(c)
  end
  puts "#{hit} #{blow}"
end

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

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

#define cout cout << setprecision(12)

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void dbg(T a) { cout << a << ' ' << endl; }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
    cin >> n;
	if (n % 2 == 1) {
    	cout << 0 << endl;
    	return 0;
    }
	k = 1;
	while(true) {
    	k *= 5;
    	if (k > n) { break; }
    	cnt += (n / (10 * k));
    }
	cnt += n / 10;
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define rrep(i,n) for(ll i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const ll mod = 1000000007;

int modPow(long long a, long long n, long long p) {
	if (n == 1) return a % p;
	if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
	long long t = modPow(a, n / 2, p);
	return (t * t) % p;
}

ll comb(ll n, ll p) {
	if (p * 2 > n) p = n - p;
	if (p > n - p) p = n - p;
	ll a = 1, b = 1;
	rrep(i, p + 1) {
		a = (a * (n - i + 1)) % mod;
		b = (b * i) % mod;
	}
	return a * (modPow(b, mod - 2, mod)) % mod;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, a, b; cin >> n >> a >> b;

	ll res = modPow(2, n, mod) - 1;
	ll res1 = comb(n, a);
	ll res2 = comb(n, b);

	ll ans = ((res - res1 - res2) % mod + mod)%mod;

	dunk(ans);

	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  REP(i,N){
    cin >> s.at(i);
   }

int a=0;
REP(i,N){
  int flag=1;
  REP(j,N){
    REP(k,N){
      if(s[(N+j-i)%N][k] != s[(N+k-i)%N][j]) {
        flag =0;
        break;
      }
    }
  }
  if(flag == 1) {
    a+=1;
  }
  
}

cout << N*a << endl;
}





Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int selectionSort(int *a, int n);

int main()
{
	int n;
	int a[100];

	scanf("%d", &n);

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

	int cnt;
    cnt = selectionSort(a, n);

	for (int i = 0; i < n; i++){
		if (i == n - 1){
			cout << a[i] << endl;
		}
		else {
			cout << a[i] << " ";
		}
	}

	cout << cnt << endl;

	return (0);
}

int selectionSort(int *a, int n)
{
	int cnt = 0;

	for (int i = 0; i < n - 1; i++){
		int minj = i;
		for (int j = i; j < n; j++){ // ?????´????????????????°??????¢???
			if (a[j] < a[minj]){
				minj = j;
			}
		}
		swap(a[i], a[minj]);
		if (i != minj){
			cnt++;
		}
	}

	return (cnt);
}

Measured memory_bytes: 1208
<?php
  $input = explode(" ", fgets(STDIN));
  $K = intval($input[0]);
  $S = intval($input[1]);
  
  $count = 0;
  for ($x = 0; $x <= $K; $x++) {
    for ($y = 0; $y <= $K; $y++) {
      // K以内でx + y = z
      $z = $S - ($x + $y);
      // S - x + y を保存してて、K以内だったらまたif分にいく
      if ($z <= $K && 0 <= $z) {
        if ($x + $y + $z == $S) {
          $count++;
        }
      }
    }
  }
  echo $count;


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

int read()
{
	int ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10+ch-'0';
	if(flag)ans=-ans;
	return ans;
}

long long rell()
{
	long long ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10ll+(long long)(ch-'0');
	if(flag)ans=-ans;
	return ans;
}

void writ(int n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}

void wrll(long long n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10ll)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}
const int N=1<<18;
int a[N];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		a[i]=read()-1;
	}
	int ans=0;
	for(int i=1;i<n;i++)
	{
		if(a[i]==i && a[i-1]==i-1)swap(a[i],a[i-1]),ans++;
	}
	for(int i=1;i<n;i++)
	{
		if(a[i]==i || a[i-1]==i-1)swap(a[i],a[i-1]),ans++;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int n, m, l, count, count_2, count_3, a[100][100], b[100][100]; 
	long c[100][100];

	scanf("%d %d %d", &n, &m, &l);

	for (count = 0; count < n; count++)
	{
		for (count_2 = 0; count_2 < m; count_2++)
		{
			scanf("%d", &a[count][count_2]);
		}
	}

	for (count = 0; count < m; count++)
	{
		for (count_2 = 0; count_2 < l; count_2++)
		{
			scanf("%d", &b[count][count_2]);
		}
	}

	for (count = 0; count < n; count++)
	{
		for (count_2 = 0; count_2 < l; count_2++)
		{
			for (c[count][count_2] = 0, count_3 = 0; count_3 < m; count_3++)
			{
				c[count][count_2] = c[count][count_2] + a[count][count_3] * b[count_3][count_2];
			}
		}
	}

	for (count = 0; count < n; count++)
	{
		for (count_2 = 0; count_2 < l; count_2++)
		{
			printf("%ld", c[count][count_2]);

			if (count_2 < (l - 1))
			{
				printf(" ");
			}
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2048
from collections import deque

N,K = list(map(int,input().split(' ')))
P = list(map(int,input().split(' ')))
sigma_max = 0
sigma = 0

queue = deque()

count = 1
for p in P:
    if count<=K:
        queue.append(p)
        sigma += p
        if sigma>sigma_max:
            sigma_max=sigma
    else:
        d = queue.popleft()
        queue.append(p)
        sigma -= d
        sigma += p
        if sigma>sigma_max:
            sigma_max=sigma
    count+=1

print((sigma_max+K)/2.0)

Measured memory_bytes: 25572
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        A, B = map(int, input().split())

        ans = (A * B) // self.gcd(A,B)
        print(ans)

    def gcd(self, a, b):
        if b == 0:
            return a
        else:
            return self.gcd(b, a % b)

# Run main
if __name__ == '__main__':
    AtCoder().main()


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

using namespace std;

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

  int n;
  cin >> n;
  set<int> s;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    s.insert(t);
  }
  cout << s.size() << "\n";
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>
#include <stdio.h>
#include <functional>
#include <chrono>
using namespace std;

#define rep(i,s,n) for(ll i=s;i<(n);++i)
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = (1LL << 60);
constexpr ll MAX_INF = 9223372036854775807;
constexpr ll MOD = (1e9 + 7);
//constexpr ll MOD = (998244353);

using vl = vector<ll>;
using vvl = vector<vector<ll>>;

template<class T>
vector<vector<T>> vvt(T init, ll m, ll n) {
	vector<vector<T>> ans = vector<vector<T>>(m, vector<T>(n, init));
	return move(ans);
}

template<class T>
vector<T> vt(T init, ll n) {
	vector<T> ans = vector<T>(n, init);
	return move(ans);
}

template<class T>
T maxVec(vector<T>& v) {
	T ans = -INF;
	rep(i, 0, v.size()) {
		ans = max(ans, v[i]);
	}
	return ans;
}

// 素数判定
bool judge(ll n) {
	for (ll i = 2; i * i <= n; i++) if (n %= i)return false;
	return true;
}


template <class C>
void print(const C & c, std::ostream & os = std::cout)
{
	std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, ", "));
	os << std::endl;
}
/*
ll count(ll n,ll r) {
	ll ans = 0,check = 1;
	rep(i,0, r) {
		if ((n & check) > 0) {
			ans++;
		}
		check = check << 1;
	}
	return ans;
}
*/
bool sortreverse(ll a, ll b) {
	return a > b;
}

ll kiriage(ll a, ll b) {
	if (a % b == 0)return a / b;
	return a / b + 1;
}

ll n, m, x, y, t, q, s,k;

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

int main() {
	cin >> n >> k;
	vl a(n);
	rep(i, 0, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	vl factorial(n + 5, 1),invFactorial(n+5);
	rep(i, 1, n+5) {
		factorial[i] = (factorial[i - 1] * i) % MOD;
		invFactorial[i] = modinv(factorial[i], MOD);
	}
	invFactorial[0] = modinv(factorial[0], MOD);
	ll ans = 0;
	rep(i, 0, n) {
		if (n - i >= k) {
			ll num = n - i - 1;
			ll M = (factorial[num] * invFactorial[k - 1]) % MOD;
			M *= invFactorial[num - (k - 1)];
			M %= MOD;
			M *= a[i];
			M %= MOD;
			ans += MOD - M;
			ans %= MOD;
		}
		if (i + 1 >= k) {
			ll num = i;
			ll M = (factorial[num] * invFactorial[k - 1]) % MOD;
			M *= invFactorial[num - (k - 1)];
			M %= MOD;
			M *= a[i];
			M %= MOD;
			ans += M;
			ans %= MOD;
		}
	}
	printf("%lld\n", ans);
}

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

template <typename T>
struct twodimBIT{
    private:
        vector<vector<T> > array;
        const int n;
        const int m;
    public:
        //初期化
        twodimBIT(int _n, int _m) : array(_n + 1, vector<T>(_m + 1, 0)), n(_n), m(_m) {}

        // (1,1)から(x, y)までの累積和を求める
        T sum(int x, int y){
            T s = 0;
            for(int i = x; i > 0; i -= i & (-i))
                for(int j = y; j > 0; j -= j & (-j))
                    s += array[i][j];
            return s;
        }

        //[(x1, y1), (x2, y2)]の要素のわ
        T sum(int x1, int y1, int x2, int y2){
            return sum(x2, y2) - sum(x1 - 1, y2) - sum(x2, y1 - 1) + sum(x1-1, y1-1);
        }

        //(x, y)に要素kを追加
        void add(int x, int y, T k){
            for(int i = x; i <= n; i+=i&(-i))
                for(int j = y; j <= m; j += j&(-j))
                    array[i][j] += k;
        }
};

int main(){
    int N, M, Q; cin >> N >> M >> Q;
    vector<pair<int, int>> Trn(M), Qst(Q);
    
    rep(i, M) cin >> Trn[i].first >> Trn[i].second;
    rep(i, Q) cin >> Qst[i].first >> Qst[i].second;

    twodimBIT<int> cnt(N,N);
    rep(i, M){
        cnt.add(Trn[i].first, Trn[i].second, 1);
    }

    rep(i, Q){
        cout << cnt.sum(Qst[i].first, 0, N, Qst[i].second) << endl;
    }
}

Measured memory_bytes: 4224