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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

ll n;
vector<ll> v;

ll solve(ll l, ll r) {
	ll res;
	if (l == r) {
		return 0;
	}
	FOR(i, l, r) {
		if (v[i] == 0) {
			res = solve(l, i) + solve(i + 1, r);
			return res;
		}
	}
	FOR(i, l, r) {
		v[i]--;
	}
	return solve(l, r) + 1;
}

signed main() {
	ll h;

	cin >> n;

	REP(i, n) {
		cin >> h;
		v.push_back(h);
	}

	cout << solve(0, n) << endl;
}

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

char a[55],b[55];
int main(){
	scanf("%s",a);
	int ta=strlen(a);
	getchar();
	scanf("%s",b);
	int tb=strlen(b);
	if(ta>tb){
		for(int i = 0;i<tb;++i){
			printf("%c",a[i]);
			printf("%c",b[i]);
		}
		for(int i = tb;i<ta;++i)
			printf("%c",a[i]);
	}
	else if(ta<=tb){
		for(int i = 0;i<ta;++i){
			printf("%c",a[i]);
			printf("%c",b[i]);
		}
		for(int i = ta;i<tb;++i)
			printf("%c",a[i]);
	}
	
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main() {
	long long ans, s, x;
	int n;
	scanf("%d", &n);
	ans = 0;
	s = 0;
	f(i, n) {
		scanf("%lld", &x);
		if (x == 0) {
			ans += (s / 2);
			s = 0;
		}
		else s += x;
	}
	ans += (s / 2);
	s = 0;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	char str[20];
	while(scanf("%s",str+1)!=EOF)
	{
		str[6]=' ';
		str[14]=' ';
        printf("%s\n",str+1);
		
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
 int  i=0,a=0,b=0;
 char s[100000];

 scanf("%s",s);
 while(s[i]=='1' || s[i]=='0'){
    if     (s[i]=='1') a=a+2;
    else if(s[i]=='0') b=b+2;
    i=i+1;
 }
 if(a<=b) printf("%d\n",a);
 else     printf("%d\n",b);
 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n;
    cin >> n ;
    vector<int>A(n),B(n);
    for(int i=0;i<n;i++){
        cin >> A[i];
        B[i] = A[i];
    }
    sort(B.begin() , B.end());
    int cnt = 0;

    for(int i=0;i<n;i++){
        if(A[i] != B[i]) cnt++;
    }

    if(cnt > 2){
        cout<<"NO"<<'\n';
    }
    else{
        cout<<"YES"<<'\n';
    }
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

int N;
string  S;

void solve(){
    int K;cin>>K;

    vint lis;
    int cur=0;
    int ans=0;
    int num=0;
    int sum=0;

    vint vec;
    rep(i,N){
        if(S[i]=='D'){
            lis.push_back(i);
            sum-=num;
            vec.push_back(num);
        }
        else if(S[i]=='M'){
            num++;
        }
        else if(S[i]=='C'){
            while(cur<lis.size()&&i-lis[cur]>=K)sum+=vec[cur++];
            ans+=num*(lis.size()-cur)+sum;
        }
    }
    cout<<ans<<endl;
}

signed main(){
    cin>>N>>S;
    int Q;cin>>Q;
    while(Q--)solve();
}

Measured memory_bytes: 22872
# solution

import fractions

data = int(input())
nim = list(map(int, input().split()))
result = 0

for i in range(100):
	prev = 0
	for j,h in enumerate(nim):
		if prev == 0 and h != 0:
			result+=1
		prev = h
		if h != 0:
			nim[j]-=1
	if sum(nim) == 0:
		break

print(result)

Measured memory_bytes: 5052
// ABC074 C - Sugar Water.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <stack>


using lolo=long long;
using namespace std;
using vec=vector<lolo>;
using pari=pair<lolo, lolo>;
using vvec=vector<vec>;
using vecb=vector<bool>;
using Rpriority_queue=priority_queue<lolo, vector<lolo>, greater<lolo>>;
using priority_Q = priority_queue<lolo>;

#define FOR(i,n) for (lolo i=0; i<n; ++i)
#define FORIT(it,V) for (auto it=V.begin(); it!=V.end(); ++it)
#define FORANGE(v, V) for (auto v : v)
#define FORN(i,a,b) for (lolo i=a; i<b; ++i)
#define REV(i,a,b) for (lolo i=a; i>b; --i)
#define REVCNT(i, const_cnt, N) for (lolo i=N-1, cnt=const_cnt; cnt > 0; --cnt, --i)
#define ALL(x) x.begin(), x.end()


template <class T>
void chmax(T& ans, const T& b)
{
	if (ans < b) {
		ans = b;
	}
}

int main()
{
	lolo A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	//vector< vector< lolo> > MEMO(F+1, vector<lolo>(-1, F+1));
	set<lolo> waters; // 可能な水の重さの集合
	set<lolo> sugers; // 可能な水の重さの集合
	stack<lolo> stack;
	stack.push(0);
	while (!stack.empty()) {
		auto v = stack.top(); stack.pop();
		if (v <= F) {
			waters.insert(v);
			if (!waters.count(v + 100 * A));
				stack.push(v + 100 * A);
			if (!waters.count(v + 100 * B));
				stack.push(v + 100 * B);
		}							
	}
	stack.push(0);
	while (!stack.empty()) {
		auto v = stack.top(); stack.pop();
		if (v <= F) {
			sugers.insert(v);
			if (!sugers.count(v +C )) 
				stack.push(v + C)	;
			if (!sugers.count(v + D))
				stack.push(v + D);
		}
	}

	double maxDens = 0;
	lolo maxSuger = 0;
	lolo maxWater = *next(waters.begin());
	const double limitDense = static_cast<double>(100 * E) / (100 + E);
	for (auto suger_w : sugers) {
		for (auto water_w : waters) {
			auto sum = suger_w + water_w;
			if (sum > F) break;
			if (sum == 0) continue;
			auto dens = static_cast<double>(100 * suger_w) / (sum);
			if (dens > limitDense) continue;
			if (dens > maxDens) {
				chmax(maxDens, dens);
				maxSuger = suger_w;
				maxWater = water_w;
			}
		}
	}
	cout << maxSuger + maxWater << " " << maxSuger << endl;
	

}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

int main()
{  
   int n,k;
   cin>>n>>k;
   int a[200010];
   for(int i=0;i<n;i++){
       cin>>a[i];
   }
   int num[200001]={0};
   for(int i=0;i<n;i++) num[a[i]]++;
   sort(num,num+200001,greater<int>());
   int S=n;
   for(int i=0;i<k;i++) S-=num[i];
   cout<<S<<endl;

} 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define PR pair<int, int>
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
//constexpr int MOD = 10e9+7;
constexpr int INF = 1LL << 60;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int N;
  cin >> N;
  int h;
  int pre = 0;
  int ans = 0;
  rep(i,N)
  {
    cin >> h;
    if(h>pre) {
      ans +=h-pre;
    }
    pre = h;
  }
  cout << ans <<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll arr[200005],pref[200005],sum=0,ans=0,n,m=1e9+7;
    vector <ll> adj;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    pref[0]=arr[0];
    sum+=arr[0];
    for(int i=1;i<n;i++)
    {
        pref[i]=arr[i]+pref[i-1];
        sum+=arr[i];
    }
    for(int i=1;i<n;i++)
    {
        adj.push_back(sum-pref[i-1]);
    }
    for(int i=0;i<adj.size();i++)
    {
        ans=(ans%m+((arr[i]%m)*(adj[i]%m))%m)%m;
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 8480
#include <stdio.h>
#include <stdlib.h>
#define NIL -1

typedef struct node{
  int id;
  int k;
  int parent;
  int *c;
}node;

void printTree(node*,int);
int depth(node*,int,int);

int main(){
  node *tree;
  int i,j,n,id,k;

  scanf("%d",&n);
  tree = (node *)malloc(sizeof(node)*n);
  for(i=0;i<n;i++) tree[i].parent = -1;

  for(i=0;i<n;i++){
    scanf("%d %d",&id,&k);
    tree[id].c = (int *)malloc(k*sizeof(int));
    tree[id].id=id;
    tree[id].k=k;
    for(j=0;j<tree[id].k;j++){
      scanf("%d",&tree[id].c[j]);
      tree[tree[id].c[j]].parent = id;
    }
  }

  printTree(tree,n);
    
  return 0;
}

void printTree(node* tree,int n){
  int i,j,d;
  
  for(i=0;i<n;i++){
    d=depth(tree,i,0);
    printf("node %d: parent = %d, depth = %d, ",i,tree[i].parent,d);
    if(d == 0) printf("root, [");
    else if(tree[i].k == 0) printf("leaf, [");
    else printf("internal node, [");
    for(j=0;j<tree[i].k;j++){
      if(j != 0) printf(", ");
      printf("%d",tree[i].c[j]);
    }
    printf("]\n");
  }
  
  return;
}

int depth(node* tree,int c,int d){
  if(tree[c].parent == NIL) return d;
  else{
    d++;
    return depth(tree,tree[c].parent,d);
  }
}
  

Measured memory_bytes: 6468
#include<stdio.h>
int gcd(int a,int b,int c){
    int k;
    if(a>=b){
        int temp;
        temp=b;
        b=a;
        a=temp;
    }
    if(b>=c){
        int temp;
        temp=c;
        c=b;
        b=temp;
    }
    if(a>=b){
        int temp;
        temp=b;
        b=a;
        a=temp;
    }
    for(int i=1;i<=a;i++){
        if(a%i==0 && b%i==0 && c%i==0){
            k=i;
        }
    }
    return k;
}
int main(){
    int k;
    int sum=0;
    scanf("%d",&k);
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int z=1;z<=k;z++){
               // gcd(i,j,k);
                sum+=gcd(i,j,z);
            }
        }
    }
    printf("%d",sum);
    
}

Measured memory_bytes: 1704
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <string>

namespace Mylib{
    using namespace std;
    
}

int main(void){
    using namespace std;
    int A,B,C;
    cin >> A >> B >> C;
    
    if((A==B&&B==C&&A==C)||(A!=B&&B!=C&&A!=C)){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <map>
 
using namespace std;
#define x1 jkflwjjkfjekjfe
#define x2 fwekwfefekfje
 
int iter = log(100 * 100 * 10000) / log(3) + 20;
typedef complex<double> P;
struct L{
	P a,b;
};
vector<double> ax,ay;
vector<L> ls;
double R,cx,cy;
 
bool eq(double a,double b){
	return fabs(a-b) < 1e-7;
}
bool eq2(double a,double b){
	return fabs(a-b) < 1e-8;
}
 
pair<double,double> seg(double y){
	double x1 = +1e5;
	double x2 = -1e5;
	for( auto &&l : ls){
		if( eq(l.a.imag(),y) ){
			x1 = min(x1,l.a.real());
			x2 = max(x2,l.a.real());
		}
		if( eq(l.b.imag(),y) ){
			x1 = min(x1,l.b.real());
			x2 = max(x2,l.b.real());
		}
		if( l.a.imag() + 1e-7 < y and y < l.b.imag() - 1e-7 ){
			P v = (l.b - l.a);
			P p = l.a + v * (y-l.a.imag()) / v.imag();
			x1 = min(x1,p.real());
			x2 = max(x2,p.real());  
		}
	}
	return {x1,x2};
}
 
double len(pair<double,double> p){
	if( p.first < p.second ) return p.second - p.first;
	return 0;
}
pair<double,double> merge(const pair<double,double> &a,const pair<double,double> &b){
	return {max(a.first,b.first),min(a.second,b.second)};
}
 
double g(double y){
	if( R - abs(y-cy) < 1e-7 ) return 0;
	// for given y, compute the overlapped length of the circle and the polygon.
	double t = sqrt(R*R-(cy-y)*(cy-y));
	pair<double,double> circle_seg = {cx-t,cx+t};
	return len(merge(circle_seg,seg(y)));
}
 
double simpson(double l,double r){
	return (r-l)/6*(g(l)+4*g((l+r)/2)+g(r));
}
double integral(double l,double r,int k=5){
	if( l >= r ) return 0;
 
	double m = (l+r) / 2;
	double A = simpson(l,m) + simpson(m,r);
	double B = simpson(l,r);
	if( k<=0 and eq2(A,B) ) return A;
	else return integral(l,m,k-1) + integral(m,r,k-1);
}
 
double f(double x,double y){
	cx = x;
	cy = y;
	double ans = 0;
	for(int i = 0 ; i+1 < ay.size() ; i++){
		ans += integral(max(cy-R,ay[i]),min(cy+R,ay[i+1]));
	}

	return ans;
}
		
double search2(double y){
	double ans = 0;
	double l,r;
 
	tie(l,r) = seg(y);
 
	for(int i = 0 ; i < iter ; i++){
		double a = (2*l+r) / 3;
		double b = (l+2*r) / 3;
		if( f(a,y) < f(b,y) ){
			l = a;
		}else{
			r = b;
		}
	}
	return f(l,y);
}
 
double search1(){
	double ans = 0;
	double l = ay.front(), r = ay.back();
	for(int i = 0 ; i < iter ; i++){
		double a = (2*l+r) / 3;
		double b = (l+2*r) / 3;
		if( search2(a) < search2(b) ){
			l = a;
		}else{
			r = b;
		}
	}
	
	return search2(l);
}
 
int main(){
	int n;
	cin >> n >> R;
	vector<P> g(n+1);
	for(int i = 0 ; i < n ; i++){
		double x,y;
		cin >> x >> y;
		g[i] = P(x,y);
		ax.push_back(x);
		ay.push_back(y);
	}
	g[n] = g[0];
	 
	for(int i = 0 ; i < n ; i++){
		ls.push_back({g[i],g[i+1]});
		if( ls.back().a.imag() > ls.back().b.imag() ) swap(ls.back().a,ls.back().b);
	}

	sort(ax.begin(),ax.end());
	sort(ay.begin(),ay.end());
	ax.erase(unique(ax.begin(),ax.end()),ax.end());
	ay.erase(unique(ay.begin(),ay.end()),ay.end());
	//printf("%.10lf\n",f(0,0));
 	//return 0;
 	
	printf("%.10lf\n",search1());
 
}

Measured memory_bytes: 3336
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
using namespace std;
const int maxn=2e5+10;
vector<ll>a;
vector<ll>b;
ll s[maxn][2];
const int mod=1e9;

int main() {
	int n;
	cin>>n;
	ll u,v;
	for(int i=0;i<n;i++) {
		cin>>s[i][0]>>s[i][1];
		a.push_back(s[i][0]+s[i][1]);
		b.push_back(s[i][0]+mod-s[i][1]);
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	ll ans=abs(a[n-1]-a[0]);
	ans=max(ans,abs(b[n-1]-b[0]));
	cout<<ans<<endl;
}

Measured memory_bytes: 9680
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const r = parseInt(args[0][0], 10)
	const d = parseInt(args[0][1], 10)
	let x = parseInt(args[0][2], 10)

	for (let i = 0; i < 10; i++) {
		x = r * x - d 
		console.log(x)
	}
}

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


Measured memory_bytes: 7628
#include <stdio.h>

int main(void)
{
	int m, f, r;
	char s;
	
	while(1){
		scanf("%d%d%d", &m, &f, &r);
		if((m == -1) && (f == -1) && (r == -1)) break;
		if((m == -1) || (f == -1))	s = 'F';
		else if((m + f) >= 80)		s = 'A';
		else if((m + f) >= 65)		s = 'B';
		else if((m + f) >= 50)		s = 'C';
		else if((m + f) >= 30){
			if(r >= 50)				s = 'C';
			else					s = 'D';
		}else						s = 'F';
		printf("%c\n", s);
	}
	
	return(0);
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  vector<ll> vec(n+2, 0);
  for (int i= 1; i < n+1; i++) {
    cin >> vec[i];
  }
  n += 2;
  ll total = 0;
  for (int i = 1; i < n; i++) {
    total += abs(vec[i-1] - vec[i]);
  }
  for (int i = 0; i < n-2; i++) {
    int a = abs(vec[i] - vec[i+1]) + abs(vec[i+1] - vec[i+2]);
    int b = abs(vec[i] - vec[i+2]);
    
    cout << total - a + b << endl;
  }
  
  return 0;
}

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

const int INF = 1001001001;

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int> (m));
    rep(i, 0, n){
        cin >> c[i];
        rep(j, 0, m){
            cin >> a[i][j];
        }
    }
    int ans = INF;
    rep(i, 0, 1<<n){
        int sum = 0;
        bool flag = true;
        vector<int> cost(m);
        rep(j, 0, n){
            if(i&1<<j){
                sum += c[j];
                rep(k, 0, m){
                    cost[k] += a[j][k];
                }
            }
        }
        rep(j, 0, m){
            if(cost[j] < x) flag = false;
        }
        if(flag) ans = min(ans, sum);
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3600
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
string s;
int n, a, b, c, d;
bool can[300002];
bool can2[300002];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> a >> c >> b >> d;
    cin >> s;
    --a, --b, --c, --d;
    if(b < d)
    {
        can[a] = 1;
        for(int i = a; i <= b; ++i)
            if(can[i])
            {
                if(i + 1 < n && s[i+1] != '#')
                    can[i+1] = 1;
                if(i + 2 < n && s[i+2] != '#')
                    can[i+2] = 1;
            }
        can2[c] = 1;
        for(int i = c; i <= d; ++i)
            if(can2[i])
            {
                if(i + 1 < n && s[i+1] != '#')
                    can2[i+1] = 1;
                if(i + 2 < n && s[i+2] != '#')
                    can2[i+2] = 1;
            }
        if(can[b] && can2[d])
            cout << "Yes";
        else
            cout << "No";
    }
    else
    {
        can[a] = 1;
        for(int i = a; i <= b; ++i)
            if(can[i])
            {
                if(i + 1 < n && s[i+1] != '#')
                    can[i+1] = 1;
                if(i + 2 < n && s[i+2] != '#')
                    can[i+2] = 1;
            }
        can2[c] = 1;
        for(int i = c; i <= d; ++i)
            if(can2[i])
            {
                if(i + 1 < n && s[i+1] != '#')
                    can2[i+1] = 1;
                if(i + 2 < n && s[i+2] != '#')
                    can2[i+2] = 1;
            }
        if(!can[b] || !can2[d])
        {
            cout << "No";
            return 0;
        }
        for(int i = 0; i + 1 <= min(b, d); ++i)
            if(can[i] && can2[i+1] && s[i] == '.' && s[i+1] == '.' && s[i+2] == '.')
            {
                cout << "Yes";
                return 0;
            }
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 848
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
using ll = long long;
ll mod = 1e9+7;
ll modpow(ll a, ll b){
    ll res = 1;
    ll temp = a;
    while(b){
        if(b&1){
            res = res * temp % mod;
        }
        b /= 2;
        temp = temp * temp % mod;
    }
    return res;
}
int main(){
    string s;
    ll ans = 0;
    cin >> s;
    int cnt = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '1'){
            ans = (ans + modpow(2,cnt) * modpow(3,s.size()-1-i)) % mod;
            cnt++;
        }
    }
    ans = (ans + modpow(2,cnt)) % mod;
    cout << ans << endl;
}


Measured memory_bytes: 512
s = input()
t = input()

sl = len(s)
tl = len(t)
diff = tl
for i in range(sl-tl+1):
    curr = 0
    for j in range(tl):
        if s[i+j] != t[j]:
            curr += 1
    diff = min(diff, curr)
print(diff)


Measured memory_bytes: 9052
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int K, A, B;
    cin >> K;
    cin >> A >> B;
    bool flag = false;

    for(int i=A; i <=B; ++i){
        if( i%K == 0 ){
            flag = true;
            break;
        }
    }

    if(flag){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;

    }
}


Measured memory_bytes: 3632
from heapq import heappush, heappop

X, Y, Z, K = map(int, input().split())

A = sorted([int(e) for e in input().split()], reverse=True)
B = sorted([int(e) for e in input().split()], reverse=True)
C = sorted([int(e) for e in input().split()], reverse=True)


def get_value(ai, bi, ci):
    return -(A[ai] + B[bi] + C[ci])


heap = []
heappush(heap, (get_value(0, 0, 0), 0, 0, 0))
used = {(0, 0, 0)}

for k in range(K):
    v, ia, ib, ic = heappop(heap)
    print(-v)

    if ia + 1 < X and (ia + 1, ib, ic) not in used:
        heappush(heap, (get_value(ia + 1, ib, ic), ia + 1, ib, ic))
        used.add((ia + 1, ib, ic))
    if ib + 1 < Y and (ia, ib + 1, ic) not in used:
        heappush(heap, (get_value(ia, ib + 1, ic), ia, ib + 1, ic))
        used.add((ia, ib + 1, ic))
    if ic + 1 < Z and (ia, ib, ic + 1) not in used:
        heappush(heap, (get_value(ia, ib, ic + 1), ia, ib, ic + 1))
        used.add((ia, ib, ic + 1))


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

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

const ll mod  = 1e9+7;
const db eps  = 1e-9 ;
const ll maxn = 1e5+1;
const ll inf = LLONG_MAX;

#define mp make_pair
#define pb push_back
#define endl "\n"
#define deb(x) cout << #x << " " << x << endl

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ull n,sum=0;
    cin >> n;

    for(ull i=1 ; i<=n ; ++i)
    {
        if( ((i%3)!=0) && ((i%5)!=0) )
            sum+=i;
    }
    
    cout << sum;
    return 0;
} 

