akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)


struct Problem {

	void Solve() {
		UL N; cin >> N;
		vector<pair<UL, UL>> A(N);
		rep(i, N) cin >> A[i].first;
		rep(i, N) cin >> A[i].second;
		rep(i, N) if (i % 2 == 1) swap(A[i].first, A[i].second);
		UL ans = 10000;
		const UL R = (N + 1) / 2, B = N / 2;
		for (UL i = 0; i < (1 << N); i++) {
			vector<UL> r, b;
			UL f = 0;
			rep(j, N) if (i & (1 << j)) f++;
			if (f != B) continue;
			vector<pair<UL, bool>> C;
			rep(j, N) {
				if (i & (1 << j)) C.push_back({ A[j].second, true });
				else C.push_back({ A[j].first, false });
			}
			UL ansbuf = 0;
			for (UL p = N; p > 0; p--) {
				UL d = 0, di = 0;
				bool col = !(p & 1);
				for (UL q = 0; q < p; q++) {
					if (C[q].second == col)
						if (C[q].first >= d) { di = q; d =  C[q].first; }
				}
				for (UL q = di + 1; q < p; q++) {
					swap(C[q - 1], C[q]);
					ansbuf++;
				}
				if (p != N) if (C[p - 1].first > C[p].first) ansbuf += 10000;
			}
			ans = min(ans, ansbuf);
		}
		if (ans == 10000) cout << -1 << endl;
		else cout << ans << endl;
	}

	
	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
/*================================================================
*   Copyright (C) 2019 Sangfor Ltd. All rights reserved.
*   
*   文件名称：C.cpp
*   创 建 者：YaliKiWi
*   创建日期：2019年07月20日
*   描    述：
*
================================================================*/


#include<bits/stdc++.h>
using namespace std;
#define maxn 200000+10
#define max_(x,y) ((x)>(y)?(x):(y))
int a[maxn];
int n;
int mxx;
int mii;
bool ma[maxn];
int cnt;
inline void init(){
	memset(ma,0,sizeof ma);
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(register int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]==mxx){
			cnt++;
			ma[a[i]]=1;
		}
		else if(a[i]>mxx){
			init();
			cnt=1;
			ma[a[i]]=1;
			mxx=a[i];
		}
	}
	for(register int i=1;i<=n;i++){
		if(a[i]!=mxx){
			mii=max(a[i],mii);
		}
	}
	for(register int i=1;i<=n;i++){
		if(mxx!=a[i])cout<<mxx<<endl;
		else if(cnt!=1)cout<<mxx<<endl;
		else cout<<mii<<endl;
	}
	return 0;
}

Measured memory_bytes: 2560
//https://vjudge.net/contest/349601#problem/A
/*
* Author : MaxSally
*/
/********   All Required Header Files ********/
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i <= k ; ++i)
#define rrep(i, j, k) for (int i = j; i >= k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define inf (int) (1e9 + 7)
#define epsi 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define read(type) readInt<type>()
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define left tuyiuoi
#define right fgjhk
#define ss second
#define ff first
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) rep(i, l, r) cout << a[i] << " "; cout << endl
#define Flag(n) cout << "here " << n << endl
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

const int N = 8005;
string s;

int main(){
    io;
    //freopen("input.txt", "r", stdin);
    cin >> s;
    int n = s.length();
    if(s[0] == s[n - 1]){
        if(n & 1){
            cout << "Second";
        }else{
            cout << "First";
        }
    }else{
        if((n & 1) == 0){
            cout << "Second";
        }else{
            cout << "First";
        }
    }
    return 0;
}



Measured memory_bytes: 512
n, d = map(int, input().split())
x = []
for i in range(n):
    x.append(list(map(int, input().split())))
ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        s = 0
        for k in range(d):
            s += (x[i][k] - x[j][k]) ** 2
        s **= 0.5
        if s.is_integer() == True:
            ans += 1
print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ITP1
{
    class ITP1_4_D
    {
        static void Main(string[] args)
        {
            int n;
            List<long> numberList;
            long max = 0, min = 0, sum = 0;

            //string path = @"C:\_workspace\_cs\vs_2019_AOJ\AOJ\ITP1\dataSet\ITP1_4_D_18.txt";

            //using (StreamReader file = new StreamReader(path))
            //{
            //    n = int.Parse(file.ReadLine());
            //    numberList = file.ReadLine().Split().Select(long.Parse).ToList();
            //}
            
            n = int.Parse(Console.ReadLine());
            numberList = Console.ReadLine().Split().Select(long.Parse).ToList();

            max = numberList.Max();
            min = numberList.Min();
            sum = numberList.Sum();

            Console.WriteLine($"{min} {max} {sum}");
            Console.ReadLine();
        }
    }
}



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

