akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
"""<https://github.com/cheran-senthil/PyRival>"""
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()


def main():
    n, k = map(int, input().split())
    print(n - k + 1)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._buffer = BytesIO()
        self._fd = file.fileno()
        self._writable = "x" in file.mode or "r" not in file.mode
        self.write = self._buffer.write if self._writable else None

    def read(self):
        if self._buffer.tell():
            return self._buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

    def flush(self):
        if self._writable:
            os.write(self._fd, self._buffer.getvalue())
            self._buffer.truncate(0), self._buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29036
#include<bits/stdc++.h>
using namespace std;
main() {
	string r, a;
	while(1) {
		cin >> r >> a;
		if ( a == "0" ) break;
		int hit = 0, blow = 0;
		for ( int i = 0; i < 4; i++ ) {
			for ( int j = 0; j < 4; j++ ) {
				if ( r[i] != a[j] ) continue;
				if ( i == j ) hit++;
				else blow++;
			}
		}
		cout << hit << " " << blow << endl;
	}
}

Measured memory_bytes: 2988
#include <iostream>
using namespace std ;
int main()
{
	int a, b;
	cin >> a >> b;
	int x = a + b;
	if ( x % 3== 0 || a % 3 == 0 || b % 3 ==0 )
		cout << "Possible";
	else
		cout << "Impossible";
	return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x); //define stack
int pop();

int main() {
    int a,b;
    top = 0;
    char s[100];
    while( scanf("%s", s) != EOF ) {
        if ( s[0] == '+' ) { //manipulate from top
            a = pop();
            b = pop();
            push(a + b);
        } else if ( s[0] == '-' ) {
            b = pop(); 
            a = pop();
            push(a - b);
        } else if ( s[0] == '*' ) {
            a = pop();
            b = pop();
            push(a * b);
        } else {
            push(atoi(s));
        }
    }
    printf("%d\n", pop());
    return 0;
}

void push( int x ) {
    S[++top] = x;  //top +1 substitute
}

int pop() {
    top--;
    return S[top+1];
}


Measured memory_bytes: 2704
K = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(", ")
K = list(map(int,K))
i = int(input())
print(K[i-1])


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
  int W, H, N;
  cin >> W >> H >> N;
  int x_low = 0;
  int x_up = W;
  int y_low = 0;
  int y_up = H;
  for (int i = 0; i < N; ++i) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) {
      x_low = max(x_low, x);
    } else if (a == 2) {
      x_up = min(x_up, x);
    } else if (a == 3) {
      y_low = max(y_low, y);
    } else {
      y_up = min(y_up, y);
    }
  }
  printf("%d\n", max(0, x_up - x_low) * max(0, y_up - y_low));
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[125252];
int acnt[125252];

ll fact[125252];
ll inv(ll a){
  ll b=MOD-2;
  ll r=1;
  while(b){
    if(b&1)r=r*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return r;
}
ll comb(int a,int b){
  if(b>a)return 0ll;
  return fact[a]*inv(fact[b])%MOD*inv(fact[a-b])%MOD;
}

int main(){
  scanf("%d",&n);
  REP(i,n+1)scanf("%d",a+i);
  int sp = -1;
  int x,y;
  REP(i,n+1){
    acnt[a[i]]++;
    if(acnt[a[i]]==2){
      sp = a[i];
      y = i;
      break;
    }
  }
  REP(i,n+1){
    if(a[i]==sp){
      x=i;break;
    }
  }
  // ... ! ... ! ...
  int s = x;
  int t = y-x-1;
  int u = n-y;
  fact[0] = 1;
  FOR(i,1,125252)fact[i]=fact[i-1]*i%MOD;
  FOR(k,1,n+2){
    ll ans = comb(n+1,k);
    // same pattern
    ans = (ans + MOD - comb(s+u,k-1)) % MOD;
    printf("%lld\n",ans);
  }
  return 0;
}


Measured memory_bytes: 2944
import sys
size_data = sys.stdin.readline().strip().split(" ")

N = int(size_data[0])
M = int(size_data[1])

shop_stock = []

for i in range(N):
    row = sys.stdin.readline().strip().split(" ")
    shop_stock.append((int(row[0]), int(row[1])))

shop_stock = sorted(shop_stock, key=lambda store: store[0])

money = 0
cans_remaining = M

for shop in shop_stock:
    price, max_cans = shop

    cans_to_buy = min(max_cans, cans_remaining)
    money += cans_to_buy * price
    cans_remaining -= cans_to_buy

print(money)


Measured memory_bytes: 18980
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}


