akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

def Zalgo(S):
    N = len(S)
    A = [0]*N

    froms = -1
    lasts = -1
    for i in range(1, N):
        same = 0
        if froms != -1:
            same = min(A[i-froms], lasts-i)
            same = max(0, same)
        while i+same<N and S[same] == S[i+same]:
            same += 1
        
        if i+same > lasts:
            lasts = i+same
            froms = i
        A[i] = same
    A[0] = N
    return A

N = int(input())
S = input().rstrip()

ans = 0
for i in range(N):
    A = Zalgo(S[i:])
    res = 0
    L = len(A)
    for j,a in enumerate(A):
        res = max(res, min(j, a))
    ans = max(res, ans)
print(ans)

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	
	int n;cin >> n;
	vector<ll> v(n);
	REP(i,n){
		cin >> v[i];
		v[i] -= i;
	}
	
	sort(ALL(v));
	
	ll seica = v[n/2];
	
	ll ans = 0;
	
	REP(i,n)ans += abs(seica - v[i]);
	
	cout << ans << endl;
	
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	int n;
	int k;
	int a,sum=0;
	cin >> n >> k;
	FOR(i,n){
		cin >> a;
		sum+=2*min(a,k-a);
	}
	cout << sum;

	return 0;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int a,b;
    cin>>a>>b;
    REP(i,5000){
        int i1=i*8/100;
        int i2=i*1/10;
        if(i1==a && i2==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<"-1"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long w[100005],v[100005],dp[101][100005];

int main(){
	ios::sync_with_stdio(0);
	int n,W;
	cin>>n>>W;
	for(int i=0;i<n;i++) cin>>w[i]>>v[i];
	for(int i=0;i<n;i++){
		for(int j=0;j<=W;j++){
			if(i==0) {if(j>=w[i]) dp[i][j]=v[i];}
			else if(j>=w[i]) dp[i][j]=max(dp[i-1][j-w[i]]+v[i],dp[i-1][j]);
			else dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n-1][W];
}

Measured memory_bytes: 80128
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#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()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

class Panel{
public:
  string name;
  int x1,x2,y1,y2;
  vector<Panel> v;
  Panel(string nm, int a, int b, int c, int d){
    name = nm;
    x1 = a; y1 = b;
    x2 = c; y2 = d;
  }
  bool check(int x, int y){
    bool ret = false;
    REP(i, v.size()){
      ret |= v[i].check(x,y);
    }
    if(ret) return true;
    if(x >= x1 && y >= y1 && x <= x2 && y <= y2){
      cout << name << " " << v.size() << endl;
      return true;
    }
    return false;
  }
};

Panel create(const string &str, int &pos){
  //printf("create: str = %s\n",str.c_str());
  int posS = 1;
  int posE = 1;
  while(str[posE] != '>') posE++;
  string name = str.substr(posS, posE - posS);
  int x1,x2,y1,y2;
  sscanf(str.c_str() + posE + 1, "%d,%d,%d,%d", &x1, &y1, &x2, &y2);
  Panel ret(name, x1, y1, x2, y2);
  while(true){
    posS = posE;
    while(str[posS] != '<') posS++; posS++;
    if(str[posS] == '/') posS++;
    posE = posS;
    while(str[posE] != '>') posE++;
    string name2 = str.substr(posS, posE - posS);
    //printf("name = %s, name2 = %s\n",name.c_str(), name2.c_str());
    if(name == name2){
      pos = posE + 1;
      //printf("end (name = %s): %s\n",name.c_str(),str.c_str()+pos);
      return ret;
    }else{
      ret.v.push_back(create(str.substr(posS-1),posE));
      posE += posS - 1;
      //printf("next (name = %s): %s\n",name.c_str(),str.c_str()+posE);
    }
  }
}

int main(){
  int n;
  while(cin>>n, n){
    string str; int tmp;
    cin>>str;
    Panel p = create(str, tmp);
    while(n --> 0){
      int x,y;
      cin>>x>>y;
      if(!p.check(x,y))
        cout << "OUT OF MAIN PANEL 1" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
import sys

def main():
  input = sys.stdin.readline
  A, B, K = map(int, input().split())
  c = 0
  D = []
  for i in range(1, min(A, B)+1, 1):
    if A%i == 0 and B%i == 0:
      D.append(i)
  
  print(D[-K])

if __name__ == '__main__':
  main()

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define all(a) a.begin(),a.end()
#define pb push_back

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;

int main(){
    S s;
    cin >> s;
    vc t;
    rp(i,s.size()){
        t.pb(s.at(i));
    }
    stack<char> ans;
    rp(i,t.size()){
        if(t.at(i)=='0'||t.at(i)=='1'){
            ans.push(t.at(i));
        }else if(t.at(i)=='B'){
            if(ans.size()){
                ans.pop();
            }
        }
    }
    vc u;
    while(ans.size()){
        u.pb(ans.top());
        ans.pop();
    }
    reverse(all(u));
    rp(i,u.size()){
        cout << u.at(i);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const A = parseInt(arg[0].split(" ")[0]);
    const B = parseInt(arg[0].split(" ")[1]);
    
    const plus  = A + B;
    const minus = A - B;
    const multi = A * B;
    
    console.log(Math.max(plus, minus, multi));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int N=in(),K=in();
	vector<ll> v(K,0);
	REP(i,N){
		v[(i+1)%K]++;
	}
	ll sum = 0;
	REP(i,K){
		if(!((2*i)%K)){
			sum += v[i]*v[i]*v[i];
		}
	}
	
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
	int a,n;
	scanf("%d %d",&n,&a);
	float s;
	s=1.0*n;
	int i;
	if((s/a)>(n/a))
	i=n/a+1;
	else 
	i=n/a;
	printf("%d",i); 
}

Measured memory_bytes: 128
using namespace std;

typedef   long long  int ll;
#include <bits/stdc++.h>


//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
#define fast  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define all(a) a.begin(),a.end()
//#define mod 998244353


#define mod   998244353

#define inf 1e18
//#define mod 3
#define flush fflush(stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<ll, ll, hash< ll > > ht;

// find_by_order()  // order_of_key
typedef tree<
    ll,
    null_type,
    less<ll>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;






ll power1(ll a, ll b)//a raised to power b
   {  if(b<=0) return 1; if(b==1) return a;
       ll c=power1(a,b/2);
        c*=c;c%=mod;if(b%2==1) c*=a;c%=mod;
        return c;
   }
   ll mi(ll a,ll m)
   { ll c= power1(a,m-2);

     return c;
   }



 struct less_then_greater {
    template<typename T, typename U>
    bool operator()(T const& lhs, U const& rhs) const {
        if (lhs.first < rhs.first) return true;
        if (rhs.first < lhs.first) return false;
        return lhs.second > rhs.second;
    }
};

 /*std::priority_queue<std::pair<int, int>,
                    std::vector<std::pair<int, int>>,
                    less_then_greater
                    > pq;*/


int main()
{  ll n;cin>>n;
   vector<pair<ll,ll> > v(n);
   for(auto &x:v)cin>>x.first>>x.second;
   bool ok=false;
    ll a=0;
   for(ll i=0;i<n;i++)
   {
       if(v[i].first==v[i].second)a++;
       else a=0;
        if(a>=3)ok=true;
   }

   if(ok)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;


    return 0;
}



Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
typedef pair<P,P> P2;

static const double eps = 1e-8;

const int tx[4] = {-1,0,1,0};
const int ty[4] = {0,1,0,-1};

char stage[1001][1001];
int gCost[1001][1001];

int main(){
	int W,H,N;
	while(~scanf("%d %d %d",&H,&W,&N)){
		for(int y=0;y<H;y++){
			char buf[1024];
			scanf("%s",buf);
			for(int x=0;x<W;x++){
				stage[y][x] = buf[x];
			}
		}

		vector<P> pos;
		for(int i=0;i<=N;i++){				
			for(int y=0;y<H;y++){
				for(int x=0;x<W;x++){
					if(i==0){
						if(stage[y][x] == 'S'){
							pos.push_back(P(x,y));
							goto next;
						}
					}
					else{
						if(stage[y][x] == '0' + i){
							pos.push_back(P(x,y));
							goto next;
						}
					}
				}
			}
next:;
		}

		priority_queue<P2,vector<P2>,greater<P2> > que; 
		for(int i=0;i+1<pos.size();i++){
			que.push(P2(P(pos[i].first,pos[i].second),P(pos[i+1].first,pos[i+1].second)));
		}

		int res = 0;
		while(!que.empty()){
			int sx = que.top().first.first;
			int sy = que.top().first.second;
			int gx = que.top().second.first;
			int gy = que.top().second.second;

			que.pop();

			queue<PP> que2;
			que2.push(PP(0,P(sx,sy)));

			memset(gCost,0x3,sizeof(gCost));
			gCost[sy][sx] = 0;
			while(!que2.empty()){
				int cost = que2.front().first;
				int x = que2.front().second.first;
				int y = que2.front().second.second;

				que2.pop();
				
				for(int i=0;i<4;i++){
					int dx = x + tx[i];
					int dy = y + ty[i];
					if(dx == gx && dy == gy) {
						res += cost + 1;
						while(!que2.empty()) que2.pop();
						break;
					}
					if(dx < 0 || dx >= W || dy < 0 || dy >= H) continue;
					if(stage[dy][dx] == 'X') continue;
					if(gCost[dy][dx] <= cost + 1) continue;
					gCost[dy][dx] = cost + 1;
					que2.push(PP(cost+1,P(dx,dy)));
				}
			}
		}

		printf("%d\n",res);
	}
}

Measured memory_bytes: 5780
def main():
    n, m = map(int, input().split())
    info = []
    for _ in range(n):
        info.append(list(map(int, input().split())))
    info.sort(key=lambda x: x[0])
    answer = 0
    for a, b in info:
        if m <= 0:
            break
        answer += a * min(b, m)
        m -= min(b, m)
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 29028
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
using P = pair <int,int>; //to, cost
using WeightedGraph = vector<vector <P>>; //to cost
const long long INF = 1LL << 60;
const int MOD = 1000000007;
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; }
//https://www.creativ.xyz/dump-cpp-652/
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
 
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

#ifdef DEBUG_
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif

signed main(void) { cin.tie(0); ios::sync_with_stdio(false);
    string s,t; cin>>s>>t;
    int a,b; cin>>a>>b;
    string u; cin>>u;
    if(s == u) a--;
    else b--;
    cout<<a<<' '<<b<<endl;
}

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

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

const int mxn = 5e5;
const int M = 1e9 + 7;

ll pw(ll b, ll e)
{
	ll res = 1;
	while (e)
	{
		if (e % 2)
			res = (res * b) % M;
		b = (b * b) % M;
		e >>= 1; // e/=2;
	}
	return res;
}

ll iv[mxn + 1], f1[mxn + 1], f2[mxn + 1];
ll nck(int n, int k)
{
	return f1[n] * f2[k] % M * f2[n - k] % M;
}

int main()
{
	fast;
	int n;
	cin >> n;
	FOR(n)
	{
		cout << "ACL";
	}
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		for (int i = 0;  i < b; i++) {
			if ((a * i) % b == c) {
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
	}
}


Measured memory_bytes: 23252
// B - Shiritori
// https://abc109.contest.atcoder.jp/tasks/abc109_b

import scala.io.StdIn.readLine

object Main extends App {

  val n = readLine.toInt
  val ws: List[String] = (0 until n).toList.map(_ => readLine)

  val isOk = (
    ws.length == ws.distinct.length &&
    ws.sliding(2).forall(wss => (wss(0).last == wss(1).head))
  )

  isOk match {
    case true  => println("Yes")
    case false => println("No")
  }

}

Measured memory_bytes: 27192
//#define		FILE_INPUT_DEFINE

#ifdef		FILE_INPUT_DEFINE
#include	<fstream>
#endif		// FILE_INPUT_DEFINE

#include	<iostream>
#include	<deque>
#include	<string>
#include	<utility>

using namespace std;

typedef		pair<string, int>		ProcessAndQuantum;
deque<ProcessAndQuantum>			P;

int main()
{
#ifdef		FILE_INPUT_DEFINE
	// input from txt
	std::ifstream in(R"(C:\Temp\input.txt)");
	std::cin.rdbuf(in.rdbuf());
#endif		// FILE_INPUT_DEFINE

	int		n, q;
	cin >> n >> q;
	cin.clear();
	cin.ignore();

	string		str;
	int			time;

	for (int i = 0; i < n; i++)
	{
		cin >> str >> time;
		cin.clear();
		cin.ignore();

		P.push_back(make_pair(str, time));
	}

	int qtime = 0;

	while (P.size() != 0)
	{
		auto nowP = P.front();
		P.pop_front();

		if (nowP.second <= q)
		{
			qtime += nowP.second;
			cout << nowP.first << " " << qtime << "\n";
		}
		else
		{
			qtime += q;
			nowP.second -= q;
			P.push_back(nowP);
		}
	}

	return 0;
}

Measured memory_bytes: 6236
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(n, k) = in.readLine().split("\\s+").map(_.toInt)

    out.println(n - k + 1)
    out.flush()
  }
}


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

using namespace std;

typedef long long int LL;

int N, P, a, o = 0, e = 0;

LL A[53][53];

LL nCr(int n, int r) {
  if (r == 0 || n == r) {
    return 1;
  }
  if (r == 1) {
    return n;
  }
  if (A[n][r] != -1) {
    return A[n][r];
  }
  return A[n][r] = nCr(n - 1, r - 1) + nCr(n - 1, r);
}

int main() {
  memset(A, -1, sizeof A);
  cin >> N >> P;
  for (int i = 0; i < N; i++) {
    cin >> a;
    if (a&1) {
      o++;
    } else {
      e++;
    }
  }
  LL ans;
  if (P == 0) {
    ans = 1LL << e;
    LL x = 0;
    for (int i = 2; i <= o; i += 2) {
      x += nCr(o, i);
    }
    ans = ans * x + ans;
  } else {
    ans = 0;
    for (int i = 1; i <= o; i += 2) {
      ans += nCr(o, i);
    }
    ans *= 1LL << e;
  }
  cout << ans << endl;
}


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

#define INF INT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

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

    int n;
    cin >> n;
    vector<int> h(n);
    REP(i,n)cin >> h[i];

    int ans = 0;
    int c = 0;
    REP(i,n-1){
        if(h[i] < h[i+1]){
            ans = max(ans,c);
            c = 0;
        }else{
            c++;
            if(n-2 == i)ans = max(ans,c);
        }
    }

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

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vl p(n), id(n+1);
    rep(i, n) {
        cin >> p[i];
        id[p[i]] = i;
    }

    set<ll> st;
    st.insert(-1);
    st.insert(n);
    ll ans = 0;
    exrep(x, 1, n) {
        ll i = id[x];
        st.insert(i);
        auto it1 = st.find(i);
        it1--;
        ll L = *it1;
        auto it2 = st.find(i);
        it2++;
        ll R = *it2;
        ans += x*(i - L)*(R - i);
    }

    out(ans);
    re0;
}

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

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

    bool isOdd = false;
    int c = 0;

    while(1)
    {
        for(int i = 0; i < N; i++)
        {
            if(A[i] % 2 != 0)
                isOdd = true;
        }

        if(isOdd)
            break;

        c++;

        for(int i = 0; i < N; i++)
        {
            A[i] = A[i] / 2;
        }
    }

    cout << c << endl;

}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for(ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for(ll i = (ll)(n - 1); i >= 0; i--)
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; }

int count16bit(unsigned short v) {
	unsigned short count = (v & 0x5555) + ((v >> 1) & 0x5555);
	count = (count & 0x3333) + ((count >> 2) & 0x3333);
	count = (count & 0x0f0f) + ((count >> 4) & 0x0f0f);
	return (count & 0x00ff) + ((count >> 8) & 0x00ff);
}

int main()
{
	cout << fixed << setprecision(18);

	ll n, m;
	cin >> n >> m;

	vector<ll> k(m);
	vector<ll> p(m);
	vector<ll> s(m, 0);

	rep(i, m) {
		cin >> k[i];
		rep(j, k[i]) {
			ll tmp;
			cin >> tmp;
			s[i] += pow(2, tmp - 1);
		}
	}

	rep(i, m)
		cin >> p[i];

	ll ans = 0;
	rep(i, 1 << n) {
		ll flag = true;
		rep(j, m) {
			ll tmp = s[j] & i;
			if (count16bit(tmp) % 2 == p[j])
				continue;
			else {
				flag = false;
				break;
			}
		}
		
		if (flag)
			ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
def find(x):
    while x!=T[x][0]:
        x = T[x][0]
    return x
def union(x,y):
    ax = find(x)
    ay = find(y)
    if T[ax][1]>T[ay][1]:
        T[ay][0] = ax
    elif T[ax][1]==T[ay][1]:
        T[ay][0] = ax
        T[ax][1] += 1
    else:
        T[ax][0] = ay
N,M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
T = {i:[i,1] for i in range(1,N+1)}
for j in range(M):
    x,y = A[j][0],A[j][1]
    union(x,y)
B = [0 for _ in range(N+1)]
for i in range(1,N+1):
    B[i] = find(i)
C = {}
for i in range(1,N+1):
    b = B[i]
    if b not in C:
        C[b] = 0
    C[b] += 1
print(len(C))

Measured memory_bytes: 119440
n=int(input())
w=[0]*n
for i in range(n):
  w[i]=input()
count=0
for i in range(n-1):
  if w[i][-1]!=w[i+1][0]:
    count+=1
for i in range(n):
  if w[i] in w[:i]:
    count+=1
if count==0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>

using namespace std;

#define EPS (1e-9)

double cross_product( double x1, double y1,
					  double x2, double y2 )
{
	return ((x1 * y2) - (x2 * y1));
}

int main( void )
{
	int n;
	while ( cin >> n )
	{
		for (int i=0; i < n; ++i)
		{
			double x1, y1, x2, y2, x3, y3, x4, y4;
			cin >> x1 >> y1 >> x2 >> y2
				>> x3 >> y3 >> x4 >> y4;

			if (EPS > fabs(cross_product((x2-x1), (y2-y1), (x4-x3), (y4-y3))))
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1228
#include<stdio.h>
int main(){
	int n,i;
	int a[10000];
	long int sum=0;
	int min=1000000,max=-1000000;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
		if(a[i]<min){
			min=a[i];
		}
		if(a[i]>max){
			max=a[i];
		}
	}
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 636
N, K = gets.split(' ').map(&:to_i)
a = gets.split(' ').map(&:to_i)
dic = {}
a.each do |n|
  if dic[n] == nil
    dic[n] = 1
  else
    dic[n] += 1
  end
end
number = dic.values.sort
if number.size > K
  puts number[0...(number.size - K)].inject(:+)
else
  puts '0'
end

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

int main(void){
	int n, tmp, ans, i, j, k;
	char s[101];

	cin >> n >> s;
	ans = 0;
	for(i = 1; i < n; i++) {
		tmp = 0;
		for(j = 0; j < 26; j++) {
			for(k = 0; k < i; k++) {
				if(s[k] == 'a' + j)
					break;
			}
			if(k < i) {
				for(k = i; k < n; k++) {
					if(s[k] == 'a' + j)
						break;
				}
				if(k < n) {
					tmp++;
				}
			}
		}
		if(ans < tmp)
			ans = tmp;
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
	vector<int> a(10), b(10);
	for(int i=0; i<10; i++) cin >> a[i];
	for(int i=0; i<10; i++) cin >> b[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	cout << a[7]+a[8]+a[9] << " " << b[7]+b[8]+b[9] << endl;
	return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<long long>> vvll;
typedef long double ld;
typedef std::vector<long double> vld;
typedef std::vector<std::vector<long double>> vvld;
using namespace std;
void yesno(bool state);

void Main(){
    string S,T;
    cin >> S >> T;
    ll ans = 0;
    for (ll i = 0; i < S.size(); i++)
        if(S[i] != T[i])
            ans++;
    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    Main();
    return 0;
}

void yesno(bool state){
    if(state)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3836
def answer(a, l)
	return 1 if l == 1
	ans = 0
	ret = {}
	count = 0
	a.each_with_index do |aa, i|
		if ret.key? aa
			ret[aa] += 1
		else
			ret[aa] = 1
		end
		if i == 0
			ans = 1
			count = 1
		else
			count += 1
			ans += count - ret[aa]
		end
	end
	return ans
end
a = gets.chomp.split(//)
l = a.size
p answer(a, l)

Measured memory_bytes: 12796
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n){
        vector<int> v(n);
        for (auto &&i : v) scanf("%d", &i);
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            for (int j = i+1; j < n; ++j) {
                if(v[i] > v[j]) ans++;
            }
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3140
# define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <unordered_set>
# include <unordered_map>
# include <climits>
# include <complex>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define STR(x) string x;cin>>x;
# define ALL(x) begin(x),end(x)
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }


int w, h;
struct P
{
	int x, y;
	int cost;
	int i;
	bool move()
	{
		x += dx[i];
		y += dy[i];
		if (x<=0||y<=0||w<x||h<y)return false;
		return true;
	}
	void turn_right()
	{
		i+=1;
		i %= 4;
	}
	void turn_left()
	{
		i+=3;
		i %= 4;
	}
	void turn_back()
	{
		i += 2;
		i %= 4;
	}
	bool operator<(const P &right)const 
	{
		return cost < right.cost;
	}
	bool operator>(const P &right)const
	{
		return cost > right.cost;
	}
};


int main()
{
	while (true)
	{
		vector<vi> a(35, vi(35, 4));
		vi cost(4, 0);
		int flag[35][35][4];

		cin >> w >> h; if (!w)break;
		FORI(i, 1, h + 1)FORI(j, 1, w + 1)
			cin >> a[i][j];
		FOR(i, 4)
			cin >> cost[i];
		FOR(i, 35)FOR(j, 35)FOR(k, 4)flag[i][j][k] = INT_MAX;


		P start{ 1,1,0,1 };
		priority_queue< P, vector<P>, greater<P> > que;
		que.push(start);
		while (!que.empty())
		{
			P now = que.top(); que.pop();
			if (now.x == w&&now.y == h)
			{
				cout << now.cost << endl;
				break;
			}
			FOR(i, 4)
			{
				P next = now;
				if (a[now.y][now.x] == i)continue;
				next.cost += cost[i];
				switch (i)
				{
				case 0:
					break;
				case 1:
					next.turn_right();
					break;
				case 2:
					next.turn_back();
					break;
				case 3:
					next.turn_left();
					break;
				}
				if (next.move()&&flag[next.y][next.x][next.i]>next.cost)
				{
					flag[next.y][next.x][next.i] = next.cost;
					que.push(next);
				}
			}
			bool ok = true;
			switch (a[now.y][now.x])
			{
			case 1:
				now.turn_right();
				break;
			case 2:
				now.turn_back();
				break;
			case 3:
				now.turn_left();
				break;
			case 4:
				ok = false;
				break;
			}
			if (!ok)continue;
			if (now.move()&&flag[now.y][now.x][now.i]>now.cost)
			{
				flag[now.y][now.x][now.i] = now.cost;
				que.push(now);
			}
		}
	}
}

Measured memory_bytes: 3192
import java.io.{BufferedReader, InputStream, InputStreamReader, PrintWriter}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val a, b = sc.nextInt()

    val ans = if (a * b == 15) "*" else if (a + b == 15) "+" else "x"
    out.println(ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

  private def rep(n: Int)(f: Int => Unit): Unit = (0 until n) foreach f

  private def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    (0 until n) foreach (i => res(i) = f(i))
    res
  }

  private implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }

    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
      rep(a => map.getOrElseUpdate(f(a), ArrayBuffer()) += a)
      map
    }

    def rep(f: A => Unit): Unit = {
      as.indices foreach (i => f(as(i)))
    }

    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      var sum = num.zero
      rep(a => sum = num.plus(sum, f(a)))
      sum
    }

    def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.lt)
    }

    def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.gt)
    }

    private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {
      var limA = as(ixRange.head)
      var limB = f(limA)

      for (i <- ixRange.tail) {
        val a = as(i)
        val b = f(a)
        if (cmp(b, limB)) {
          limA = a
          limB = b
        }
      }
      (limA, limB)
    }
  }

  private implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
    }
  }
}


Measured memory_bytes: 25536
N, A, B, C = map(int, input().split())
b = [int(input()) for _ in range(N)]

ans = 10**10
for i in range(2**(2*N)) :
    As = []
    Bs = []
    Cs = []
    for j in range(N) :
        if (i >> 2*j)%4 == 0 :
            As.append(b[j])
        elif (i >> 2*j)%4 == 1 :
            Bs.append(b[j])
        elif (i >> 2*j)%4 == 2 :
            Cs.append(b[j])
        else :
            continue
    if As and Bs and Cs :
        mp = 10 * (len(As) + len(Bs) + len(Cs) - 3) \
              + abs(A - sum(As)) + abs(B - sum(Bs)) + abs(C - sum(Cs))
        ans = min(ans, mp)

print(ans)


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

bool kansu(vector<int> &a, int n, int m, set<int> &s) {
  int len=n;
  for (int tmp=0; tmp<(1 << len); ++tmp) {
    int count=0;
    rep(tmp2, len) {
      if (tmp & (1<<tmp2)) count += a[tmp2];
    }
    if (!s.count(count)) s.insert(count);
    //if (m == count) return true;
  }
  return false;
}

int main() {
  int n, q;
  cin >> n;
  vector<int> a(n);
  rep (i, n) cin >> a[i];
  cin >> q;
  int m[q];
  rep (i, q) cin >> m[i];
  set<int> s;
  int x=kansu(a, n, m[0], s);
  rep (i, q) {
    if (s.count(m[i])) cout << "yes" << endl;
    else cout << "no" << endl;
  }
}


Measured memory_bytes: 3120
#include <stdio.h>

int main()
{
    char op[19];

    scanf("%s", &op);

    for (int i = 0 ; op[i] != '\0' ; i++){

        if (op[i] != ','){
        printf("%c", op[i]);
        }else {
        printf(" ");
        }


    }

    return 0;
}


Measured memory_bytes: 1656
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<bool> seat(20);
    string fir, las;
    int l = 0, r = n-1;
    cout << 0 << endl;
    cin >> fir;
    if(fir == "Vacant") return 0;
    cout << n-1 << endl;
    cin >> las;
    if(las == "Vacant") return 0;
    rep(i,18){
        int mid = (l + r) / 2;
        cout << mid << endl;
        string s;
        cin >> s;
        if(s == "Vacant") return 0;
        if((s == las) ^ ((r - mid)%2 == 0)){
            l = mid;
            fir = s;
        }
        else{
            r = mid;
            las = s;
        }
    }
    return 0;
}