#define M 1000000/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char);

long long getKey(char []);

int h1(int);
  
int h2(int);

int find(char []);
 
int insert(char []);

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';

    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
      scanf("%s %s", com, str);

      if ( com[0] == 'i' ){
        insert(str);
      }
      else {
	
        if (find(str)){
          printf("yes\n");
        }
	
	else {
          printf("no\n");
        }
      }
    }

    return 0;
  }

int getChar(char ch){
  if ( ch == 'A') {
    return 1;
  }
  else if ( ch == 'C'){
    return 2;
  }
  else if ( ch == 'G') {
    return 3;
  }
  else if ( ch == 'T') {
    return 4;
  }
  return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M/* your task */; }
int h2(int key){ return 1+(key%(M-1))/* your task */; }

int find(char str[]){
  int key, i, h;
  key = getKey(str);
  for(i = 0 ; ; i++){
    h = (h1(key) + i * h2(key))%M;
    if(strcmp(H[h], str) == 0 ) return 1;
    else if(strlen(H[h]) == 0 ) return 0;
  }
  return 0;
  /* your task */
}

int insert(char str[]){
  /* your task */
  int key, i, h;
  key = getKey(str);
  for(i = 0 ; ; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0 ) return 1;
    else if(strlen(H[h]) == 0 ){
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}



Measured memory_bytes: 15428
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    set<int> S;
    for (int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        if (S.find(x) != S.end())
            S.erase(x);
        else
            S.insert(x);
    }
    cout << S.size();
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

typedef pair<int, int> P;

int main()
{
	int N, n, d, U, D, L, R;
	while (cin >> N, N) {
		U = D = L = R = 0;
		vector<P> vc(N,P(0,0));
		for (int i = 1; i < N; i++) {
			cin >> n >> d;
			switch (d) {
			case 0:
				vc[i] = P(vc[n].first - 1, vc[n].second);
				if (vc[i].first < L)
					L = vc[i].first;
				break;
			case 1:
				vc[i] = P(vc[n].first, vc[n].second + 1);
				if (vc[i].second > D)
					D = vc[i].second;
				break;
			case 2:
				vc[i] = P(vc[n].first + 1, vc[n].second);
				if (vc[i].first > R)
					R = vc[i].first;
				break;
			case 3:
				vc[i] = P(vc[n].first, vc[n].second - 1);
				if (vc[i].second < U)
					U = vc[i].second;
				break;
			}
		}
		cout << R - L + 1 << " " << D - U + 1 << endl;
	}
	return 0;
}

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

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

  if (A + B == C + D ) {
    cout << "Balanced" << endl;
  }
  else if (A + B > C + D ) {
    cout << "Left" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    string S;
    cin >> S;
    
    map<char, int> m;
    for(int i = 0; i < S.length(); i++){
        m[S[i]] = 0;
    }
    for(int i = 0; i < S.length(); i++){
        m[S[i]]++;
    }
    for(auto it = m.begin(); it != m.end(); ++it){
        if(it->second != 2){
            cout << "No\n";
            return 0;
        }
    }
    
    cout << "Yes\n";
}


Measured memory_bytes: 256
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
string s, t;
//最長共通部分列問題
//dp[i][j] si.tjに対するLCSの長さ
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s>>t;
    ll dp[s.size()+1][t.size()+1];
    int prev[s.size()+1][t.size()+1];
    for(int i=0;i<=s.size();i++){
        for(int j=0;j<=t.size();j++){
            dp[i][j]=0;
            prev[i][j]=0;
        }
    }
    for (int i = 1; i <= s.size(); i++)
    {
        for(int j=1;j<=t.size();j++){
            if(s[i-1]==t[j-1]){
                dp[i][j]=max(dp[i-1][j-1]+1,max(dp[i-1][j],dp[i][j-1]));
                if(dp[i][j]==dp[i-1][j-1]+1){
                    prev[i][j]=1;
                }
                else if(dp[i][j]==dp[i-1][j]){
                    prev[i][j]=2;
                }
                else{
                    prev[i][j]=3;
                }
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                if(dp[i][j]==dp[i-1][j]){
                    prev[i][j]=2;
                }
                else{
                    prev[i][j]=3;
                }
            }
        }
    }
    int count= dp[s.size()][t.size()];
    string ans;
    int i=s.size();
    int j=t.size();
    while(ans.size()<count){
        if(prev[i][j]==1){
            ans.push_back(s[i-1]);
            i--;
            j--;
        }
        else if(prev[i][j]==2){
            i--;
        }
        else{
            j--;
        }
    }
    reverse(ALL(ans));
    cout<<ans<<"\n";
}



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

