akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
int num(){
    char s[11];
    int i, n;
    for(i=0; i<sizeof(s); i++){
        s[i] = getchar();
        if(s[i] == ' ' || s[i] == '\n'){
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}
int main(void){
    int k, s;
    int x, y;
    int z;
    int ans=0;
    k = num();
    s = num();
    
    for(x=0; x<=k; x++){
        for(y=0; y<=k; y++){
            z = s-x-y;
            if(s-x-y <= k && z >= 0){
                ans++;
            }
        }
    }
    printf("%d\n", ans);
    
    return 0;
    
}

Measured memory_bytes: 128
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int h,w,n;
void dump(vector<string> &blocks) {
    rep(y,h) {
        rep(x,w) {
            cout<<blocks[y][x];
        }
        cout<<endl;
    }
    cout<<endl;
}
bool erase(vector<string> &blocks) {
    bool res=false;
    bool flag[31][31]={};
    rep(y,h) rep(x,w) {
        char c=blocks[y][x];
        if(c=='.') c='+';
        int ny=y;
        while(ny<h&&c==blocks[ny][x]) {
            ny++;
        }
        if(n<=ny-y) {
            for(int i=y;i<ny;i++) flag[i][x]=true;
        }
        int nx=x;
        while(nx<w&&c==blocks[y][nx]) {
            nx++;
        }
        if(n<=nx-x) {
            for(int i=x;i<nx;i++) flag[y][i]=true;
        }
    }

    rep(y,h) rep(x,w) if(flag[y][x]) blocks[y][x]='.';
    rep(y,h) rep(x,w) if(flag[y][x]) res=true;
    return res;
}
void fall(vector<string> &blocks) {
    for(int y=h-1;y>=0;y--) rep(x,w) {
        if(blocks[y][x]!='.') {
            int tmp=y;
            while((tmp+1)<h && blocks[tmp+1][x]=='.') {
                blocks[tmp+1][x] = blocks[tmp][x];
                blocks[tmp][x]='.';
                tmp++;
            }
        }
    }
}
bool ok(vector<string> blocks) {
    fall(blocks);
    while(erase(blocks)) {
        // dump(blocks);
        fall(blocks);
    }

    bool res=true;
    rep(y,h) rep(x,w) res&=blocks[y][x]=='.';
    return res;
}
int main() {
    vector<string> blocks(31);
    cin>>h>>w>>n;
    rep(i,h) cin>>blocks[i];
    rep(y,h) {
        rep(x,w-1) {
            swap(blocks[y][x],blocks[y][x+1]);
            // printf("[debug] %d %d %d\n", y,x,x+1);
            if(ok(blocks)) {
                cout<<"YES"<<endl;
                return 0;
            }
            swap(blocks[y][x],blocks[y][x+1]);
        }
    }
    cout<<"NO"<<endl;

    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#include <boost/range.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>
using namespace std;
constexpr char nl = '\n';
using ll = long long;
using boost::irange;
namespace rng {
    using namespace boost;
    using namespace boost::range;
    using namespace boost::adaptors;
}

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

template<class C> auto operator>>(istream& in, C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, istream&>::type {
    for (auto& v : c) { in >> v; } return in; }
template<class C> auto operator<<(ostream& out, const C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, ostream&>::type {
    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
constexpr auto color_s_ = "\033[2m\033[33m", color_e_ = "\033[0m";
template<class T> void trace_(const T& v) { cerr << v; }
template<class T> void trace_(const vector<vector<T>>& m) { cerr << "\n"; for (const auto& v : m) { trace_(v); cerr << "\n"; } }
template<class T> void trace_(const char* s, const T& v) { cerr << color_s_ << s << "="; trace_(v); cerr << color_e_ << "\n"; cerr.flush(); }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { cerr << color_s_; for (; *s != ','; ++s) { cerr << *s; } cerr << "="; trace_(v); cerr << ","; trace_(++s, vs...); }
#define TRACE(...) trace_(#__VA_ARGS__, __VA_ARGS__)
#else
#define TRACE(...)
#endif

int main() {
    int n, m;
    cin >> n >> m;
    multiset<int, greater<int>> ms;
    for (int i : irange(0, n)) {
        int a;
        cin >> a;
        ms.emplace(a);
    }
    for (int i : irange(0, m)) {
        auto maxi = ms.begin();
        int x = *maxi;
        ms.erase(maxi);
        ms.emplace(x / 2);
    }
    ll ans = rng::accumulate(ms, 0ll);
    cout << ans << nl;
}


Measured memory_bytes: 4992
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int R, G, B, N;

int main() {
    cin >> R >> G >> B >> N;
    int ans = 0;
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= N; ++j) {
            int q = N - R * i - G * j;
            if (q >= 0 && q % B == 0) ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# ABC045B - 3人でカードゲームイージー / Card Game for Three (ABC Edit)
from collections import deque


def main():
    S = {s: deque(list(input().rstrip())) for s in ("a", "b", "c")}
    cur = S["a"].popleft()
    while True:  # search greedily
        if not S[cur]:
            print(cur.upper())
            break
        cur = S[cur].popleft()


if __name__ == "__main__":
    main()

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

using namespace std;

#define ldouble long double
#define llong long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(STL) STL.begin(), STL.end()
#define stl_rep(itr, STL) for (auto itr = STL.begin(); itr != STL.end(); ++itr)

const static llong MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

llong sumN(llong n) {
    return n * (n + 1) / 2;
}

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    bool flag = false;
    for (int i = 0; i < s.size(); ++i) {
        for (int j = i + 1; j < s.size(); ++j) {
            if (s[i] == 'C' && s[j] == 'F') flag = true;
        }
    }

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

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
	return 0;
}

void Main(){
	int n,x,t;
	cin >> n >> x >> t;
	cout << (int)ceil(n/(double)x) * t << endl;
}


Measured memory_bytes: 3648
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a, b;
    cin >> a >> b;
    int res = a * b - a - b + 1;

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  string S;
  cin>>S;
  rep(i,20){
    if(S[i]==',')S[i]=' ';
  }
  cout<<S<<endl;
  return 0;
}

Measured memory_bytes: 3604
# -*- coding: utf-8 -*-
from itertools import product

def parse(S, op):
    """
    構文木を返す
    Sは普通の記法の式
    opは優先順序　通常は(*/: 1, +-: 2)
    """
    S = "0+({})".format(S)
    V = []
    for x in list("()+-*"):
        S = S.replace(x, " {} ".format(x))
    i = 0
    rank = 0
    O = []
    for s in S.split():
        if s == "(":
            rank += 1
        elif s == ")":
            rank -= 1
        elif s.isdigit():
            V.append(s)
            i += 1
        else:
            V.append(s)
            O.append([-rank, op[s], i])
            i += 1

    G = [[] for _ in range(len(V))]
    P = [-1]*len(V)
    O = sorted(O)
    
    def get_pair(i):
        while P[i] != -1:
            i = P[i]
        return i
    
    for _, _, i in O:
        l, r = get_pair(i-1), get_pair(i+1)
        G[i].extend([l, r])
        P[l], P[r] = i, i
    p = O[-1][2]
    return G, V, p

def make(G, V, p):
    def call(i):
        if V[i].isdigit():
            return V[i]
        else:
            assert len(G[i]) == 2
            left = call(G[i][0])
            right = call(G[i][1])
            return "({}{}{})".format(left, V[i], right)
    return call(p)

S = input()
ans = -float("inf")

for a, b, c in product(range(3), repeat=3):
    op = {}
    op["+"] = a
    op["-"] = b
    op["*"] = c
    ans = max(ans, eval(make(*parse(S, op))))
print(ans)


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll a,b,c,k;

int main(){
  cin>>a>>b>>c>>k;
  if(k%2==0)cout<<a-b<<endl;
  else cout<<b-a<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h,w,c,dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};
vector<int> p(64);

int nu(int x,int y,int cl,int t){
  int res=1;
  p[y*w+x]=cl;
  for(int i=0;i<4;i++){
    int nx=x+dx[i],ny=y+dy[i];
    if(nx<0||w<=nx||ny<0||h<=ny||p[ny*w+nx]!=t||p[ny*w+nx]==cl)continue;
    res+=nu(nx,ny,cl,t);
  }
  return res;
}

int dfs(int d){
  vector<int> tp=p;
  int res=0;
  if(d==4){
    nu(0,0,c,p[0]);
    return nu(0,0,7,p[0]);
  }
  for(int j=1;j<7;j++){
    nu(0,0,j,p[0]);
    res=max(res,dfs(d+1)),p=tp;
  }
  return res;
}

int main(){
  while(cin>>h>>w>>c,h){
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)cin>>p[i*w+j];
    cout<<dfs(0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3140
class UnionFind():
    # 各要素の親要素の番号を格納するリスト
    # 要素が根（ルート）の場合は-(そのグループの要素数)を格納する
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # 要素xが属するグループの根を返す
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # 要素xが属するグループと要素yが属するグループとを併合する
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # 要素xが属するグループのサイズ（要素数）を返す
    def size(self, x):
        return -self.parents[self.find(x)]

    # 要素x, yが同じグループに属するかどうかを返す
    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    # すべての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    # グループの数を返す
    def group_count(self):
        return len(self.roots())

    # {ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    # ルート要素: [そのグループに含まれる要素のリスト]を文字列で返す (print()での表示用)
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def resolve():
    N, M = map(int, input().split())
    G = [list(map(lambda x:int(x)-1, input().split())) for _ in range(M)]

    # なくなる橋は、1番目の辺を削除、2番目の辺を削除なので1・2の辺がない状態
    # 3番目の辺を削除なので1・2・3番目の辺がない状態・・・と変化していく
    # よって、単純に後ろの辺から追加していく
    uf = UnionFind(N)
    pair = N * (N - 1) // 2 # aからbの島の組み合わせ
    ans = []
    for a, b in G[::-1]:
        ans.append(pair)
        # 連結しているか判定
        if not uf.is_same(a, b):
            n_a = uf.size(a)
            n_b = uf.size(b)
            pair -= n_a * n_b

        # 時間を巻き戻し(追加していく)
        uf.union(a, b)

    print("\n".join(map(str, ans[::-1])))

if __name__ == "__main__":
    resolve()

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

int main(void){
    vector<vector<int> > v(3, vector<int>(3));
    vector<int> s(3);
    rep(i, 3)rep(j, 3) cin>>v[i][j];
    rep(j, 3) s[j]=v[0][j];
    rep(i, 3){
        rep(j, 3){
            v[i][j]-=s[j];
        }
    }
    rep(i, 3){
        rep(j, 3){
            if(v[i][j]!=v[i][0]){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
unit = ["","Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko",
        "Kan","Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts"]
while 1:
    m,n = map(int,raw_input().split())
    if m == 0: break
    a = m**n
    ans = ""
    for i in xrange(20):
        c = a%10000
        if c > 0: 
            ans = str(c)+unit[i]+ans
        a /= 10000
        if a == 0: break
    print ans

Measured memory_bytes: 4228
#include<iostream>

using namespace std;

int main(){
    long long X;
    cin >> X;
    int n500 = X / 500;
    X = X - 500 * n500;
    int n5 = X / 5;

    long long h = n500 * 1000 + n5 * 5;

    cout << h << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int d, n;
  cin >> d >> n;
  int base;
  if(d == 0 && n == 100){
    cout << "101\n"; 
    return 0;
  }
  if(d == 1 && n == 100){
    cout << "10100\n"; 
    return 0;
  }
  if(d == 2 && n == 100){
    cout << "1010000\n"; 
    return 0;
  }
  if(d == 0) base = 1;
  else if(d == 1) base = 100;
  else base = 10000;
  cout << base * n << "\n";
}

Measured memory_bytes: 256
N = int(input())
X = input().strip()
C = X.count("1")
D = int(X, 2)
Mm, Mp = 0, D % (C+1)
if C > 1:
    Mm = D % (C-1)

p = [0]*(2*10**5+2)
for i in range(1, len(p)):
    n = i
    while True:
        b = bin(n).count("1")
        if b <= 0:
            break
        p[i] += 1
        n = n % b

for i in range(1, N+1):
    c = C
    if X[i-1] == "1":
        c -= 1
        if c == 0:
            print(0)
            continue
        m = Mm
        d = pow(2, N-i, c)
        d = (m-d+c) % c
    else:
        c += 1
        m = Mp
        d = pow(2, N-i, c)
        d = (m+d) % c

    print(p[d]+1)


Measured memory_bytes: 77012
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define PB push_back
#define SP << " " <<

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VLL;

__attribute__((constructor))
void initial(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed <<setprecision(15);
}


int main(void){
	string S,T,U;
    int A, B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if(U == S){
        A --;
    }else{
        B--;
    }

    cout << A SP B <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<bitset>
using namespace std;
const int maxn=100005;
int n,k,s,a[maxn];
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
		if(ch=='-')
			f=-1;
		ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
    }
    return x*f;
}
inline void write(int a)
{
    if(a<0)
    {
		putchar('-');
		putchar('1');
    }
    else
    {
		if(a>=10)
			write(a/10);
		putchar(a%10+'0');
    }
}

int main()
{
    n=read(),k=read(),s=read();
	for(int i=1;i<=k;++i)
		a[i]=s;
	for(int i=k+1;i<=n;++i)
		if(s>1e6)
			a[i]=1;
		else
			a[i]=99999999;
	for(int i=1;i<=n;++i)
		cout<<a[i]<<' ';
    return 0;
}


Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		long l;
		long r;

		Scanner sc = new Scanner(System.in);

		l =  sc.nextInt();
		r =  sc.nextInt();

		long res;

		if (r - l >= 2018) {
			res = 0;
		} else {

			res = 2018;

			for (long i = l; i < r; i++) {

				for (long j = i+1;j <= r; ++j) {
					res = Math.min(res, (i * j) % 2019);
				}

			}
		}

		System.out.println(res);


	}
}


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

int main(void) {
	// your code goes here
	int n,v[100001],o[100001],e[100001],i,j,max=100000,flag=0,flagsum=0;
	cin >> n;
	for(i=0;i<n;i++) {
		cin >> v[i];
		if(i%2==0) e[i/2]=v[i];
		else o[(i-1)/2]=v[i];
	}
	o[n/2]=0;
	e[n/2]=0;
	sort(o,o+n/2);
	sort(e,e+n/2);
	i=0;
	int kari=1,omax=1,oo=o[0];
	for(i=0;i<n/2;i++){
		if(o[i]==0) continue;
		if(o[i+1]==o[i]) {
			kari++;
		} else {
			if(omax<kari) {
				omax=kari;
				oo=o[i];
			}
			kari=1;
		}
	}
	kari=1;
	int emax=1,ee=e[0];
	for(i=0;i<n/2;i++){
		if(e[i]==0) continue;
		if(e[i+1]==e[i]) {
			kari++;
		} else {
			if(emax<kari) {
				emax=kari;
				ee=e[i];
			}
			kari=1;
		}
	}
	if(ee!=oo) {
		cout << n-emax-omax << endl;
		return 0;
	}
	if(emax+omax==n) {
		cout << n/2 << endl;
		return 0;
	}
	for(i=0;i<n/2;i++) {
		if(e[i]==ee) e[i]=0;
		if(o[i]==oo) o[i]=0;
	}
	kari=1;
	int omax1=1;
	for(i=0;i<n/2;i++){
		if(o[i]==0) continue;
		if(o[i+1]==o[i]) {
			kari++;
		} else {
			if(omax1<kari) {
				omax1=kari;
			}
			kari=1;
		}
	}
	kari=1;
	int emax1=1;
	for(i=0;i<n/2;i++){
		if(e[i]==0) continue;
		if(e[i+1]==e[i]) {
			kari++;
		} else {
			if(emax1<kari) {
				emax1=kari;
			}
			kari=1;
		}
	}
	if(omax+emax1>=omax1+emax) cout << n-omax-emax1 << endl;
	if(omax+emax1<omax1+emax) cout << n-omax1-emax << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <unordered_map>
using namespace std;
int main(){
    int N;
    string S,s1,s2;
    scanf("%d",&N);
    cin>>S;
    s1=S.substr(0,N/2);
    s2=S.substr(N/2,N/2);
    //cout<<s1<<" "<<s2<<endl;
    if(s1==s2&&(N%2==0)){
        printf("Yes");
    }else printf("No");

}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
A = list(map(int, input().split()))

C = Counter(A)
C = [[k, v] for k, v in C.items() if v >= 2]
C.sort(key=lambda x:x[0], reverse=True)

ans = 0
if len(C) >= 1:
    if C[0][1] >= 4:
        ans = C[0][0] * C[0][0]
    elif len(C) >= 2:
        ans = C[0][0] * C[1][0]

print(ans)

Measured memory_bytes: 18600
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
    //Seiranchan!
    int a,b,c,i=1;
    cin >> a >> b>> c;
    bool fl=true;
    while(fl){
        if((i*a)%b==c){
            cout << "YES" << endl;
            return 0;
        }
        i++;
        if(i==10000){
            break;
        }
    }
    
        cout << "NO" <<endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
using namespace std;

int main(void){
	int N,K;
	cin>>N>>K;
	ll V[N];
	rep(i,N)cin>>V[i];
	//rep(i,N)cout<<"V["<<i<<"]="<<V[i]<<endl;

	ll ans=0;
	rep(i,K){
		//cout<<"choice"<<i+1<<endl;
		rep(j,i+2){
			if(i+1 > N)break;
			ll work[i+1];
			rep(k,i+1){
				work[k] = V[(N-i+k+j-1)%N];
			}
			sort(work,work+i+1);
			//rep(ix,i+1)cout<<"["<<ix<<"]"<<work[ix];
			//cout<<endl;
			int cnt = K-(i+1);
			ll tmp=0;
			rep(k,i+1){
				if(cnt>0 && work[k]<0)cnt--;
				else tmp+=work[k];
			}
			//cout<<"value ="<<tmp<<endl;
			if(ans < tmp) ans = tmp;
		}
	}

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


Measured memory_bytes: 256
import java.math.BigInteger
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    val n = sc.nextBigInteger()
    val a = sc.nextBigInteger()
    val b = sc.nextBigInteger()
    var sumB : BigInteger

    val count = n/(a+b)
    val l = n - count*(a+b)

    sumB = count*a

    sumB += if(l>=a){
        a
    }else{
        l
    }
    println(sumB)
}


Measured memory_bytes: 31396
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;

const int inf = int(1e9);
const int mod = inf + 7;
using namespace std;
const int N = 5e5 + 555;

void solve()
{
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); ++i){
		if(k - 1 == i){
			cout << (char)tolower(s[i]);
			continue;
		}
		cout << s[i];

	}
}

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

Measured memory_bytes: 256
import math
n,m = map(int, input().split())
mod = 1000000007
fact = [1]*(n+10000+1)
rfact = [1]*(n+10000+1)
for i in range(n+10000):
    fact[i+1] = rr = ((i+1) * fact[i]) % mod
    rfact[i+1] = pow(rr, mod-2, mod)
def comb(N, K,mod):
    return fact[N] * rfact[K] * rfact[N-K] % mod
def make_prime_list_2(num):
    if num < 2:
        return []

    # 0のものは素数じゃないとする
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 # 1は素数ではない
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]
def prime_factorization_2(num):
    if num <= 1:
        print(1)
        exit()
        return False
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list_2(num_sqrt)

        dict_counter = {}
        for prime in prime_list:
            while num % prime == 0:
                if prime in dict_counter:
                    dict_counter[prime] += 1
                else:
                    dict_counter[prime] = 1
                num //= prime
        if num != 1:
            if num in dict_counter:
                dict_counter[num] += 1
            else:
                dict_counter[num] = 1

        return dict_counter
x = prime_factorization_2(m)
x = list(x.values())
ans = 1
for i in x:
  ans*= comb(i+n-1,i,mod)
  ans %=mod
print(ans)

Measured memory_bytes: 13048
#include <stdio.h>
//printf("1\n");

int main(){
    int a,b,n;
//    printf("1\n");
    scanf("%d %d %d",&n,&a,&b);
    
    if(a>b || (n==1&&a!=b)){
        printf("0");
        return 0;
    }
    if(a==b){
        printf("1");
        
    }else{
        printf("%lld",(long long)(b-a)*(n-2)+1);
    }
    return 0;
}

Measured memory_bytes: 128
function dfs(G,A,X,u)
	ret=0
	N=length(A)
	flag=false
	for i=1:N
		if !X[i]
			flag=true
			if G[u,A[i]]==0 continue end
			X[i]=true
			flag=true
			ret+=dfs(G,A,X,A[i])
			X[i]=false
		end
	end
	if !flag 1 else ret end
end
function main()
	N,M=map(x->parse(Int,x),split(readline()))
	G=zeros(Int,N,N)
	for s=readlines()
		a,b=map(x->parse(Int,x),split(s))
		G[a,b]=G[b,a]=1
	end
	println(dfs(G,collect(2:N),[false for _=2:N],1))
end
main()


Measured memory_bytes: 116284
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

 
int main() {

    int k;
    cin >> k;
    string s;
    cin >> s;

    if(s.size()<=k) cout<<s<<endl;
    else {
        rep(i,k) {
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }


    
 return 0;
}

Measured memory_bytes: 3628
x, y = list(map(int, input().split(" ")))

group_list = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]

for i in range(3):
    if x in group_list[i]:
        if y in group_list[i]:
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 3060
import numpy as np

N, D = map(int, input().split())

x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

ans = 0
for i in range(N):
    if np.sqrt(x[i]**2 + y[i]**2) <= D:
        ans += 1

print(ans)


Measured memory_bytes: 42492
#include "bits/stdc++.h"
using namespace std;

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

// 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
#endif

bool isprime(int  n) {
	if (n < 2) return false;
	else if (n == 2) return true;
	else if (n % 2 == 0) return false;
	else
		for (int i = 3; i * i <= n; i++)
			if (n % i == 0) return false;

	return true;
}

signed main() {

	int N;
	cin >> N;

	if (isprime(N)) { cout << N - 1 << endl; return 0; }

	int ans = INF;
	for (int a = 1; a * a <= N; a++) {
		if (N % a == 0)
			ans = min(ans, a + (N / a) - 2);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
from collections import deque


N, K = map(int, input().split())
P = list(map(int, input().split()))

smin = deque()
smax = deque()
x = 0
r = 0
r2 = 0

for i, p in enumerate(P):
    while len(smin) > 0 and P[smin[-1]] > p:
        smin.pop()
    smin.append(i)
    if smin[0] <= i - K:
        smin.popleft()
    while len(smax) > 0 and P[smax[-1]] < p:
        smax.pop()
    smax.append(i)
    if smax[0] <= i - K:
        smax.popleft()
    if i > 0 and P[i-1] < P[i]:
        x = min(x + 1, K - 1)
    else:
        x = 0
    if i == K-1 or (i >= K and not (P[i - K] < P[smin[0]] and smax[0] == i)):
        if x != K-1:
            r += 1
        else:
            r2 = 1
print(r + 1 if r2 else r)

Measured memory_bytes: 25120
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int D = scanner.nextInt();
        int T = scanner.nextInt();
        int S = scanner.nextInt();
        if(T*S>=D){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}


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

int main(){
    int N, Y; cin >> N >> Y;

    bool flag = false;

    for(int x = 0; x <= N; ++x) {
        for(int y = 0; y <= N - x; ++y) {
            int z = N - x - y;

            if(10000 * x + 5000 * y + 1000 * z == Y) {
                cout << x << " " << y << " " << z << endl;
                flag = true;
                break;
            }
        }

        if(flag == true) {
            break;
        }

        if(x == N) {
            cout << "-1 -1 -1" << endl;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int a;
	int b;
	int c;
	int e;
	cin>>a;
	cin>>b;
	cin>>c;
	cin>>e;
	int d=a+b+c+e;
	int x=d/60;
	int y=d-60*x;
	cout<<x<<endl;
	cout<<y<<endl;

	return 0;
}

Measured memory_bytes: 1164
n, m = map(int, input().split())
edges = [tuple(map(int, input().split())) for _ in range(m)]

c = [[] for _ in range(n + 1)]

for a, b in edges:
    c[a].append(b)
    c[b].append(a)

for i in range(1, n + 1):
    print(len(c[i]))

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;

long long Pow(long long a,long long b)
{
    long long res=1ll;
    a%=mod;
    while (b)
    {
        if (b & 1)
            res = (1ll*res * a) % (1ll*mod);
        a = (1ll*a * a) % (1ll*mod);
        b >>= 1ll;
    }
    return 1ll*res%mod;
}

long long C(long long n,long long m)
{
	if (m*2>n)  m=n-m;
	
	if(m==0) return 1;	
	if(m>n-m) m=n-m;
	long long up=1,down=1;	
	for(long long i=1;i<=m;i++)
	{		
		up=(up*(n-i+1))%mod;		
		down=(down*i)%mod;	
	}	
	return up*Pow(down,mod-2)%mod;
}

signed main()
{
	long long n,a,b,aa,bb;
	cin>>n>>a>>b;
	long long k=Pow(2ll,n)-1ll;
	aa=C(n,a);
	bb=C(n,b);
	
	long long ans=((k-aa-bb)%mod+mod)%mod;
	
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double w = sc.nextDouble();
		double h = sc.nextDouble();
		double x = sc.nextDouble();
		double y = sc.nextDouble();
		System.out.println(w * h / 2);
		if(x == w / 2 && y == h / 2) {
			System.out.println(1);
		} else {
			System.out.println(0);
		}

	}

}


Measured memory_bytes: 23252
N = int(input())
R = [int(input()) for _ in range(N)]

max_profit = float('inf') * -1
min_v = R[0]
for i in range(1, len(R)):
    max_profit = max(max_profit, R[i]-min_v)
    min_v = min(min_v, R[i])

print(max_profit)


Measured memory_bytes: 13616
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int p=1e9+7,N=100005;
char s[N];
int f[N],f3[N],f4[N],f1[N],f2[N],ans,cnt;
signed main()
{
	scanf("%s",s+1);
	f[0]=1;
	for (int i=1;i<=strlen(s+1);i++)f[i]=f[i-1]*3%p;
	for (int i=1;s[i];i++)
	 if (s[i]=='A')f1[i]=f1[i-1]+1;
	 else f1[i]=f1[i-1];
	for (int i=strlen(s+1);i;i--)
	 if (s[i]=='C')f2[i]=f2[i+1]+1;
	 else f2[i]=f2[i+1]; 
	for (int i=1;s[i];i++)
	 if (s[i]=='?')f3[i]=f3[i-1]+1;
	 else f3[i]=f3[i-1];
	for (int i=strlen(s+1);i;i--)
	 if (s[i]=='?')f4[i]=f4[i+1]+1;
	 else f4[i]=f4[i+1]; 
	for (int i=1;s[i];i++)
	 if (s[i]=='?')cnt++; 	 
	for (int i=1;s[i];i++)
	 if (s[i]=='B')
	  {
	  	(ans+=f1[i-1]*f2[i+1]%p*f[cnt])%=p;
	  	if (f3[i-1])(ans+=f3[i-1]*f[cnt-1]%p*f2[i+1])%=p;
	  	if (f4[i+1])(ans+=f1[i-1]*f[cnt-1]%p*f4[i+1])%=p;
	  	if (f3[i-1]&&f4[i+1])
	  	 (ans+=f3[i-1]*f[cnt-2]%p*f4[i+1])%=p;
	  }
	for (int i=1;s[i];i++)
	 if (s[i]=='?')
	  {
	  	(ans+=f1[i-1]*f2[i+1]%p*f[cnt-1])%=p;
	  	if (f3[i-1])(ans+=f3[i-1]*f[cnt-2]%p*f2[i+1])%=p;
	  	if (f4[i+1])(ans+=f1[i-1]*f[cnt-2]%p*f4[i+1])%=p;
	  	if (f3[i-1]&&f4[i+1])
	  	 (ans+=f3[i-1]*f[cnt-3]%p*f4[i+1])%=p;
	  }	  
	printf("%lld",ans);   
} 

Measured memory_bytes: 4224
def main():
    N = int(input())
    data = []
    for i in range(N):
        s, p = input().split()
        data.append((i + 1, s, int(p)))

    sort_with_score = sorted(data, key=lambda x: x[2], reverse=True)
    sort_with_name = sorted(sort_with_score, key=lambda x: x[1])

    for place in sort_with_name:
        print(place[0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int D;
  cin >> D;
  vector<int> c(26);
  REP(i, 26) cin >> c[i];
  vector<vector<int>> s(D, vector<int>(26));
  REP(i, D) { REP(j, 26) cin >> s[i][j]; }
  ll score = 0;
  unordered_map<int, int> lastday{};
  REP(i, D) {
    ll mx = -1e15;
    ll mxi = -1;
    int t;
    cin >> t, t--;
    mx = s[i][t];
    mxi = t;
    lastday[mxi] = i + 1;
    score += mx;
    REP(j, 26) { score -= c[j] * (i + 1 - lastday[j]); }
    cout << score << endl;
  }
}

Measured memory_bytes: 3644
from sys import stdin


def input():
    return stdin.readline()[:-1]


def intput():
    return int(input())


def sinput():
    return input().split()


def intsput():
    return map(int, sinput())


n, k = intsput()

a = list(intsput())
f = list(intsput())

a.sort()
f.sort(reverse=True)
p = [a[i] * f[i] for i in range(n)]
scrap = [0] * n

start = 0
end = max(p)
target = (start + end) // 2
while start != end:
    cnt = 0
    for i in range(n):
        fix = 0
        if p[i] > target:
            fix = (p[i] - target + f[i] - 1) // f[i]
            cnt += fix
        #scrap[i] = a[i] - fix
        if cnt > k:
            start = target + 1
            target = (start + end) // 2
            break
    else:
        end = target
        target = (start + end) // 2

print(start)


Measured memory_bytes: 118912
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
const long mod = 1000000007l;
long gcd(long a, long b){return b?gcd(b,a%b):a;}
long modpow(long x, long y, long m){
	long res = 1, tmp = x;
	while(y){
		if(y&1)res = res * tmp % m;
		tmp = tmp * tmp % m;
		y >>= 1;
	}
	return res;
}
long pom(long x, long y){return modpow(x, y, mod);}
typedef struct{
	long x, y;
}cor;
bool lt(cor u, cor v){
	if(u.x < v.x)return true;
	if(u.x == v.x && u.y < v.y)return true;
	return false;
}
bool eq(cor u, cor v){
	return u.x == v.x && u.y == v.y;
}
bool gt(cor u, cor v){
	return !lt(u, v) && !eq(u, v);
}
int cmp(const void *a, const void *b){
	cor u = *(cor*)a, v = *(cor*)b;
	if(lt(u, v))return 1;
	if(eq(u, v))return 0;
	return -1;
}
int N, sz=0, cnt_zero = mod - 1;
long ans = 1;
cor A[1<<18];
int lower_bound(cor u){
	int l = -1, r = sz;
	while(r - l > 1){
		int mid = (r + l) / 2;
		if(gt(A[mid], u))l = mid;
		else r = mid;
	}
	return r;
}
int upper_bound(cor u){
	int l = -1, r = sz;
	while(r - l > 1){
		int mid = (r + l) / 2;
		if(lt(A[mid], u))r = mid;
		else l = mid;
	}
	return r;
}
cor m(long s, long t){
	cor res;
	if(s == 0){
		if(t != 0)t = 1;
	}else if(t == 0){
		s = 1;
	}else {
		long x = gcd(labs(s), labs(t));
		s /= x;
		t /= x;
		if(t < 0){
			s *= -1;
			t *= -1;
		}
	}
	res.x = s;
	res.y = t;
	return res;
}
int main(){
	scanf("%d", &N);
	for(int i=0; i<N; i++){
		long s, t;
		scanf("%ld%ld", &s, &t);
		cor tmp = m(s, t);
		if(tmp.x == 0 && tmp.y == 0){
			cnt_zero++;
		}else{
			A[sz++] = tmp;
		}
	}
	qsort(A, sz, sizeof(cor), cmp);
	int cnt = 1;
	for(int i=1; i<=sz; i++){
		if(i<sz && eq(A[i-1], A[i]))cnt++;
		else {
			cor tmp = m(A[i-1].y, -A[i-1].x);
			int l = lower_bound(tmp), r = upper_bound(tmp);
			if(l==r){
				ans *= pom(2, cnt);
				ans %= mod;
			}else{
				if(gt(A[i-1], tmp)){
					ans *= (pom(2, cnt) + pom(2, r-l) - 1);
					ans %= mod;
				}
			}
			cnt = 1;
		}
	}
	printf("%ld\n", (ans + cnt_zero) % mod);
	return 0;
}

Measured memory_bytes: 7592
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	if (n<=999) cout<<"ABC";
	else cout<<"ABD"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
int a[6],mx,mn,k;
int main(){
    mx = -1;
    mn = 1000;
    for(int i=0;i<5;i++){
        cin>>a[i];
        mx = max(mx,a[i]);
        mn = min(mn,a[i]);
    }
    cin>>k;
    if(mx-mn>k)cout<<":(\n";
    else cout<<"Yay!\n";

}


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

int main(void){
    int n,ans=0,now,old=0,c=0;
    vector<int> low;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>now;
        if(old>=now) c++;
        else{
            if(ans<c) ans=c;
            c=0;
        }
        old=now;
    }
    cout<<(c>ans?c:ans)<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
import datetime

# 入力
#N = int(input())
#S = str(input())
#N, A, B = map(int, input().split())
A, B, C = map(int, input().split())

if A + B + C >= 22 :
  print ("bust")
else :
  print ("win")


Measured memory_bytes: 3316
txt=input()
a=[]
i=0
while(i<len(txt)):
    if txt[i].isupper():
        a.append(txt[i].lower())
        i+=1
    elif txt[i].islower():
        a.append(txt[i].upper())
        i+=1
    else:
        a.append(txt[i])
        i+=1
for j in range(0,len(a),1):
    if j==len(a)-1:
        print(a[j])
    else:    
        print(a[j],end="")


Measured memory_bytes: 5716
#include <stdio.h>
#include <algorithm>
using int64u = unsigned long long;
using namespace std;
int main() {
	int64u n;
	scanf("%llu", &n);

	int nine_count = 0, last_, carry = 0;
	while (n != 0) {
		if (10 <= n) {
			nine_count++;
			carry = max((int) (n % 10 != 9), carry);
		}
		else
			last_ = n;
		n /= 10;
	}

	printf("%d\n", last_ - carry + nine_count * 9);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
char s[1005][1005];
int dp[1005][1005];
int main(){
    int h, w;
    scanf("%d%d", &h, &w);
    for(int i=1;i<=h;i++){
        scanf("%s", s[i]+1);
    }   
    dp[1][1] = 1;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(i == 1 && j == 1) continue;
            if(s[i][j] == '#') continue;
            dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
        }
    }
    printf("%d\n", dp[h][w]);
}

Measured memory_bytes: 5120
package main

import (
	"fmt"
)

func palindromePhilia(s string) int {
	var c int
	l := len(s)
	for i := 0; i < l/2; i++ {
		if s[i] != s[l-i-1] {
			c++
		}
	}
	return c
}

func main() {
	var s string
	fmt.Scan(&s)
	fmt.Println(palindromePhilia(s))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e12;
typedef complex<double> P;
typedef pair<P,int> PP;
typedef pair<P,P> L;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a)!=real(b)?real(a)<real(b):imag(a)<imag(b);
  }
}
bool cmp(PP aa,PP bb) {
  P a=aa.first,b=bb.first;
  return atan2(a.imag(),a.real())<atan2(b.imag(),b.real());
}
double cross(const P& a, const P& b) {return imag(conj(a)*b);}
double dot(const P& a, const P& b) {return real(conj(a)*b);}
double area(vector<P> p) {
  double a=0;
  for(int i=0; i<(int)p.size(); i++) a+=cross(p[i],p[(i+1)%p.size()]);
  return a/2;
}

int main() {
  int n,m;
  while(cin >> n >> m && n) {
    P a[n];
    vector<PP> g[n];
    vector<int> v[n];
    for(int i=0,x,y; i<n; i++) {
      cin >> x >> y;
      a[i]=P(x,y);
    }
    for(int i=0,x,y; i<m; i++) {
      cin >> x >> y;
      x--,y--;
      g[x].push_back(PP(a[y]-a[x],y));
      g[y].push_back(PP(a[x]-a[y],x));
    }
    for(int i=0; i<n; i++) {
      sort(g[i].begin(),g[i].end(),cmp);
      for(int j=0; j<g[i].size(); j++) v[i].push_back(g[i][j].second);
    }
    set<vector<int> > sv;
    map<int,set<P> > ma;
    int N=0;
    for(int i=0; i<n; i++) {
      for(int j=0; j<v[i].size(); j++) {
        int x=i,y=v[i][j];
        vector<int> p;
        vector<P> p2;
        while(!ma[N].count(P(min(x,y),max(x,y)))) {
          p.push_back(x);
          p2.push_back(a[x]);
          ma[N].insert(P(min(x,y),max(x,y)));
          int l=0;
          for(l=0;l<v[y].size();l++) {
            if(v[y][l]==x) break;
          }
          int yy=v[y][(l-1+v[y].size())%v[y].size()];
          x=y;
          y=yy;
        }
        sort(p.begin(),p.end());
        if(area(p2)>0&&!sv.count(p)) {
          N++;
          sv.insert(p);
        } else ma[N].clear();
      }
    }
    int d[N];
    fill(d,d+N,1<<29);
    vector<int> e[N];
    queue<int> que;
    for(int i=0; i<N; i++) {
      set<P> s=ma[i];
      bool f=0;
      for(set<P>::iterator it=s.begin(); it!=s.end(); it++) {
        bool ff=0;
        for(int j=0; j<N; j++) {
          if(i==j) continue;
          if(ma[j].count(*it)) {
            e[i].push_back(j);
            ff=1;
          }
        }
        if(!ff) f=1;
      }
      if(f) {
        d[i]=1;
        que.push(i);
      }
    }
    if(N==1) {
      d[0]=1;
      que.push(0);
    }
    while(!que.empty()) {
      int x=que.front();que.pop();
      for(int i=0; i<e[x].size(); i++) {
        int y=e[x][i];
        if(d[y]!=1<<29) continue;
        d[y]=d[x]+1;
        que.push(y);
      }
    }
    int ans=0;
    for(int i=0; i<N; i++) ans=max(ans,d[i]);
    cout << ans << endl;
    
  }
  return 0;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a==b&&b!=c)
    cout <<"Yes"<< endl;
  else if(b==c&&a!=b)
    cout <<"Yes"<< endl;
  else if(a==c&&a!=b)
    cout <<"Yes" << endl;
  else
    cout <<"No"<< endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
ll a[10010],b[10010];
int main(){
  ll n,asum=0,bsum=0;
  cin>>n;
  lol(i,n)cin>>a[i];
  lol(i,n)cin>>b[i];
  lol(i,n){
    if(a[i]<b[i]){
      asum+=(b[i]-a[i])/2;
    }
    else{
      bsum+=a[i]-b[i];
    }
  }
  if(asum>=bsum)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std ;
const int N = 1e7 + 4;
void FastInputOutput()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline ll LLD()
{
    ll ret;
    scanf("%lld", &ret);
    return ret;
}
inline int D()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
void bin( int x )
{
    if(!x)
        return;
    bin( x / 2 );
    cout << x % 2 ;
}
bool checkPrimeNumber(int n)
{
    bool flag = true;
    for(int j = 2 ; j <= n ; ++j)
    {
        if (n % j == 0)
        {
            flag = false;
            break;
        }
    }
    return flag;
}
bool cmp(string last, string first)
{
    if(last.size() < first.size())
        return 1;
    return 0;
}
int calculateDigit(int n)
{
    double temp = (double)(n);
    double a = 0.39908-(0.434294 * n);
    double b = log10( n ) ;
    double c = ( n + 0.5 ) * b ;
    double ans = c - abs( a ) ;
    return ceil(ans) ;
}
int findDigits(int n)
{
    double E = 2.71828182845904523536;
    double PI = 3.141592654;

     if (n < 0)
        return 0;
    if (n <= 1)
        return 1;

    double x = ((n * log10(n / E) +
                 log10(2.0 * PI * n) /
                 2.0));

    return floor(x) + 1;
}
ll fact(ll n){
ll ans = 1 ;
for(ll i = 1 ; i <= n ; ++i)
    ans *= i ;
return ans ;
}
int main()
{
    FastInputOutput() ;
    int x , a , b ;
    cin >> x >> a >> b ;
    int xa = abs(a - x) ;
    int xb = abs(b - x) ;
    if(xa > xb)
        cout << "B" << endl ;
    else
        cout << "A" << endl ;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Main main=new Main();
		main.run();
	}

	void run() {

		Scanner sc=new Scanner(System.in);

		int A=sc.nextInt();
		int B=sc.nextInt();

		if(A<=8 && B<=8) {
			System.out.println("Yay!");
		}else {
			System.out.println(":(");
		}


	}

}



Measured memory_bytes: 21972