Measured memory_bytes: 852
#include<stdio.h>
#include<string.h>

int main()
{
    int m,i,j,k,x,c;
    char s[15];

    gets(s);

    m=strlen(s);

    for(i=m-1;i>=0;i--){
        if(s[i]=='B'){
            for(j=i-1;j>=0;j--){
                if(s[j]=='0'||s[j]=='1'){
                    s[j]='2';
                    s[i]='2';
                    break;
                }
            }
        }
    }
    for(i=0;i<m;i++){
        if(s[i]=='0'||s[i]=='1'){
            printf("%c",s[i]);
        }
    }
    printf("\n");

    return 0;
}


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

using namespace std;

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

  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  vector<string> any = {"dream", "dreamer", "erase", "eraser"};
  for (auto& e : any) {
    reverse(e.begin(), e.end());
  }
  size_t i = 0;
  while (i < s.size()) {
    bool found = false;
    for (size_t j = 0; j < any.size(); ++j) {
      if (s.size() - i < any[j].size()) continue;
      if (memcmp(any[j].data(), &s[i], any[j].size()) == 0) {
        found = true;
        i += any[j].size();
      }
    }
    if (i < s.size() && !found) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
}


Measured memory_bytes: 512
import sys

input = sys.stdin.buffer.readline
in_n = lambda: int(input())
in_nn = lambda: map(int, input().split())
in_s = lambda: input().rstrip().decode('utf-8')
in_map = lambda: [s == ord('.') for s in input() if s != ord('\n')]