using namespace std;


int main() {
    int size;
    string T;
    char hatena[] = "?";
    char small_t, previous;
    cin >> T;
    size = T.size();
    rep(i, size)
    {
        small_t = (char)T[i];
        if (small_t  != '?')
        {
            cout << small_t;
            // cout << "next" << endl;
            continue;
        }
        
        //cout << "next" << endl;
        if (i == size)
        {
            cout << "D";
            break;
        }
        previous = (char)T[i - 1];
        small_t = (char)T[i + 1];
        if (previous == 'P')
        {
            cout << "D";
            continue;
        }

        if (small_t == '?')
        {
            cout << "PD";
            i = i + 1;
            continue;
        }
        else
        {
            cout << "D";
            continue;
        }
        
    }
  
    cout << endl;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int X; cin >> X;
  int i = 0, sum = 0;
  while (++i) {
    sum += i;
    if (sum >= X) {
      cout << i << CRLF;
      return;
    }
  }
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			w = scanner.nextInt();
			h = scanner.nextInt();
			if ((w | h) == 0)
				break;
			map = new boolean[h][w];
			for (int i = 0; i < h; i++)
				for (int j = 0; j < w; j++)
					map[i][j] = scanner.nextInt() == 0;
			ans = 0;
			for (int i = 0; i < h; i++)
				for (int j = 0; j < w; j++) {
					if (map[i][j])
						continue;
					ans = Math.max(ans, dfs(i, j));
				}
			System.out.println(ans);
		}
	}

	private int dfs(int y, int x) {
		map[y][x] = true;
		int res = 1;
		for (int[] m : move) {
			int ny = y + m[0];
			int nx = x + m[1];
			if (!isOK(ny, nx))
				continue;
			if (map[ny][nx])
				continue;

			res = Math.max(dfs(ny, nx) + 1, res);

		}
		map[y][x] = false;
		return res;
	}

	private boolean isOK(int y, int x) {
		if (0 <= y && y < h && 0 <= x && x < w)
			return true;
		return false;
	}

	int h, w;
	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };
	boolean[][] map;
	int ans;
}

Measured memory_bytes: 36288
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
using namespace std;

