akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <iostream>
#include <stack>

using namespace std;

int main(){
    int x;
    string input;
    int tmp1;
    int tmp2;
    stack<int> brain;

    while( cin >> input){
        if(input == "+"){
            tmp2 = brain.top();
            brain.pop();
            tmp1 = brain.top();
            brain.pop();
            brain.push(tmp1 + tmp2);
        }else
        if(input == "-"){
            tmp2 = brain.top();
            brain.pop();
            tmp1 = brain.top();
            brain.pop();
            brain.push(tmp1 - tmp2);
        }else
        if(input == "*"){
            tmp2 = brain.top();
            brain.pop();
            tmp1 = brain.top();
            brain.pop();
            brain.push(tmp1 * tmp2);
        }else{
            brain.push(atoi(input.c_str()));
        }

    }

    cout << brain.top() << endl;
   
    return 0;
}


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

using namespace std;

#define INF 1000007
#define MOD 998244353
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}
signed main()
{
    int N, M;
    cin >> N >> M;
    int A[N][M];
    int K[N];
    rep(i, N)
    {
        cin >> K[i];
        rep(j, K[i])
        {
            cin >> A[i][j];
        }
    }
    int ans = 0;
    rep(k, M + 1)
    {
        int count = 0;
        rep(i, N)
        {
            rep(j, K[i])
            {
                if (k == A[i][j])
                {
                    count++;
                }
            }
        }
        if (count == N)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

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

ans = 0
first = True

def get_list(x):
    l = []
    for i in range(10):
        l.append(x%2)
        x//=2
    return l

for z in range(1, 2**10):
    l = get_list(z)
    p = 0
    c = 0
    for i in range(n):
        c = 0
        for j, x in enumerate(l):
            if x == 0:
                continue
            if runs[i][j] == 1:
                c += 1
        p += points[i][c]
    if first:
        ans = p
        first = False
    else:
        ans = max(ans, p)
print(ans)


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 100010
#define inf 1e9

int main()
{

    ll a, b, mn, mx;
    cin >> a >> b;
    mn = min(a,b);
    mx = max(a,b);
    for(ll i = 0; i < mx; i++) cout << mn;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <utility>
#include <cstring>
using namespace std;

#define INF 1000

int w, h;
int barrier[2][40][40];
int cost[40][40];

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

inline bool isRegion(int x, int y){
    return x >= 0 && x < w && y >= 0 && y < h;
}

void bfs(){
    bool isChecked[40][40] = {true, false};
    queue<pair<int,int> > q;
    q.push(make_pair(0,0));
    
    while(!q.empty()){
        int x = q.front().first, y = q.front().second;
        q.pop();
        
        cost[x][y] = INF;
        if(!x && !y) cost[x][y] = 1;
        
        for(int i = 0; i < 4; i++){
            int nx = x + dx[i], ny = y + dy[i];
            
            int isV = (i+1) & 1;
            int minX = min(x, nx), minY = min(y, ny);
            if(isRegion(nx, ny) && !barrier[isV][minX][minY]){
                if(cost[nx][ny]){
                    cost[x][y] = min(cost[x][y], cost[nx][ny] + 1);
                } else if(!isChecked[nx][ny]){
                    q.push(make_pair(nx, ny));
                    isChecked[nx][ny] = true;
                }
            }
        }
    }
}

int main(int argc, const char * argv[]) {
    
    while(1){
        scanf("%d %d", &w, &h);
        if(!w && !h) break;

        memset(cost, 0, sizeof(cost));

        for(int y = 0; y < h; y++){
            for(int x = 0; x < w - 1; x++){
                scanf("%d", &barrier[0][x][y]);
            }
            if(y != h-1){
                for(int x = 0; x < w; x++){
                    scanf("%d", &barrier[1][x][y]);
                }
            }
        }
        
        bfs();
        cout << cost[w-1][h-1] << endl;
    }
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; 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 ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll a[60], p[60];

ll f(ll n, ll x) {
    if (n == 0) {
        if (x <= 0) return 0;
        return 1;
    } else if (x <= 1 + a[n-1]) {
        return f(n-1, x-1);
    } else {
        return p[n-1] + f(n-1, x - a[n-1] - 2) + 1;
    }
}

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

    a[0] = p[0] = 1;
    for (int i = 1; i <= n; i++) {
        a[i] = 2 * a[i-1] + 3;
        p[i] = 2 * p[i-1] + 1;
    }

    cout << f(n, x) << endl;
}


Measured memory_bytes: 256
s=input()
ans=0

if s[0]=="R" or s[1]=="R" or s[2]=="R":
  ans=1
if s[0]=="R" and s[1]=="R":
  ans=2

if s[1]=="R" and s[2]=="R":
  ans=2

if s[0]=="R" and s[1]=="R" and s[2]=="R":
  ans=3

print(ans)

Measured memory_bytes: 9124
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll N; cin >> N;
    vl A(N); REP(i, N) cin >> A[i];
    auto B = A;
    sort(B.begin(), B.end());
    map<ll, ll> Idx;
    REP(i, N) Idx[B[i]] = i;
    
    ll cnt = 0;
    REP(i, N){
        if(Idx[A[i]]%2 != i%2) cnt++;
    }
    cout << (cnt+1)/2 << endl;
    return 0;
}


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

int main(){

int a,b,c;
cin>>a>>b>>c;

  vector<int>d(a);

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

  
  for(int i=0;i<a;i++){
      for(int j=0;j<((b-1)/d[i]+1);j++){
 c++;
          
      }
   
          }
       cout<<c<<endl;
}     


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#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, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ERASE(v,n) v.erase(v.begin()+n);
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }

//vector< vector<int> > v (size1, vector<int>(size2) );

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

    ll H,W;
    cin>>H>>W;
    vector< vector<ll> > c (10, vector<ll>(10) );
    FOR(i,0,10)
        FOR(j,0,10)cin>>c[i][j];

    //最短経路問題
    FOR(k,0,10)
        FOR(i,0,10)
            FOR(j,0,10)
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    
    ll temp;
    ll ans=0;
    FOR(i,0,H*W){
        cin>>temp;
        if(temp!=1 && temp!=-1)ans+=c[temp][1];
    }

    cout<<ans<<endl;
    
}

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