MOD = 10**9 + 7
INF = 8 * 10**18


def main():

    S = in_s()
    if "AC" in S:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
#include <cstddef>
#include <vector>

template <class S>
void subset_zeta_transform(std::vector<typename S::value_type> &a) {
  using size_t = std::size_t;

  const size_t n = a.size();
  for (size_t i = 1; i < n; i *= 2) {
    for (size_t j = 0; j != n; j += 1) {
      if ((j & i) != 0)
        a[j] = S::operation(a[j & ~i], a[j]);
    }
  }
}

template <class S>
void superset_zeta_transform(std::vector<typename S::value_type> &a) {
  using size_t = std::size_t;

  const size_t n = a.size();
  for (size_t i = 1; i < n; i *= 2) {
    for (size_t j = 0; j != n; j += 1) {
      if ((j & i) != 0)
        a[j & ~i] = S::operation(a[j & ~i], a[j]);
    }
  }
}

template <class G>
void subset_mobius_transform(std::vector<typename G::value_type> &a) {
  using size_t = std::size_t;

  const size_t n = a.size();
  size_t i = 1;
  while (i < n)
    i *= 2;
  while (i != 1) {
    i /= 2;
    for (size_t j = 0; j != n; j += 1) {
      if ((j & i) != 0)
        a[j] = G::operation(G::inverse(a[j & ~i]), a[j]);
    }
  }
}