int main(){
    int a;
    cin>>a;
    int ans = 0;

    while(1){
        ans++;
        if(a==4 || a==2 || a==1){
            break;
        }
        if(a%2==0){
            a = a/2;
        }
        else{
            a = 3*a+1;
        }


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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		sc.close();
		int check = A * B;
		if(check == 2) {
			System.out.println(3);
		}else if(check == 3) {
			System.out.println(2);
		}else {
			System.out.println(1);
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    A--, B--, C--, D--;
    string S;
    cin >> S;

    for (int i = B; i < D; i++) {
        if (S[i] == '#' && S[i + 1] == '#') {
            cout << "No\n";
            return 0;
        }
    }
    for (int i = A; i < C; i++) {
        if (S[i] == '#' && S[i + 1] == '#') {
            cout << "No\n";
            return 0;
        }
    }

    bool flag = true;
    if (C > D) {  // 追い越す必要があるとき
        flag = false;
        for (int i = B; i <= D; i++) {
            if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
                flag = true;
            }
        }
    }
    if (flag) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int N;
    cin>>N;
    long long sum=0;
    for(int i=1;i<=N;i++)
    {
        if(i%5!=0 && i%3!=0)
            sum+=i;
    }
    cout<<sum<<endl;

}


Measured memory_bytes: 3584
import math

N, D = map(int, input().split())
X_Y = []
for i in range(N):
    X_Y.append(list(map(int, input().split())))
    
ans = 0
for n in range(N):
  x, y = X_Y[n]
  if(math.sqrt(x**2 + y**2) <= D): ans += 1

print(ans)

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

#define ll long long

void solve(){
	int n; cin>>n;
	vector< int > v(n);
	unordered_map< int, int > m;
	for(int &i : v){
		cin>>i;
		m[i]++;
	}
	int cnt = 0;
	for(int i: v){
		int flag = 1;
		if(i == 1){
			if(m[1] == 1)	cnt++;
			continue;
		}
		if(m[i] > 1){
			continue;
		}
		for(int j = 2; j * j <= i; j++){
			if(i%j == 0 && m[j]){
				flag = 0;
			}
			if(i%j == 0){
				if(m[i / j]){
					flag = 0;
				}
			}
		}
		if(m[1]) flag = 0;

		cnt += flag;
	}
	cout<<cnt<<endl;
}

int 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: 32396
/*input
5 5
..#..
.....
#...#
.....
..#..
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb emplace_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int dp[1005][1005];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	REP(i,n){
		REP(j,m){
			char a;
			cin>>a;
			if(i==0 and j==0) dp[0][0]=1;
			else if(a=='#') dp[i][j]=0;
			else if(i==0) dp[i][j]=dp[i][j-1];
			else if(j==0) dp[i][j]=dp[i-1][j];
			else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
		}
	}
	cout<<dp[n-1][m-1];
}

Measured memory_bytes: 4224
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N (1<<20)
class RSQ{
private:
    ll dat[2*N];
    ll dfs(int l,int r,int a,int b,int k){
	if(l<=a&&b<=r)return dat[k];
	if(b<=l||r<=a)return 0;
	ll vl=dfs(l,r,a,(a+b)/2,k*2+1);
	ll vr=dfs(l,r,(a+b)/2,b,k*2+2);
	return vl+vr;
    }
public:
    void Init(){
	lol(i,2*N)dat[i]=0;
    }
    void Upd(int i,int x){
	i+=N-1,dat[i]=x;
	while(i>0){
	    i=(i-1)/2;
	    dat[i]=dat[i*2+1]+dat[i*2+2];
	}
    }
    void Add(int i,int x){
	Upd(i,Sum(i,i)+x);
    }
    int Sum(int l,int r){
	return dfs(l,r+1,0,N,0);
    }
};
ll a[N],n;
bool Solve(ll k){
    RSQ seg;seg.Init();
    ll cnt=(1<<19),ans=0;
    seg.Add(cnt,1);
    lol(i,n){
	if(a[i]<=k)cnt+=2;
	cnt--;
	ans+=seg.Sum(0,cnt-1);
	seg.Add(cnt,1);
    }
    //cout<<k<<" "<<ans<<endl;
    return (ans>=n*(n+1)/4+1);
}
int main(){
    cin>>n;lol(i,n)cin>>a[i];
    ll l=0,r=mod,mid;
    while(l<r-1){
	mid=(l+r)/2;
	if(Solve(mid))r=mid;
	else l=mid;
    }
    cout<<r<<endl;
    return 0;
}


Measured memory_bytes: 17408
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// #ifndef ONLINE_JUDGE
 //        freopen ("INPUT.txt" , "r" , stdin);
 //        // freopen ("OUTPUT.txt" , "w" , stdout);
 //    #endif

    int a=0,b=0;
    char c;
    cin>>c;
    a=(int)c-(int)'0';
    cin>>c;
    a=(a*10)+(int)c-(int)'0';
    cin>>c;
    b=(int)c-(int)'0';
    cin>>c;
    b=(b*10)+(int)c-(int)'0';
    if((a>12 || a==0) && b<=12 && b>0)
    {
    	cout<<"YYMM"<<endl;
    }
    else if((b>12 || b==0) && a<=12 && a>0)
    {
    	cout<<"MMYY"<<endl;
    }
    else if(a<=12 && b<=12 && a>0 && b>0)
    {
    	cout<<"AMBIGUOUS"<<endl;
    }
    else
    {
    	cout<<"NA"<<endl;
    }

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483648
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

int main() {
	int n; cin >> n;
	vi t(n), a(n);
	Loop(i, n) cin >> t[i];
	Loop(i, n) cin >> a[i];
	vector<P> data(n);
	data[0] = { t[0],1 }; //1なら確定
	ll ans = 1;
	Loop1(i, n - 1) {
		if (t[i] > t[i - 1]) data[i] = { t[i],1 };
		else data[i] = { t[i], 0 };
	}
	if (a[n - 1] > t[n - 1]) ans = 0;
	if (data[n - 1].second == 1 && a[n - 1] != t[n - 1]) ans = 0;
	data[n - 1] = { a[n - 1],1 };
	if (ans != 0) {
		Loopr(i, n - 1) {
			if (a[i] > a[i + 1]) data[i] = { a[i],1 };
			else if (data[i].second == 1) {
				if (data[i].first > a[i]) ans = 0;
				break;
			}
			else if (data[i].second == 0) {
				data[i].first = min(t[i], a[i]);
			}
		}
	}
	if (ans == 0) cout << 0 << endl;
	else {
		Loop(i, n) {
			if (data[i].second == 1) continue;
			else ans = ans*data[i].first % (ll)(1e9 + 7);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1792
import java.lang.*;
import java.io.*;
import java.util.*;

class Main{
	public static void main(String args[]) throws FileNotFoundException{
		FScanner sc=new FScanner();
		//Scanner sc=new Scanner(System.in);
		
		int n=sc.readInt();
		
		
		int o=0;
		int e=0;
		
		for(int i=1; i<=n; i++){
			
			if(i%2==1){
				o+=1;
			}else{
				e+=1;
			}
		}
		System.out.println(o*e);
	}
	
	static void solve(){}

	static void disp(int[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
	
	static void disp(String[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%s ",data[i]);
		}
			System.out.println();
	}
	
	static class FScanner{
		Scanner sc;
		FScanner() throws FileNotFoundException{
			sc=new Scanner(System.in);
		}
		boolean hasNextLine(){
			boolean has=true;
			if(!sc.hasNextLine()){
				has=false;
			}
			return has;
		}
		int readInt(){
			int i=sc.nextInt();
			return i;
		}
		long readLong(){
			long i=Long.parseLong(sc.nextLine());
			return i;
		}
		int[] readIntL(){
			String[] buf=sc.nextLine().split(" ");
			int[] num=new int[buf.length];
			for(int i=0; i<buf.length; i++){
				num[i]=Integer.parseInt(buf[i]);
			}
			return num;
		}
		
		String readString(){
			return sc.nextLine();
		}
		String[] readStringL(String dlm){
			String[] s=sc.nextLine().split(dlm);
			return s;
		}
	}
}


Measured memory_bytes: 22868
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

/* #include <bits/stdc++.h> */

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    int n,m;
    while (cin >> n >> m) {
        map<int,int> cnt;
        FOR(i,1,n+1) {
            int a; cin >> a;
            cnt[a]++;
        }
        FOR(_,0,m) {
            int b,c; cin >> b >> c;
            cnt[c] += b;
        }
        auto i = cnt.rbegin(); int total = 0; LL ans = 0;
        while (total < n) {
            const int x = min(i->second, n-total);
            ans += 1LL* i->first * x;
            total += x; 
            ++i;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 9600
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 2;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int n, k, c;
  string s;
  cin >> n >> k >> c >> s;
  int L[200010], R[200010];
  fill(L, L + k, -1);
  fill(R, R + k, -1);
  int i = 0, cnt = 0;
  while (cnt < k)
  {
    if (s[i] == 'o')
    {
      L[cnt] = i;
      cnt++;
      i += c + 1;
    }
    else
    {
      i++;
    }
  }
  i = n - 1, cnt = k - 1;
  while (cnt >= 0)
  {
    if (s[i] == 'o')
    {
      R[cnt] = i;
      cnt--;
      i -= c + 1;
    }
    else
    {
      i--;
    }
  }

  vector<int> ans;
  rep(j, k)
  {
    if (L[j] == R[j])
      ans.push_back(L[j] + 1);
  }
  for (auto ai : ans)
    cout << ai << "\n";
  return 0;
}


Measured memory_bytes: 4236
//なにを出力するかをしっかり確認する必要がある

/*	<limit.h>で範囲を確認できる
	int型サイズ4バイト	変換指定子d
	2147483647～-2147483648
	
	unsigned int型4バイト	変換指定子u
	4294967295～0
	
	long int型　8バイト	変換指定子ld
	9223372036854775807～-9223372036854775808
	
	unsigned long int 型 8バイト　変換指定子lu
	18446744073709551615～0
	
	short int型2バイト　変換指定子d
	32767～-32768
	
	unsigned short int型2バイト 変換指定子u
	65535～0
	
	long long int型
	LLまたはｌｌで表す、　unsignedは頭にuをつける
	
	
	配列はnを利用して宣言するわけだからnの格納後に宣言しなければならない
	
	アルゴリズム
	i番目の数字が1～i-1番目の任意の数字以下であるという条件を満たす
	整数iの個数を数える
	
	直観的な考え方
	1～i-1番目の全ての数字と比較する
	計算量が多くなりそう
	
	最小の数字を記録していく
	その最小の数字>=現在の数字
	ならば最小の数字を更新+count+1
	
	
	
*/
#include <stdio.h>
int main (void){
	int n, i;
	int count=0;
	int min =2000000;
	
	scanf("%d", &n);
	int P[n];
	for(i=0; i<n ;i++){
		scanf("%*c%d", &P[i]);
		
		if(min < P[i]){
			//最初はどのような値でも条件を満たすことに注意
			if(i==0){
				count+=1;
			}
		}else{
			min = P[i];
			count+=1;
		}
		
		
		
	}
	printf("%d", count);
	return 0;
}

Measured memory_bytes: 896
h, w, m = map(int, input().split())

bomb = []
cnth = [0 for i in range(h)]
cntw = [0 for i in range(w)]
bomh = [set() for i in range(h)]
bomw = [set() for i in range(w)]
for i in range(m):
  x, y = map(int, input().split())
  x -= 1
  y -= 1
  cnth[x] += 1
  cntw[y] += 1
  bomh[x].add(y)
  bomw[y].add(x)
  bomb.append([x,y])
maxh = max(cnth)
maxw = max(cntw)
ans = maxh + maxw - 1

xx = []
yy = []
for i in range(h):
  if maxh == cnth[i]:
    xx.append(i)
for i in range(w):
  if maxw == cntw[i]:
    yy.append(i)

for i in xx:
  for j in yy:
    if j not in bomh[i]:
      print (ans+1)
      exit()
print (ans)

Measured memory_bytes: 321360
def solve(n_list):
    max_len = max(n_list)
    max_key = n_list.index(max_len)

    n_list.pop(max_key)
    else_len = sum(n_list)

    return "Yes" if else_len > max_len else "No"


def main():
    n = int(input())
    n_list = list(map(int, input().split()))

    ans = solve(n_list)
    print(ans)


main()


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

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

constexpr long long INF = (1ll << 60);

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

	long long n, m, l;
	cin >> n >> m >> l;

	vector<int> k(n);
	for(auto &e : k) cin >> e;
	sort(begin(k), end(k));

	vector<long long> s(m);
	for(auto &e : s) cin >> e;

	vector<long long> sum(m + 1, 0);
	partial_sum(begin(s), end(s), begin(sum) + 1);

	const auto calc = [&](int a, int b) -> long long {
		if(a > b) swap(a, b);
		return (sum[k[b]] - sum[k[a] - 1]) / l;
	};

	vector<vector<long long>> dp(n - 1, vector<long long>(n - 1, INF));
	dp[0][1] = calc(0, 1);

	for(int i = 0; i < n - 2; ++i) {
		for(int j = i + 1; j < n - 2; ++j) {
			const int next = j + 1;
			chmin(dp[i][next], dp[i][j] + calc(j, next));
			chmin(dp[j][next], dp[i][j] + calc(i, next));
		}
	}

	long long ans = INF;
	for(int i = 0; i < n - 2; ++i) {
		chmin(ans, dp[i][n - 2] + calc(i, n - 1));
	}
	ans += calc(n - 2, n - 1);
	cout << ans << endl;

	return EXIT_SUCCESS;
}

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

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

const int N = 1e5 + 5;
ll m;
int n;
ll A[N];
ll psum[N];

int bs(ll target) { // find index of x which [ x >= target ]
  if (A[n - 1] < target) return -1;
  int l = 0, r = n - 1;
  while (l < r) {
    int mid = (r - l) / 2 + l;
    if (A[mid] >= target) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  return l;
}

ll check(ll mid) {
  ll cnt = 0;
  for (int i = 0; i < n; ++i) {
    int ti = bs(mid - A[i]);
    if (ti >= 0) {
      cnt += n - ti;
    }
  }
  return cnt;
}

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

  cin >> n >> m;
  ll sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
    sum += A[i];
  }
  sort(A, A + n);
  ll cur = 0;
  for (int i = 0; i < n; ++i) {
    psum[i] = sum - cur;
    cur += A[i];
  }
  ll l = A[0] * 2;
  ll r = A[n - 1] * 2;
  while (l < r) {
    ll mid = (r - l + 1) / 2 + l;
    if (check(mid) >= m) { // mid may be larger
      l = mid;
    } else {
      r = mid - 1;
    }
  }
  ll last_cnt = check(l);
  ll res = 0;
  ll mv = INT_MAX;
  for (int i = n - 1; i >= 0; --i) {
    int index = bs(l - A[i]);
    if (index < 0) break;
    mv = min(mv, A[i] + A[index]);
    res += psum[index] + A[i] * (n - index);
  }
  ll more = last_cnt - m;
  res -= more * mv;
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	ll N;
	while (scanf("%d", &N) == 1)
	{
        for(ll h=1;h<=3500;h++)
        for(ll n=1;n<=3500;n++){
            ll t1=N*h*n;
            ll t2=4*n*h-N*(h+n);
            if((t2>0)&&(t1%t2==0)){
                cout<<h<<" "<<n<<" "<<t1/t2<<endl;
                return 0;
            }
        }
	}
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int IDCard = input[0];
            int Gate = input[1];

            int left = 1, right = IDCard;
            for(int i = 0; i < Gate; i++)
            {
                input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                left = Math.Max(left, input[0]);
                right = Math.Min(right, input[1]);
            }
            Console.WriteLine(Math.Max(right - left + 1, 0));
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 17456
package main

import (
	"bufio"
	"fmt"
	"os"

	// "strings"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	res := 0
	bottom := a[0]
	for i := 0; i < n; i++ {
		if a[i] <= bottom {
			res++
		}
		if a[i] < bottom {
			bottom = a[i]
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 3584
n,m,cx,cy = map(int,input().split())
x = list(int(i) for i in input().split())
y = list(int(i) for i in input().split())

x.sort()
y.sort()
z = range(cx+1,cy+1)

ans = "War"
for v in z:
    if (v > x[n-1]) and (v <= y[0]):
        ans = "No War"
        break

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    ll k; cin >> k;
    ll remain = k % 50;
    ll ct = k / 50;
    ll x = 49+ct;
    cout << 50 << endl;
    rep(i,50-remain) cout << x-remain << " ";
    rep(i,remain) cout << x+50-remain+1 << " ";
    cout << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int H = sc.nextInt();
   int A = sc.nextInt();

   int sum = 0;
   while(H > 0) {
	   H = H - A;
	   sum += 1;
   }

   System.out.print(sum);
    }
}


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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    string s;
    cin >> s;
    int res = 0;
    for (int i = 0; i < n - 2; i++) {
        if (s.substr(i, 3) == "ABC") res++;
    }
    cout << res <<"\n";

    return 0;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define OUT(a) cout << (a) << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll a, b, c, d;

    cin >> a >> b >> c >> d;

    ll isTaka = 1;
    while(a > 0 && c > 0){
        if(isTaka == 1){
            c -= b;
            isTaka = 0;
        } else {
            a -= d;
            isTaka = 1;
        }
    }

    if (a <= 0){
        cout << "No" << endl;
    } else {
        cout << "Yes" <<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3628
from collections import deque

s = deque(list(str(input())))
q = int(input())
que = [list(map(str, input().split())) for _ in range(q)]

r_cnt=0
for query in que:
    if len(query) == 1:
        r_cnt+=1
    else:
        if int(query[1]) == 1:
            if r_cnt % 2 == 1:
                s.append(query[2])
            else:
                s.appendleft(query[2])
        else:
            if r_cnt % 2 == 1:
                s.appendleft(query[2])
            else:
                s.append(query[2])

for _ in range(r_cnt % 2):
    s.reverse()

print(*s,sep='')


Measured memory_bytes: 48224
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
using namespace std;
// using namespace atcoder;


void Main()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;

    rep(pat, 1 << 2) {
        string res(n, ' ');
        res[0] = pat & 1 ? 'W' : 'S';
        res[1] = pat & 2 ? 'W' : 'S';

        char res0 = res[0];
        for (int i = 1; i <= n - 1; i++) {
            bool same = s[i] == 'o';
            if (res[i] == 'W') {
                same = !same;
            }
            if (same) {
                res[(i+1)%n] = res[(i-1+n)%n];
            }
            else {
                res[(i+1)%n] = res[(i-1+n)%n] == 'S' ? 'W' : 'S';
            }
        }

        // check
        bool ok = true;
        for (int i = 0; i < n; i++) {
            bool same = s[i] == 'o';
            if (res[i] == 'W') {
                same = !same;
            }
            if (same) {
                if (res[(i+1)%n] != res[(i-1+n)%n]) {
                    ok = false;
                    break;
                }
            }
            else {
                if (res[(i+1)%n] == res[(i-1+n)%n]) {
                    ok = false;
                    break;
                }
            }
        }

        if (ok) {
            put(res);
            return;
        }
    }

    put(-1)
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define ll long long
using namespace std;
signed main(){
  ll n,i=1;
  cin>>n;
  map<ll,ll> mp;
  while(true){
    mp[n]++;
    if(mp[n]==2){
      cout<<i<<"\n";
      return 0;
    }
    if(n % 2 == 0){
      n /= 2;
    }else{
      n = 3 * n + 1;
    }
    i++;
  }
  return 0;
}

Measured memory_bytes: 256
// problem: "https://atcoder.jp/contests/abc149/tasks/abc149_c"

#include<bits/stdc++.h>

using namespace std;

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

    vector<bool>P(int(1e6),1);

    P[0] = P[1] = 0;
    int i,j;

    i = 2;
    while(i < int(1e6))
    {
        j = 2*i;

        while(j < int(1e6))
        {
            P[j] = 0;
            j += i;
        }

        i++;
        while(i < int(1e6) && P[i] == 0)
            i++;
    }

    i = x;
    while(i < int(1e6) && P[i] == 0)
        i++;

    cout<<i;
    
    return 0;
}


Measured memory_bytes: 384
def main():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))

    r = [0]
    for i in range(N):
        r.append(r[i]+p[i])


    ans = 0
    max_i = 0
    max_value = 0
    for i in range(1,N-K+1):
        t = r[i+K]-r[i]
        if max_value < t:
            max_value = t
            max_i = i



    for i in range(max_i, max_i+K):
        if len(p) <= i:
            break
        n = p[i] + 1
        ans += (n*(n-1)//2) / (n-1)
    
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 24804
n = int(input())
a = list(map(int,input().split()))
ans = 1
for i in range(n):
    if a[i]==0:
        print(0)
        exit()
for i in range(n):       
    ans *=a[i]
    if ans >10**18:
        print(-1)
        exit()
print(ans)


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


int main() {
    int A1, A2, A3; cin >> A1 >> A2 >> A3;
    if (A1 + A2 + A3 >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

int main(int argc, char* argv[])
{
  int a,b;
  std::cin >> a >> b;

  std::vector< int > vi;
  vi.push_back(a+b);
  vi.push_back(a-b);
  vi.push_back(a*b);

  std::vector< int >::iterator it = std::max_element(vi.begin(), vi.end());
  std::cout << *it << std::endl;

  return 0;
}


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

using namespace std;

const int P = (int) 1e9 + 7;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<int> b(1, 1);
  int ans = 1;
  for (int i = 1; i < n; ++i) {
    if (a[i] != b.back() + 1) {
      b.push_back(b.back() + 2);
    } else {
      ans = (long long) ans * (b.size() + 1) % P;
    }
  }
  for (int i = 0; i < (int) b.size(); ++i) {
    ans = (long long) ans * (i + 1) % P;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 4288
#include<iostream>
#include<queue>
using namespace std; // 575

const int MAX = 1002;
const int d[] = {0, 1, 0, -1, 0};
int main() {
	int H, W;
	cin >> H >> W;
	string A[MAX];
	for (int i = 0;i <= W + 1;++ i) {
		A[0] += '#';
		A[H + 1] += '#';
	}
	for (int i = 1;i <= H;++ i) {
		cin >> A[i];
		A[i] = '#' + A[i] + '#';
	}
	
	queue<pair<int, pair<int, int> > > que;
	for (int i = 1;i <= H;++ i) {
		for (int j = 1;j <= W;++ j) {
			if (A[i][j] == '#') que.push(make_pair(0, make_pair(j, i)));
		}
	}
	
	int ans = 0;
	while (!que.empty()) {
		pair<int, int> p = que.front().second;
		int operate = que.front().first;
		ans = operate;
		que.pop();
		
		for (int i = 0;i < 4;++ i) {
			if (A[p.second + d[i]][p.first + d[i + 1]] == '#') continue;
			A[p.second + d[i]][p.first + d[i + 1]] = '#';
			que.push(make_pair(operate + 1, make_pair(p.first + d[i + 1], p.second + d[i])));
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 14352
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sn = new Scanner(System.in);
        int x = Integer.parseInt(sn.next());
        int y = Integer.parseInt(sn.next());
        int[] list = new int[y];
        boolean flg = true;
        if ( y == 0){
            System.out.println(x);
            return;
        }else{
            for(int i =0; i < y ; i++ ){
                list[i] = Integer.parseInt(sn.next());
            }
        }
        for( int i = 0; i <= x ; i++ ){
            int d = x - i;
			for (int b =0; b < y ; b++ ){
                if (list[b] == d){
                    flg = false;
                } 
            }
            if (flg){
                System.out.println(d);
                return;
            }
            flg = true;
            int e = x + i;
			for (int c =0; c < y ; c++ ){
                if (list[c] == e){
                    flg = false;
                } 
            }
            if (flg){
                System.out.println(e);
                return;
            }
            flg = true;
        }
        
	}
}



Measured memory_bytes: 35700