akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

string s,t;

int main(){
    cin >> s >> t;
    s += s;
    rep(i,s.size()/2){
        bool f = true;
        rep(j,t.size()){
            if(s[i+j] != t[j])f = false;
        }
        if(f){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

result = A
while True:
    result = list(set(result))
    result.sort()
    if min(result) == 0:
        result.remove(0)
    tmp_min = min(result)
    #print(result)
    if len(result) == 1:
        break
    result =[r % tmp_min for r in result[1:]]
    #print(result)
    if max(result) == 0:
        result.append(tmp_min)
        break
    result.append(tmp_min)
    #print(result)

print(max(result))


Measured memory_bytes: 14224
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int c[VMAX+1];
int i, j, n;

void CountingSort(int a[], int b[])
{
	for(i = 0; i <= VMAX; i++)
	{
		c[i] = 0;
	}
	
	for(j = 1; j <= n; j++)
	{
		c[a[j]]++;
	}
	
	for(i = 1; i <= VMAX; i++)
	{
		c[i] = c[i] + c[i-1];
	}
	
	for(j = n; j >= 1; j--)
	{
		b[c[a[j]]] = a[j];
		c[a[j]]--;
	}
}

int main(void)
{
	scanf("%d", &n);
	
	int a[n];
	int b[MAX];
	
	for(i = 0; i < n; i++)
	{
		scanf("%d", &a[i+1]);
	}
	
	CountingSort(a, b);
	
	for(i = 1; i <= n; i++)
	{
		if(i > 1) printf(" ");
		printf("%d", b[i]);
	}
	printf("\n");
	
	return 0;
}
	


Measured memory_bytes: 17404
//{{{
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

using PII = pair<int, int>;
using TI3 = tuple<int, int, int>;
using LL = long long;
using ULL = unsigned long long;
using MAT = array<array<LL, 2>, 2>;

template<class T> constexpr inline T begin(const T&) {return 0;}
template<class T> constexpr inline T end(const T& x) {return max(T(0), x);}

#define SZ(x) int((x).size())
#define PB push_back
#define EB emplace_back
#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define CHECK(a,b) static_assert(std::is_same<decltype(a), decltype(b)>::value, "REP diff types");

#define REPPP(i,s,c,t) for(i; ((s) and (c)) or (putchar("\n "[c]) and (c)); (t))
#define REPP2(i,n) REPPP(auto i=begin(n),i==begin(n),i!=end(n),++i)
#define REPP3(i,m,n) CHECK(m,n) REPPP(auto i=(m),i==(m),i<(n),++i)
#define REPP4(i,m,n,s) CHECK(m,n) REPPP(auto i=(m),i==(m),((s)>0 and i<(n)) or ((s)<0 and i>(n)),i+=(s))
#define REPP(...) GET_MACRO(__VA_ARGS__, REPP4, REPP3, REPP2)(__VA_ARGS__)

#define REP2(i,n) for(auto i=begin(n);i!=end(n);++i)
#define REP3(i,m,n) CHECK(m,n) for(auto i=(m);i<(n);++i)
#define REP4(i,m,n,s) CHECK(m,n) for(auto i=(m);((s)>0 and i<(n)) or ((s)<0 and i>(n));i+=(s))
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)

template<class T> void _read(T &x) {cin >> x;}
void _read(size_t &x) {scanf("%zu", &x);}
void _read(int &x) {scanf("%d", &x);}
void _read(LL &x) {scanf("%lld", &x);}
void _read(ULL &x) {scanf("%llu", &x);}
void _read(double &x) {scanf("%lf", &x);}
void _read(char &x) {scanf(" %c", &x);}
void _read(char *x) {scanf("%s", x);}
void read() {}
template<class T, class... U>
void read(T& head, U&... tail) {
    _read(head);
    read(tail...);
}

template<class T> void _print(const T &x) {cout << x;}
void _print(const size_t &x) {printf("%zu", x);}
void _print(const int &x) {printf("%d", x);}
void _print(const LL &x) {printf("%lld", x);}
void _print(const ULL &x) {printf("%llu", x);}
void _print(const double &x) {printf("%.16lf", x);}
void _print(const char &x) {putchar(x);}
void _print(const char *x) {printf("%s", x);}
void _print(const string &x) {printf("%s", x.c_str());}
template<class T> void _print(const vector<T> &x) {
    for(auto i = x.begin(); i != x.end(); _print(*i++)) {
        if (i != x.cbegin()) putchar(' ');
    }
}
void print() {putchar('\n');}
template<class T, class... U> void print(const T& head, const U&... tail) {
    _print(head);
    if(sizeof...(tail)) putchar(' ');
    print(tail...);
}

//}}}
const int MOD = 1000000007;

#define LLINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f

#define MAX_N 300005

int main()
{
    map<int, int> s = {{1, 300000}, {2, 200000}, {3, 100000}};
    int X, Y;
    read(X, Y);
    int ans = s[X] + s[Y];
    if(X == 1 and Y == 1) {
        ans += 400000;
    }
    print(ans);
    return 0;
}


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

map<string, int> Map;
vector<pair<int, string>> res;

int main()
{
    int n;
    cin >> n;
    string str;
    for (int i = 1; i <= n; i++) {
        cin >> str;
        Map[str]++;
    }

    for (auto it : Map)
        res.push_back(make_pair(it.second, it.first));
    sort(res.begin(), res.end());

    for (auto it : res)
        if (it.first == res.back().first)
            cout << it.second << '\n';
    return 0;
}

Measured memory_bytes: 29424
#include <stdio.h>
int main(){
  int n,i,j,flag=1,a[100],swap,c=0;

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

  while(flag){
    flag = 0;
    for(j = n-1; j > 0; j--){ 
	if(a[j] < a[j-1]){
	  
	  swap = a[j-1];
	  a[j-1] = a[j];
	  a[j] = swap;
	  c++;
	  flag = 1;
	}
      }

      
    }
    for( j = 0; j < n-1; j++){
      printf("%d ",a[j]);
    }
    printf("%d\n%d\n",a[n-1],c);
    
    return 0;
}

  

Measured memory_bytes: 600
/*************************************************************************
    > File Name: f.cpp
    > Author: Amano Sei
    > Mail: amano_sei@outlook.com 
    > Created Time: 2019年12月22日 星期日 22时47分59秒
 ************************************************************************/

#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

const int maxn = 100005;

vector<int> edge[maxn];
int n;

int sp[maxn];
bool book[maxn];
int ans;

void dfs(int u, int cf, int cr, int dep){
    if(cr == 1){
        if(dep > sp[u])
            return;
        ans = max(sp[u], ans);
    }else
        sp[u] = dep;
    for(size_t i = 0; i < edge[u].size(); i++){
        register int cv = edge[u][i];
        if(cv != cf)
            dfs(cv, u, cr, dep+1);
    }
}

int main(){
    int cu, cv, u, v;
    scanf("%d%d%d", &n, &u, &v);
    for(int i = 0; i < n-1; i++){
        scanf("%d%d", &cu, &cv);
        edge[cu].push_back(cv);
        edge[cv].push_back(cu);
    }
    if(edge[u].size() == 1 && edge[u][0] == v){
        puts("0");
        return 0;
    }
    dfs(v, 0, 0, 0);
    dfs(u, 0, 1, 0);
    printf("%d\n", ans-1);
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << 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;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int N;
  cin >> N;
  vector<ll> a(N);
  cin >> a;
  map<ll, int> m;
  for (int i = 0; i < N; i++) { m[a[i]]++; }
  vector<ll> b;
  for (auto p : m) {
    for (int j = 0; j < p.second / 2; j++) b.push_back(p.first);
  }
  sort(all(b), [](ll x, ll y) { return x > y; });
  while (b.size() > 2) b.pop_back();
  if (b.size() < 2)
    cout << 0 << endl;
  else {
    assert(b.size() == 2);
    cout << b[0] * b[1] << endl;
  }
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 7296
#include<cstdio>
#include<iostream>
#include<vector>
#define Maxn 100010 
using namespace std;
int n,a,b,c,q,k,xx,yy;
vector<pair<int,int> > tree[Maxn];
long long depth[Maxn];
void dfs(int x,int y)
{
    for (int i = 0; i < tree[x].size(); i++)
    {
        if(tree[x][i].first  == y)
            continue;
        depth[tree[x][i].first] = depth[x] + tree[x][i].second;
        dfs(tree[x][i].first,x); 
    }
}
int main()
{
    cin>>n;
    for (int i = 0; i < n - 1; i++)
    {
        cin>>a>>b>>c;
        tree[a].push_back(make_pair(b,c));
        tree[b].push_back(make_pair(a,c));
    }

    // for (int i = 0; i < tree[0].size(); i++)
    //     cout<<tree[0][i].first<<" "<<tree[0][i].second<<endl;

    cin>>q>>k;
    dfs(k,-1);
    for (int i = 0; i < q; i++)
    {
        cin>>xx>>yy;
        cout<<depth[xx]+depth[yy]<<endl;
    }
    return 0;
}

Measured memory_bytes: 15616
import math 

INF = 10**9 + 7
n,m = map(int, input().split())
ans = 0
n,m = max(n,m),min(m,n)
a = math.factorial(n)%INF
b = math.factorial(m)%INF
ans = a*b
if n==m:
    ans = ans*2
    ans = ans%INF
elif n ==m+1:
    ans = ans%INF
else:
    ans = 0
print(ans)

Measured memory_bytes: 47324
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main()
{
    string S;
    ll K;
    cin >> S >> K;
    ll count = 0;
    while(S[count] == '1')
    {
        count++;
    }
    if(count >= K)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << S[count] << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
int main()
{
	set<int> cpp;
	int q, com, o;
	cin >> q;
	bool x = true;
	while (q--)
	{
		cin >> com >> o;
		if (com)  cout << cpp.count(o) << endl;	
		else
		{
			cpp.insert(o);
			cout << cpp.size() << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 12464
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <iomanip>

#define INF 10000000000

using namespace std;

int n, k, x;

long long tab[3010];
long long dp[3010][3010];

void s(int a, int b){
    if(dp[a][b] == INF){
        if(a == b){
            dp[a][b] = tab[a];
        }
        else{
            s(a + 1, b);
            s(a, b - 1);
            dp[a][b] = max(tab[a] - dp[a + 1][b], tab[b] - dp[a][b - 1]);
            
        }
    }
    //return dp[a][b]
}
int main(){

    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    cin >> n;
    
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            dp[i][j] = INF;
        }
    }
    for(int i = 0; i < n; i++){
        cin >> tab[i];
    }
    
    s(0, n - 1);
    cout << dp[0][n - 1];
}



Measured memory_bytes: 71040
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <cmath>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007
const long long INF = 1LL<<60;


int main(){	
	int N,L;
	cin >> N >> L;
	vector<string> iroha(N);
	for(int i = 0; i < N; i++){
		cin >> iroha[i];
	}
	sort(iroha.begin(),iroha.end());
	string ans;
	for(int i = 0; i < N; i++){
		ans += iroha[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, a, b;
	cin >> n;
	if (n == 1) cout << "Hello World\n";
	else {
		cin >> a >> b;
		cout << a + b << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
def main():
    atgc = ["A", "T", "G", "C"]
    mod = 10 ** 9 + 7
    n = int(input())

    dp = [[[[0 for i3 in range(4)] for i2 in range(4)] for i1 in range(4)] for i0 in range(n)]

    for i in range(4):
        for j in range(4):
            for k in range(4):
                dp[0][i][j][k] = 1
    dp[0][0][2][3] = 0
    dp[0][0][3][2] = 0
    dp[0][2][0][3] = 0

    for t in range(n-3):
        for i in range(4):
            for j in range(4):
                for k in range(4):
                    dp[t+1][i][j][k] = dp[t][0][i][j] + dp[t][1][i][j] + dp[t][2][i][j] + dp[t][3][i][j]

        for i in range(4):
            dp[t+1][i][2][3] -= dp[t][0][i][2]
        for i in range(4):
            dp[t+1][2][i][3] -= dp[t][0][2][i]
        #AGG→GGC
        dp[t + 1][2][2][3] += dp[t][0][2][2]


        dp[t+1][0][2][3] = 0
        dp[t+1][0][3][2] = 0
        dp[t+1][2][0][3] = 0

    ans = 0
    for i in range(4):
        for j in range(4):
            for k in range(4):
                ans += dp[n-3][i][j][k]
    print(ans%mod)
main()



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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    //good luck kittu!
    ll a, ans = 1;
    string b;
    cin>>a>>b;

    int n = b.size();
    ll x = stoi(b), y = (b[n-2]-'0')*10 + (b[n-1]-'0');
    ans = a*x + (a*y)/100;
    cout<<ans<<"\n";
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int A, B;
    cin >> A >> B;

    if (A > B) swap(A, B);
    int ans = 1;
    if (A == 1 && B == 2) ans = 3;
    if (A == 1 && B == 3) ans = 2;
    if (A == 2) ans = 1;

    cout << ans << endl;
}

Measured memory_bytes: 256
A, B, C, D = gets.split.map(&:to_i)

lcm = C.lcm(D)
A_in = ((A-1) / C) + ((A-1) / D) - ((A-1) / lcm)
B_in = (B / C) + (B / D) - (B / lcm)

puts (B - A) + 1 - (B_in - A_in)


Measured memory_bytes: 1788
N, M = map(int, input().split())
a = [0] * (N + 1)
for i in range(M):
  a[int(input())] = 1
dp = [0] * (N + 1)
dp[0] = 1
for i in range(N - 1):
  if a[i + 1] == 0:
    dp[i + 1] += dp[i]
  if a[i + 2] == 0:
    dp[i + 2] += dp[i]
print((dp[N] + dp[N - 1]) % (10 ** 9 + 7))

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

void solve() {

}

int main() {
  int n,r;
  cin >> n >> r;
  if( n >= 10 ) {
    cout << r << endl;
  } else {
    int K = 100 * ( 10 - n );
    cout << r + K << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
def is_palindrome(s):
    #print(s)
    s1=s[::-1]
    return s == s1

s=list(input())

if is_palindrome(s) and is_palindrome(s[:(len(s)-1)//2]) and is_palindrome(s[(len(s)+3)//2-1:]):
    r = "Yes"
else:
    r = "No"

print(r)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; ++i)
#define REPR(i,n) for(int i = n; i >= 0; --i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = b-1;i >= a;--i)
#define p(s) cout << (s) << endl
#define p2(s,t) cout << (s) << " " << (t) << endl 
#define ALL(v) (v).begin(), (v).end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

static const ll MOD  = 1e9 + 7;
static const ll INF  = 1e18;

static const int White = 0;
static const int Gray = 1;
static const int Black = 2;

void pvector(vector<int> A){
    cout << "[vector]";
    for(int i = 0; i < A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

static const int MAXS = 100001;
static const int MAXN = 2010;

//完全一致する部分列を見つければ良い

int main(){
    int N, M;
    cin >> N >> M;
    vector<ll> S(N), T(M);
    ll dp[MAXN][MAXN] = {0}, sdp[MAXN][MAXN] = {0};
    //dp[i][j]:=Sのi文字目とTのj文字目が同じ時のその文字を含む部分文字列の数(違うときは0)
    //sdp[i][j]:= sum(0<=x<i,0<=y<j)dp[x][y]
    REP(i,N){
        cin >> S[i];
    }
    REP(i,M){
        cin >> T[i];
    }
    dp[0][0] = 1, sdp[1][1] = 1;
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= M; j++){
            if(i == 0 && j == 0) continue;
            if(i-1 >= 0 && j - 1 >= 0 && S[i-1] == T[j-1]) dp[i][j] = sdp[i][j];
            sdp[i+1][j+1] = ((sdp[i+1][j] + (sdp[i][j+1] - sdp[i][j]) % MOD )% MOD + dp[i][j] % MOD ) % MOD;
            if(sdp[i+1][j+1] < 0) sdp[i+1][j+1] += MOD;
        }
    }
    cout << sdp[N+1][M+1] << endl;
}


Measured memory_bytes: 63488
#include<bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for(int i = (l); i < (r); ++i)
#define debug(n) cerr << #n << ':' << n << endl;
using ll = long long;
template<class T,class U>using umap = unordered_map<T,U>;
template<class T>using uset = unordered_set<T>;
template<class T>using max_heap = priority_queue<T>;
template<class T>using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<class T>inline bool Chmax(T&a, const T&b){
  if(b > a){    a = b;    return true;  }
  return false;
}
template<class T>inline bool Chmin(T&a, const T&b){
  if(a > b){    a = b;    return true;  }
  return false;
}
bool IsPrime(ll x){
  if(x == 1)return false;
  if(x==2)return true;
  if(x%2==0)return false;
  for(ll i = 3; i*i <= x; i += 2){
    if(x%i==0) return false;
  }
  return true;
}
int main(){
  ios::sync_with_stdio(false);  
  cin.tie(0);
  ll a,b; cin >> a >> b;
  if(a > b)swap(a,b);
  vector<ll> c;
  for(ll i = 1; i*i <= a; ++i){
    if(a%i == 0){
      c.push_back(i);
      if(i*i != a)c.push_back(a/i);
    }
  }
  ll p=0;
  ll size = c.size();
  for(ll i = 0; i < size; ++i){
    ll e = c[i];
    if(b%e==0){
      if(IsPrime(e)){
	p++;
      }
    }
  }
  cout << p+1 << endl;
  return 0;
}


Measured memory_bytes: 384
from bisect import bisect_left,bisect_right
# 自分より小さい数字がk個未満のうち最大の値を求める
# 自分より小さい数字がk個未満ならTrue
def func(mn,zn,pn,am,ap,x):
    cnt=0
    if x>0:
        cnt+=mn*pn
        cnt+=(zn*(n-1+n-zn))//2
        cnt1=0
        for y in ap:
            cnt1+=bisect_left(ap,(x+y-1)//y)
            if y**2<x:cnt1-=1
        for y in am:
            cnt1+=bisect_left(am,(x+y-1)//y)
            if y**2<x:cnt1-=1
        cnt+=cnt1//2
    elif x<0:
        x=abs(x)
        for y in ap:
            cnt+=mn-bisect_right(am,x//y)
    elif x==0:
        cnt+=mn*pn
    return cnt<k
def main(n,k,a):
    a.sort()
    # 0未満の個数
    mn=bisect_left(a,0)
    # 0の個数
    zn=bisect_right(a,0)-mn
    # 0より大きい個数
    pn=n-mn-zn
    am=a[:mn]
    am=[-x for x in am[::-1]]
    ap=a[mn+zn:]
    if k<=mn*pn:# 答えは負になる
        l,r=a[0]*a[-1]-1,0
    elif k<=mn*pn+zn*(n-zn)+(zn*(zn-1))//2:#答えはゼロになる
        print(0)
        exit()
    else:# 答えは正
        l,r=0,max(a[0]*a[1],a[-1]*a[-2])+1
    while r-l>1:
        x=(l+r)//2
        if func(mn,zn,pn,am,ap,x):
            l,r=x,r
        else:
            l,r=l,x
    print(l)

    """
    b=[]
    for i in range(n-1):
        for j in range(i+1,n):
            b.append(a[i]*a[j])
    b.sort()
    print(b[k-1])
    """
if __name__=='__main__':
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    main(n,k,a)


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

int main() {
  
  int n, r;
  cin >> n >> r;
  
  if (n >= 10) {
    cout << r << endl;
  }
  else {
    int adjust = 100 * (10 - n) ;
    cout << r + adjust << endl;
  }
}

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

int main() {
  int X, Y;
  cin >> X >> Y;
  // a + b = x
  // 2a + 4b = y;
  for (int a = 0; a <= 1000; ++a) {
    for (int b = 0; b <= 1000; ++b) {
      if (a + b == X && a * 2 + b * 4 == Y) {
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<math.h>
#include <stdlib.h>

int main() {
	int N,o;
	o = scanf("%d",&N);
	int x[N],y[N],t[N];
	x[0] = 0; y[0] = 0; t[0] = 0;
	int num = 1;
	for (int mawasu= 0 ; mawasu < N; mawasu++){
		o = scanf("%d %d %d",&t[num],&x[num],&y[num]);
		num++;
  	}
  	int Kotae = 0;
  	for(int ma = 1; ma <= N; ma++){
  		int k = 0, ti = 0;
  		ti = t[ma] - t[ma-1];
  		k  = abs((x[ma]+y[ma]) - (x[ma-1]+y[ma-1]));
  		if(ti < k || ti%2 != k%2){
  			Kotae = -1;
  			break;
  			}  		
  	}  	
  if(Kotae== 0){
  	printf("Yes");
  }else{
  	printf("No");
  }
return 0;
}

Measured memory_bytes: 1280
import numpy as np
from functools import reduce


mod = 10**9+7
def cmb(R,B):
    numerator = reduce(lambda x,y: x * y % mod, [R+B-k for k in range(B)])
    denominator = reduce(lambda x, y: x * y % mod, [B-k for k in range(B)])
    return numerator * pow(denominator, mod - 2, mod) % mod


S = int(input())
p = S // 3
A = 0

for b in range(p):

    r = S-3*(b+1)

    if b == 0:
        A+=1
    else:
        A+=cmb(r,b)

print(A%mod)





Measured memory_bytes: 26676
#include<cstdio>
#define M 2197152
#define N 22
int d[M],e[M],f[M][N],g[M],h[M],i,j,m,n;char c[M];
int main()
{
    for(scanf("%d%d",&n,&m),i=2,j=1<<n+1;i<j;i++)d[i]=i&1?d[i>>1]+1:0,e[i]=i&1?0:e[i>>1]+1,h[i]=h[i>>1]+1;
    for(i=1;i<=1<<n;i<<=1)for(scanf("%s",c),e[i]=n,j=0;j<i;j++)f[i|j][0]=c[j]^48;
    for(i=1<<n+1;--i;)for(j=0;j<=h[i];j++)f[i&(1<<j)-1|i>>d[i>>j]&-(1<<j)][j+1]+=f[i][j],f[i&(1<<j)-1|i>>e[i>>j]&-(1<<j)][j+1]+=f[i][j],g[i&(1<<j)-1|1<<j]+=f[i][j];
    for(i=1,n=1<<n+1,j=0;i<n;i++)if(m<=g[i]&&h[j]<h[i])j=i;
    for(i=h[j];i--;i)putchar(j>>i&1^48);
    return 0*puts("");
}

Measured memory_bytes: 218368
#include<cstdio>
#include<iostream>
using namespace std;
#define MAX 100000
#define SENTINEL 2000000000
struct H{char suit; int value;};
struct H L[MAX/2+2],R[MAX/2+2];
void merge(struct H A[],int n,int left,int mid,int right)
{
    int i,j,k;
    int n1=mid-left;
    int n2=right-mid;
    for(i=0;i<n1;i++) L[i]=A[left+i];
    for(i=0;i<n2;i++) R[i]=A[mid+i];
    L[n1].value=R[n2].value=SENTINEL;
    i=j=0;
    for(k=left;k<right;k++)
    {
        if(L[i].value<=R[j].value)
            A[k]=L[i++];
        else A[k]=R[j++];
    }
}
void me(struct H A[],int n,int left,int right)
{
    int mid;
    if(left+1<right)
    {
        mid=(left+right)/2;
        me(A,n,left,mid);
        me(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}
int part(struct H A[],int n,int p,int r)
{
    int i,j;
    struct H t,x;
    x=A[r];
    i=p-1;
    for(j=p;j<r;j++)
    {
        if(A[j].value<=x.value)
        {
            i++;
            swap(A[i],A[j]);
        }
    }
    swap(A[i+1],A[r]);
    return i+1;
}
void quick(struct H A[],int n,int p,int r)
{
    int q;
    if(p<r)
    {
        q=part(A,n,p,r);
        quick(A,n,p,q-1);
        quick(A,n,q+1,r);
    }
}
int main()
{
    int n,i,v;
    struct H A[MAX],B[MAX];
    char S[10];
    int stable=1;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s %d",S,&v);
        A[i].suit=B[i].suit=S[0];
        A[i].value=B[i].value=v;
    }
    me(A,n,0,n);
    quick(B,n,0,n-1);
    for(i=0;i<n;i++)if(A[i].suit!=B[i].suit) stable=0;
    if(stable==1) printf("Stable\n");
    else printf("Not stable\n");
    for(i=0;i<n;i++)
    {
        printf("%c %d\n",B[i].suit,B[i].value);
    }
    return 0;
}

Measured memory_bytes: 5468
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, x = map(int, input().split())

ans = 0
ans += n

l1, l2 = min(n - x, x), max(n - x, x)
#while True:
#    if l1 == l2:
#        ans += l1
#        break
#    else:
#        ans += (l1 * 2)
#        l1, l2 = min(l1, l2 -l1), max(l1, l2 - l1)
#while True:
#    if l2 % l1 == 0:
#        ans += (l1 * ((l2 // l1) * 2 - 1))
#        break
#    else:
#        ans += (l1 * 2)
#        l1, l2 = min(l1, l2 -l1), max(l1, l2 - l1)
while True:
    if l2 % l1 == 0:
        ans += (l1 * ((l2 // l1) * 2 - 1))
        break
    else:
        ans += (l1 * 2) * (l2 // l1)
        l1, l2 = l2 % l1, l1

print(ans)


Measured memory_bytes: 61960
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	vi a(3);
	for(int& i: a) cin>>i;
	sort(a);
	int ans=a[0]+a[1]+a[2]*10;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VVVB = vector<VVB>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
#define pb push_back
#define INF 1e15

class SegTree {
public:
	int n;
	VL nodes;
	VL lazy;
	SegTree(VL a) {
		int size = a.size();
		n = 1;
		while(n < size) n *= 2;
		nodes.resize(n * 2 - 1, 0);
		lazy.resize(n * 2 - 1, 0);
		for (int i = 0; i < size; ++i) {
			nodes[n - 1 + i] = a[i];
		}
		for (int i = n - 2; i >= 0; --i) {
			nodes[i] = nodes[i * 2 + 1] + nodes[i * 2 + 2];
		}
	}

	void eval(int k, int l, int r) {
		if(lazy[k] != 0) {
			nodes[k] += lazy[k];
			if(r - l > 1) {
				lazy[k * 2 + 1] += lazy[k] / 2;
				lazy[k * 2 + 2] += lazy[k] / 2;
			}
			lazy[k] = 0;
		}
	}

	void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) {
		if(r < 0) r = n;
		eval(k, l, r);
		if(r <= a || l >= b) return;
		if(a <= l && r <= b) {
			lazy[k] += x * (r - l); eval(k, l, r);  return;
		}
		add(a, b, x, k * 2 + 1, l, (l + r) / 2);
		add(a, b, x, k * 2 + 2, (l + r) / 2, r);
		nodes[k] = nodes[k * 2 + 1] + nodes[k * 2 + 2];
	}

	ll get(int a, int b, int k = 0, int l = 0, int r = -1) {
		if(r < 0) r = n;
		if(r <= a || l >= b) return 0;
		eval(k, l, r);
		if(a <= l && r <= b) return nodes[k];
		return get(a, b, k * 2 + 1, l, (l + r) / 2)
			+ get(a, b, k * 2 + 2, (l + r) / 2, r);
	}
};

int main(int argc, char **argv) {
	int n, q;
	cin >> n >> q;
	VL a(n, 0);
	SegTree st(a);
	VVL qu(q, VL(4));
	for (int i = 0; i < q; ++i) {
		cin >> qu[i][0];
		if(qu[i][0] == 0) {
			cin >> qu[i][1] >> qu[i][2] >> qu[i][3];
		}else {
			cin >> qu[i][1] >> qu[i][2];
		}

	}
	for (int i = 0; i < q; ++i) {
		if(qu[i][0] == 0) {
			st.add(qu[i][1] - 1, qu[i][2], qu[i][3]);
		}else {
			cout << st.get(qu[i][1] - 1, qu[i][2]) << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 14688
#include <iostream>

using namespace std;

int main() {
  long a, b, x;
  cin >> a >> b >> x;
  long da = a / x;
  long db = b / x;
  long ans = db - da;
  if (a % x == 0) {
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3160
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int N = sc.nextInt();
        long[] A = new long[N];
        for(int i=0;i<N;i++){
            A[i]=sc.nextInt();
        }
        PriorityQueue<Pair> queue = new PriorityQueue<Pair>(Comparator.comparing(Pair::getMin).reversed());
        Arrays.sort(A);
        queue.add(new Pair(A[N-1], A[N-2]));
        queue.add(new Pair(A[N-1], A[N-2]));
        ans += A[N-1];
        for(int i=N-3;i>=0;--i){
            Pair top = queue.poll();
            ans += top.getMin();
            queue.add(new Pair(top.p,A[i]));
            queue.add(new Pair(top.q,A[i]));
            // System.out.println(ans);
        }
        System.out.println(ans);
    }

    class Pair{
        long p,q;
        long min;
        Pair(long a,long b){
            p=a;q=b;
            min=Math.min(a,b);
        }
        public long getMin() {
            return min;
        }
    }

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


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

bool isKaibun(string s);

int main()
{
    string s;

    cin >> s;

    int len = s.size();

    //まずsが回文か確認
    if (!isKaibun(s))
    {
        cout << "No" << endl;
        return 0;
    }

    string s1;
    s1 = s.substr(0, (len - 1) / 2);

    string s2;
    s2 = s.substr((len + 3) / 2 - 1, len - (len + 3) / 2 + 1);

    // cout << s1 << "-temp-" << s2 << endl;

    //次にs1が回文か確認
    if (!isKaibun(s1))
    {
        cout << "No" << endl;
        return 0;
    }

    //次にs2が回文か確認
    if (!isKaibun(s2))
    {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    return 0;
}

bool isKaibun(string s)
{
    int len = s.size();

    for (int i = 0; i < (len + 1) / 2; i++)
    {
        if (s[i] != s[len - 1 - i])
        {
            return false;
        }
    }

    return true;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <fstream>
#include <cassert>
using namespace std;

//common
typedef long long i64,ll;

#define BR "\n"
#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,r) for(int i=(l);i<(int)(r);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}

template<class T> inline string toString(const vector<vector<T> >& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

string BITtoString(int bit){
    stringstream ss;
    while(bit!=0){ss<<(bit%2);bit/=2;}
    string res=ss.str();reverse(ALL(res));
    return res;
}

template<typename T,typename V> inline T pmod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

int INF=1<<28;

class Main{
public:
	
	void run(){

		while(true){
			int N;scanf("%d",&N);if(N==0)break;
			vector<int> as(N);REP(i,N)scanf("%d",&as[i]);
			vector<int> bs(N);REP(i,N)scanf("%d",&bs[i]);
			sort(ALL(as),greater<int>());sort(ALL(bs),greater<int>());

			int k=INF;
			int wc=0,nwc=0;
			REP(ai,N){
				if(as[ai]<=bs[nwc])nwc++;
				wc=(ai+1)-nwc;
				if(wc>(ai+1)/2){
					k=(ai+1);break;
				}
			}
			if(k<INF && k!=N){
				cout << k<<endl;
			}else{
				cout <<"NA"<<endl;
			}

		}

	}
};

 int main(){
	//ios::sync_with_stdio(false);
 	Main().run();
 	return 0;
 }

Measured memory_bytes: 1524
#include<iostream>
using namespace std;
int main(){
  int n;cin>>n;
  int* h=new int[n];
  for(int i=0;i<n;i++){
  	cin>>h[i];
  }
  int c=0;
  while(1){
    int k=-1;
    for(int i=0;i<n;i++){ 
      if(h[i]!=0){k=i; break;}
    }
    if(k==-1) break;
    for(int i=k;i<n;i++){ 
      if(h[i]!=0){
        h[i]--;
        if(i==n-1){
          c++;
        }
      }else{
        c++;
        break;
      }
    }
  }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 256
def solve(k):
    t = 0
    for i in range(k, N-1):
        if t < S[i]:
            t = S[i] + C[i]
        else:
            if (t - S[i]) % F[i] == 0:
                t += C[i]
            else:
                t = t + (F[i] - (t - S[i]) % F[i]) + C[i]
    return t

N = int(input())
C, S, F = [0] * (N - 1), [0] * (N - 1), [0] * (N - 1)
for i in range(N-1):
    C[i], S[i], F[i] = map(int, input().split())
res = [0] * N
for i in range(N):
    res[i] = solve(i)
print(*res, sep='\n')


Measured memory_bytes: 9236
#include <cstdio>
#include <cstdint>
#include <cctype>
#include <cassert>
#include <vector>
#include <string>
#include <map>

enum { A=1, T=2, G=4, C=8 };
constexpr intmax_t MOD=1e9+7;

std::vector<int> parse(
    const std::string &s, size_t &i,
    const std::map<std::string, size_t> &ind,
    const std::vector<std::vector<int>> &expl) {

  if (islower(s[i])) {
    std::string n(1, s[i]);
    while (++i < s.length() && islower(s[i]))
      n += s[i];
    if (i < s.length()) ++i;
    return expl[ind.at(n)];
  }
  if (s[i] == '[') {
    int res=0;
    while (s[++i] != ']') {
      if (s[i] == 'A') res |= A;
      if (s[i] == 'T') res |= T;
      if (s[i] == 'G') res |= G;
      if (s[i] == 'C') res |= C;  // :(
    }
    if (++i < s.length()) ++i;
    return {res};
  }
  __builtin_unreachable();
}

int main() {
  size_t Na, Nt, Ng, Nc;
  scanf("%zu %zu %zu %zu", &Na, &Nt, &Ng, &Nc);
  size_t Nsum=Na+Nt+Ng+Nc;

  size_t m;
  scanf("%zu", &m);

  std::vector<std::string> nont(m), prod(m);
  std::map<std::string, size_t> nind;
  for (size_t i=0; i<m; ++i) {
    char sym[32], buf[1024];
    scanf(" %[a-z]: %[^\n]", sym, buf);
    nont[i] = sym;
    prod[i] = buf;
    nind[sym] = i;
  }

  std::vector<std::vector<int>> expl(m);
  for (size_t i=m; i--;) {
    size_t j=0;
    while (j < prod[i].length()) {
      std::vector<int> res=parse(prod[i], j, nind, expl);
      expl[i].insert(expl[i].end(), res.begin(), res.end());

      if (expl[i].size() > Nsum)
        break;
    }
  }

  std::vector<int> term=std::move(expl[0]);
  if (term.size() > Nsum)
    return !printf("0\n");

  std::vector<std::vector<std::vector<intmax_t>>> dp(
      Na+1, std::vector<std::vector<intmax_t>>(
        Nt+1, std::vector<intmax_t>(Ng+1))), tmp=dp, zero=dp;

  if (term[0] & A && 1 <= Na) dp[1][0][0] = 1;
  if (term[0] & T && 1 <= Nt) dp[0][1][0] = 1;
  if (term[0] & G && 1 <= Ng) dp[0][0][1] = 1;
  if (term[0] & C) dp[0][0][0] = 1;

  for (size_t i=1; i<term.size(); ++i) {
    tmp = zero;
    for (size_t ia=0; ia<=Na; ++ia)
      for (size_t it=0; it<=Nt; ++it)
        for (size_t ig=0; ig<=Ng; ++ig) {
          if (term[i] & A && ia+1 <= Na)
            (tmp[ia+1][it][ig] += dp[ia][it][ig]) %= MOD;
          if (term[i] & T && it+1 <= Nt)
            (tmp[ia][it+1][ig] += dp[ia][it][ig]) %= MOD;
          if (term[i] & G && ig+1 <= Ng)
            (tmp[ia][it][ig+1] += dp[ia][it][ig]) %= MOD;
          if (term[i] & C)
            (tmp[ia][it][ig] += dp[ia][it][ig]) %= MOD;
        }
    dp = std::move(tmp);
  }

  printf("%jd\n", dp[Na][Nt][Ng]);
}



Measured memory_bytes: 5764
#include<iostream>
using namespace std;
typedef long long ll;
ll backet[100001];
int main() {
	ll n, k,num,roop,sum=0;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> num >> roop;
		backet[num] += roop;
	}
	for (int i = 1; i < 100001; i++) {
		sum += backet[i];
		if (sum >= k) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int n, x;
    cin >> n >> x;
    if (n == 0 && x == 0){
      break;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++){
      for (int j = i + 1; j <= n; j++){
        for (int k = j + 1; k <= n; k++){
          if (i + j + k == x){
            ans++;
          }
        }
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int INF = 10e8;
const int maxN = 300010;
const int maxM = 100010;
 
const int MOD = 1000000007;

int a[maxN];
int N;
int b1[maxN];
int b2[maxN];
int main()
{
	scanf("%d",&N);
	int n = 1<<N;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	int maxn = 0;
	for(int k=1;k<n;k++)
	{
		int a1 = a[0], a2 = 0;
		int pos = -1;
		for(int t=k; t ; t = (t-1)&k)
		{
			if(a[t] > a1)
			{
				a2 = a1;
				a1 = a[t];
			}
			else if (a[t] > a2)
			{
				a2 = a[t];
			}
		}
		b1[k] = a1+a2;
		b1[k] = max(b1[k],b1[k-1]);
		
		printf("%d\n",b1[k]);
	}
	return 0;
}  

Measured memory_bytes: 5120
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include<algorithm>

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

int main()
{
    ll N,K,res,T;
    vector <ll> A(3);
    cin >> N >> K;

    if(K == 1)res = 0;
    else
    {
        res = N - K;
    }

    cout << res << endl;

}



Measured memory_bytes: 256
'use strict';
function main(inn) {
  const input = inn.split("\n");
  const a = input[0].split(" ");
  const b = input[1].split(" ");
  let b1 = parseInt(b[0], 10);
  let b2 = parseInt(b[1], 10);
  const c = input[2];

  if (a[0] === c) {
    b1 --;
  } else {
    b2 --;
  }
  
  console.log(`${b1} ${b2}`);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,n; cin>>a>>b>>n;
    ll x;
    if (n>=b-1){
        x = b-1;
    }else{
        x = n;
    }
    cout<<a*x/b-a*(x/b)<<"\n";

    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL); \
    cout.tie(NULL)
#define inc(x, y, i) for (int i = x; i <= y; i++)
#define dec(x, y, i) for (int i = x; i >= y; i--)
#define repeat(n) for (int i = 0; i<n;i++)

#define ll long long
#define ld long double
#define ull unsigned long long
#define infl LONG_MAX
#define infi INT_MAX
#define nl cout<<'\n'

#define all(v) v.begin(),v.end()
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define mkpr make_pair
#define pq priority_queue
/*void show(auto v){
    for(auto t : v)cout << t <<" ";cout <<endl;
}

void printAr(int a[],int n)  // print the array
{
    for(int *i = a; i!=a+n; ++i)cout << *i << " ";
    cout << endl;
}*/
const int N = 3000+6;
int a[N];
vector<int> v[N];
int dp[N];
int main()
{
    fastio;

    ll a,b,c ,d;
    cin >> a >> b >> c >> d;
    ll x = a*c;
    ll y = b*d;
    ll z = a*d;
    ll w = b*c;
    cout << max(max(x,y),max(z,w))<<endl;

}


Measured memory_bytes: 3700
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int lli;
const long long int MaxN=500005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	lli arr[MaxN];
	void solve(){
		lli N,obj,i,j,p,q,res=0;
		cin>>N>>obj;
		if(N>=0&&obj>0)p=1;
		if(N>=0&&obj<=0)p=2;
		if(N<0&&obj>=0)p=3;
		if(N<0&&obj<=0)p=4;
		//cout<<p<<"\n";
		if(p==1){
			if(N<=obj)res=obj-N;
			else res=abs(obj-N)+2;
		}
		if(p==2){
			if(N<=abs(obj))res=abs(obj)-N+1;
			else res=abs(abs(obj)-N)+1;
		}
		if(p==3){
			if(abs(N)<=obj)res=obj-abs(N)+1;
			else res=abs(obj-abs(N))+1;
		}	
		if(p==4){
			if(abs(N)<abs(obj))res=abs(abs(N)-abs(obj))+2;
			else 	res=abs(abs(N)-abs(obj));
		}
		cout<<res;
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
}


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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<int, pair<int,int>> tup;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()

#define EACH(i, c) \
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define SORT(c) sort((c).begin(), (c).end())

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
const double PI = acos(-1.0);
#define CLR(a) memset((a), 0, sizeof(a))

// int tansaku[110];
// map<string,string> d;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  bool  visited[1010][1010];
  char field[1010][1010];
  queue<tup> kuwa;
  int H, W, N;
  //CLR(visited);
  REP(i,W){REP(j,H) visited[i][j]=false;}
  cin >> H >> W >> N;
  REP(j, H) {
    REP(i, W) { cin >> field[i][j]; }
  }
  tup start;
  cin.ignore();
  REP(i, W) {
    REP(j, H) {
      if (field[i][j] == 'S') {
        start = {0,{i, j}};
      }
    }
  }
  kuwa.push(start);
  int ans=0;
  int cost =0;
  char cheeze='1';
  while(!kuwa.empty()){
  	tup r = kuwa.front();kuwa.pop();
  	int haba = r.first;
  	PII p = r.second;
  	visited[p.first][p.second] = true;
  	if(field[p.first][p.second]==cheeze){
      cost += haba;
  		if(cheeze-'0' == N)break;
  		cheeze++;
  		queue<tup> daisuke;
  		swap(kuwa,daisuke);
  		kuwa.push(make_pair(0,p));
      //CLR(visited);
      REP(i,W){REP(j,H) visited[i][j]=false;}

  		continue;
  	}
  	for(int i=0 ; i<4 ;i++){
          PII new_xy = {p.first + dx[i], p.second + dy[i]};
          if(0 <= new_xy.first && new_xy.first < W &&
              0 <= new_xy.second && new_xy.second < H &&
                  !visited[new_xy.first][new_xy.second] &&
                  field[new_xy.first][new_xy.second] != 'X'){
          kuwa.push(make_pair(haba+1,new_xy));
          visited[new_xy.first][new_xy.second] = true;
          }
        }
  }
  cout << cost << endl;
  return 0;
}

Measured memory_bytes: 3192
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
count=0
for i in range(N):
  A=list(map(int, input().split()))
  p=C
  for j in range(M):
    p+=A[j]*B[j]
  if p>0:
    count+=1
print(count)

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



int main() 
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(s.size()%2!=0)
    {
        cout << "No" << endl;
    }
    else
    {
        bool ans = true;
        rep(i, s.size() / 2)
        {
            if(s[i]!=s[i+s.size()/2])
            {
                ans = false;
            }
        }

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

    return 0;
}

Measured memory_bytes: 256
a1 , b1 = map(int,input().split())
a2 , b2 = map(int,input().split())
a3 , b3 = map(int,input().split())
l = [0] * 4
l[a1-1]+=1
l[a2-1]+=1
l[a3-1]+=1
l[b1-1]+=1
l[b2-1]+=1
l[b3-1]+=1
l = sorted(l)
if l == [1,1,2,2]:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
X,Y = map(str,input().split())
def chan(S):
    if S == "A":
        s = 1
    elif S == "B":
        s = 2
    elif S == "C":
        s = 3
    elif S == "D":
        s = 4
    elif S == "E":
        s = 5
    elif S == "F":
        s = 6
    return s

x = chan(X)
y = chan(Y)
if x>y:
    print(">")
elif x<y:
    print("<")
else:
    print("=")
    

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

char S[16];
char ans[64];
int sz;

int main(){
    scanf("%s",S);
    int len=strlen(S);
    sz=0;
    REP(i,len){
        if (S[i]=='B'){
            if (sz!=0){
                ans[--sz]=0;
            }
        }else{
            ans[sz++]=S[i];
        }
    }
    printf("%s\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <chrono>
using namespace std;

#define INF 1e18
#define int long long

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

    if(k <= a) {
        cout << a - k << " " << b << endl;
        return 0;
    } else if(k <= a + b) {
        cout << 0 << " " << b - (k - a) << endl;
        return 0;
    } else {
        cout << 0 << " " << 0 << endl;
        return 0;
    }
}


Measured memory_bytes: 256