template <class G>
void superset_mobius_transform(std::vector<typename G::value_type> &a) {
  using size_t = std::size_t;

  const size_t n = a.size();
  size_t i = 1;
  while (i < n)
    i *= 2;
  while (i != 1) {
    i /= 2;
    for (size_t j = 0; j != n; j += 1) {
      if ((j & i) != 0)
        a[j & ~i] = G::operation(a[j & ~i], G::inverse(a[j]));
    }
  }
}

#include <algorithm>
#include <array>
#include <functional>
#include <iostream>

struct top2 {
  using value_type = std::array<int, 2>;

  static value_type operation(const value_type &l, const value_type &r) {
    std::array<int, 4> v = {l[0], l[1], r[0], r[1]};
    std::sort(v.begin(), v.end(), std::greater<int>());
    return {v[0], v[1]};
  }
  static constexpr value_type identity = {0, 0};
};
constexpr typename top2::value_type top2::identity;

int main() {
  int n;
  std::cin >> n;
  std::vector<top2::value_type> a(1 << n);

  for (auto &e : a) {
    std::cin >> e[0];
  }

  subset_zeta_transform<top2>(a);
  a.erase(a.begin());
  int cur = 0;
  for (const auto &e : a) {
    cur = std::max(cur, e[0] + e[1]);
    std::cout << cur << std::endl;
  }
}

