akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
 
int main(){
  int n,a[100],temp,j,i,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      if(a[i]<a[j]){
        temp=a[i];
        a[i]=a[j];
        a[j]=temp;
      }
    }
  }
  for(i=0;i<n;i++){
    if(i%2==0) sum+=a[i];
    else sum-=a[i];
  }
  printf("%d\n",sum);
}


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

#define ll long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define MOD 1000000007
#define println(x) cout << "[" << #x << ":" << x << "]\n"; 
#define print(x) cout << "[" << #x << ":" << x << "] "; 

double dp[301][301][301];

double solve(int one, int two, int three, int &n){
	if(one < 0 || two < 0 || three < 0)
		return 0;
	if(one == 0 && two == 0 && three == 0)
		return 0;
	if(dp[one][two][three] > 0)
		return dp[one][two][three];
	int remaining_sushi = one + two + three;
	double exp_value = n + one*solve(one-1, two, three, n) + two*solve(one+1, two-1, three, n) + three*solve(one, two+1, three-1, n);
	return dp[one][two][three] = (double)exp_value/remaining_sushi;
}

int main(){
	ios::sync_with_stdio(0); 
    cin.tie(0); 
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int n; cin >> n;
	int one = 0, two = 0, three = 0;
	for(int i=0; i<n; i++){
		int x; cin >> x;
		if(x == 1)
			one++;
		else if(x == 2)
			two++;
		else
			three++;
	}

	memset(dp, -1, sizeof dp);
	cout << fixed << setprecision(10) << solve(one, two, three, n);
	return 0;
}

Measured memory_bytes: 216864
#include<stdio.h>
#include<math.h>

typedef struct{
  double x,y;
}Point;

void kei(int,Point,Point);

int main(){
  Point a,b;
  int n;

  scanf("%d",&n);

  a.x = a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%f %f\n",a.x,a.y);

  kei(n,a,b);

  printf("%f %f\n",b.x,b.y);
  return 0;
  
}

void kei(int n,Point a,Point b){
  Point s,t,u;
  double th = M_PI * 60.0 / 180.0;

  if(n==0)return;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x -s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x -s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  kei(n-1,a,s);
  printf("%f %f\n",s.x,s.y);
  kei(n-1,s,u);
  printf("%f %f\n",u.x,u.y);
  kei(n-1,u,t);
  printf("%f %f\n",t.x,t.y);
  kei(n-1,t,b);
  
}



