akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){ 
  string s; cin >> s;
  int n = s.size();

  vector<int> S, G;
  rep(i, n){
      if(i<n-1 and s[i]=='R' and s[i+1]=='L'){
          S.push_back(i);
          G.push_back(-(i+1));
      }
  }
  //空の配列を二分探索しないようにする
  if(!S.size()){
      S.push_back(-1), G.push_back(-INF);
  }
  sort(all(G));
  vector<int> res(n, 1);
  rep(i, n){
      if(s[i]=='R'){
          auto iter = lower_bound(all(S), i);
          if(iter==S.end()){
              res[i]--;
              res[n-1]++;
          }else{
              int d = abs(*iter - i);
              if(d%2==0)res[*iter]++;
              else res[*iter+1]++;
              res[i]--;
          }
      }else{
          auto iter = lower_bound(all(G), -i);
          if(iter==S.end()){
              res[i]--;
              res[0]++;
          }else{
              int d = abs(-*iter - i);
              if(d%2==0)res[-*iter]++;
              else res[(-*iter)-1]++;
              res[i]--;
          }
      }
  }
  for(auto a: res)cout << a << " ";
  cout << ln;
}



Measured memory_bytes: 4352
#include<iostream>
#include<cmath>
using namespace std;
int n,m,c,d,p,Q,R,e,f;
int main(){
	while(true){
		cin>>n>>m>>c;if(!n){break;}
		p=0;Q=100000000;R=100000000;
		while(true){
			d=(p*n-c)/m;
			if(p*n==d*m+c){
				if(Q+R>abs(p)+abs(d)){
					Q=abs(p);
					R=abs(d);
				}
				if(Q+R==abs(p)+abs(d)){
					e=abs(p)*n+abs(d)*m;
					f=Q*n+R*m;
					if(f>e){
						Q=abs(p);
						R=abs(d);
					}
				}
			}
			d=(p*n+c)/m;
			if(p*n+c==d*m){
				if(Q+R>abs(p)+abs(d)){
					Q=abs(p);
					R=abs(d);
				}
				if(Q+R==abs(p)+abs(d)){
					e=abs(p)*n+abs(d)*m;
					f=Q*n+R*m;
					if(f>e){
						Q=abs(p);
						R=abs(d);
					}
				}
			}
			p++;
			if(p>100000){break;}
		}
		cout<<Q<<' '<<R<<endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(){
  string S ;
  int N, M, ans = 0, score = 0 ;
  cin >> S ;
  if(S == "ABC" ){
    cout << "ARC" << endl ;
  }  
  else{
    cout << "ABC" << endl ;
  }  
  return 0 ;
}  

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

int main() {
	string s;
	int a, b,c;
	cin >> a >> b;
	cin >> s;
	c = 0;
	for (int i = 0; i < a; i++) {
		if ( s[i] =='9'||s[i]=='8'|| s[i] == '7' || s[i] == '6' || s[i] == '5' || s[i] == '4' || s[i] == '3' || s[i] == '2' || s[i] == '1' || s[i] == '0');
		else c++;
	}
	if (s[a] == '-');
	else c++;
	for (int i = a+1; i < a+b+1; i++) {
		if (s[i] == '9' || s[i] == '8' || s[i] == '7' || s[i] == '6' || s[i] == '5' || s[i] == '4' || s[i] == '3' || s[i] == '2' || s[i] == '1' || s[i] == '0');
		else c++;
	}
	if (c > 0)cout << "No" << endl;
	else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
using namespace std;
int main() {
    int n;
    cin >> n;
    ll num, ans = 0;
    rep(i, n) {
        cin >> num;
        while (true) {
            if (num % 2 != 0) break;
            ans++;
            num /= 2;
        }
    }
    cout << ans << endl;

    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

int main(void){
	string s;
	cin >> s;

	const int n=s.size();
	int cidx=-1,fidx=-1;
	rrep(i,n) if(s[i]=='C') cidx=i;
	rep(i,n)  if(s[i]=='F') fidx=i;
	
	if(cidx!=-1 and fidx!=-1 and cidx<fidx)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<pair<int, int> > VPII;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	string S;
	cin >> S;
	FOR(i, 0, S.length() - 8) {
		cout << S[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
object Main {
  import scala.io.StdIn.readLine
  def main(args: Array[String]): Unit = {
    val x = readLine.trim().toLong
    var current = 100L

    var i = 0
    while(current < x) {
      current = (current * 1.01).toLong
      i += 1
    }
    println(i)
  }
}


Measured memory_bytes: 54604
import math

class MaxPrice(object):
    
    def __init__(self):
        self.min_price = math.inf
        self.max_price = -math.inf
        self.max_diff = -math.inf

    def set_price(self, p):
        if self.max_price < p:
            self.max_price = p
        else:
            if self.max_diff < p - self.max_price:
                self.max_diff = p - self.max_price

        if p < self.min_price:
            self.min_price = p
        else:
            if self.max_diff < p - self.min_price:
                self.max_diff = p - self.min_price

def run():
    n = int(input())
    mp = MaxPrice()
    for i in range(n):
        p = int(input())
        mp.set_price(p)
    print(mp.max_diff)

if __name__ == '__main__':
    run()


Measured memory_bytes: 5672
#include "bits/stdc++.h"
using namespace  std;
int main()
  {
  
  int a,b;
  cin>>a>>b;
  if(b==1) cout<<0<<endl;
  
  else
  for(int i=1;i<=b;i++)
    if(i*a-i+1>=b) 
      {cout<<i<<endl;
       return  0;
      }
  return 0;
  }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

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

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

    ll N, K;
    cin >> N >> K;
    vec A(N);
    ll neg = 0, pos = 0, zero = 0;
    Rep (i, N) {
        cin >> A[i];
        if (A[i] < 0) neg++;
        else if (A[i] == 0) zero++;
        else pos++;
    }

    ll negp = neg * pos, posp = neg * (neg-1) / 2 + pos * (pos-1) / 2;
    ll zerop = N * (N-1) / 2 - negp - posp;

    // cout << negp << " " << zerop << " " << posp << "\n";

    sort(A.begin(), A.end());

    if (K <= negp) {
        // ans < 0
        ll ok = -1, ng = -1e18-10;
        while (abs(ok-ng) > 1) {
            ll mid = (ok + ng) / 2;
            ll cnt = 0;
            Rep (i, N) {
                if (A[i] < 0) cnt += A.end() - lower_bound(A.begin(), A.end(), (abs(mid) + abs(A[i]) - 1) / abs(A[i]));
                // if (A[i] > 0) cnt += lower_bound(A.begin(), A.end(), mid / A[i]) - A.begin();
            }
            // cout << "mid=" << mid << " cnt=" << cnt << "\n";
            if (cnt >= K) ok = mid;
            else ng = mid;
        }
        cout << ok << "\n";
    } else if (K <= negp + zerop) {
        cout << 0 << "\n";
    } else {
        ll ok = 1e18 + 10, ng = 1;
        while (abs(ok-ng) > 1) {
            ll mid = (ok + ng) / 2;
            ll cnt = 0;
            Rep (i, N) {
                if (A[i] < 0) {
                    ll tmp = A.end() - lower_bound(A.begin(), A.end(), mid / A[i]);
                    chmin(tmp, N-i-1);
                    cnt += tmp;
                }
                if (A[i] == 0) cnt += N-i-1;
                if (A[i] > 0) {
                    ll tmp = upper_bound(A.begin(), A.end(), mid / A[i]) - A.begin();
                    tmp -= i+1;
                    chmax(tmp, (ll)0);
                    cnt += tmp;
                }
                // cout << "i=" << i << " cnt=" << cnt << "\n";
            }
            // cout << "mid=" << mid << " cnt=" << cnt << "\n";
            if (cnt >= K) ok = mid;
            else ng = mid;
        }
        cout << ok << "\n";
    }


}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
 
int main(){
    ll N; string S;
    cin>>N>>S;
    ll ans=0;
    rep(i,2,N){
        if(S[i]=='C'&&S[i-1]=='B'&&S[i-2]=='A')ans++;
    }
    cout<<ans;
    return 0;
}

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

int main(){

	int n, k;
	cin >> n >> k;
	vector<string> p(n);
	for(int i=0; i<n; i++) cin >> p[i];

	vector<int> alp(26, 0);
	for(int i=0; i<n; i++){
		alp[ p[i][0]-'A' ]++;
	}

	sort(alp.begin(), alp.end());

	int cnt = 0;
	while(true){
		int l = 0;
		for(int i=25; i>=0; i--){
			if( alp[i] > 0 ){
				alp[i]--;
				l++;
			}

			if( l == k ) break;
		}
		if( l == k ) cnt++;
		else break;
		sort(alp.begin(), alp.end());

	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 896
//#include "bits/stdc++.h"
//using namespace std;
//
//typedef long long ll;
//typedef pair<int, int> pii;
//typedef pair<ll, ll> pll;
//
//#define FOR(i, s, e) for (ll(i) = (s); (i) < (e); (i)++)
//#define FORR(i, s, e) for (ll(i) = (s); (i) > (e); (i)--)
//#define debug(x) cout << #x << ": " << x << endl
//#define mp make_pair
//#define pb push_back
//#define ALL(x) x.begin(),x.end()
//const ll MOD = 1000000007;
//const int INF = 1e9;
//const ll LINF = 1e16;
//const double PI = acos(-1.0);
//int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1};
//int dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};
//
///* -----  2017/04/15  Problem: ARC 013 C / Link: http://arc013.contest.atcoder.jp/tasks/arc013_c  ----- */
///* ------問題------
//
//
//
//-----問題ここまで----- */
///* -----解説等-----
//
//
//
//----解説ここまで---- */
//
//
//int N;
//ll M, T;
//int S[303030], NS[303030], ret[303030];
//int D[303030];
//int O[303030];
//int NL, NR;
//pair<int, int> P[303030];
//
//void solve() {
//	int i, j, k, l, r, x, y; string s;
//
//	cin >> N >> M >> T;
//	//R=1;L=2;
//	vector<int> VL, VR;
//	FOR(i,0, N) {
//		cin >> S[i] >> s;
//		S[i];
//		D[i] = s[0] == '1';
//		if (D[i] == 0) {
//			NL++;
//			VL.push_back(S[i]), VL.push_back(S[i] + M);
//			NS[i] = (M + (S[i] - T) % M) % M;
//		}
//		else {
//			NR++;
//			VR.push_back(S[i]), VR.push_back(S[i] + M);
//			NS[i] = (S[i] + T) % M;
//		}
//
//		P[i] = { S[i],i };
//	}
//
//	if (NL == 0 || NR == 0) {
//		FOR(i,0, N) printf("%d ", NS[i] + 1);
//		printf("\n");
//		return;
//	}
//
//	sort(P, P + N);
//	FOR(i,0, N) O[P[i].second] = i;
//	sort(ALL(VL));
//	sort(ALL(VR));
//
//	FOR(i,0, N) {
//		x = P[i].second;
//		if (D[x] == 0) {
//			ll col = 2 * T / M*NR;
//			int left = (int)(2 * T%M);
//			auto it1 = lower_bound(ALL(VR), S[x] + M);
//			auto it2 = lower_bound(ALL(VR), S[x] + M - left);
//			col += it1 - it2;
//			y = (N + (i - col) % N) % N;
//		}
//		else {
//			ll col = 2 * T / M*NL;
//			int left = (int)(2 * T%M);
//			auto it1 = lower_bound(ALL(VL), S[x] + left + 1);
//			auto it2 = lower_bound(ALL(VL), S[x]);
//			col += it1 - it2;
//			y = (i + col) % N;
//		}
//		ret[P[y].second] = NS[x] ;
//
//	}
//
//	FOR(i, 0, N) cout << ret[i] << endl;
//}
//
//int main() {
//  cin.tie(0);
//  ios_base::sync_with_stdio(false);
//
//  solve();
//
//  return 0;
//}

#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
const int N = 3e5 + 500;
int n, m, p[N], ra[N], dir[N], ans[N];
bool cmp(int x, int y) { return p[x]<p[y]; }
ll s;
int main() {
	scanf("%d%d%I64d", &n, &m, &s);
	rep(i, 0, n - 1) {
		char ch[10]; scanf("%d %s", p + i, ch);
		p[i]; ra[i] = i;
		dir[i] = ch[0] == '2' ? -1 : 1;
	}
	sort(ra, ra + n, cmp);
	int t = 0;
	rep(i, 0, n - 1) {
		if (dir[i] == 1) t += (p[i] + s) / m%n;
		else t += (p[i] - s - m + 1) / m%n;
		t = (t%n + n) % n;
		p[i] = p[i] + s%m*dir[i];
		p[i] = (p[i] % m + m) % m;
	}
	sort(p, p + n);
	rep(i, 0, n - 1) ans[ra[(i + n - t) % n]] = p[i];
	rep(i, 0, n - 1)
		printf("%d\n", ans[i]);
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<int> mondai(N+1);
  int sum=0;
  for(int i=1; i<=N; i++){
    int T;
    cin>>T;
    mondai.at(i)=T;
    sum+=T;
  }
  int M;
  cin>>M;
  for(int i=1; i<=M; i++){
    int P, X;
    cin>>P>>X;
    cout<<sum-mondai.at(P)+X<<endl;
  }
}


Measured memory_bytes: 256
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

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

int main() {
  int n, m;
  int64 rem;
  scanf("%d%d%lld", &n, &m, &rem);
  vector<int> a(n), b(m);
  vector<int64> preb(m + 1);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  for (int i = 0; i < m; ++i) {
    scanf("%d", &b[i]);
    preb[i + 1] = preb[i] + b[i];
  }
  int best = 0;
  int64 sum = 0;
  for (int i = 0; i <= n && sum <= rem; ++i) {
    int64 target = rem - sum;
    int cnt = upper_bound(preb.begin(), preb.end(), target) - preb.begin();
    best = max(i + cnt - 1, best);
    sum += a[i];
  }
  printf("%d\n", best);
  return 0;
}


Measured memory_bytes: 6044
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  int n;
  cin >> n;
  VL t(n), a(n);
  REP(i, 0, n) {
    cin >> t[i];
  }
  REP(i, 0, n) {
    cin >> a[i];
  }
  VL def(n, -1);
  bool ok = 1;
  def[0] = t[0];
  REP(i, 1, n) {
    if (t[i - 1] < t[i]) {
      def[i] = t[i];
    }
  }
  if (def[n - 1] >= 0) {
    if (def[n - 1] != a[n - 1]) {
      ok = 0;
    }
  } else {
    def[n - 1] = a[n - 1];
  }
  REP(i, 0, n - 1) {
    if (a[i] > a[i + 1]) {
      if (def[i] >= 0) {
	if (def[i] != a[i]) {
	  ok = 0;
	}
      } else {
	def[i] = a[i];
      }
    }
  }
  REP(i, 0, n) {
    if (def[i] >= 0 && (def[i] > t[i] || def[i] > a[i])) {
      ok = 0;
    }
  }
  if (!ok) {
    cout << 0 << endl;
    return 0;
  }
  ll sum = 1;
  REP(i, 0, n) {
    if (def[i] == -1) {
      sum *= min(t[i], a[i]);
      sum %= mod;
    }
  }
  cout << sum << endl;
}


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

int main() {
  int X,A,B,C;
  cin >> A >> B >> C >> X;
  
  
  //int size = (A+1)*(B+1)*(C+1);
  //vector<int> ans(size,0);
  //vector<vector<vector<int>>> vec(100, vector<vector<int>>(100, vector<int>(100)));
  int sum = 0;
  int ans = 0; 

  rep(i,A) rep(j,B) rep(k,C){
      sum = 500 * i + 100 * j + 50 * k;
      if(sum == X){
          ans++;
      }
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 3580
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

int main() {
    int N, W;
    cin >> N >> W;
    vector<vector<int>> dp(N+1, vector<int>(W+1,0));
    vector<pair<int,int>> vw;
    REP(i,N) {
        int v, w;
        cin >> v >> w;
        vw.push_back(make_pair(v,w));
    }
    
    REP(i,N) {
        REP(j, W+1) {
            if (j < vw[i].second) dp[i+1][j] = dp[i][j];
            else dp[i+1][j] = max(dp[i][j], dp[i+1][j-vw[i].second] + vw[i].first);
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 6856
n = int(input())
nums = {0:0}

for i in list(map(int, input().split())):
    if i in nums:
        nums[i] += 1
        if nums[i] > 2:
            ans = 0
            break
    else:
        nums[i] = 1
        
if n % 2 == 0:
    if 1 in nums.values():
        ans = 0
    else:
        ans = 2**(n//2)
        
else:
    if nums[0] == 1:
        del nums[0]
        if 1 in nums.values():
            ans = 0
        else:
            ans = 2**((n-1)//2)
    else:
        ans = 0
        
print(ans % (10**9+7))

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

int main() {
  int a, b; cin >> a >> b;
  int ans = max(a + b, max(a + a - 1, b + b - 1));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a, b;
    scanf("%d %d", &a, &b);

    if (a == 1 || b == 1) {
        if (a == b) {
            printf("Draw\n");
        }
        else if (a > b) {
            printf("Bob\n");
        }
        else {
            printf("Alice\n");
        }
    }
    else {
        if (a == b) {
            printf("Draw\n");
        }
        else if (a > b) {
            printf("Alice\n");
        }
        else {
            printf("Bob\n");
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N,W;
    cin >> N >> W;
    int w[N],v[N];
    rep(i,N) cin >> w[i] >> v[i];

    ll dp[102][100002];
    for(int i=0;i<=W;i++) dp[0][i] = 0;

    for(int i=0;i<N;i++){
        for(int j=0;j<=W;j++){
            if(j-w[i]>=0){
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
            }else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 79360
from collections import defaultdict as dd, deque

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

solved = set()
penals = dd(int)

for _ in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'AC':
        solved.add(p)
    else:
        if p not in solved:
            penals[p] += 1

print(len(solved), sum(penals[p] for p in penals if p in solved))




Measured memory_bytes: 12268
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
#define MAXN 100000
vector<int> ch[MAXN+10];
int dfs(int now)
{
	if (ch[now].empty()) return 0;
	vector<int> v;
	for(auto son:ch[now]) {
		v.push_back(dfs(son));
	}	
	sort(v.begin(),v.end(),greater<int>());
	for(int i=0; i<v.size(); ++i) {
		v[i]+=i+1;
	}
	return *max_element(v.begin(),v.end());
}
void solve(long long N, vector<long long> a){
	for(int i=2; i<=N; ++i) {
		ch[a[i-2]].push_back(i);
	}
	cout<<dfs(1)<<endl;
}

int main(){	
#ifdef WAAUTOMATON
	//freopen("in.txt","r",stdin);
#endif
	long long N;
	scanf("%lld",&N);
	vector<long long> a(N-2+1);
	for(int i = 0 ; i <= N-2 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, a);
	return 0;
}



Measured memory_bytes: 15104
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,k;cin>>n>>k;
    vector<bool> v(n,0);
    for(int i=0;i<k;i++){
        int d;cin>>d;
        for(int j=0;j<d;j++){
            int a;cin>>a;
            v[a-1]=1;
        }
    }
    int ans=0;
    for(int i=0;i<n;i++)ans+=(v[i]==0);
    cout<<ans;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=998244353;

int main(){
  int N;
  double p[3000];
  cin>>N;
  for (int i(1);i<=N;i++) cin>>p[i];
  double dp[3000] = {0.0}; 
  dp[0] = 1;
  for (int i(0);i<N;i++){
    for (int j(N-1);j>=0;j--){
      double tmp = dp[j];
      dp[j]=(tmp*(1-p[i+1]));
      dp[j+1]+=(tmp*p[i+1]);
    }
  }
  double ans(0.0);
  for (int i(N/2+1);i<=N;i++){
    ans+=dp[i];
  }
  cout <<setprecision(10) << ans << endl;
  return 0;
}



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

int main(void){
    string str;
    cin >> str;
    int a = 0;
    for (int i=0; i<3; i++) if (str[i] == 'o') a++;
    cout << 700 + 100 * a << endl;
    return 0;
}

Measured memory_bytes: 3596
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

vector<int> nums;

void func(int v, int d, int maxd)
{
	static const int vs[3] = { 3,5,7 };

	if (d > maxd)
	{
		nums.push_back(v);
		return;
	}

	rep(i, 0, 3)
	{
		func(10 * v + vs[i], d + 1, maxd);
	}
}

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

	int N;
	cin >> N;

	rep(i, 0, 9)
	{
		func(0, 0, i + 1);
	}

	int ans = 0;
	for (auto n : nums)
	{
		if (n <= N)
		{
			int a[10] = { 0 };
			rep(i, 0, 9)
			{
				a[n % 10]++;
				n /= 10;
			}
			if (a[3] > 0 && a[5] && a[7] > 0)
			{
				ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1400
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()


int main() {
    string s,t;
    int a,b;
    string u;
    cin>>s>>t>>a>>b>>u;
    
    if(s==u) a--;
    else if(t==u) b--;
    
    cout<<a<<" "<<b<<endl;
}



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

#define ll long long int
#define pi 3.141592653589793238
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007

ll mod_pow(ll a,ll b,ll m)
{
    ll res = 1;
    while(b)
    {
        if(b&1)
        {
            res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

void solve()
{
    ll n;
    cin>>n;
    vector<ll> dis;
    vector<ll> plus,minus;
    for(ll i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        plus.push_back(x+y);
        minus.push_back(x-y);

    }
    sort(plus.begin(),plus.end());
    sort(minus.begin(),minus.end());

    cout<<max((plus[n-1]-plus[0]),(minus[n-1]-minus[0]));
    return;
}

int main()
{
    FAST;
    #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
      #endif
    ll q;
    q=1;
    // sieve();
    // cin>>q;
    while(q--)
        solve();
    return 0;
}


Measured memory_bytes: 6672
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define foreach(i,a) for(auto &i:a)
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}

void solve(){
  ll n; cin>>n;
  vector<pll> PI(n);
  rep(i,n){
    ll p; cin>>p;
    PI[i]=make_pair(p,i);
  }
  sort(PI.begin(),PI.end(),greater<pll>());

  ll ans=0;
  multiset<ll> S{-1,-1,n,n};
  foreach(tup,PI){
    ll p,i; tie(p,i)=tup;
    auto it1=S.insert(i);
    auto it2=it1;
    ll l0=*(--it1), l1=*(--it1);
    ll r0=*(++it2), r1=*(++it2);
    ans+=p*((i-l0)*(r1-r0)+(l0-l1)*(r0-i));
  }
  
  cout<<ans<<"\n";
}

Measured memory_bytes: 6528
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
bool h[1000010]={false};
int main(){
	vector<int>in(10);
	rep(i,10)cin>>in[i];
	sort(all(in));
	cout<<in[9]<<endl;
	cout<<in[8]<<endl;
	cout<<in[7]<<endl;
	
}

Measured memory_bytes: 1208
#include<iostream>
using namespace std;
int main(){
int n,num,max=-1e9,min=1e9;
cin>>n;
for(int i=0;i<n;++i){
cin>>num;
if(num>max)max=num;
if(num<min)min=num;
}
cout<<max-min<<"\n";
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define MOD 1000000007
using namespace std;

vector<pair<ll,int> >a;

ll dp[102][100005];

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);cout.tie(NULL);
	int n;
	ll W;
	cin>>n>>W;
	a.resize(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i].ff>>a[i].ss;
	}
	// cout<<W+1;
	for(int i=0;i<=100001;++i)
		dp[0][i]=W+1;
	dp[0][0]=0;
	for(int i=0;i<n;++i){
		for(int j=100001;j>=0;--j){
			if(j>=a[i].ss){
				// cout<<dp[i][j]<<" : ";
				dp[i][j]=min(dp[i][j-a[i].ss]+a[i].ff,dp[i][j]);
				// cout<<dp[i][j]<<" ";
			}
			dp[i+1][j]=dp[i][j];
		}
		// cout<<'\n';
	}
	for(int i=100001;i>=0;--i){
		if(dp[n][i]<W+1)
			return cout<<i,0;
	}
	// cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
	return 0;
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
#include <atcoder/dsu>
using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M;
    cin >> N >> M;
    atcoder::dsu uf(N);
    for(int i=0; i<M; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.merge(a, b);
    }

    auto gs = uf.groups();
    cout << gs.size() - 1 << '\n';

    return 0;
}


Measured memory_bytes: 8852
#include <stdio.h>

int A[1000000],n;

int binarySearch(int key)
{
  int left=0;
  int right=n;
  int mid;
  while(left<right){
    mid=(left+right)/2;
    if(key==A[mid]) return 1; //key ??????
    if(key>A[mid]) left=mid+1; //???????????¢?´¢
    if(key<A[mid]) right=mid; //???????????¢?´¢
  }
  return 0;
}

int main()
{
  int i,q,k,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&k);
    if(binarySearch(k)) sum++;
  }
  printf("%d\n",sum);
  return 0;
}

	

Measured memory_bytes: 988
a,b = map(int, input().split())
s = input()
if b == 1:
  print("Yes" if s[0:a].isdecimal() and s[a] == "-" and s[-1].isdecimal() else "No")
else:
  print("Yes" if s[0:a].isdecimal() and s[a] == "-" and s[a+1:].isdecimal() and s[-b-1] == "-" else "No")

Measured memory_bytes: 9080
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int i = 0;
		while (i < 1000) {
			String line = sc.nextLine();
			String[] array = line.split(" ");
			int H = Integer.parseInt(array[0]);
			int W = Integer.parseInt(array[1]);

			if (W == 0 && H == 0) {
				break;

			} else {

				for (int k = 0; k < H; k++) {

					for (int j = 0; j < W; j++) {
						if (k == 0 || k == H - 1) {
							System.out.print("#");

						} else {
							if (j == 0 || j == W - 1) {
								System.out.print("#");

							} else {
								System.out.print(".");

							}
						}

					}
					System.out.println();
				}
				System.out.println();
			}
		}

	}

}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  int ans = 0;
  for(int i = 0; i < 6; i++){
    if(s.at(i) == '1') ans++;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long a = sc.nextLong();
		String b = sc.next();
		String B = b.replace(".", "");
		
		// 計算
		long result = 0;
		result = (a*Long.valueOf(B))/100;
		
		// 出力
		System.out.println(result);
	}

}


Measured memory_bytes: 27092
#include <bits/stdc++.h>
using namespace std;
int main() {
  	int a, b;
    cin >> a >> b;

    int max=31,cnt=0;
    for(int i=1; i<=a;i++){
      if(i==a) max=b;
      for(int j=1;j<=max;j++) {
        if(i==j) cnt++;
      }
    }
  	cout << cnt << endl;
    return 0;
}

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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

bool func(int a,int b,int c){
    return ((a+b)>c)&&((b+c)>a)&&((c+a)>b) && (a!=b&&b!=c&&c!=a);
}

signed main()
{

    int n;
    cin>>n;
    vector<int>l(n);
    rep(i,n){
        cin>>l[i];
    }
    int ans = 0;

    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(func(l[i],l[j],l[k])){
                    ans++;
                }

            }
        }
    }




    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 3632
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    string s; cin >> s;
    int idx1 = 0, idx2 = 0;
    while(idx2 < n && s[idx2] == '1'){ idx2++; }
    for(int i = 0; i < k; i++){
        while(idx2 < n && s[idx2] == '0'){ idx2++; }
        while(idx2 < n && s[idx2] == '1'){ idx2++; }
    }
    int ans = idx2 - idx1;
    while(idx2 < n){
        while(s[idx1] == '1'){ idx1++; }
        while(s[idx1] == '0'){ idx1++; }
        while(idx2 < n && s[idx2] == '0'){ idx2++; }
        while(idx2 < n && s[idx2] == '1'){ idx2++; }
        ans = max(ans, idx2 - idx1);
    }
    cout << ans << '\n';
}


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

int main() {
    string s;
    cin>>s;
    int a=0,b=0,c=0;
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='a') a++;
        if(s.at(i)=='b') b++;
        if(s.at(i)=='c') c++;
    }
    if(abs(a-b)>1 || abs(b-c)>1 || abs(a-c)>1) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#define maxn 100005
using namespace std;
typedef long long ll;
ll a[maxn] = { 0 };
int main() {
    ll n, i;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    ll sum1 = 0;  ll sum2 = 0;
    ll ans1 = 0; ll ans2 = 0;
    for (int i = 1;i <= n; ++i) {
        sum1 += a[i];
        if (i % 2 == 0 && sum1 >= 0) {
            ans1 += sum1 + 1;
            sum1 = -1;
        }
        else if (i % 2 != 0 && sum1 <= 0) {
            ans1 += abs(sum1) + 1;
            sum1 = 1;
        }
    }
    for (int i = 1; i <= n; ++i) {
        sum2 += a[i];
        if (i % 2 == 0 && sum2 <= 0) {
            ans2 += abs(sum2) + 1;
            sum2 = 1;
        }
        else if (i % 2 != 0 && sum2 >= 0) {
            ans2 += abs(sum2) + 1;
            sum2 = -1;
        }
    }
    cout << min(ans1, ans2) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#define ll long long
using namespace std;
int main(void){
    ll h,w; cin>>h>>w;
    if(h == 1 || w == 1){
        cout<<1<<endl;
        return 0;
    }
    ll ans = h*w;
    if(h%2 == 0 || w%2 == 0) cout<<ans/2<<endl;
    else cout<<ans/2+1<<endl;
}


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

ll abs(ll x,ll y){
    ll ret;
    if(x > y) ret = x - y;
    else ret = y - x;
    return ret;
}

ll chmin(ll x,ll y){
    if(x > y){
        return y;
    }
    else{
        return x;
    }
}

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> h (n);
    for(int i=0; i<n; i++){
        cin >> h.at(i);
    }
    vector<ll> dp (n,10000000000);
    dp.at(0) = 0;
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<=min(n-1,i+k); j++){
            dp.at(j) = chmin(dp.at(i) + abs(h.at(i),h.at(j)) , dp.at(j));
        }
    }
    cout << dp.at(n-1) << endl;
} 

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>   // popen, pclose, fgets
#include <cstdlib> 
using namespace std;
#define rep0(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>;
using ll = long long; //10e19までいける
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll =vector<vvll>;
const double PI=3.14159265358979323846;
//小数点以下を指定したい時　　→→→→  cout << fixed << setprecision()<<答え<<endl;
//int→string
//string→int   int num = atoi(numStr.c_str());

int main() {
    int n;cin>>n;
    vi v(n);
    rep0(i,n){
        cin>>v[i];
    }
    sort(all(v));
    int ans = v[n/2]-v[n/2-1];
    cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

bool even_string(string S) {
    if (S.size() % 2 != 0) return false;
    REP(i, S.size() / 2) {
        if (S[i] != S[S.size() / 2 + i]) return false;
    }
    return true;
}

int main() {
    string S;
    cin >> S;
    int size = S.size();
    RREP(i, size) {
        if (even_string(S.substr(0, i))) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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

int main() {
  int N; cin >> N;
  map<string, int> odd;
  map<string, int> even;
  for(int i = 0; i < N; i++) {
    string a; cin >> a;
    if(i % 2 == 1) {
      if(odd.count(a) > 0) {
        odd.at(a)++;
      } else {
        odd[a] = 1;
      }
    } else {
      if(even.count(a) > 0) {
        even.at(a)++;
      } else {
        even[a] = 1;
      }
    }
  }

  pair<string,int> oddMaxV = make_pair("", 0);
  pair<string,int> oddMaxS = make_pair("", 0);
  for(auto o = odd.begin(); o != odd.end() ; ++o ) {
    if(oddMaxV.second <= o->second) {
      oddMaxS = oddMaxV;
      oddMaxV = make_pair(o->first, o->second);
    } else if(oddMaxS.second < o->second) {
      oddMaxS = make_pair(o->first, o->second);
    }
  }

  pair<string,int> evenMaxV = make_pair("", 0);
  pair<string,int> evenMaxS = make_pair("", 0);
  for(auto o = even.begin(); o != even.end() ; ++o ) {
    if(evenMaxV.second < o->second) {
      evenMaxS = evenMaxV;
      evenMaxV = make_pair(o->first, o->second);
    } else if(evenMaxS.second < o->second) {
      evenMaxS = make_pair(o->first, o->second);
    }
  }

  if(oddMaxV.first != evenMaxV.first) {
    cout << N - oddMaxV.second - evenMaxV.second << endl;
  } else {
    if( (oddMaxV.second - (oddMaxS.second) ) < (evenMaxV.second - (evenMaxS.second)) ) {
      cout << N - oddMaxS.second - evenMaxV.second << endl;
    } else {
      cout << N - oddMaxV.second - evenMaxS.second << endl;
    }
  }
}


Measured memory_bytes: 11136
top, back, right, left, front, bottom = [int(i) for i in input().split()]
for i in input():
    if i == "N":
        top, front, bottom, back = back, top, front, bottom
    elif i == "S":
        top, front, bottom, back = front, bottom, back, top
    elif i == "E":
        top, left, bottom, right = left, bottom, right, top
    else:
        top, left, bottom, right = right, top, left, bottom
print(top)



Measured memory_bytes: 5604
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<time.h>
#include<cstring>
#include<iomanip>
#include<numeric>
#include<list>
#include<stack>
#include<sstream>
#define lli long long int
#define h 10000
#define pf push_front
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
using namespace std;
int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL) ;
  lli t, flag, i, l, j, k, x, y=0, n, m;
  string a;
  	cin>>x;
  	stringstream ss;
  	ss<<x;
  	ss>>a;
    for(i=0;i<a.size();i++) 
    y+=(a[i]-'0');
    if(x%y==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  return 0;
} 


Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
using ld = long double;

int b[110];
int a[110];
int cnt[110];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(5);

    string s;
    cin >> s;
    int n = s.size();
    int cnt = 0;
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')
        {
            cnt++;
        }
        else
        {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

template<class T>
void copy(vector<T> from, vector<T> to) {
  copy(from.begin(), from.end(), back_inserter(to));
}

template<class T>
void sort(vector<T> a) {
  sort(a.begin(), a.end());
}

template<class T>
void input_to(vector<T> a) {
  T a_i;
  cin >> a_i;
  a.push_back(a_i);
}

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  
  int n = -1 * a + b;
  if (n <= 0) {
    cout << "delicious" << endl;
  } else if (n > x) {
    cout << "dangerous" << endl;
  } else {
    cout << "safe" << endl;
  }
}

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

using namespace std;

int main(void)
{
	string str;
	getline(cin,str);
	string w[2]={"apple","peach"};
	string t[2]={"topeac","toappl"};
	for(int i=0;i<2;i++){
		while(1){
			if(str.find(w[i])!=string::npos){
				str.replace(str.find(w[i]),w[i].length(),t[i]);
			}
			else break;
		}
	}
	for(int i=0;i<2;i++){
		while(1){
			if(str.find(t[i])!=string::npos){
				str.replace(str.find(t[i]),t[i].length(),w[1-i]);
			}
			else break;
		}
	}
	cout<<str<<endl;
}

Measured memory_bytes: 1204