#define int             long long int
#define ff              first
#define ss              second
#define pb              push_back

#define vi              vector <int>
#define pii             pair <int, int>

#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))

#define endl            "\n"
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl



template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}


void solve()
{
	int k;
	cin >> k;
	string s;
	cin >> s;
	int n = s.size();
	if (n <= k) cout << s << endl;
	else
	{
		string ans = "";
		loop(i, 0, k)
		{
			ans += s[i];
		}
		ans += "...";
		cout << ans << endl;
	}
	return;
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);



	int t = 1;
	//cin >> t;
	while (t--) solve();

	return 0;
}

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

int main()
{
    string cf = "CODEFESTIVAL2016";
    string s;
    int c = 0;
    cin >> s;
    rep(i, 16){
        if (s[i] != cf[i])
            c++;
    }
    cout << c << endl;
}

Measured memory_bytes: 3568
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

int main()
{
    int r;
    cin>>r;
    cout<<r*r;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a[4];
	int b[4];
	int h=0, br=0;
	while (cin >> a[0] >> a[1] >> a[2] >> a[3]){
		h = 0, br = 0;
		for (int i = 0; i < 4; i++){
			cin >> b[i];
		}
		for (int i = 0; i < 4; i++){
			if (a[i] == b[i]){
				h++;
				a[i] = -1;
				b[i] = -1;
			}
		}
		for (int i = 0; i < 4; i++){
			for (int i2 = 0; i2 < 4; i2++){
				if (a[i] == b[i2]&&b[i2]!=-1){
					br++;
				}
			}
		}
		cout << h << " " << br << endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <complex>

#define all(n) n.begin(),b.end()
#define INF (1<<10)

using namespace std;

struct P : public complex<int> {
    P(){}
    P(int x, int y) : complex<int>(x, y) {}
    static bool comp_x(const P&a, const P& b){
        if(a.real() != b.real())
            return a.real() < b.real();
        else return a.imag() < b.imag();
    }
    static bool comp_y(const P&a, const P& b){
        if(a.imag() != b.imag())
            return a.imag() < b.imag();
        else return a.real() < b.real();
    }
};

struct L : public pair<P, P> {
    L(P a, P b) : pair<P, P>(a, b){}
};

int n;

L closest_pair(vector<P>::iterator begin, vector<P>::iterator end){
    int len = end - begin;
    if(len <= 1) return L(P(), P(INF, INF));
    auto mid = begin + len / 2;
    int x = mid->real();
    auto pL = closest_pair(begin, mid), pR = closest_pair(mid, end);
    int dL = norm(pL.first - pL.second), dR = norm(pR.first - pR.second);
    auto res = dL < dR ? pL : pR;

    int range = norm(res.first - res.second);
    inplace_merge(begin, mid, end, P::comp_y);
    vector<P> b;
    for(int i = 0; i < len; i++){
        if(abs(begin[i].real() - x) >= range) continue;
        for(int j = b.size() - 1; j >= 0; j--) {
            int dx = begin[i].real() - b[j].real();
            int dy = begin[i].imag() - b[j].imag();
            if(dy >= range)
                break;
            if(dx*dx + dy*dy < range){
                range = dx*dx + dy*dy;
                res = L(begin[i], b[j]);
            }
            range = min(range, dx*dx + dy*dy);
        }
        b.push_back(begin[i]);
    }
    return res;
}

int main(){
    cin >> n;
    vector<P> a(n);
    for(int i = 0; i < n; i++){
        int x, y;
        cin >> x >> y;
        a[i] = P(x, y);
    }
    sort(a.begin(), a.end(), P::comp_x);
    auto ans = closest_pair(a.begin(), a.end());
    cout << norm(ans.first - ans.second) << endl;
}

Measured memory_bytes: 10708
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 0
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; std::cin >> N;
  std::vector<int> L(N+1);
  for (int i = 1; i <= N; ++i) std::cin >> L[i];
  std::sort(L.begin(), L.end());

  LL count = 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 (L[k] < L[i] + L[j]) {
          ++count;
#if DEBUG
          std::cout << i << " " << j << " " << k << std::endl;
          std::cout << L[i] << " " << L[j] << " " << L[k] << std::endl;
#endif
        }
      }
    }
  }
  std::cout << count << std::endl;
}


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