Measured memory_bytes: 2048
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }
        int[] q = new int[n];
        for (int i = 0; i < n; i++) {
            q[i] = sc.nextInt();
        }
        int[] fac = new int[n];
        fac[0] = 1;
        for (int i = 1; i < n; i++) {
            fac[i] = fac[i - 1] * i;
        }
        long res = Math.abs(per(p, n, fac) - per(q, n, fac));
        System.out.println(res);
    }

    private static long per(int[] p, int n, int[] fac) {
        long res = 0;
        for(int i=0;i<n;++i)
        {
            int k=0;
            for(int j=i+1; j<n; ++j)
                if(p[j] < p[i])
                {
                    k++;
                }
            res += fac[n-i-1]*k;
        }
        return res;
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;
// int64_t INF = 9223372036854775807;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s;
    cin >> s;
    // 1つ単位でわけていく
    // 隣と同じだったら2つくっつける
    int64_t res = 0;
    if(s.size()==1){
        cout << 1 << endl;
        return 0;
    }
    rep(i,s.size()-2){
        if(s.at(i) == '#') continue;
        if(s.at(i) == s.at(i+1)){
            s.at(i+1) = '#';
            s.at(i+2) = '#';
            res+=2;
            // cout << s << endl;
        }else{
            res++;
        }
    }

    char last1 = s.at(s.size()-1);
    char last2 = s.at(s.size()-2);
    if(last1!='#') res++;
    if(last2!='#') res++;
    if(last1!='#' && last2!='#' && last1==last2) res--;
    cout << res << endl;
}

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

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

    int n;
    cin >> n;
    vector<int> vi;
    vi.push_back(0);
    for (int i = 0; i < n; i++) 
    {
        int a;
        cin >> a;
        vi.push_back(a);
    }
    int count = 0;
    int now = 1;
    while (true) 
    {
        now = vi[now];
        count++;
        if (now == 2) break;
        if (count > n)
        {
            count = -1;
            break;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n,k;
    cin >> n;
    cin >> k;
    
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 0;i < n;i++){
        ans += 2 * min(a[i], k - a[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DEBUG_OUTPUT_ENABLED 1
	#define DBG(X) dout << #X << "=" << (X) << '\n';
	#define SAY(X) dout << (X) << '\n';
#else
	#define DEBUG_OUTPUT_ENABLED 0
	#define DBG(X) 42;
	#define SAY(X) 42;
#endif

#define dout   debug::instance

using namespace std;

template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
namespace debug {
	struct DebugStream {
		private:
			bool is_first;
		public:
			DebugStream(bool _is_first): is_first(_is_first) {}
			template<typename T> DebugStream operator<<(const T& value) const {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				cout << value;
				return DebugStream(false);
			};

			template<typename T> DebugStream printArray(T* l, T* r) {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				while(l != r) {
					cout << (*l);
					++l;
					if(l == r) {
						cout << '\n';
					} else {
						cout << ' ';
					}
				}
				return DebugStream(false);
			}
	};
	DebugStream instance(true);
};

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }
inline ll Get(ll X, ll Y, ll Z) {
	return X + Y + Z - X % 2 - Y % 2 - Z % 2;
}
void solve() {
	ll I = fetch<ll>();
	ll O = fetch<ll>();
	ll T = fetch<ll>();
	ll J = fetch<ll>();
	ll L = fetch<ll>();
	ll S = fetch<ll>();
	ll Z = fetch<ll>();
	ll ANSW1 = O + Get(I, L, J);
	ll ANSW2 = (I && L && J ? O + 3 + Get(I - 1, L - 1, J - 1) : 0);
	cout << max(ANSW1, ANSW2) << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


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

 int main(){
   string A="QWERTYUIOPASDFGHJKLZXCVBNM";
   string a="qwertyuiopasdfghjklzxcvbnm";
   char alpha;
   cin>>alpha;
   
   for(int i=0;i<26;i++){
     if(alpha == A.at(i))
       cout<<"A"<<endl;
     if(alpha == a.at(i))
       cout<<"a"<<endl;
   }
     return 0;
 }


Measured memory_bytes: 3620
n = int(input())
pow2s = [2**item for item in range(32)]
if n in pow2s:
    print("No")
    exit()
print("Yes")
print(n+1, n+2)
for i in range(3, n+1, 2):
    print(1, i)
    print(1, i - 1)
    print(i, n + i - 1)
    print(i - 1, n + i)
if n % 2 == 0:
    upper = 1 << (n.bit_length() - 1)
    lower = n ^ 1 ^ upper
    print(upper, n)
    print(lower, n + n)

Measured memory_bytes: 5436
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
int n,a,x[51];
ULL dp[51][2501];
int main(){
  int i,j,k;
  scanf("%d%d",&n,&a);
  for (i=1; i<=n; ++i) scanf("%d",x+i);
  memset(dp,0,sizeof dp);
  dp[0][0]=1;
  for (k=1; k<=n; ++k){
    for (i=k-1; i>=0; --i){
      for (j=0; j<=i*50; ++j){
        dp[i+1][j+x[k]]+=dp[i][j];
      }
    }
  }
  ULL ans=0;
  for (i=1 ;i<=n; ++i) ans+=dp[i][a*i];
  cout<<ans<<endl;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

template <typename T>
std::tuple<T, T, T> extgcd(T a, T b){
    T s1 = 1, t1 = 0, s2 = 0, t2 = 1;
    while(b != 0){
        std::tie(s1, t1, s2, t2) = std::make_tuple(s2, t2, s1 - (a / b) * s2, t1 - (a / b) * t2);
        std::tie(a, b) = std::make_tuple(b, a % b);
    }
    return std::make_tuple(s1, t1, a);
}

template <typename T>
T mod_expt(T a, std::int64_t n, T mod){
    T power {1};
    while(n > 0){
        if(n & 1){power = power * a % mod;}
        a = a * a % mod;
        n >>= 1;
    }
    return power;
}

template <typename T>
T mod_inverse(T a, T mod){
    T b;
    std::tie(b, std::ignore, std::ignore) = extgcd(a, mod);
    if(b < 0){b += mod;}
    return b;
}

template <typename T>
struct Combinatorics{
    T modulo;
    std::vector<T> fact, inv_fact;

    Combinatorics(T max, T modulo) : modulo(modulo), fact(max + 1), inv_fact(max + 1) {
        fact[0] = 1;
        for(T i=1;i<=max;++i){
            fact[i] = i * fact[i - 1] % modulo;
        }

        inv_fact[max] = mod_inverse(fact[max], modulo);
        for(T i=max;i>0;--i){
            inv_fact[i - 1] = i * inv_fact[i] % modulo;
        }
    }

    T nPk(T n, T k){
        if(n < k){return 0;}
        return fact[n] * inv_fact[n - k] % modulo;
    }

    T nCk(T n, T k){
        if(n < k){return 0;}
        return fact[n] * inv_fact[k] % modulo * inv_fact[n - k] % modulo;
    }

    T nHk(T n, T k){
        if(n == 0 && k == 0){return 1;}
        return nCk(n + k - 1, k);
    }
};

constexpr ll MOD = 1'000'000'007;
ll N, A, B, C;
Combinatorics<ll> comb(200100, MOD);

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

    std::cin >> N >> A >> B >> C;

    ll inv_100 = mod_inverse<ll>(100, MOD);
    ll p = A * inv_100 % MOD, q = B * inv_100 % MOD;
    ll alpha = 100ll * mod_inverse(A + B, MOD) % MOD;
    ll expected = 0;

    for(int i=0;i<N;++i){
        ll E = comb.nCk(N - 1 + i, i);
        E = E * mod_expt(p, N, MOD) % MOD;
        E = E * mod_expt(q, i, MOD) % MOD;
        E = E * (mod_expt(alpha, N + i + 1, MOD) * (N + i) % MOD) % MOD;
        
        expected += E;
    }

    for(int i=0;i<N;++i){
        ll E = comb.nCk(N - 1 + i, i);
        E = E * mod_expt(q, N, MOD) % MOD;
        E = E * mod_expt(p, i, MOD) % MOD;
        E = E * (mod_expt(alpha, N + i + 1, MOD) * (N + i) % MOD) % MOD;

        expected += E;
    }

    expected %= MOD;

    std::cout << expected << std::endl;
}


Measured memory_bytes: 3328
import re
import sys
from itertools import product
from typing import Callable, Set, Tuple


scan: Callable[[], str] = sys.stdin.readline


def main():
    n: int = int(scan().rstrip())
    s: str = scan().rstrip()

    r_n: int = s.count("R")
    g_n: int = s.count("G")
    b_n: int = s.count("B")

    exceptions = 0
    for i in range(n):
        candidates = {"R", "G", "B"} - {s[i]}
        for j in range(1, (n - i + 1) // 2):
            if candidates == {s[i + j], s[i + 2 * j]}:
                exceptions += 1

    answer = r_n * g_n * b_n - exceptions
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10280
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <bitset>
typedef long long lint;
const int N=5005;
int n,q,val[N];
bool dp[N],invld[N];
std::bitset <N> pre[N],suf[N];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x>y?x=y:0;}
	template <class T> inline void apx(T &x,const T y){x<y?x=y:0;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

bool jdg(const int x){
	static int sum[N];
	sum[0]=1;
	for(int i=1; i<=q; ++i){
		sum[i]=sum[i-1]+suf[x+1][i];
	}
	for(int i=1; i<q; ++i){
		if(pre[x-1][i]&&sum[q-1-i]-(i>=q-val[x]?0:sum[q-val[x]-i-1])) return 1;
	}
	return sum[q-1]-sum[q-val[x]-1];
}

int main(){
	n=nxi(),q=nxi();
	for(int i=1; i<=n; ++i){
		val[i]=std::min(q+1,nxi());
	}
	pre[0][0]=1;
	for(int i=1; i<=n; ++i){
		pre[i]=pre[i-1]|pre[i-1]<<val[i];
	}
	suf[n+1][0]=1;
	for(int i=n; i>=1; --i){
		suf[i]=suf[i+1]|suf[i+1]<<val[i];
	}
	int ans=0;
	for(int i=1; i<=n; ++i){
		ans+=val[i]>=q?0:!jdg(i);
	}
	printf("%d\n",ans);
	return 0;
}


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

using ll = long long;
using P = pair<int, int>;
#define reps(i,n) for (int i=1; i<=n; i++)
#define zarray(x,n) x[n+1]; reps(i,n) {x[i]=0;} 
#define zarray2(x,n,m) x[n+1][m+1]; reps(i,n) { reps(j,m) {x[i][j]=0;}}

int main() {
    int k, a, b;
    cin >> k >> a >> b;

    for (int i=k; i<=1000; i+=k) {
        if (a <= i && i <= b) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

}


Measured memory_bytes: 3632
#include <iostream>
#include <cassert>
//#define NDEBUG
int main(void){
	using namespace std;
	static const int DATA_SET_MAX = 3000;
	static const int INPUT_X_MAX = 10000;
	static const int INPUT_Y_MAX = 10000;
	static const int INPUT_X_MIN = 0;
	static const int INPUT_Y_MIN = 0;
	int case_cnt = 0;
	int input_x = 0;
	int input_y = 0;

	do{
		cin >> input_x;
		cin >> input_y;

		assert (INPUT_X_MIN <= input_x && input_x <= INPUT_X_MAX); /* Precondition */
		assert (INPUT_Y_MIN <= input_y && input_y <= INPUT_Y_MAX); /* Precondition */

        /* Output */
		if((input_x == 0) && (input_y == 0)){
			break;
		}
		else{
			if (input_x <= input_y){
				cout << input_x << " " << input_y << endl;
			}
			else{
				cout << input_y << " " << input_x << endl;
			}
		}
		case_cnt++;
	}while(case_cnt < DATA_SET_MAX);
	return 0;
}


Measured memory_bytes: 3004
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	ll N; cin >> N;
	vector<ll>A(N);
	rep(i, 0, N)cin >> A[i];
	rep(i, 1, N)A[i] += A[i - 1];
	ll ans = (ll)1e18;
	rep(i, 0, N) {
		ll x = A[i], y = A[N - 1] - A[i];
		chmin(ans, abs(y - x));
	}
	cout << ans << "\n";

	return 0;
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, m;
  std::cin >> n >> m;
  int64_t min = 1, max = n;
  for (int64_t i = 0; i < m; i++) {
    int64_t l, r;
    std::cin >> l >> r;
    min = std::max(l, min);
    max = std::min(r, max);
  }
  std::cout << std::max<int64_t>(max - min + 1, 0) << std::endl;
  return 0;
}


Measured memory_bytes: 256
ans = ''
N = int(input())
if N % 2 == 0:
	ans = '0' + ans
else:
	ans = '1' + ans
	N -= 1

t = -2

while N != 0:
	if N - t == 0:
		ans = '1' + ans
		break
	if N % (abs(t) * 2) == 0:
		ans = '0' + ans
	else:
		ans = '1' + ans
		N -= t
	t *= -2

print(ans)

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

using namespace std;

int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(b>c&&d>a)
    {
    printf("%d",abs(min(b,d)-max(a,c)));
    }
    else
    {
        printf("0");
    }
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	lli n;
	cin>>n;
	set<lli> s;

	REP(i,0,n){
		lli tmp;
		cin>>tmp;
		s.insert(tmp);
	}

	if(n==s.size())cout<<"YES"<<endl;
	else cout<<"NO"<<endl;

	return 0;
}

Measured memory_bytes: 9600
#include <cstdio>
#define max(a,b) ((a>b)?a:b)
using namespace std;
int N;
long long lucas[90];
void init(int n){
	if(n>86) return;
	lucas[n]=lucas[n-1]+lucas[n-2];
	init(n+1);
}
int main()
{
	scanf("%d",&N);
	lucas[0]=2;lucas[1]=1;
	init(2);
	printf("%lld\n",lucas[N]);
	return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
ii0 = lambda: ii() - 1
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    A, B = mis()
    if A <= 9>= B:
        print(A*B)
    else:
        print(-1)


main()


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#define INF 1000000007
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> P;


int main() {

	int n, x;
	int rest = 0;
	int sum = 0;
	int least = INF;
	int a[100000] = { 0 };
	cin >> n >> x;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	for (int i = 0; i < n; i++) {
		sum += a[i];
		least = min(least, a[i]);
	}

	cout << n + (x - sum) / least << endl;


	return 0;

}

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

const int mod=1000000007;
const int N=2000100;
typedef long long ll;
int ksm(ll a,int b,int c=1){
	for(;b;b/=2,a=a*a%mod)
		if(b&1)c=c*a%mod;
	return c;
}
int jc[N],jc2[N],x_1,x_2,x_3,x_4,x_5,x_6,y_1,y_2,y_3,y_4,y_5,y_6,ans;
void init(){
	jc[0]=1;
	for(int i=1;i<N;++i)jc[i]=(ll)jc[i-1]*i%mod;
	jc2[N-1]=ksm(jc[N-1],mod-2);
	for(int i=N-1;i;--i)jc2[i-1]=(ll)jc2[i]*i%mod;
}
inline void reduce(int&x){x+=x>>31&mod;}
int c(int x,int y){return (ll)jc[x+y]*jc2[x]%mod*jc2[y]%mod;}
int calc(int xl,int xr,int yl,int yr){
	int ret=0;
	reduce(ret+=c(xr+1,yr+1)-mod);reduce(ret+=c(xl,yl)-mod);
	reduce(ret-=c(xl,yr+1));reduce(ret-=c(xr+1,yl));
	return ret;
}
int calc1(int x,int y){return calc(x-x_2,x-x_1,y-y_2,y-y_1);}
int calc2(int x,int y){return calc(x_5-x,x_6-x,y_5-y,y_6-y);}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	init();
	cin>>x_1>>x_2>>x_3>>x_4>>x_5>>x_6>>y_1>>y_2>>y_3>>y_4>>y_5>>y_6;
	for(int i=x_3;i<=x_4;++i)
		reduce(ans=(ans+(ll)(i+y_4+1)*calc1(i,y_4)%mod*calc2(i,y_4+1)-(ll)(i+y_3)*calc1(i,y_3-1)%mod*calc2(i,y_3))%mod);
	for(int i=y_3;i<=y_4;++i)
		reduce(ans=(ans+(ll)(i+x_4+1)*calc1(x_4,i)%mod*calc2(x_4+1,i)-(ll)(i+x_3)*calc1(x_3-1,i)%mod*calc2(x_3,i))%mod);
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 15872
N, W = map(int, input().split())
v = []
w = []
for i in range(N):
    vv, ww = map(int, input().split())
    v.append(vv)
    w.append(ww)
# テーブルは一つ多く作っておく
dp = [['.' for _ in range(W+1)] for _ in range(N+1)]
for i in range(W+1):  # 境界条件
    dp[N][i] = 0

for i in range(N - 1, -1, -1):
    for u in range(0, W+1):
        if u < w[i]:    # uが小さいため入れられない
            dp[i][u] = dp[i + 1][u]
        else:  # 入る時の価値を計算
            dp[i][u] = max(dp[i + 1][u], dp[i + 1][u - w[i]] + v[i])

print(dp[0][W])



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

#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define go(x, i) for(register int i = head[x]; i; i = nxt[i])
#define For(i, a, b) for(register int i = (a), i##_end_ = (b); i <= i##_end_; ++ i)
#define FOR(i, a, b) for(register int i = (a), i##_end_ = (b); i >= i##_end_; -- i)
#define debug(x) cout << #x << " = " << x << endl
#define mem(a, b) memset(a, b, sizeof(a))
#define cpy(a, b) memcpy(a, b, sizeof(a))
#define min(a, b) (a < b ? a : b)
#define max(a, b) (b < a ? a : b)
#define inf (0x3f3f3f3f)
#define INF (1e18)
#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef unsigned long long ull;
typedef unsigned int uint;
typedef long long ll;
typedef std::pair<ll, int> PLI;
typedef std::pair<int, int> PII;
typedef long double ldb;
typedef double db;

namespace IO {
#define getc() ((S_ == T_) && (T_ = (S_ = Ch_) + fread(Ch_, 1, Buffsize, stdin), S_ == T_) ? 0 : *S_ ++)
#define putc(x) *nowps ++ = (x)
	const uint Buffsize = 1 << 15, Output = 1 << 23;
	static char Ch_[Buffsize], *S_ = Ch_, *T_ = Ch_;
	static char Out[Output], *nowps = Out;
	inline void flush(){fwrite(Out, 1, nowps - Out, stdout); nowps = Out;}
	template<class T>inline void read(T &_) {
		_ = 0; static char __; T ___ = 1;
		for(__ = getc(); !isdigit(__); __ = getc()) if(__ == '-') ___ = -1;
		for(; isdigit(__); __ = getc()) _ = (_ << 3) + (_ << 1) + (__ ^ 48);
		_ *= ___;
	}
	template<class T>inline void write(T _, char __ = '\n') {
		if(!_) putc('0');
		if(_ < 0) putc('-'), _ = -_;
		static uint sta[111], tp;
		for(tp = 0; _; _ /= 10) sta[++ tp] = _ % 10;
		for(; tp; putc(sta[tp --] ^ 48)); putc(__);
	}
	template<class T>inline bool chkmax(T &_, T __) {return _ < __ ? _ = __, 1 : 0;}
	template<class T>inline bool chkmin(T &_, T __) {return _ > __ ? _ = __, 1 : 0;}
}

using namespace std;
using namespace IO;

const int N = 1e5 + 10;

ll front[N], back[N], sum, ans = -INF, now;
int n, x, y, z;

struct node {
	int au, ag, cu;
}a[N];

bool cmp(node A, node B) {
	return A.au - A.ag < B.au - B.ag;
}

int main() {
#ifdef ylsakioi
	file("agc018c");
#endif
	read(x), read(y), read(z);
	n = x + y + z;
	For(i, 1, n) {
		read(a[i].au), read(a[i].ag), read(a[i].cu);
		a[i].au -= a[i].cu;
		a[i].ag -= a[i].cu;
		sum += a[i].cu;
	}
	sort(a + 1, a + n + 1, cmp);

	priority_queue<int, vector<int>, greater<int> > q;

	for(int i = 1; i <= n; ++ i) {
		now += a[i].ag, q.push(a[i].ag); front[i] = -INF;
		if(i >= y) {
			if(i != y) now -= q.top(), q.pop();
			front[i] = now;
		}
	}

	now = 0; while(!q.empty()) q.pop();

	for(int i = n; i >= 1; -- i) {
		now += a[i].au, q.push(a[i].au); back[i] = -INF;
		if(n - i + 1 >= x) {
			if(n - i + 1 != x) now -= q.top(), q.pop();
			back[i] = now;
		}
	}

	for(int i = 1; i < n; ++ i) chkmax(ans, front[i] + back[i + 1]);

	write(ans + sum);

	return flush(), 0;
}


Measured memory_bytes: 4856
from collections import defaultdict

N, M = map(int, input().split())
pS = [input().split() for _ in range(M)]

ac, wa = 0, 0
solved = defaultdict(int)
warning = defaultdict(int)

for p, S in pS :
  if solved[p] == 1 :
    continue
    
  if S == 'WA' :
    warning[p] += 1
    
  else :
    ac += 1
    solved[p] = 1
    wa += warning[p]
    
print(ac, wa)

Measured memory_bytes: 87628
import sys

AList = []
BingoList = [[0, 0, 0],
             [0, 0, 0],
             [0, 0, 0]]

for i in range(3):
    AList.append(list(map(int, input().split())))
    

N = int(input())

tmp = -1
for i in range(N):
    tmp = int(input())
    for p in range(3):
        for q in range(3):
            if AList[p][q] == tmp:
                BingoList[p][q] = 1

for i in range(3):
    if BingoList[i][0] == 1 and BingoList[i][1] == 1 and BingoList[i][2] == 1:
        print('Yes')
        sys.exit(0)

for i in range(3):
    if BingoList[0][i] == 1 and BingoList[1][i] == 1 and BingoList[2][i] == 1:
        print('Yes')
        sys.exit(0)

if BingoList[0][0] == 1 and BingoList[1][1] == 1 and BingoList[2][2] == 1:
    print('Yes')
elif BingoList[2][0] == 1 and BingoList[1][1] == 1 and BingoList[0][2] == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define ll long long

int main() {
	int n;
	scanf("%d", &n);
	int arr[n + 1];
	map<int, int> mp;
	for (int i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
		if (mp[arr[i]] == 0) mp[arr[i]] = 1;
		else mp[arr[i]] = 0;
	}
	long long ans = 0;
	for (auto c : mp){
		ans += c.second;
	}
	printf("%lld" , ans);
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
#define all(c) (c).begin(),(c).end()
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"[";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"]";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&p)
{o<<"{"<<p.first<<", "<<p.second<<"}";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj)
{o<<"{";for(auto itr=obj.begin();itr!=obj.end();++itr)o<<(itr!=obj.begin()?", ":"")<<*itr;o<<"}";return o;}
void print() {}
template <class H, class... T>void print(H&& head, T&&... tail)
{cout << head << (sizeof...(tail)==0 ? "\n" : " "); print(forward<T>(tail)...);}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, ans = 0;
  cin >> n;
  vector<deque<int>> a(n,deque<int>());

  for(int i=0; i<n; i++){
    for(int j=0; j<n-1; j++){
      int t;
      cin >> t; t--;
      a[i].push_back(t);
    }
  }

  set<P> st;
  vector<int> target;
  for(int i=0; i<n; i++){
    target.push_back(i);
  }
  while(!target.empty() && ans <= n*(n-1)/2+1){
    vector<int> nxt;
    for(auto i : target){
      if(a[i].empty()) continue;
      int t = a[i].front();
      a[i].pop_front();
      P nx = P(min(i,t), max(i,t));
      if(st.find(nx) == st.end()){
        st.insert(nx);
      }else{
        st.erase(nx);
        nxt.push_back(i);
        nxt.push_back(t);
      }
    }
    target = nxt;
    ans++;
    //cout << target << endl;
  }
  for(int i=0; i<n; i++){
    if(!a[i].empty()){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans-1 << endl;
  return 0;
}


Measured memory_bytes: 4736
/**akshaykumar99**/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T> using id_setp = tree<pair<T,T>,null_type,less<pair<T,T>>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e6+1;
 
typedef long long ll;
typedef long double ld;
 
int main()
{
    IOS();
   
    ll i,n,ans=0,b,c;
    cin>>n;
    int a[n];
    f(i,0,n)
    	cin>>a[i];
    ll s=1;
    f(i,0,n)
    {
    	if(a[i]==s)
    	{
    		s++;
    	}
    	else
    		ans++;
    }
    if(ans!=n)
    	cout<<ans<<'\n';
    else
    	cout<<-1<<'\n';
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define lp(n) for(int i = 0; i < n; i++)
#define LP(i, a, n) for(int i = a; i < n; i++)
#define lpp(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef struct node node;
int main() {
  int n, q, b, c=0;
  int a[10000];
  cin >> n;
  lp(n) cin >> a[i];
  cin >> q;
  lp(q) {
    cin >> b;
    lp(n) if(a[i] == b) {
      c++;
      break;
    }
  }
  cout << c << endl;
  return 0;
}




Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int col[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};
int main(){
	int x,y;cin>>x>>y;
	if(col[x]==col[y])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(s) int(s.size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

set<ll> s;
int n;

void go(int x, ll now){
	if(x>n){
		if(now>0) s.insert(now);
	}
	else go(x+1,now),go(x+1,now-x),go(x+1,now+x);
}

int main(){FIN;
	ll n; cin>>n;
	ll l=1,r=1e9;
	while(l<=r){
		ll m=(l+r)/2;
		if(m*(m+1)/2>=n) r=m-1;
		else l=m+1;
	}
	cout<<l<<"\n";
	return 0;
	
	go(1,0);
	for(auto x:s)cout<<x<<" ";cout<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<vector<int> > v(2,vector<int>(N));
  rep(i,2)rep(j,N)cin >> v[i][j];
  int S1[N+1],S2[N+1];
  S1[0] = 0;
  S2[N] = 0;
  rep(i,N){
    S1[i+1] = S1[i] + v[0][i];
    S2[N-1-i] = S2[N-i] + v[1][N-1-i];
  }
  int maximum = 0;
  rep(i,N){
    maximum = max(maximum, S1[i+1]+S2[i]);
  }
  cout << maximum << endl;
  return 0;
}


Measured memory_bytes: 256
// atcoder/m-solutions2020/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n, k;
  while (cin >> n >> k) {
    vec<lli> a(n);
    cin >> a;

    for (int i = k; i < n; ++i) {
      bool f = (a[i - k] < a[i]);
      cout << (f ? "Yes" : "No") << endl;
    }
  }

  return 0;
}


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

int main(){
  int n;
  cin >> n;
  string s;
  int c[4] = {};
  
  for(int i=0;i<n;i++){
    cin >> s;
    
    if(s == "AC")
      c[0]++;
    if(s == "WA")
      c[1]++;
    if(s == "TLE")
      c[2]++;
    if(s == "RE")
      c[3]++;
    
  }
  
  cout << "AC x " << c[0] << endl; 
  cout << "WA x " << c[1] << endl; 
  cout << "TLE x " << c[2] << endl; 
  cout << "RE x " << c[3] << endl; 
} 

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int h,w,k;
    cin >> h >> w >> k;
    string s[h];
    rep(i,h)cin >> s[i];
    int a[h][w];
    int c[h] = {};
    rep(i,h){
        rep(j,w){
            if(s[i][j] == '#')c[i]++;
            a[i][j] = 0;
        }
    }

    int start = 0;
    int now = 1;
    rep(i,h){
        if(c[i] > 0){
            start = i;
            break;
        }
    }

    srep(i,start, h){
        if(c[i] == 0)continue;
        int tmp = 0;
        rep(j,w){
            if(s[i][j] == '.'){
                a[i][j] = now;
            }else{
                a[i][j] = now;
                tmp++;
                if(tmp < c[i])now++;
            }
        }
        now++;
    }

    drep(i,start){
        rep(j,w)a[i][j] = a[i+1][j];
    }

    srep(i,start, h){
        if(c[i] > 0)continue;
        rep(j,w)a[i][j] = a[i-1][j];
    }

    rep(i,h){
        rep(j,w){
            cout << a[i][j] << ' ';
        }
        cout << endl;
    }
   
    return 0;
}
 
 


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt;
    cin >> tt;
    while (tt--) {
        ll a, b;
        cin >> a >> b;
        ll c = a * b, ans = 0;
        if (c < 3) {
            cout << 0 << '\n';
            continue;
        }
        if (a == b) {
            cout << a + b - 2 << '\n';
            continue;
        }
        if (a < b) {
            swap(a, b);
        }
        if (a == b + 1) {
            cout << 2 * b - 2 << '\n';
            continue;
        }
        ans = (b - 1);
        ll t = c / (a + 1);
        ans += t;
        ll lo = 0, hi = a - b + 1;
        debug(t);
        while (hi - lo > 1) {
            ll mid = (lo + hi) / 2;
            if (t + mid < b + 1) {
                ll x = (t + mid) * (b + 1);
                if (x < c) {
                    lo = mid;
                } else {
                    hi = mid;
                }
            } else {
                ll x = (t + b + mid + 1) / 2;
                ll y = x + (t + b + mid + 1) % 2;
                if (x * y < c) {
                    lo = mid;
                } else {
                    hi = mid;
                }
            }
        }
        ans += lo;
        cout << ans << '\n';
    }
    return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;




int main() {
    li n, a;
    cin >> n >> a;
    cout << n - a + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
from collections import deque
from heapq import heappush,heappop
import re

def int_raw():
    return int(input())
 
def ss_raw():
    return input().split()
 
def ints_raw():
    return tuple(map(int, ss_raw()))


DIV=10**9+7

def mod_invs(n,mod=DIV):
    inv=[0]*(n+1)
    inv[0]=1
    inv[1]=1
    for i in range(2,n+1):
        inv[i] = (-(mod//i)*inv[mod%i]) % mod
    return inv



def main():
    P,Q,R  = ints_raw()
    ans = min(P+Q,Q+R,P+R)
    return ans

print(main())


Measured memory_bytes: 38256
#include <stdio.h>

int main()
{
    int j=0;
    char s[4];
    scanf("%s",s);
    for(int i=0; i<3; ++i){
        if(s[i]==s[i+1]){
            j=1;
            break;
        }
    }
    if(j==0){
        printf("Good");
    }else{
        printf("Bad");
    }
    return 0;
}

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

int main() {
  int n,count,sum=0;
  cin >> n;
  vector<int> vec(n);
  rep(i,n){
    int a;
    cin >> a;
    count=0;
    while (a%2==0){
      a /= 2;
      count++;
    }
    sum += count;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;

const ll mod=1e9+7;

ll gcd(ll a, ll b){
    ll r;
    while((r =a%b)){
        a = b;
        b = r;
    }
    return b;
}


int main(){

  int A,B;
  cin >> A >> B;

  if ( A <10 && B < 10){
    cout << A * B << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;

}


Measured memory_bytes: 256
s = input()
a_head = 0
z_tail = -1
for i in range(len(s)):
    if s[i] == "A":
        a_head = i
        break
for i in range(len(s), 0, -1):
    if s[i - 1] == "Z":
        z_tail = i
        break
print(z_tail - a_head)


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

int main( ) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    long long a,b;
    t = 1;
    while(t--) {
     cin >> a >> b;
     cout << (a * b) / (__gcd(a, b)) << "\n";
    }
    return 0;
}


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

int main(int argc, char const *argv[])
{
  int n, m;
  cin >> n >> m;
  vector< vector<int> > A(n, vector<int>(m));
  vector<int> b(m);
  vector<int> c(n, 0);

  for(int i = 0; i < n; i++)
  {
    for(int j = 0; j < m; j++)
      cin >> A[i][j];
  }
  for(int i = 0; i < m; i++)
    cin >> b[i];

  for(int i = 0; i < n; i++)
  {
    for(int j = 0; j < m; j++)
      c[i] += A[i][j] * b[j];
  }
  for(int i = 0; i < n; i++)
    cout << c[i] << endl;
  return 0;
}

Measured memory_bytes: 3172
s = str(input())
n = len(s)
distance = 0
count = 0
max_W = 0

for i in range(n):
    if s[i] == 'W':
        distance += (i - count)
        count += 1
        max_W = i

if s.count('W') == 0 or s.count('W') == n:
    print(0)
    exit()

print(distance)

Measured memory_bytes: 3500
// B.

#include <iostream>
#include <sstream>

using namespace std;

int main(int argc, char *argv[])
{
	string s[3];
	cin >> s[0] >> s[1] >> s[2];
	int p = 0;
	while (!s[p].empty()) {
		int n = s[p][0] - 'a';
		s[p] = s[p].substr(1);
		p = n;
	}
	cout << ("ABC"[p]) << endl;
	return 0;
}


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

int main() {
  int x1;
  double x2, a, b;
  cin >> a >> b;
  x2 = (a + b) / 2;
  x1 = x2;
  x2 -= x1;
  if (x2 > 0) {
    cout << x1 + 1 << endl;
} else {
    cout << x1 << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    string S; cin>>S;
    int N=SZ(S);
    vec num(200010); num[0]=0;
    ll ans=0;
    rep(i,N){
        num[i+1]=num[i];
        if(S[N-i-1]=='W') num[i+1]++;
        else              ans+=num[i+1];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2180
H, W, K = map(int,input().split())
board = [list(input()) for h in range(H)]

ans = 0
for paint_h in range(2 ** H):#すべての行、列の塗り方を二進数列挙
    for paint_w in range(2 ** W):
        cnt = 0
        for h in range(H):
            for w in range(W):
                if (paint_h >> h) & 1 == 0 and (paint_w >> w) & 1 == 0:
            #各行h番目のビットと各列w番目のビット両方が０やったら
            #そのマスは塗られん
                    if board[h][w] == "#":#塗りつぶされんのが黒マスやったら＋１
                        cnt += 1
        if cnt == K: #塗られん黒マスがＫ個やったらans+=1
            ans += 1
print(ans)

Measured memory_bytes: 9128
#define _USE_MATH_DEFINES
#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 < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int N, A, B;
    cin >> N >> A >> B;

    cout << min(A*N, B) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
multiset<string>s;
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	for(int i = 1;i<=a;i++)s.insert("a");
	for(int i = 1;i<=b;i++)s.insert("b");
	for(int i = 1;i<=c;i++)s.insert("c");
	for(int i = 1;i<a+b+c;i++)
	{
		string x = *s.begin(),y = *(--s.end());
		s.erase(s.lower_bound(x)),s.erase(s.lower_bound(y));
		s.insert(x+y);
	}cout<<*s.begin();
	return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, M;
int x[110], y[110];

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

    std::cin >> N >> M >> x[0] >> y[0];
    
    for(int i=1;i<=N;++i){
        std::cin >> x[i];
    }

    for(int i=1;i<=M;++i){
        std::cin >> y[i];
    }

    if(*std::max_element(x, x + N + 1) < *std::min_element(y, y + M + 1)){
        std::cout << "No War" << std::endl;
    }else{
        std::cout << "War" << std::endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100005
#define For(i,x,y) for(int i=(x);i<=(y);++i)
#define Rof(i,x,y) for(int i=(x);i>=(y);--i)
#define NosoL return puts("No"),0
#define SoL return puts("Yes"),0
using namespace std;
int a[4][N],cnt[2],to[N],n,c[N];
void ins(int x){ for(int i=x;i<=n;i+=(i&(-i))) c[i]++; }
int qry(int x){ int res=0;for(int i=x-1;i;i-=(i&(-i)))res+=c[i];return res; }
int main(){
	scanf("%d",&n);
	For(i,1,3) For(j,1,n) scanf("%d",&a[i][j]);
	For(i,1,n){
		if(abs(a[1][i]-a[2][i])!=1 || abs(a[2][i]-a[3][i])!=1) NosoL;
		For(j,1,3) if(a[j][i]%2!=(i+3*j-3)%2) NosoL;
		if(a[1][i]%3==1 && a[1][i]>a[2][i]) NosoL;
		if(a[1][i]%3==0 && a[1][i]<a[2][i]) NosoL;
		to[i]=(a[2][i]+1)/3;
		cnt[i&1]^=(a[1][i]>a[3][i]);	
	}
	For(i,1,n) if(to[i]%2!=i%2) NosoL;
	for(int i=n-(n%2==0);i>=1;i-=2){
		int x=qry(to[i]);
		cnt[0]^=(x&1);
		ins(to[i]);
	}
	For(i,1,n) c[i]=0;
	for(int i=n-(n&1);i>=1;i-=2){
		int x=qry(to[i]);
		cnt[1]^=(x&1);
		ins(to[i]);
	}
	if(!cnt[0] && !cnt[1]) SoL;
	else NosoL;
}

Measured memory_bytes: 2176
#!/usr/bin/env ruby
# coding: utf-8

day = { SUN: 0, MON: 1, TUE: 2, WED: 3, THU: 4, FRI: 5, SAT: 6, EOF: 7 }
s = ARGF.gets.chomp
puts day[:EOF] - day[s.to_sym]


Measured memory_bytes: 1788
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long int ll;

int main()
{
    int x;
    for (int i = 0; i < 5; i++)
    {
        cin >> x;
        if (x == 0)
        {
            cout << (i + 1) << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3636