int main2() {
  int N = nextLong();
  int Q = nextLong();
  fenwick_tree<ll> fw(N+10);
  REP(i, N) {
    int x = nextLong();
    fw.add(i, x);
  }
  REP(qqq, Q) {
    int t = nextLong();
    if (t == 0) {
      int p = nextLong();
      int x = nextLong();
      fw.add(p, x);
    }
    else
    {
      int l = nextLong();
      int r = nextLong();
      ll ans = fw.sum(l, r);
      cout << ans << '\n';
    }
  }

  
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 8236
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef double ld;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};


int main(){
	init();
	ll r,D,x;cin>>r>>D>>x;
	for(int i=0;i<10;i++){
		x=r*x-D;
		cout<<x<<endl;
	}
}


Measured memory_bytes: 384
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

X = int(input())
S = make_divisors(X)

t = 0
for s in S:
    a = s//2
    b = a-s
    while a**5 - b**5 <= X:
        if a**5 - b**5 == X:
            print(a,b)
            break
        a += 1
        b += 1
    if a**5 - b**5 == X:
        break

Measured memory_bytes: 9100
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=200010;
int w[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++) {
	int x=gi();
	w[x]=w[x-1]+1;
	ans=max(ans,w[x]);
    }
    cout<<n-ans;
    return 0;
}

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

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> using iodef_rng_t = typename enable_if<decltype(declval<C>().begin(), true_type{})::value && !is_same<C, string>::value>::type;
template<class C, class = iodef_rng_t<C>> istream& operator>>(istream& in, C& c) { for (auto& v : c) { in >> v; } return in; }
template<class C, class = iodef_rng_t<C>> ostream& operator<<(ostream& out, const C& c) { int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
template<class T> void trace_(const char* s, const T& v) { cerr << s << "=" << v; }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { for (; *s != ','; ++s) { cerr << *s; } cerr << "=" << v << ","; trace_(++s, vs...); }
#define TRACE(...) (cerr << "\033[2m\033[33m", trace_(#__VA_ARGS__, __VA_ARGS__), cerr << "\033[0m\n")
#else
#define TRACE(...)
#endif

int main() {
    int n;
    cin >> n;
    vector<int64_t> a(n);
    cin >> a;
    partial_sum(a.begin(), a.end(), a.begin());
    map<int64_t, int> cnt;
    cnt[0]++;
    for (auto& ai : a) cnt[ai]++;
    int64_t ans = 0;
    for (auto p : cnt) {
        int64_t c = p.second;
        ans += c * (c - 1) / 2;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 14336
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, M, K;
	bool ans = false;

	cin >> N >> M >> K;

	repc(i, 0, N) repc(j, 0, M) {
		int black = 0;
		black += M * i;
		black += (N - i) * j;
		black -= i * j;
		if (black == K) ans = true;
	}

	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}


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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

const int N = 100005;

int n, l[N], p[N], q[N], r[N];
bool v[N];

inline int Move(int &x, LL &a, int l, int r) {
  if (x < l) {
    a += l - x, x = l;
  } else if (x > r) {
    a += x - r, x = r;
  }
}

LL Solve() {
  for (int i = 1; i <= n; ++i) {
    p[i] = q[i] = i, v[i] = false;
  }
  sort(p + 1, p + n + 1, [&](const int &x, const int &y) {
    return l[x] > l[y];
  });
  sort(q + 1, q + n + 1, [&](const int &x, const int &y) {
    return r[x] < r[y];
  });
  int cur = 0;
  LL ret = 0;
  for (int t = 1, i = 1, j = 1; t <= n; ++t) {
    if (t & 1) {
      while (v[p[i]]) {
        ++i;
      }
      Move(cur, ret, l[p[i]], r[p[i]]);
      v[p[i]] = true;
    } else {
      while (v[q[j]]) {
        ++j;
      }
      Move(cur, ret, l[q[j]], r[q[j]]);
      v[q[j]] = true;
    }
  }
  ret += abs(cur);
  return ret;
}

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  Read(n);
  for (int i = 1; i <= n; ++i) {
    Read(l[i]), Read(r[i]);
  }
  LL ans = Solve();
  for (int i = 1; i <= n; ++i) {
    l[i] = -l[i], r[i] = -r[i], swap(l[i], r[i]);
  }
  ans = max(ans, Solve());
  printf("%lld\n", ans);
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


Measured memory_bytes: 1920
// Add compile option "-std=c++11" for C++11 compile.

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

// Macro
#define rep(i, N) for(int i=0; i<(int)N; i++)
#define rrep(i, N) for(int i=(int)N-1; i>=0; i--)

// Type
template <typename T> using P = pair<T, T>;
using ll = long long;
using ull = unsigned long long;

// Constants
const ll INF = 1e18;
const ll MOD = 1000000007;

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

  if(e - a > k) cout << ":(" << endl;
  else cout << "Yay!" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

ll nCk(ll n){
    return n*(n-1)/2;
}

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

    int n;
    cin>>n;
    vs v(n);
    rep(i,n)cin>>v[i];
    rep(i,n){
        Sort(v[i]);
    }
    map<string,ll> m;
    rep(i,n){
        if(m.find(v[i])==m.end()){
            m[v[i]]=1;
        }
        else{
            m[v[i]]++;
        }
    }
    ll ans=0;
    for(auto it=m.begin();it!=m.end();it++){
        ans+=nCk(it->second);
    }
    fin(ans);
    

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 16640
#include <stdio.h>
 
int main(void) {
	int a,b,i,m,j;
	int n[20000];
	scanf("%d",&a);
	for(b=0;b<a;b++){
		scanf("%d",&n[b]);
	}
	for(i=0;i<a/2;i++){
		m=n[i];
		n[i]=n[a-1-i];
		n[a-1-i]=m;
	}
	for(j=0;j<a;j++){
		if(j>0){printf(" ");}
		printf("%d",n[j]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2048
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <vector>
char buf[1 << 23], *ps = buf, *pt = buf, pbuf[1 << 23], *pp = pbuf;
#define getchar() (ps == pt && (pt = (ps = buf) + fread(buf, 1, 1 << 23, stdin), ps == pt) ? EOF : *ps++)
int read(){
	register int x = 0;
	register char f = 1, ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f ^= 1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');
	return f ? x : -x;
}
#define N 100005
int n, a[N];
void solve(){
	n = read();
	for (register int i = 1; i <= n; ++i) a[i] = read();
	std :: sort(a + 1, a + 1 + n);
	std :: reverse(a + 1, a + 1 + n);
	a[n + 1] = 0;
	for (register int i = 1; i <= n; ++i)
		if (i >= a[i + 1]){
			int j = i + 1;
			while (j <= n && a[j] == i) ++j;
			--j;
			if ((j - i) & 1 || (a[i] - i) & 1) return puts("First"), void(0);
			else return puts("Second"), void(0);
		}
}
int main(){
	int T = 1;
	while (T--) solve();
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>

int
main(void)
{
    int r, c, sum, i, j, num, rSum;
    int * cSum;

    sum = 0;
    scanf("%d %d", &r, &c);
    cSum = (int *) calloc(sizeof(int), c);

    for (i = 0; i < r; i++) {
        rSum = 0;
        for (j = 0; j < c; j++) {
            scanf("%d", &num);
            printf("%d ", num);
            rSum += num;
            cSum[j] += num;
            sum += num;
        }
        printf("%d\n", rSum);
    }


    for (i = 0; i < c; i++)
        printf("%d ", cSum[i]);
    printf("%d\n", sum);

    return 0;
}


Measured memory_bytes: 2096
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  int n, m;
  readf("%s %s\n", &n, &m);
  bool[int] from1, toN;
  foreach (_; 0..m) {
    int a, b;
    readf("%s %s\n", &a, &b);
    if (a == 1) {
      from1[b] = true;
    }
    if (b == n) {
      toN[a] = true;
    }
  }

  bool f;
  foreach (k; from1.keys) {
    if (toN.get(k, 0)) {
      f = true;
    }
  }
  if (f) {
    writeln("POSSIBLE");
  } else {
    writeln("IMPOSSIBLE");
  }
}


Measured memory_bytes: 11900
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

vll divisor(ll n) {
    vll ans;
    for (ll i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ans.push_back(i);
            if (i*i != n) ans.push_back(n/i);
        }
    }
    sort(all(ans));
    return ans;
}

int main() {
    ll n;
    cin >> n;
    auto g = divisor(n);
    int ans = INF;
    rep(i, g.size()) {
        int a = to_string(g[i]).length();
        int b = to_string(n/g[i]).length();
        ans = min(ans, max(a, b));
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <deque>
#include <vector>
#include <map>
#include <math.h>
#include <limits.h>
using namespace std;

int main() {
	string s;
	cin >> s;
	string str = "";
	for (int i = 0; i < s.length(); i++) {
		str += "x";
	}
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
ab = [list(map(int,input().split())) for _ in range(n)]

ab.sort(key=lambda x: x[1])
t = 0
flag = True
for i in range(n):
    t += ab[i][0]
    if t > ab[i][1]:
        flag = False
if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 88024
#include<iostream>
using namespace std;
#include<utility>
#include<algorithm>
#include<cstdio>
#include<cmath>

typedef pair<double, double> point;
typedef point* data;

inline double dist(const point &a, const point &b)
{
    double dx = a.first - b.first, dy = a.second - b.second;
    return sqrt(dx * dx + dy * dy);
}

bool y_less(const point &P1, const point &P2){ return P1.second < P2.second; }
bool y_greater(const point &P1, const point &P2){ return P1.second > P2.second; }

double closest(data P, int n)
{
    if(n <= 1) return 1000;
    if(n == 2) return dist(P[0], P[1]);
    int m = n / 2;
    sort(P, P + n, y_less); // y_sort, down to up.
	double median = P[m].second;
    double d = min(closest(P, m), closest(P + m, n - m));

    sort(P, P + m, y_less);
    sort(P + m, P + n, y_greater);
    int a, b;
    for(a = m - 1; a > 0; a--){ if(P[a].second < median - d) break; }
    for(b = n - 1; b > m; b--){ if(P[b].second > median + d) break; }
    sort(P + a, P + m);
    sort(P + b, P + n);

    // x_sort, left to right.
    int u, v, i, j;
    u = i = a, v = j = b;
    while(i < m && j < n){
        if(P[u].first < P[v].first){
            for(i = a; i < m; i++){
                if(P[i].first >= P[v].first){ u = i; break; }
                if(P[v].first - P[i].first >= d){ a++; }
                else{
                    d = min(d, dist(P[v], P[i]));
                }
            }
        }else{
            for(j = b; j < n; j++){
                if(P[j].first > P[u].first){ v = j; break; }
                if(P[u].first - P[j].first >= d){ b++; }
                else{
                    d = min(d, dist(P[u], P[j]));
                }
            }
        }
    };
    return d;
}

int main()
{
	int i, n;
	double x, y;
	scanf("%d", &n);
	data P;
	P = new point [n];

	for(i = 0; i < n; i++){
		scanf("%lf %lf", &x, &y);
		P[i] = make_pair(x, y);
	}
	printf("%.12f\n", closest(P, n));

	return 0;
}

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

//関数
long ijo(long x,long a){//x以上で最小のaの倍数。a>=2
    if(x%a==0){
        return x;
    }else{
        return x-x%a+a;
    }
}

long ika(long x,long a){//x以下で最大のaの倍数。a>=2
    return x-x%a;
}


    
//main関数
int main() {
    
    
    //入力
    long K;
    cin>>K;
    vector<long> A(K);
    for(int i=0;i<K;i++){
        cin>>A.at(i);
    }
    
    
    //計算 後ろから区間を広げてく
    long mi=2,ma=2;//今の区間(必ず区間になる←大切)
    bool possible=true;//区間が空か？
    for(int i=K-1;i>=0;i--){//後ろから確認
        if(ijo(mi,A.at(i))<=ma && ika(ma,A.at(i))>=mi){//区間にA.at(i)の倍数があるかチェック
            mi=ijo(mi,A.at(i));//一番下の更新
            ma=ika(ma,A.at(i))+A.at(i)-1;//一番上の更新
        }else{
            possible=false;//ダメならダメだと返す
            break;
        }
    }
    
    
    //出力
    if(possible){
        cout<<mi<<" "<<ma<<endl;
    }else{
        cout<<-1<<endl;
    }
}


Measured memory_bytes: 1024
N=int(input())
*A,=map(int, input().split())
*B,=map(int, input().split())
ans=0
for i in range(N):
    m1=min(B[i],A[i])
    m2=min(A[i+1],B[i]-m1)
    A[i+1]-=m2
    ans+=m1+m2
print(ans)


Measured memory_bytes: 87780
#include<stdio.h>
 
int main(){
  
  int i, n;
  int a=0, w=0, t=0, r=0;
  
  char judge[4];
  
  scanf("%d" ,&n);
  
  for(i = 0; i < n; i++){
    
    scanf("%s" ,judge);
    
    if(judge[0] == 'A'){a++;}
    if(judge[0] == 'W'){w++;}
    if(judge[0] == 'T'){t++;}
    if(judge[0] == 'R'){r++;}
            
  }
          
   printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",a,w,t,r); 
             
   return 0;
             
 }

Measured memory_bytes: 1704
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int a[100000]={0};
  int i;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  int ans=0;
  int count[100001]={0};
  for(i=0;i<n;i++){
    if(a[i]<100001){
      count[a[i]]++;
    }
    else{
      ans++;
    }
  }
  for(i=1;i<100001;i++){
    if(count[i]<i){
      ans+=count[i];
    }
    else{
      ans+=count[i]-i;
    }
  }

  printf("%d",ans);

  return 0;

}

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

int main() {
  int a,b; cin >> a >> b;
  if(a<=5){
    cout << 0 << endl;
    exit(0);
  }
  else if(a>=13){
    cout << b << endl;
    exit(0);
  }
  else cout << b/2 << endl;
}



Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <set>
#include <stack>
#include <sstream>
#include <list>
//#include <array>
#include <vector>
#include <queue>
#include <map>
#include <memory>
#include <iterator>
#include <climits>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned int UINT;
typedef unsigned long long ull;
typedef pair<int, int> pdi;
typedef pair<ll, int> pli;

int const maxn = 100 + 10;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
inline int lc(int x)  {return x << 1;}
inline int rc(int x)  {return x << 1 | 1;}

int c[maxn];
int a[maxn][maxn];
int vis[maxn];
int n, m, x;
ll ans = INF;
vector<int> v;

void dfs(int id, int step) {
    int flag = 1;
    if (step >= n + 1) {
        return;
    }
    for (int i = 1; i <= m; i++) {
        int temp = 0;
        for (auto & j : v) {
            temp += a[j][i];
        }
        if (temp < x) {
            flag = 0;
            break;
        }
    }
    if (flag) {
        ll temp = 0;
        for (auto & i : v) {
            temp += c[i];
        }
        ans = min(ans, temp);
    }
    for (int i = id; i <= n; i ++) {
        if (vis[i] == 0) {
            vis[i] = 1;
            v.emplace_back(i);
            dfs(i + 1, step + 1);
            vis[i] = 0;
            v.pop_back();
        }
    }
}

int main(void) {
    FAST_IO;
    
    
    cin >> n >> m >> x;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m + 1; j++) {
            if (j == 1) cin >> c[i];
            else {
                cin >> a[i][j - 1];
            }
        }
    }
    dfs(1, 0);
    if (ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3668
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().solve(new Scanner(System.in));
	}
	
	public void solve(Scanner sc) {
		long k = Integer.parseInt(sc.next());
		long a = Integer.parseInt(sc.next());
		long b = Integer.parseInt(sc.next());
		
		if(a >= b - 2) {
			System.out.println(k+1);
			return;
		}
		
		long bisk = 1;
		long money = 0;
		while(k>0) {
			if(money >= 1) {
				money--;
				bisk += b;
			} else if(k>=2 && bisk>=a) {
				bisk -= a;
				money++;
			} else {
				bisk++;
			}
			k--;
		}
		System.out.println(bisk);
	}
}


Measured memory_bytes: 23252
N, M = map(int, input().split())
cakes = []
for _ in range(N):
    x, y, z = map(int, input().split())
    cakes.append((x, y, z))

ans = 0
for i in range(2**3):
    op1, op2, op3 = 1, 1, 1
    for idx, j in enumerate(bin(i)[2:][::-1], 1):
        j = int(j)
        if idx == 1:
            op1 = 1 if j == 0 else -1
        elif idx == 2:
            op2 = 1 if j == 0 else -1
        elif idx == 3:
            op3 = 1 if j == 0 else -1
            
    cakes.sort(reverse=True, key=lambda x: op1 * x[0] + op2 * x[1] + op3 * x[2])
    sx, sy, sz = 0, 0, 0
    for cake in cakes[:M]:
        sx += cake[0]
        sy += cake[1]
        sz += cake[2]
    ans = max(ans, abs(sx) + abs(sy) + abs(sz))
print(ans)


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

int main() {
    int n;
	cin>>n;
    
    if(n == 1)
    {
        cout << "Yes";
        return 0;
    }
    
    int h[n];
    for(int i=0;i<n;i++) cin >> h[i];
    
    for(int i=1;i<n;++i)
    {
        int pre = h[i-1];
        int cur = h[i];
        
        if(cur >= (pre + 1))
        {
            cur = cur - 1;
            h[i] = cur;
        }
        if(pre > cur)
        {
            cout << "No";
            return 0;
            
        }
    }
    
    cout << "Yes";

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
    const ll bit = 41;
    ll n, k; cin >> n >> k;
    vector<ll> A(n); rep(i, n) cin >> A[i];
    vector<ll> cnt(bit, 0);
    rep(i, n) {
        ll a = A[i];    // i桁目(2^iの位)
        rep(j, bit) {
            if (a%2==1) cnt[j]++;   // ビットが立ってるやつを数える
            else cnt[j]--;          // 立ってない総数
            a /= 2;
        }
    }
    ll X = 0;
    rep(i, bit) {
        if (cnt[bit-i-1] < 0) {
            if (X+pow(2, bit-i-1) <= k) X += pow(2, bit-i-1);
        }
    }
    ll res = 0;
    rep(i, n) {
        res += X ^ A[i];
    }
    cout << res << endl;
    return 0;
}

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

int main(){
	int a, b, i;
	int ans[10000];
	char op;
	
	for(i = 0; i <= 9999; i++){
		cin >> a >> op >> b;
		if(op == '?'){
			break;
		}
		switch(op){
			case '+':
				ans[i] = a+b;
				break;
			case '-':
				ans[i] = a-b;
				break;
			case '/':
				ans[i] = a/b;
				break;
			case '*':
				ans[i] = a*b;
				break;
		}
	}
	
	for(int j = 0; j <= i-1; j++){
		cout << ans[j] << endl;
	}
	
	return 0;
}

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

int main(){
    int n, i, b = 0, r = 0;
    string s;
    cin >> n >> s;
    for(i=0; i<n; i++){
        if(s[i] == 'R'){
            r++;
        }else{
            b++;
        }
    }
    if(r > b){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl;
#define STOP assert(false);
#else
#define dump(x) ;
#define LINE 	;
#define dumpV(v);
#define STOP 	;
#endif

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}


ll dp[(1 << 23)][2];

int bitNum(int n) {
	int ret = 0;
	while(n > 0) {
		ret += n & 1;
		n >>= 1;
	}
	return ret;
}

int main() {
	int n, m;
	while (cin >> n >> m) {
		if (n * m == 0) break;
		vector<string> s(n);
		rep(i, n) cin >> s[i];

		auto brute = [&] {
			typedef bitset<510> B;
			vector<B> bits(n);
			rep(i, n) rep(j, m) if(s[i][j] == '1') bits[i][j] = true;
			int ret = 0;
			rep(mask, (1 << n)) {
				B tmp;
				rep(i, n) if((1<<i)&mask) tmp ^= bits[i];
				if(tmp.none()) ret = max(ret, bitNum(mask));
			}
			return ret;
		};
		auto bitDP = [&] {
			vector<int> bits(510);
			rep(i, n) {
				rep(j, m) if (s[i][j] == '1') bits[i] |= (1 << j);
			}
			rep(i, (1 << 23)) rep(j, 2) dp[i][j] = -1;
			dp[0][0] = 0;
			rep(i, n) {
				int now = i & 1, nxt = (i + 1) & 1;
				rep(mask, (1 << m)) dp[mask][nxt] = max(dp[mask][now], dp[mask][nxt]);
				rep(mask, (1 << m)) if(dp[mask][now]!=-1){
					int nmask = mask ^ bits[i];
					dp[nmask][nxt] = max(dp[nmask][nxt], dp[mask][now]+1);
				}
			}
			return dp[0][n & 1];
		};
		if(m < 23) cout << bitDP() << endl;
		else cout << brute() << endl;
		// if (n < 23) cout << brute() << endl;
		// else cout << bitDP() << endl;
	}
	return 0;
}

Measured memory_bytes: 134144
module ArrayL = ArrayLabels
module ListL = ListLabels

let dbg = Printf.printf "[debug]%s"

let max_num = 100_000_000_000

let id = fun x -> x
let tuple2 x y = (x,y)
let tuple3 x y z = (x,y,z)
let succ x = x + 1
let pred x = x - 1

let (++) n m =
  let rec aux i =
    if i = m then [m]
    else i :: aux (i+1) in
  if n > m then [] else aux n

let (++^) n m = n ++ (m-1)

let scan fmt f = Scanf.sscanf (read_line ()) fmt f

let scan_list ~sep cnv =
  let line = read_line () in
  Str.split (Str.regexp_string sep) line
  |> List.map cnv

let scan_array ~sep cnv =
  Array.of_list @@ scan_list ~sep cnv

let scan_lines n fmt f =
  List.map (fun _ -> scan fmt f) (0++^n)

let scan_matrix n m e conv =
  let arr = Array.make_matrix n m e in
  Array.iteri (fun i line ->
      let s = Scanf.Scanning.from_string @@ read_line () in
      Array.iteri (fun j _ ->
          arr.(i).(j) <- Scanf.bscanf s " %s" conv;
        ) line) arr; arr

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

let between n x m = n <= x && x < m

let string_to_list s =
  List.map (String.get s) (0 ++^ String.length s)

let n = scan "%d" id
let arr = let arr = Array.make (succ n) [||] in
  ListL.iter (0++^n) ~f:(fun _ ->
      let a = scan_array ~sep:" " int_of_string in
      let n = a.(0) in
      let routes = Array.sub a 2 a.(1) in
      arr.(n) <- routes
    ); arr

let () =
  let dists = Array.make (succ n) (-1) in
  let rec aux q =
    if Queue.is_empty q then ()
    else
      let (v, n) = Queue.pop q in
      if dists.(v) <> -1 then aux q
      else
        (dists.(v) <- n;
         ArrayL.iter arr.(v) ~f:(fun w -> Queue.add (w, succ n) q);
         aux q)
  in
  let q = Queue.create () in
  Queue.add (1,0) q;
  aux q;
  ListL.iter (1++n) ~f:(fun i -> Printf.printf "%d %d\n" i dists.(i))



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


void solve(long long S, long long W){
    if(W >= S){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
}

int main(){
    long long S;
    scanf("%lld",&S);
    long long W;
    scanf("%lld",&W);
    solve(S, W);
    return 0;
}


Measured memory_bytes: 3764
(defun split (str)
  (labels ((inner (rest-str-list stack-str-list temp-out)
                  (if rest-str-list
                      (let ((now-char (car rest-str-list)))
                        (cond ((eq #\space now-char) (inner (cdr rest-str-list)
                                                            '()
                                                            (cons (concatenate 'string (reverse stack-str-list))
                                                                  temp-out)))
                              (t (inner (cdr rest-str-list)
                                        (cons now-char stack-str-list)
                                        temp-out))))
                      (reverse (cons (concatenate 'string (reverse stack-str-list))
                                     temp-out)))))
          (inner (concatenate 'list str)
                 '()
                 '())))

(defun input-to-list (str)
  (mapcar #'parse-integer (split str)))

(defvar n (read))
(defvar p (input-to-list (read-line)))

(defun centerp (left num right)
  (let ((leftd (- num left))
        (rightd (- num right)))
    (< (* leftd rightd) 0)))

(defun count-center (lst)
  (let ((len (length lst)))
    (apply #'+ (loop for i from 1 to (- len 2)
                                    collect (if (centerp (nth (1- i) lst)
                                                         (nth i lst)
                                                         (nth (1+ i) lst))
                                                1
                                                0)))))

(format t "~a" (count-center p))


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

using namespace std;

using ll = long long;

ll f[55][2];

int main() {
   int n, p;
   cin >> n >> p;
   f[0][0] = 1ll;
   for (int i = 1; i <= n; ++i) {
      int x;
      cin >> x;
      for (int j = 0; j < 2; ++j) {
         f[i][j] = (f[i - 1][j] + (f[i - 1][(j + x) & 1]));
      }
   }
   cout << f[n][p] << '\n';
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);

        long[] ppp = new long[n];
        long[] ppm = new long[n];
        long[] pmp = new long[n];
        long[] pmm = new long[n];
        long[] mpp = new long[n];
        long[] mpm = new long[n];
        long[] mmp = new long[n];
        long[] mmm = new long[n];
        
        for(int i=0;i<n;i++){
            string[] temp = ReadLine().Split(' ');
            long a = long.Parse(temp[0]);
            long b = long.Parse(temp[1]);
            long c = long.Parse(temp[2]);
            ppp[i] = a+b+c;
            ppm[i] = a+b-c;
            pmp[i] = a-b+c;
            pmm[i] = a-b-c;
            mpp[i] = -a+b+c;
            mpm[i] = -a+b-c;
            mmp[i] = -a-b+c;
            mmm[i] = -a-b-c;
        }
        Array.Sort(ppp);
        Array.Sort(ppm);
        Array.Sort(pmp);
        Array.Sort(pmm);
        Array.Sort(mpp);
        Array.Sort(mpm);
        Array.Sort(mmp);
        Array.Sort(mmm);
        long tppp = 0;
        long tppm = 0;
        long tpmp = 0;
        long tpmm = 0;
        long tmpp = 0;
        long tmpm = 0;
        long tmmp = 0;
        long tmmm = 0;
        for(int i=n-1;i>=n-m;i--){
            tppp+=ppp[i];
            tppm+=ppm[i];
            tpmp+=pmp[i];
            tpmm+=pmm[i];
            tmpp+=mpp[i];
            tmpm+=mpm[i];
            tmmp+=mmp[i];
            tmmm+=mmm[i];
        }
        long max = tppp;
        max = Max(max,tppm);
        max = Max(max,tpmp);
        max = Max(max,tpmm);
        max = Max(max,tmpp);
        max = Max(max,tmpm);
        max = Max(max,tmmp);
        max = Max(max,tmmm);
        
        WriteLine(max);

    }
}

Measured memory_bytes: 13324
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
char s[N],t[N];
signed main()
{
    scanf("%s%s",s,t);
    int n=strlen(s), m=strlen(t);
    sort(s,s+n), sort(t,t+m);
    if(s[0]<t[m-1]) puts("Yes");
    else if(s[0]>t[m-1]) puts("Yes");
    else
    {
        if(s[0]==s[n-1]&&t[0]==t[m-1]&&s[0]==t[0])
        {
            if(m>n) puts("Yes");
            else puts("No");
            return 0;
        }
        int qwq=0;
        for(ri int i=0;i<n;i++)
        for(ri int j=0;j<m;j++)
        {
            if(t[j]>s[i]) { qwq++; break; }
        }
        if(qwq==n) puts("Yes");
        else puts("No");
    }
    return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
 
int fa[1000006], dis[1000006];
 
int find(int x) {
	if (fa[x] == x) return x;
	int tmpfa = find(fa[x]);
	dis[x] += dis[fa[x]];
	return fa[x] = tmpfa;
}
 
 
bool add(int L, int R, int D) {
	if (find(L) == find(R)) {
		if (dis[L] - dis[R] != -1 * D) {
			cout << "No";
			return 0;
		}
		return 1;
	}
	int faR = fa[R], faL = fa[L];
	fa[faR] = fa[faL];
	dis[faR] = dis[L] + D - dis[R];
	return 1;
}
 
 
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) fa[i] = i;
	
	for (int i = 1; i <= m; ++i) {
		int L, R, D;
		scanf("%d%d%d", &L, &R, &D);
		if (!add(L, R, D)) {
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}
 

Measured memory_bytes: 4736
#include<stdio.h>
int main(void){
    int N,D,X,i,j;
    scanf("%d %d %d",&N,&D,&X);
    int A[N],sum=N;
    for(i=0;N>i;++i)
    scanf("%d",&A[i]);
    /*入力*/
    for(i=0;N>i;++i){
        for(j=1;A[i]*j+1<=D;++j){
            ++sum;
        }
    }
    printf("%d",sum+X);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;

const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long

const int inf = 1e9;

string s[3];

int main() {
  //auto start_clock = clock();
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif
  cin >> s[2];
  int m;
  scanf("%d", &m);
  int idx = 0;
  while(m--) {
    int op;
    scanf("%d", &op);
    if(op == 1) {
      idx ^= 1;
    }
    else {
      int x;
      char ch[3];
      scanf("%d%s", &x, ch);
      x -= 1;
      s[idx ^ x] += ch[0];
    }
  }
  if(idx == 0) {
    reverse(s[0].begin(), s[0].end());
    cout << s[0] << s[2] << s[1] << endl;
  }
  else {
    reverse(s[1].begin(), s[1].end());
    reverse(s[2].begin(), s[2].end());
    cout << s[1] << s[2] << s[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 1088
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;

	for (int i = 0; i < s.length(); i++) {
		if (i == a) {
			if (s[a] != '-') {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if (s[i] == '-') {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 256
arg = input().split(' ')
H = int(arg[0])
W = int(arg[1])

if H == 1 or W == 1:
    print(1)
    exit(0)

w_odd = (W+1) // 2
w_even = W // 2

h_odd_line = (H+1) // 2
h_even_line = H // 2

reachable = w_odd * h_odd_line + w_even * h_even_line
print(reachable)

Measured memory_bytes: 3064
#include <stdio.h>

int insertionSort(int A[], int n, int g) {
	int i, j, v, cnt;
	cnt = 0;
	for(i=g;i<n;i++) {
		v = A[i];
		j = i - g;
		while(j>=0 && A[j] > v) {
			A[j+g] = A[j];
			j = j - g;
			cnt ++;
		}
		A[j+g] = v;
	}
	
	return cnt;
}

int shellSort(int A[], int n) {
	int i, h, m, cnt;
	int G[120000];
	cnt = 0;
	m = 0;
	
    h = 1; m = 0;
    G[m] = h;
    m ++;
    if(n > 100) {
	    while( h < (n/9.0) ) {
	        h = h*3 + 1;
	        G[m] = h;
	        m++;
	    }
    } else {
	    while( h < (n/3.0) ) {
	        h = h*3 + 1;
	        G[m] = h;
	        m++;
	    }
    }
	
	printf("%d\n", m);
	for(i=0;i<m;i++) {
		cnt += insertionSort(A, n, G[m-i-1]);
		printf("%d", G[m-i-1]);
		if(i<m-1) {
			printf(" ");
		} else {
			printf("\n");
		}
	}
	
	return cnt;
}

int list[1000000];

int main(void) {
	int n, i, cnt;
	scanf("%d\n", &n);
	for(i=0;i<n;i++) {
		scanf("%d\n", &list[i]);
	}
	cnt = shellSort(list, n);
	printf("%d\n", cnt);
	
	for(i=0;i<n;i++) {
		printf("%d\n", list[i]);
	}
	
	return 0;
}

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

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
//const int INF = 0x3f3f3f3f;
//const int mod=1e9+7;
//###################################################################
const int N=100009;
int n,m;
vector<vector<int>>g(N);

int mem[N];
int solve(int num){
    if(mem[num]!=-1)return mem[num];
    if(g[num].size()) {
        int ret=0;
        for (auto i:g[num]) {
            ret =max(ret,solve(i));
        }
        return mem[num]=1+ret;
    }
    return mem[num]=0;

}

int main(){
    n=D(),m=D();
    for(int i=0;i<m;i++){
        int u=D(),v=D();
        g[u].push_back(v);
    }
    int mx=0;
    memset(mem,-1,sizeof(mem));
    for(int i=1;i<=n;i++){
        mx=max(mx,solve(i));
    }
    printf("%d",mx);
}

Measured memory_bytes: 11004