Measured memory_bytes: 3648
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""

import numpy as np
import sys
""""
import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter
import itertools
import copy
import bisect
"""

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


"""
N, X = map(int, input().split())

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

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

"""
A, B, T = map(int, input().split())

def main():
    print((T//A)*B)
    
if __name__ == '__main__':
    main()


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

int main() {
    
    int n;
    cin >> n;
    string s;
    cin >> s;
  
    int l=s.size();
  
    for(int i=0;i<l;i++) {
        int x=s[i]+n;
        if(x>90)
        x=x-26;
        s[i]=(char)x;
    }
    cout << s << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;
#define MAX_N 100000000
int main() {
  int N;
  int ans = 0;
  cin >> N;
  while (N > 0) {
	  if (N % 10 == 2) {
		  ans++;
		}
	  N /= 10;
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
X[]={1,0,-1,0},Y[]={0,1,0,-1},s[11][11];char *D="RDLU";
main(x,y,i,j,z){
	x=y=5;
	for(j=0;j<2*y;j++)for(i=0;i<2*x;i++)s[i][j]=0;
	for(j=1;j<2*y;getchar(),j++)
		for(i=(j&1)?2:1;i<2*x;i+=2){
			s[i][j]=getchar()-'0';
		}
	putchar('R');
	for(z=0,x=3,y=1;x!=1||y!=1;){
		z=(z+3)%4;
		for(;!s[x+X[z]][y+Y[z]];z=(z+1)%4);
		x+=X[z]*2,y+=Y[z]*2;
		putchar(D[z]);
	}
	puts("");exit(0);
}

Measured memory_bytes: 524
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)

b1 = [i[0] for i in c.items() if i[1] >= 4]
b2 = [i[0] for i in c.items() if i[1] >= 2]
b = b1 + b2 + [0,0]

b.sort()
print(b[-1]*b[-2])

Measured memory_bytes: 22268
typedef int ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    ll a,b;
    std::cin >> a>>b;
    if(a*b%2 ==0){
        std::cout << "No" << std::endl;
    }else{
        std::cout << "Yes" << std::endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
using namespace std ;
int n;
/*ll waka_waka(vector<vector<int>> inp,vector<vector<ll>> dp,int i=0,int act=-1)
{
    if(i == n) return 0;
    
    ll ans=0;
    for(int j=0;j<3;j++)
    {
        if(j != act)
        {
            if(dp[i][j] == -1) dp[i][j] = inp[i][j] + waka_waka(inp,dp,i+1,j);
            ans = max(ans,dp[i][j]);
        }
    }
    return ans;
}*/

ll bottoms_up(vector<vector<int>> inp,vector<vector<ll>> dp)
{
    dp[n-1][0] = inp[n-1][0];
    dp[n-1][1] = inp[n-1][1];
    dp[n-1][2] = inp[n-1][2];
    
    for(int i=n-2;i>=0;i--)
    {
        for(int j=0;j<3;j++)
        {
            ll ans=0;
            for(int k=0;k<3;k++)
            {
                if(j!=k) ans =max(ans,dp[i+1][k]);
            }
            dp[i][j] = inp[i][j]+ans;
        }
    }
    ll final_ans = max(dp[0][0],dp[0][1]);
    final_ans = max (final_ans,dp[0][2]);
    return final_ans;
}

int main()
{
    cin>>n;
    
    std::vector<vector<int>> inp(n,vector<int>(3));
    for(int i=0;i<n;i++)
    {
        cin>>inp[i][0]>>inp[i][1]>>inp[i][2];
    }
    vector<vector<ll>> dp(n,vector<ll> (3,-1));
    
    cout<<bottoms_up(inp,dp)<<endl;
}

Measured memory_bytes: 25076
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll n;
	cin >> n;

	unordered_set<string> ust;
	rep(i, n){
		string s;
		cin >> s;
		ust.insert(s);
	}
	co(ust.size());

	return 0;
}


Measured memory_bytes: 17620
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll S;cin>>S;
  ll x1,x2,y1,y2;
  ll i,j;

  //S=x1*y2-x2*y1
  if(S<=INF){
    x1=S;x2=0;y1=0;y2=1;
    cout<<0<<" "<<0<<" "<<x1<<" "<<0<<" "<<0<<" "<<y2<<endl;
    return 0;
  }
  //elseの時はまず2で割れる形にする
  else{
    x1=INF;
    y2=(S+INF-1)/INF;
    ll s=x1*y2-S;
    x2=s;
    y1=1;
    cout<<0<<" "<<0<<" "<<x1<<" "<<x2<<" "<<y1<<" "<<y2<<endl;
    return 0;
  }
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================
int main() {
  // 入力
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  vector<ll> dp(n);
  for (int i = 0; i < n; i++) dp[i] = INFL;
  dp[0] = 0;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      if (i - j < 0) break;
      dp[i] = min(dp[i], dp[i - j] + abs(v[i] - v[i - j]));
    }
  }

  cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1408
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65
//おまじない



int main() {

	int x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int a,b;


	a = x1 - x2;
	b = y1 - y2;

	cout << x2 + b << ' ' << y2 - a << ' ' << x1 + b << ' ' << y1 - a<<endl;
	

	return 0;
}


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    vec<ll> x(n), y(n);
    REP(i, n) {
        cin >> x[i] >> y[i];
    }

    vec<ll> o(n);
    REP(i, n) {
        o[i] = i;
    }

    ll con = 0;
    ld sum = 0;
    do {
        REP(i, n - 1) {
            sum += sqrt((x[o[i]] - x[o[i + 1]]) * (x[o[i]] - x[o[i + 1]]) + (y[o[i]] - y[o[i + 1]]) * (y[o[i]] - y[o[i + 1]]));
        }
        con++;
    } while(next_permutation(all(o)));

    ld ans = sum / (ld)con;
    cout << fixed << setprecision(10) << ans << en;
}

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

    solve();

    /*
    ll t;
    cin >> t;
    REP(i, t) { solve();}
    */

    return 0;
}


Measured memory_bytes: 3816
// Lets go to the next level
// AIM EXP at CF *__* asap
// Hit A,B,C faster and reach Expert
// Remember you were also a novice when you started,
// hence never be rude to anyone who wants to learn something!Be calm and help everyone.
// Never open the rank list until and unless you are done with solving problems!

//Author: kaiyu
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define leastsigbit(x)     __builtin_ffs(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int,int>
#define vpii vector<pii>
#define tt ll tt;cin >> tt;while(tt--)
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n";}
const double PI = acos(-1);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
struct cmp {
    bool operator() (const pair<int,int>& lhs, const pair<int,int>& rhs) const {
        return lhs.ff * rhs.ss < lhs.ss * rhs.ff;
    }
//for map<pii,int>
};

bool cmps(pair<int,int>p1,pair<int,int>p2) {
    return p1.ss > p2.ss;
}

const int MAXN = 1e6+ 10;

#define int long long
int n;
int a[MAXN];
int have[MAXN],mark[MAXN];
void work() {
    for (int i = 1; i < MAXN ; ++i) {
        if(have[i]) {
            if(have[i]>=2){
                mark[i] = 1;
            }
            for (int j = 2; i * j < MAXN; ++j) {
                mark[i*j] = 1;
            }
        }
    }
}
int32_t main() {
//#ifndef ONLINE_JUDGE
    //freopen("inp1.txt","r",stdin);
    //freopen("out1.txt","w",stdout);
//#endif
    fio

    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        have[a[i]]++;
    }
    int ans = 0;
    work();
    for(int i = 1; i <= n; i++)
        ans += !mark[a[i]];
    cout << ans;
    cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}






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

int countDigits(llong num) {
	int digit = 0;
	while (num) {
		num /= 10;
		digit++;
	}
	return digit;
}

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

	int res = countDigits(N);
	for (llong A = 1LL; A*A <= N; A++) {
		if (N%A != 0) continue;
		llong B = N / A;
		res = min(res, max(countDigits(A), countDigits(B)));
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define REP(i,a,b) for (int i = (a); i < (int)(b); i++)
#define rep(i,a) REP(i,0,a)

using namespace std;

vector<string> ans;

void search(string s, char c) {
    if (c == 'a') {
        ans.push_back(s);
        return;
    }
    
    rep(i, s.size()) {
        if (s[i] == c) return;
        
        if (s[i] == c-1) {
            string t(s);
            t[i] = c;
            
            search(t, c-1);
        }
    }
    search(s, c-1);
}

int main(void){
    while (1) {
        string S;
        cin >> S;
        if (S == "#") break;
        
        ans.clear();
        search(S,'z');
        
        sort(ans.begin(), ans.end());
        ans.erase(unique(ans.begin(), ans.end()), ans.end());
        
        cout << ans.size() << endl;
        if (ans.size() <= 10) {
            rep(i, ans.size()) cout << ans[i] << endl;
        }
        else {
            rep(i, 5) cout << ans[i] << endl;
            rep(i, 5) cout << ans[ans.size()-5+i] << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 2352
#define y1 askjdkasldjlkasd
#include <bits/stdc++.h>
#undef y1

using namespace std;

#define pb push_back
#define mp make_pair
#define fi(a, b) for(int i=a; i<=b; i++)
#define fj(a, b) for(int j=a; j<=b; j++)
#define fo(a, b) for(int o=a; o<=b; o++)
#define fdi(a, b) for(int i=a; i>=b; i--)
#define fdj(a, b) for(int j=a; j>=b; j--)
#define fdo(a, b) for(int o=a; o>=b; o--)
#define sz(x) (int)x.size()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<ll> vll;

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while (0)
#endif

double START_TIME;

void exit() {
#ifdef LOCAL	
	cerr << "TIME: " << setprecision(5) << fixed << (clock() - START_TIME) / CLOCKS_PER_SEC << endl;
#endif	
	exit(0);
}

template<typename A, typename B>
ostream& operator<<(ostream& os, pair<A, B> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
	fi(0, sz(v) - 1) {
		os << v[i] << " ";
	}
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T> t) {
	for (auto z : t) {
		os << z << " ";
	}
	return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2> t) {
	cerr << endl;
	for (auto z : t) {
		os << "\t" << z.first << " -> " << z.second << endl;
	}
	return os;
}

#ifdef LOCAL
#define dbg(x) {cerr << __LINE__ << "\t" << #x << ": " << x << endl;}
#define dbg0(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 0; ABC < n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#else
#define dbg(x) while(0){}
#define dbg0(x, n) while(0){}
#endif

#ifdef LOCAL
#define ass(x) if (!(x)) { cerr << __LINE__ << "\tassertion failed: " << #x << endl, abort(); }
#else
#define ass(x) assert(x)
#endif

///////////////////////////////////////////////////

const int MAX = 141;

int n;
char s[MAX];


void solve () {
	int b = 0;
	fi(0, n - 1) {
		if (s[i] == 'R') b++;
		else b--;
	}
	if (b > 0) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	START_TIME = (double)clock();
#endif
		
	scanf("%d", &n);
	scanf("%s", s);
	solve();

	exit();
	return 0;
}





Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n, x;
	scanf("%d", &n);
	
	for (int i = 1; i <= n; i++) {
		x = i;
		if (x % 3 == 0) {
			printf(" %d", i);
		} else {
			do {
				if (x % 10 == 3) {
					printf(" %d", i);
					x = 0;
				} else {
					x /= 10;
				}
			} while (x);
		}
	}

	printf("\n");
	return 0;
}

Measured memory_bytes: 2688
#if defined(LOCAL)
#define PROBLEM_NAME "d"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#else
#define L(x, ...) (x)
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)
#define max(a,b)({__typeof__(a)__x=(a);__typeof__(b)__y=(b);__x>__y?__x:__y;})
#define min(a,b)({__typeof__(a)__x=(a);__typeof__(b)__y=(b);__x<__y?__x:__y;})

void solve(istream& cin, ostream& cout) {
  l n, m, k; cin >> n >> m >> k;
  F(i, 0, n) {
    F(j, 0, m) {
      l x = (i + j) / k, y = (i - j + m + n) / k;
      if (x % 2) {
        cout << ((y % 2) ? "R" : "G");
      } else {
        cout << ((y % 2) ? "B" : "Y");
      }
    }
    cout << lf;
  }
}

// return false to stop
bool generate_random(l tc, ostream& cout) {
  l max_cases = 10000;
  if (tc % (max_cases / 100) == 0) cerr << (tc * 100 / max_cases) << "%\r";
  cout << (tc % 10 + 1) << ' ' << ((tc / 10) % 10 + 1) << ' ' << ((tc / 100) % 10 + 1) << lf;
  cerr << (tc % 10 + 1) << ' ' << ((tc / 10) % 10 + 1) << ' ' << ((tc / 100) % 10 + 1) << endl;
  return tc < max_cases;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int i;
int main()
{   cin>>s1>>s2;
	int l1=s1.size(),l2=s2.size();
    for(i=0;i<l2;i++)
    cout<<s1[i]<<s2[i];
    if(l1>l2)
    cout<<s1[l1-1]<<endl;//记得减一 
	return 0;
}

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

int a, b, c;

int solve(string s){
	int tmp;
	if(s=="North")tmp=a, a=b, b=7-tmp;
	else if(s=="East")tmp=c, c=a, a=7-tmp;
	else if(s=="West")tmp=a, a=c, c=7-tmp;
	else if(s=="South")tmp=b, b=a, a=7-tmp;
	else if(s=="Right")tmp=b, b=c, c=7-tmp;
	else if(s=="Left")tmp=c, c=b, b=7-tmp;
	return a;
}

int main(){
	string s;
	int n, sum;
	while(cin>>n, n){
		a=1; b=2; c=3;
		sum=1;
		while(n--){
			cin>>s;
			sum+=solve(s);
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1212
n, m = map(int, raw_input().split())
ln = []
for k in range(n):
    a = map(int, raw_input().split())
    ln.append(a[1:])
clist = []
for j in range(1, m+1):
    c = 0
    for i in range(len(ln)):
        if j in ln[i]:
            c += 1 
        else:
            break
    clist.append(c)
print clist.count(n)


Measured memory_bytes: 2568
#include <cstdio>
#ifdef _MSC_VER
#define GC getchar
#else
#define GC getchar_unlocked
#endif
int input()
{
	int x=0;
	char c;
	bool minus=false;
	for(;;)
	{
		c=GC();
		if (c=='-')
		{
			minus=true;
			continue;
		}
		if (c==' '||c=='\n')
			if (minus)
				return -x;
			else
				return x;
		x=10*x+c-'0';
	}
}
void fix()
{
	char c;
	for(;;)
	{
		c=GC();
		if (c==-1||c!=' '&&c!='\n')
			break;
	}
	if (c!=-1)
		ungetc(c,stdin);
}
int main()
{
	int N,i,j,k,d=2;
	int a[6];
	int m[32];
	int M[32];
	for (i=0; i<32; i++)
	{
		m[i]=1000000000;
		M[i]=-1000000000;
	}
	scanf("%d",&N);
	fix();
	for (i=0; i<N; i++)
	{
		for (j=0; j<d; j++)
			a[j]=input();//,fix();
		for (j=0; j<1<<(d-1); j++)
		{
			int x=a[0];
			for (k=0; k<d-1; k++)
				if (j&(1<<k))
					x+=a[k+1];
				else
					x-=a[k+1];
			if (m[j]>x)
				m[j]=x;
			if (M[j]<x)
				M[j]=x;
		}
	}
	int ans=0;
	for (i=0; i<1<<(d-1); i++)
		if (ans<M[i]-m[i])
			ans=M[i]-m[i];
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1728
#include<iostream>
#include<cstring>
#include<cstdio>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef struct{
	int pec;
	int rank;
}node;
map<int, node>mp, mp2; 
int main(){
//	ios::sync_with_stdio(false);
//	ifstream cin("data.txt");
//	freopen("data.txt", "r", stdin);
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= m; i++){
		int p, year;
		cin >> p >> year;
		node x;
		x.pec = p;
		x.rank = i;
		mp.insert(pair<int, node>(year, x));
	}
	map<int, node>::iterator it;
	int yy[100000 + 5];
	for(int i = 0; i < 100000 + 4; i++){
		yy[i] = 1;
	}
	for(it = mp.begin(); it != mp.end(); it++){
		node x;
		int rr = it->second.rank;
		x.pec = it->second.pec;
		x.rank = yy[it->second.pec]++;
		mp2.insert(pair<int, node>(rr, x));
	}
	for(it = mp2.begin(); it != mp2.end(); it++){
		printf("%06d%06d\n", it->second.pec, it->second.rank);
	}
}

Measured memory_bytes: 14464
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define FOR(i, i0, n) for(int i = (i0); i < (n); i ++)
#define COUT(val) cout << (val) << "\n";
using namespace std;
using ll = long long int;

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    FOR(i, 0, n) cin >> a[i];
    
    vector<vector<ll>> dp(n, vector<ll>(n));
    for(int i = 0; i < n; i ++) dp[i][i] = a[i];
    for(int s = 1; s < n; s ++){
        for(int l = 0; l+s < n; l ++){
            int r = l+s;
            dp[l][r] = max(a[l]-dp[l+1][r], a[r]-dp[l][r-1]);
        }
    }
    
    COUT(dp[0][n-1]);
}

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

int main()
{
  int n;
  bool il[101010];

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

  for (int i = 0; i < n; i++){
    il[i] = il[i] ^ (1 & i);
  }

  int ans = 0;
  int l = 0, r = 0;
  while (il[r] && r < n) r++;
  while (r < n){
    while (!il[r] && r < n) r++;
    int nl = r;
    while ( il[r] && r < n) r++;

    ans = max(ans, r - l);
    l = nl;
  }

  l = r = 0;
  while (!il[r] && r < n) r++;
  while (r < n){
    while ( il[r] && r < n) r++;
    int nl = r;
    while (!il[r] && r < n) r++;

    ans = max(ans, r - l);
    l = nl;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3192
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define INF 1 << 30;

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

    int n;
    cin >> n;
    vector<ll> a(n);
    vector<vector<ll>> dp(n+1, vector<ll>(2, 0));
    dp[0][1] = -INF;
    ll sum = 0;
    for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
    for (int i = 0; i < n; i++) {
        dp[i+1][0] = max(dp[i][0]+a[i], dp[i][1]-a[i]);
        dp[i+1][1] = max(dp[i][0]-a[i], dp[i][1]+a[i]);
    }

    cout << dp[n][0] << endl;

}

Measured memory_bytes: 9184