#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 vi vector<int>

#define ll long long
#define vl vector<ll>
#define vll vector<vl>
#define pb push_back

const int INF = 1e9;

int main() {
	string s="ACL";
	int k;
	cin >> k;
	rep(i, k) cout << s;
	cout << endl;
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define sz(v) (v).size()
#define debug(x) cerr << #x << "_=_" << x << "\n";
#define sum(n) ((n)*((n)+1)>>1)
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;

const ll MAXN = 1e5+5, MAXM=105, oo=1e15;
ll dp[MAXM][MAXN], c[MAXM], w[MAXN];
int n, W;

ll f(int i, int sum){
    if(sum<0) return -oo;
    if(i<0) return 0;
    if(~dp[i][sum]) return dp[i][sum];
    return dp[i][sum] = max(f(i-1, sum-w[i]) + c[i], f(i-1, sum));
}


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



    cin >> n >> W;
    for (int i=0; i<n; i++)
            cin >> w[i] >> c[i];

    memset(dp, -1, sizeof dp);
    cout << f(n-1, W) << "\n";

    return 0;
}

/*
1
9 3
111100000
 */

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

int main(){//0-index
    int n; cin >> n;
    vector<vector<int> > F(n,vector<int>(14));
    vector<vector<int> > P(n,vector<int>(15));
    rep(i,n){
        rep(j,10){
            cin >> F[i][j];
        }
    }
    rep(i,n){
        rep(j,11){
            cin >> P[i][j];
        }
    }
    ll ans=-INF;
    for(int bit=1;bit<(1<<10);++bit){//bitの2進数表記した時に1である桁に対応した日に自分が営業している
        vector<int> ct(n);
        rep(i,n) ct[i]=0;
        ll res=0;
        rep(i,10){//i番目の時間帯に営業しているか調べる
            if(bit & (1<<i)){//i番目の時間帯に自分の店が営業している時
                rep(j,n){
                    ct[j]+=F[j][i];//j番目の店が時間帯iに営業しているか
                }
            }
        }
        rep(i,n) res += P[i][ct[i]];
        ans = max(bit==1?res:ans,res);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("ride.in");ofstream coutt("ride.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 


signed main(){
    FASTER;
    int n,m;cin>>n>>m;
    vi a(n),pre(n);cin>>a;
    sort(all(a));
    pre=a;
    for(int i=1;i<n;i++)pre[i]+=pre[i-1];

    
    vii v(m);cin>>v;
    
    sort(all(v),[](pii a,pii b){return a.second>b.second;});
    
    int st=0,sum=pre[n-1];
    for(int i=0;i<m;i++){
        int id=upper_bound(a.begin()+st,a.end(),v[i].second)-a.begin();
        if(id!=st){
            id--;
            //st to id
            if(id-st+1>v[i].first)id=st+v[i].first-1;
            sum-=(pre[id]-pre[st]+a[st]);
            sum+=(id-st+1)*v[i].second;
            st=id+1;
        }else break;
    }
    cout<<sum;
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    vector<ll> a(n);
    ll mx=0,idx=0;
    rep(i,n){
        cin>>a[i];
        if(chmax(mx,abs(a[i]))){
            idx = i;
        }
    }
    vector<pair<ll,ll>> res;
    rep(i,n){
        if(i!=idx){
            res.push_back(make_pair(idx,i));
        }
    }
    if(a[idx]>=0){
        rep(i,n-1){
            res.push_back(make_pair(i,i+1));
        }
    }else{
        for(ll i=n-1;i>=1;i--){
            res.push_back(make_pair(i,i-1));
        }
    }
    cout << res.size() << endl;
    rep(i,res.size()){
        cout << res[i].first+1 << " " << res[i].second+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999

ll max(ll a, ll b){
	if (a>b) return a;
	else return b;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n;
	map<string, ll> mp;
	REP(i, n){
		string s;
		cin >> s;
		mp[s]++;
	}
	cin >> m;
	REP(i, m){
		string t;
		cin >> t;
		mp[t]--;
	}
	ll ans  = 0;
	for(auto m: mp){
		ans = max(ans, m.second);
	}
	cout << ans << endl;
}

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

using namespace std;
#define ll long long
#define int long long

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
	#define lcout(a) cout << a;
	#define lcoutln(a) cout << a << endl;
	#define lcerr(a) cerr << a;
	#define lcerrln(a) cerr << a << endl;
#else
	#define lcout(a) 
	#define lcoutln(a) 
	#define lcerr(a) 
	#define lcerrln(a) 
#endif

#define MOD 1000000007


bool ch(int x)
{
	int y = 0;
	int n = x;
	while (n) {
		y = y * 10 + n % 10;
		n /= 10;
	}
	return x == y;
}

signed main()
{
	int a, b;
	cin >> a >> b; 
	int res = 0;
	reps(i, a, b+1) {
		res += ch(i);
	}
	cout << res << endl;
}

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

int main(){
    int n,q; cin >> n >> q;
    vector<queue<int> > v(n);
    vector<int> ans(0);
    for(int i = 0; i < q; i++){
        int tmp; cin >> tmp;
        if (tmp == 1){
            int t; cin >> t;
            if (v[t].size()){
                ans.push_back(v[t].front());
            } else {
                continue;
            }
        } else if (tmp == 2){
            int t; cin >> t;
            if (v[t].size()){
                v[t].pop();
            } else {
                continue;
            }
        } else if (tmp == 0){
            int t,x; cin >> t >> x;
            v[t].push(x);
        }
    }
       for(int i = 0; i < ans.size(); i++){
            cout << ans[i] << endl;
        }
}


Measured memory_bytes: 4384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ASheepAndWolves solver = new ASheepAndWolves();
        solver.solve(1, in, out);
        out.close();
    }

    static class ASheepAndWolves {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            if (sc.nextInt() <= sc.nextInt()) {
                pw.println("unsafe");
            } else
                pw.println("safe");
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 32932
using System;

namespace abca146
{
    class Program
    {
        static void Main(string[] args)

        {
            string n;
            n = Console.ReadLine();
            if (n == "SUN")
                Console.WriteLine("7");
            if (n == "MON")
                Console.WriteLine("6");
            if (n == "TUE")
                Console.WriteLine("5");
            if (n == "WED")
                Console.WriteLine("4");
            if (n == "THU")
                Console.WriteLine("3");
            if (n == "FRI")
                Console.WriteLine("2");
            if (n == "SAT")
                Console.WriteLine("1");

        }
    }
}


Measured memory_bytes: 13140
import math
n = int(input())
a = [0]*n
b = [0]*n
for i in range(n):
  a[i], b[i] = list(map(int, input().split()))
a.sort()
b.sort()
ans = 0
h = int(n/2)
if n % 2 == 0:
  a_harf = a[h-1] + a[h]
  b_harf = b[h-1] + b[h]
  ans = b_harf - a_harf + 1
else:
  ans = b[h] - a[h] + 1
  
print(ans)

Measured memory_bytes: 25528
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
combinations = [0] + [c * (c - 1) // 2 for c in range(1, 1 + max(C.values()))]
_all = sum([combinations[c] for c in C.values()])
for a in A:
    print(_all - combinations[C[a]] + combinations[C[a] - 1])


Measured memory_bytes: 26780
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 5e5 + 5;
ll *v;
ll n, q;

void solve(){
    cin >> n;
    string s;
    cin >> s;
    set<ll> alpha[26];
    for(ll i = 1; i <= n; i++)
        alpha[s[i - 1] - 'a'].insert(i);
    cin >> q;
    while(q--){
        ll t; cin >> t;
        if(t == 1){
            ll x;
            char ch;
            cin >> x >> ch;
            auto prev = s[x - 1];
            alpha[prev - 'a'].erase(x);
            alpha[ch - 'a'].insert(x);
            s[x - 1] = ch;
        }else{
            ll l, r;
            cin >> l >> r;
            ll ans = 0;
            for(ll i = 0; i < 26; i++){
                ll lb = *alpha[i].lower_bound(l);
                if(lb <= n && lb >= l && lb <= r && (s[lb - 1] - 'a') == i)
                    ans++;
            }
            cout << ans << endl;
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 24368
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N;
map<int, int> m;

signed main()
{
	cin >> N;
	REP(i, N)
	{
		int a;
		cin >> a;
		if (CONTAINS_MAP(m, a))
		{
			m[a]++;
		}
		else
		{
			m[a] = 1;
		}
	}

	int ans = 0;
	for (auto it = m.begin(); it != m.end(); ++it)
	{
		int a = it->first;
		int b = it->second;

		if (a > b)
		{
			ans += b;
		}
		else
		{
			int n = b - a;
			int m = b;

			ans += MIN(n, m);
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 6272
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<iostream>
#include<algorithm>

using namespace std;
const int maxn=200000+10;
vector<int> G[maxn];
bool vis[maxn];
int n;

int bfs_node(){
    memset(vis,0,sizeof vis);
    queue<int> Q;
    int u=0;
    Q.push(1);vis[1]=1;
    for(;!Q.empty();){
        u=Q.front();
        Q.pop();
        for(auto v: G[u])if(!vis[v]){
            vis[v]=true;
            Q.push(v);
        }
    }
    return u;
}

int bfs_d(int rt){
    memset(vis,0,sizeof vis);
    queue<pair<int,int> > Q;
    Q.push(make_pair(rt,1));
    vis[rt]=1;
    int u,d;
    for(;!Q.empty();){
        u=Q.front().first;
        d=Q.front().second;
        Q.pop();
        for(auto v: G[u])if(!vis[v]){
            vis[v]=true;
            Q.push(make_pair(v,d+1));
        }
    }
    return d;
}
int main(){
    scanf("%d",&n);
    for(int i=1,u,v;i<n;++i){
        scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int hd=bfs_node();
    int de=bfs_d(hd);
    //cout<<hd<<" "<<de<<endl;
    if(de%3==2)puts("Second");
    else puts("First");
    return 0;
}

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

int main(){

    int a,b,c;
    cin >> a >>b >>c;

    if((a*100+b*10+c)%4==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;
public class Main{
	
	public static void main(String[]args) {
		PrintWriter out = new PrintWriter(System.out);
		Scanner sc=new Scanner (System.in);
		int n=sc.nextInt();
		if(n>=30)out.println("Yes");
		else out.println("No");
		out.close();
	}
}

Measured memory_bytes: 27092
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1125

#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int N, W, H, S, T;
bool field[110][110];

void init() {
  fill(&field[0][0], &field[0][0]+110*110, false);
}

int trees(int o_x, int o_y) {
  int count = 0;
  for (int i=o_x; i<o_x+S; i++) {
    for (int j=o_y; j<o_y+T; j++) {
      if (field[i][j]) {
	count++;
      }
    }
  }
  return count++;
}

int main() {
  while (scanf("%d", &N) != EOF && N) {
    init();
    scanf("%d%d", &W, &H);
    int x, y;
    for (int i=0; i<N; i++) {
      scanf("%d%d", &x, &y);
      x--; y--; // 0からにする。
      field[x][y] = true;
    }
    scanf("%d%d", &S, &T);
    int max = 0;
    for (int i=0; i+S<=W; i++) {
      for (int j=0; j+T<=H; j++) {
	int temp = trees(i, j);
	if (max < temp) {
	  max = temp;
	}
      }
    }
    printf("%d\n", max);
  }
}

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

int dp[30][30][30];
int x[30], y[30], p[30][30];
int n;
int X, Y;

void A(int B, int C, int D) {
	if (p[C][D] == 0) {
		dp[B + 1][C][D] = 1;
	}
}

int main() {
	while (true) {
		cin >> X >> Y;
		if (X == 0 && Y == 0) {
			break;
		}
		for (int i = 0; i < 30; i++) {
			for (int j = 0; j < 30; j++) {
				if (i < 10 || i >= 20 || j < 10 || j >= 20) {
					p[i][j] = 1;
				}
				else {
					p[i][j] = 0;
				}
			}
		}
		for (int i = 0; i < 30; i++) {
			for (int j = 0; j < 30; j++) {
				for (int k = 0; k < 30; k++) {
					dp[i][j][k] = 0;
				}
			}
		}
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> x[i] >> y[i];
			x[i] += 10; y[i] += 10;
		}
		dp[0][X + 10][Y + 10] = 1;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 30; j++) {
				for (int k = 0; k < 30; k++) {
					if (dp[i][j][k] == 1) {
						A(i, j - 2, k - 1);
						A(i, j - 2, k);
						A(i, j - 2, k + 1);
						A(i, j + 2, k - 1);
						A(i, j + 2, k);
						A(i, j + 2, k + 1);
						A(i, j - 1, k - 2);
						A(i, j, k - 2);
						A(i, j + 1, k - 2);
						A(i, j - 1, k + 2);
						A(i, j, k + 2);
						A(i, j + 1, k + 2);
					}
				}
			}
			for (int j = 0; j < 30; j++) {
				for (int k = 0; k < 30; k++) {
					if (abs(x[i] - j) >= 2 || abs(y[i] - k) >= 2) {
						dp[i + 1][j][k] = 0;
					}
				}
			}
		}
		bool ok = false;
		for (int i = 0; i < 30; i++) {
			for (int j = 0; j < 30; j++) {
				if (dp[n][i][j] == 1) {
					ok = true;
				}
			}
		}
		if (ok == true) { cout << "OK" << endl; }
		else { cout << "NA" << endl; }
	}
	return 0;
}

Measured memory_bytes: 1264
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

  vector<int> h;
  int htmp;
  int maxh;
  for (int i = 0; i < N; ++i) {
    cin >> htmp;
    maxh = max(maxh, htmp);
    h.push_back(htmp);
  }

  int cnt = 0;
  int h_now = 0;
  int number_of_section = 0;

  while (h_now < maxh) {
    ++h_now;

    bool flg_insection = false;
    for (int i = 0; i < N; ++i) {
      if (h[i] >= h_now) {
        if (!flg_insection) {
          ++cnt;
          flg_insection = true;
        }
      } else {
        flg_insection = false;
      }
    }
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 384
s=input()
i=1
while 1:
    if i==len(s)+1:
        print(1);exit()
    if s[i-1]!="1":
        t=i 
        ans=int(s[i-1])
        break
    i+=1
# print(t)
if int(input())<t:
    print(1);exit()
print(ans)


Measured memory_bytes: 9084
#include<stdio.h>
#include<map>
using namespace std;
#define ll long long
ll d[100010],a[100010];
map<ll,int>p;
int main()
{
    ll n,m,maxi=0;
    scanf("%lld%lld",&n,&m);
    for(ll i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    for(ll i=1;i<=n;i++)
        d[i]=d[i-1]+a[i];
    for(ll i=1;i<=n;i++)
        d[i]%=m;
    for(ll i=0;i<=n;i++)/*******如果前缀和为m的倍数，则选择方案不为C(N,2)，应考虑首项0即C(N+1,2)***********/
        p[d[i]]++;
    for(ll i=1;i<=n;i++)
    {
        if(p[d[i]]>1)
        {
            ll t=p[d[i]];
            p[d[i]]=-1;
            maxi+=t*(t-1)/2;
        }
    }
    printf("%lld\n",maxi);
    return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

const int64 mod = 1e9+7;


using Row = vector<int64>;
using Mat = vector<Row>;

vector<int64> fact, inv;

int64 mpow(int64 a, int64 b){
	if(b == 0) return 1;
	if(b %2) return a*mpow(a, b-1)%mod;
	int64 ret = mpow(a, b/2);
	return ret*ret%mod;
}

void init(){
	fact.resize(212345, 1); inv.resize(212345, 1);
	FOR(i, 1, fact.size()){
		fact[i] = fact[i-1]*i%mod;
		inv[i] = mpow(fact[i], mod-2);
	}
}

int64 comb(int64 a, int64 b){
	return fact[a]*inv[b]%mod*inv[a-b]%mod;
}

int main(void){
	int64 H, W, N;
	cin >> H >> W >> N;
	using T = tuple<int64, int64, int64>;
	vector<T> rc(N);
	vector<int64> dp(N);
	init();
	REP(i, N){
		int64 r, c;
		cin >> r >> c;
		rc[i] = T(min(r, c), r, c);
	}
	sort(all(rc));
	REP(i, N){
		int64 r1, r2, c1,c2, _;
		tie(_, r1, c1) = rc[i];
		dp[i] = comb(r1+c1-2, r1-1);
		REP(j, i){
			tie(_, r2, c2) = rc[j];
			if(r2 <= r1 && c2 <= c1){
				dp[i] = (dp[i]-dp[j]*comb(r1-r2+c1-c2, c1-c2)%mod+mod)%mod;
			}
		}
	}
	int64 res = comb(H+W-2, W-1);
	REP(i, N){
		int64 r, c, _;
		tie(_, r, c) = rc[i];
		res = (res-dp[i]*comb(H+W-r-c, H-r)%mod+mod)%mod;
	}
	cout << res << endl;
}


Measured memory_bytes: 3840
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define int long long
int n;
inline void check(int i,int j,int x,int y){
	if (x<=0) return;
	int g=__gcd(x,y);
	if (x==g) {
		printf("%lld %lld %lld\n",i,j,y/g);
		exit(0);
	}
}
main(){
	scanf("%lld",&n);
	for (int i=1;i<=3500;++i)
		for (int j=1;j<=3500;++j)
		check(i,j,4*i*j-n*j-n*i,n*i*j);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
 using namespace std ;
 int main ()
 {
     int a , b ,c;
     cin >> a >> b >>c;
    
     
      if ( a> b)
     {
         swap ( a , b ) ;
     }
     
     if (a>c)
     {
        swap (a,c);
        
     }
      if (b>c)
     {
         swap (b,c);
     }
     
     cout <<a<<" "<<b<<" "<<c<<endl;
     return 0;
     }

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){
   ll a,b,x;
   cin>>a>>b>>x;
   ll ans=b/x-a/x;
  

   if(a%x==0) ans++;
   cout<<ans;

return 0;
}


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

using namespace std;

const int MAXN = 1000000 + 10;
int r,g,b;
int a[MAXN];

int main() {
    ios_base::sync_with_stdio(0);
    cin >> r >> g >> b;
    int x = 100 * r + 10 * g + b;

    if (x%4 == 0) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }

    return 0;
}


Measured memory_bytes: 256
from collections import Counter
import sys
sys.setrecursionlimit(1000000)

def solve():
  n,p = (int(i) for i in input().split())
  ans = 1
  if n == 1:
    print(p)
    exit()
  p_dummy = p
  for i in range(2,int(p_dummy**0.5)+4):
    ct = 0
    while p_dummy%i == 0:
      ct += 1
      p_dummy //= i
      if ct >= n:
        ans *= i
        ct -= n
  

  print(ans)
  
solve()

Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

string vacant = "Vacant";
string male = "Male";
string female = "Female";

signed main() {
	int N;
	cin >> N;

	int pt1 = 0;
	int pt2 = N;
	string ans1, ans2, ans3;

	cout << 0 << endl;
	cin >> ans1;
	if (ans1 == vacant) return 0;

	ans2 = ans1;
	rep(i, 19) {
		int pt3 = (pt1 + pt2) / 2;
		cout << pt3 << endl;
		cin >> ans3;

		if (ans3 == vacant) return 0;

		if (ans1 == ans3 && (pt3 - pt1) % 2) {
			pt2 = pt3;
			ans2 = ans3;
		} else if (ans1 != ans3 && (pt3 - pt1) % 2 == 0) {
			pt2 = pt3;
			ans2 = ans3;
		} else if (ans2 == ans3 && (pt2 - pt3) % 2) {
			pt1 = pt3;
			ans1 = ans3;
		} else if (ans2 != ans3 && (pt2 - pt3) % 2 == 0) {
			pt1 = pt3;
			ans1 = ans3;
		}
	}

    return 0;
}


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

int main()
{
        int n, i, j, l=0;
	long m = -1000000000, k = 0;
	int a[200000];
	cin >> n;
	for (i = 0;i < n;i++){
	    cin >> a[i];
	    }
       
	l=a[0];
	for (i=1;i<n;i++){
	  k = a[i]-l;
	  if (m<k){
	    m=k;
	  }
	  if (a[i]<l){
	    l=a[i];
	  }
	}	

	cout << m << endl;

	return 0;
}

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

unsigned int G[100][100];
char use_v[100];

int main(void)
{
	int v, e;
	int ans;
	
	while (1){
		memset(G, -1, sizeof(G));
		memset(use_v, 0, sizeof(use_v));
		
		scanf("%d", &v);
		if (v == 0){
			break;
		}
		scanf("%d", &e);
		for (int i = 0; i < e; i++){
			int a, b, c;
			scanf("%d,%d,%d", &a, &b, &c);
			
			G[a][b] = c / 100 - 1;
			G[b][a] = c / 100 - 1;
		}
		/*
		for (int i = 0; i < v; i++){
			for (int j = 0; j < v; j++){
				printf("%d ", G[i][j]);
			}
			puts("");
		}*/
		ans = 0;
		use_v[0] = 1;
		while (1){
			int i, j;
			int min;
			int min_e;
			
			for (i = 0; i < v; i++){
				if (use_v[i] == 0){
					break;
				}
			}
			if (i == v){
				break;
			}
			
			min = 100000000;
			for (i = 0; i < v; i++){
				if (use_v[i] == 1){
					for (j = 0; j < v; j++){
						if (min > G[i][j] && use_v[j] == 0){
							min = G[i][j];
							min_e = j;
						}
					}
				}
			}
			
			use_v[min_e] = 1;
			ans += min;
		}
		
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] ans = new int[10000];
		for(int x = 1; x < 100; x++){
			for(int y = 1; y < 100; y++){
				for(int z = 1; z < 100; z++){
					if((x* x)+(y*y)+(z*z)+(x*y)+(y*z)+(x*z)-1 < 10000)
						ans[(x* x)+(y*y)+(z*z)+(x*y)+(y*z)+(x*z)-1]++;
				}
			}
		}
		for(int i = 0; i< n;i++){
			System.out.println(ans[i]);
		}
	}



}

Measured memory_bytes: 38976
#include <iostream>

using namespace std;

int main(){
    int N = 0;
    int AC = 0;
    int WA = 0;
    int TLE = 0;
    int RE = 0;

    cin >> N;
    string S[N];

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

    for(int i = 0; i < N; i++){
        if (S[i].compare("AC") == 0){
            AC++;
        }else if(S[i].compare("WA") == 0){
            WA++;
        }else if(S[i].compare("TLE") == 0){
            TLE++;
        }else if(S[i].compare("RE") == 0){
            RE++;
        }else{
            ;
        }
    }

    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;

    return 0;
    
}



Measured memory_bytes: 5576
#include <cstdio>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

int n,m;
char a[510][510],ans1[510][510],ans2[510][510];;

int main()
{
    scanf("%d%d",&n,&m);
    repu(i,1,n)
        scanf("%s",a[i]+1);
    repu(i,1,n)
    {
        ans1[i][1]=ans2[i][m]='#',ans1[i][m]=ans2[i][1]='.';
        repu(j,2,m-1)
        {
            ans1[i][j]=(i&1) || a[i][j]=='#'?'#':'.';
            ans2[i][j]=!(i&1) || a[i][j]=='#'?'#':'.';
        }
        printf("%s\n",ans1[i]+1);
    }
    puts("");
    repu(i,1,n)
        printf("%s\n",ans2[i]+1);
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
string a;
int l;
int main()
{
	cin>>a;
	l=a.size();
	for(int i=0; i<l; i++)
	{
		if(a[i]=='C')
			for(int j=i+1; j<l; j++)
				if(a[j]=='F')
				{

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
	int a, b;
	char op;
	cin >> a >> op >> b;
	cout << (op == '+' ? a + b : a - b);
	return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/keyence2019/tasks/keyence2019_c
//C - Exam and Wizard
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,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 (b<a) { a=b; return 1; } return 0;}
int main() {
    ll N; cin>>N;
    vector<ll> an(N);
    vector<ll> bn(N);    
    for(auto&& a:an){
        cin>>a;
    }
    for(auto&& b:bn){
        cin>>b;
    }
    ll ans=0;
    ll sub=0;
    vector<ll> rn(N);
    REP(i,N){
        auto a=an.at(i);
        auto b=bn.at(i);
        if(a<b){
            ++ans;
            sub += (b-a);
        }else{
            rn.at(i)=a-b;
        }
    }
    sort(rn.begin(),rn.end(),greater<ll>());
    REP(i,N){
        if(sub>0){
            sub -= rn.at(i);
            ++ans;
        }
    }
    if (sub>0) cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a,b,c,sum=0;
	vector<int>v(3);
	for(int i=0;i<3;i++){
		cin>>v.at(i);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<2;i++){
		sum+=v.at(i);
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    l, r = map(int, input().split())
    ans = 2019
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            ans = min(ans, i * j % 2019)
            if ans == 0:
                break
        if ans == 0:
            break
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9036
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  int N; cin>>N;
  vector<double> xs(N);
  vector<string> us(N);
  double sum = 0;
  for(int i=0; i<N; i++) {
    cin>>xs[i]>>us[i];
    if(us[i] == "JPY") {
      sum += xs[i];
    } else {
      sum += xs[i] * 380000.0;
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 256