Measured memory_bytes: 5120
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	int N = rei();
	int K = rei();
	cout << N-K+1 << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

int main() {
    int n;
    int d[51];
    int sum = 0;
    int i = 0;
    int j = 0;

    cin >> n;
    for(i = 0; i < n; i++) cin >> d[i];

    for(i = 0; i < n; i++) {
        for(j = i + 1; j < n; j++) {
            sum += d[i] * d[j];
        }
    }
    
    cout << sum << endl;
}

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

int main(){
    string s;
    cin >> s;
    int c0 = 0,c1 = 0;

    for(int i = 0; i < s.size(); ++i){
        if(s[i] == '0')c0++;
        else c1++;
    }

    cout << min(c0,c1) * 2 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int x,y;
    int cnt = 0;
    bool isAns = false;
    while(n--)
    {
        int a,b;
        cin>>a>>b;
        if(a==b)
        {
            cnt++;
        }
        else
        {
            cnt = 0;
        }
        if(cnt==3)
        {
            isAns = true;
        }
    }
    cout<<(isAns  ? "Yes" : "No");
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int x;if(s.size()%2==1)x=1;else x=2;
  int t=s.size();
  for(int i=x;;i+=2){
    int v=0;
    for(int j=0;j<(t-i)/2;j++){
      if(s[j]!=s[j+(t-i)/2]){
        v=1;
        break;
      }
    }
    if(v==0){
      cout<<t-i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <iostream>
using namespace std;


int main()
{
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }
    sort(x.begin(), x.end());
    
    vector<int> y(M);
    for (int i = 0; i < M; i++) {
        cin >> y[i];
    }
    sort(y.begin(), y.end());
    
    
    int maxX = X;
    int minY = Y;
    for (int i = 0; i < N; i++) {
        maxX = max(maxX, x[i]);
    }
    for (int i = 0; i < M; i++) {
        minY = min(minY, y[i]);
    }

    if (maxX < minY) {
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }
    
    return 0;
}

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

int a[200005];
int main() {
    int k,n,i;
    cin>>k>>n;
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    int m=k-(a[n-1]-a[0]);
    for(i=1;i<n;i++){
        if(abs(a[i]-a[i-1])>m){
            m=a[i]-a[i-1];
        }
    }
    printf("%d\n",k-m);
}


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


int main(){
  long long int a, b, c;
  cin >> a >> b >> c;
  if(c-a-b<0){
    cout << "No" << endl;
    return 0;
  }
  cout << (4*a*b < (c-a-b)*(c-a-b) ? "Yes" : "No") << endl;
  return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);    
    long long N;
    cin >> N;
    long long ans = 0;
    for (long long i = 1; i * i < N; ++i) {
        if (N % i == 0) {
            long long m = N / i - 1;
            if (N / m == N % m) ans += m;
        }
    }
    cout << ans;
    return 0;
}



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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code
ll arr[N];
int main()
{
	ll n, m;
	cin>>n>>m;
	rep(i, 0, m)
	{
		int x, y;
		cin>>x>>y;
		arr[x]++;
		arr[y+1]--;
	}
	ll curr = 0;
	ll ans = 0;
	repn(i, 1, n)
	{
		curr += arr[i];
		if(curr >= m) ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const long long maxn=105;
const long long inf=1e18;
long long x[maxn],y[maxn],p[maxn],ans[maxn],res[maxn][maxn],n; 
void dfs(long long i,long long num)
{
	if(i==n)
	{
		long long x=0;
		ans[num]=min(ans[num],accumulate(res[n],res[n]+n,x));
		return ;
	}
	for(long long j=0;j<n;j++)
		res[i+1][j]=res[i][j];
	dfs(i+1,num);
	for(long long j=0;j<n;j++)
		res[i+1][j]=min(res[i][j],p[j]*abs(x[j]-x[i]));
	dfs(i+1,num+1);
	for(long long j=0;j<n;j++)
		res[i+1][j]=min(res[i][j],p[j]*abs(y[j]-y[i]));
	dfs(i+1,num+1);
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n;
	for(long long i=0;i<n;i++)
		cin>>x[i]>>y[i]>>p[i];
	for(long long i=0;i<n;i++)
	{
		res[0][i]=p[i]*min(abs(x[i]),abs(y[i]));
		ans[i]=inf;
	}
	dfs(0,0);
	for(long long i=0;i<=n;i++)
		cout<<ans[i]<<"\n";
	return 0;
}




Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
  
typedef struct{
  double x;
  double y;
} pos;
  
void kock( int n, pos p1, pos p2) {
  
  pos s, t, u;
  
  if(n == 0) {
    return;
  }
  
  s.x = ( 2 * p1.x + p2.x )/3;
  s.y = ( 2 * p1.y + p2.y )/3;
  t.x = ( p1.x + 2 * p2.x )/3;
  t.y = ( p1.y + 2 * p2.y )/3;
  u.x = (t.x - s.x)*cos(M_PI/3) - (t.y - s.y)*sin(M_PI/3) + s.x;
  u.y = (t.x - s.x)*sin(M_PI/3) + (t.y - s.y)*cos(M_PI/3) + s.y;
  
  kock( n-1, p1, s);
  printf("%f %f\n", s.x, s.y);
  kock( n-1, s, u);
  printf("%f %f\n", u.x, u.y);
  kock( n-1, u, t);
  printf("%f %f\n", t.x, t.y);
  kock( n-1, t, p2);
}
  
int main() {
  
  int n;
  pos start={ 0, 0};
  pos end={ 100, 0};
  
  scanf("%d", &n);
  
  printf("%f %f\n", start.x, start.y);
  
  kock( n, start, end);
  
  printf("%f %f\n", end.x, end.y);
  
  return 0;
  
}

Measured memory_bytes: 2608