akhauriyash/Code-Regression huggingface dataset:
/*
* @FileName: D:\代码与算法\2017训练比赛\11.18-atcoder\a.cpp
* @Author: Pic
* @Created Time: 2017/11/18 19:49:23
*/
#include <bits/stdc++.h>
using namespace std;
int a[6];
int res[6];//+ is 1,- is -1
int dfs(int now,int tot)
{
	if(now==3){
		if(tot+a[3]==7){
			res[3]=1;
			return 1;
		}
		else if(tot-a[3]==7){
			res[3]=-1;
			return 1;
		}
		else{
			return 0;
		}
	}
	else{
		if(dfs(now+1,tot+a[now])){
			res[now]=1;
			return 1;
		}
		if(dfs(now+1,tot-a[now])){
			res[now]=-1;
			return 1;
		}
	}
	return 0;
}
int main()
{
	string str;
	cin>>str;
	for(int i=0;i<4;i++){
		a[i]=str[i]-'0';
	}	
	dfs(1,a[0]);
	cout<<a[0];
	for(int i=1;i<4;i++){
		if(res[i]==1){
			cout<<'+';
		}
		else{
			cout<<'-';
		}
		cout<<a[i];
	}
	cout<<"=7"<<endl;
}


Measured memory_bytes: 256
N,M=[int(x) for x in str(input()).split()]
X=[]
for i in range(M):
  t=[int(x) for x in str(input()).split()]
  X.append(t)

X.sort()
#print(X)
temp=N+1
ans=0
for j in range(1,M+1):
  if not (X[-j][0]<=temp and temp<=X[-j][1]):
    temp=X[-j][0]+1
    #print(temp)
    ans+=1

print(ans)


Measured memory_bytes: 60640
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
  ll n,k;
  cin>>n>>k;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  map<ll,ll>M;
  rep(i,n)M[a[i]]++;
  vl data;
  for(auto p:M){
    data.push_back(p.second);
  }
  if(data.size()<=k){
    cout<<0<<endl;
    return 0;
  }
  sort(data.begin(),data.end());
  reverse(data.begin(),data.end());
  ll ans=0;
  rep(i,k)ans+=data[i];
  ans=n-ans;
  cout<<ans<<endl;
}

Measured memory_bytes: 16500
/*
 * a.c
 *
 *  Created on: 2017/06/13
 *      Author: AWV060608
 */

#include	<stdio.h>

int		main(void)
{
	int		x, y;

	while(1)
	{
		scanf("%d",&x);
		scanf("%d",&y);

		if( x == 0 && y == 0 )
			break;
		if( x < y)
			printf("%d %d\n",x,y);
		else
			printf("%d %d\n",y,x);
	}

	return 0;
}

Measured memory_bytes: 600
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int from, to, cost; };
struct gNode { int from, to, cost; };
struct tNode { int value; int parent; vector<int> child; };

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

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

int dp[SIZE];

int main(void){
	int n; cin >> n;
	vint h(n);
	rep(i, n) cin >> h[i];
	
	fill(dp, dp+SIZE, INF);
	dp[0] = 0;
	rep(i, n){
		if(i < n-1) dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1] - h[i]));
		if(i < n-2) dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2] - h[i]));
	}
	cout << dp[n-1] << endl;

	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int n,m,x;
int main()
{
	scanf("%d%d",&m,&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		m-=x;
	}
	if (m>=0) printf("%d",m); else printf("-1");
} 

Measured memory_bytes: 3868
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>
#include <complex>

using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const int INF = 1<<30;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<string> c(H);
    rep(i, H) cin >> c[i];
    // count '#'
    int cnt=0;
    rep(i, H) rep(j, W) if(c[i][j] == '#') cnt++;

    deque<vector<int>> q;
    q.push_back({0,0,1}); // x, y, dist
    c[0][0] = '#';
    int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
    int leng = INF;
    while (!q.empty()){
        vector<int> tmp = q.front(); q.pop_front();
        int x = tmp[0], y = tmp[1], dist = tmp[2];
        if(x == W-1 && y==H-1){
            leng = dist;
            break;
        }
        rep(i, 4){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(0 <= nx && nx < W && 0 <= ny && ny < H && c[ny][nx] == '.'){
                q.push_back({nx, ny, dist+1});
                c[ny][nx] = '#';
            }
        }
    }
    if(leng == INF) cout << -1 << endl;
    else cout << H*W-leng-cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using std::cin;
typedef long long ll;
const int INF=1e+9;
const ll INFLL=1e+17;
int N;
int V[21],C[21];
void solve(){
  int res=0;
  rep(i,N){
    if(V[i]-C[i]>0){
      res+=V[i]-C[i];
    }
  }
  prin(res);
}
int main(){
  cin>>N;
  rep(i,N) cin>>V[i];
  rep(i,N) cin>>C[i];
  solve();
  return 0;
}


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

int n,m,x,y;
short a[N][N],b[N][N],f[N][N][N];

void pls(short &x,short y){x=max(x,y);}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();m=read();
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++){
			char ch;scanf(" %c",&ch);
			if (ch=='E') x=i,y=j;
			if (ch=='o') a[i][j]=b[i][j]=1;
			a[i][j]+=a[i][j-1];
			b[i][j]+=b[i-1][j];
		}
	for (int i=0;i<=x-1;i++)
		for (int j=0;j<=n-x;j++)
			for (int k=0;k<=y-1;k++)
				for (int l=0;l<=m-y;l++){
					int u=max(x-i,1+j),v=min(x+j,n-i);
					pls(f[j][k][l+1],f[j][k][l]+((y+l+1<=m-k&&u<=v)?(b[v][y+l+1]-b[u-1][y+l+1]):0));
					pls(f[j][k+1][l],f[j][k][l]+((y-k-1>=1+l&&u<=v)?(b[v][y-k-1]-b[u-1][y-k-1]):0));
					u=max(y-k,1+l);v=min(y+l,m-k);
					pls(f[j+1][k][l],f[j][k][l]+((x+j+1<=n-i&&u<=v)?(a[x+j+1][v]-a[x+j+1][u-1]):0));
					pls(f[j][k][l],f[j][k][l]+((x-i-1>=1+j&&u<=v)?(a[x-i-1][v]-a[x-i-1][u-1]):0));
				}
	printf("%d\n",f[n-x][y-1][m-y]);
	return 0;
}

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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;


signed main() {
	while (1) {
		string x; cin >> x;
		if (x == "0")break;
		ll ans = 0;
		for (auto a : x) {
			string s;
			s = a;
			ans += stoi(s);
		}
		cout << ans << endl;
	}
}


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

int main(){
  string S;
  bool A = true;
  cin >> S;
  for(int i = S.size(); i > 0; --i){
    for(int j = 0; j < i; ++j){
      if(S[j] == S[i]){
        A = false;
        break;
      }
    }
  }
  if(A) cout << "yes" << endl;
  else cout << "no" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string o,e; cin>>o>>e;
  int i=0;
  char c;
  for(int i=0; i<o.length(); i++) {
    if(e.length()>i) cout<<o[i]<<e[i];
    else cout<<o[i];
  }
}

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

ll id;
int N, c;
string s;

const ll MAX = 2000000;

struct Node {
	ll v, len;
	string s;
	vector<Node*> children;
	Node() : v(1), len(0), s(string()) {}
};

int readNum(){
	int n = 0;
	while(c < N && isdigit(s[c])) {
		n = n * 10 + (s[c] - '0');
		c++;
	}
	return n;
}

string readS(){
	string ret;
	assert(s[c] != '(' && s[c] != ')');
	while(c < N && 'A' <= s[c] && s[c] <= 'Z') {
		ret += s[c];
		c++;
	}
	return ret;
}

char ans;

Node* f(){
	Node* node = new Node();
	if(isdigit(s[c])) {
		int n = readNum();
		node->v = n;

		if(s[c] != '(') {
			Node* res = f();
			node->children.push_back(res);
			node->len = min(MAX, node->len + res->len * res->v);
			return node;
		}

		while(c < N) {
			if(s[c] == '(') {
				c++;
			}

			Node* res = f();
			node->children.push_back(res);
			node->len = min(MAX, node->len + res->len * res->v);

			if(c < N && s[c] == ')') {
				c++;
				return node;
			}
		}
		return node;
	}

	assert('A' <= s[c] && s[c] <= 'Z');

	node->s = readS();
	node->len = min(MAX, (ll)node->s.size());

	return node;
}

void g(Node* node){
	if(node->children.size() == 0) {
		assert(id < node->s.size());
		ans = node->s[id];
		return;
	}

	while(!(id < node->len)) id -= node->len;

	for(auto child : node->children) {
		if(child->len * child->v <= id) {
			id -= child->len * child->v;
		}
		else{
			g(child);
			assert(ans);
			return;
		}
	}
}

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

	while(cin >> s >> id, s != "0") {
		N = s.size();
		c = 0;
		ans = 0;
		while(c < N && ans == 0){
			Node* res = f();
			if(res->len * res->v <= id) {
				id -= res->len * res->v;
			}
			else {
				g(res);
				break;
			}
		}

		if(ans) cout << ans << endl;
		else cout << 0 << endl;
	}
}

Measured memory_bytes: 3568
/******
Author:Ashraful Fuad Mehmet
University of Asia Pacific
date :07 Feb 2020
problem : https://codeforces.com/problemset/problem/639/B
*******/

#include<bits/stdc++.h>
#define input freopen("input.txt","r",stdin);
#define all(x) (x).begin(), (x).end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

typedef long long ll;
int tc,cs=1,n,m;
void debug();
const int N=405;
template<class T> inline T sqr(const T &x)
{
  return x*x;
}
void brain_fry()
{
  string a,b;
  cin>>a>>b;
  int x,y;
  cin>>x>>y;
  string p;
  cin>>p;
  if(p==a)cout<<x-1<<" "<<y<<endl;
  else cout<<x<<" "<<y-1<<endl;
}// end func
int main()
{
  // input
  fastio
  brain_fry();
  // debug();
  return 0;
}
void debug()
{
  cout<<"Debug goes here"<<endl;
}

Measured memory_bytes: 256
cnt = 0
def merge(L,R):
    global cnt
    n = len(L)+len(R)
    cnt += n
    A = []
    i = j = 0
    L.append(float("inf"))
    R.append(float("inf"))
    for _ in range(n):
        if L[i] <= R[j]:
            A.append(L[i])
            i += 1
        else:
            A.append(R[j])
            j += 1
    return A

def mergeSort(A):
    if len(A)==1: return A
    m = len(A)//2
    return merge(mergeSort(A[:m]),mergeSort(A[m:])) 
    

if __name__=='__main__':
    n=int(input()) 
    A=list(map(int,input().split()))
    print(*mergeSort(A))
    print(cnt)

Measured memory_bytes: 63748
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int s, w;
  cin >> s >> w;
  if(w >= s) cout << "unsafe" << endl;
  else cout << "safe" << endl;
  return 0;
}

Measured memory_bytes: 3636
A,B,C=sorted(map(int,input().split()))

if A%2==B%2==C%2:
  print((C-A)//2+(C-B)//2)
elif A%2==B%2:
  print((C-A)//2+(C-B)//2+1)
else:
  print((C-A)//2+(C-B)//2+2)



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
 	 string s;
	 cin>>s;
	 int i,k=0;
	 for(i=1;i<=s.size()-1;i++)
	 {
	  	if(s[i]!=s[i-1])
		  	k++;								   	
	 }	
	 cout<<k<<endl;
	 return 0;
}

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

int main(){
  int N;
  cin >> N;
  cout << N / 3 << endl;
}

Measured memory_bytes: 3568
n,l=map(int,input().split())
left=l
right=l+n-1
apple=[i for i in range(left,right+1)]
if left<=0<=right:
  print(sum(apple))
elif left<0 and right<0:
  print(sum(apple)-right)
elif 0<left and 0<right:
  print(sum(apple)-left)



Measured memory_bytes: 8900
#include <iostream>

using namespace std;

int main() {
    int t, cAC=0, cWA=0, cTLE=0, cRE=0;
    cin >> t;
    while(t--){
        string s;
        cin >> s;
        if(s=="AC")
            cAC++;
        else if(s=="WA")
            cWA++;
        else if(s=="TLE")
            cTLE++;
        else if(s=="RE")
            cRE++;
    }
    cout << "AC x " << cAC << endl;
    cout << "WA x " << cWA << endl;
    cout << "TLE x " << cTLE << endl;
    cout << "RE x " << cRE << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int h,w;
    cin>>h>>w;
    int n;
    cin>>n;
    int x,y;
    cin>>y>>x;
    string s,t;
    cin>>s;
    cin>>t;
    int mr=x,ml=x,mu=y,md=y;
    int cr=x,cl=x,cu=y,cd=y;
    rep(i,n){
        if(s[i]=='R')mr=max(++cr,mr);
        if(t[i]=='L'&&cr>1)--cr;
    }
    rep(i,n){
        if(s[i]=='L')ml=min(--cl,ml);
        if(t[i]=='L'&&cl<w)++cl;
    }
    rep(i,n){
        if(s[i]=='D')md=max(++cd,md);
        if(t[i]=='U'&&cd>1)--cd;
    }
    rep(i,n){
        if(s[i]=='U')mu=min(--cu,mu);
        if(t[i]=='D'&&cu<h)++cu;
    }
    if(mr>w||ml<=0||md>h||mu<=0)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;

    return 0;
}

Measured memory_bytes: 904
/*Shivam Bhalla */
/* f2016941@pilani.bits-pilani.ac.in */



#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iostream>
#include <string>
#include <cmath>
#include <cassert>
#include <bits/stdc++.h>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;
long long maxv = 1e9;

int main()
{
  int N,M,A;
  cin>>N>>M;
  vector<int>arr(M+1);
  for(int i=0;i<N;i++){
    int K;
    cin>>K;
    for(int j=0;j<K;j++){
      cin>>A;
      arr[A]+=1;
    }
  }
  int total=0;
  for(int i=1;i<=M;i++){
    if(arr[i]==N)
      total++;
  }
  cout<<total;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
int main(){
    boost;
    ll n, m;    cin>>n>>m;
    ll ans = ((n*(n-1)) + (m*(m-1)))/2;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        m: usize
    }
    let d = 1000000007;
    let mut dp = vec![vec![0usize; 2]; n + 1];
    dp[0][1] = 1;
    for i in 1..n + 1 {
        dp[i][0] = 1;
    }
    for _ in 0..m {
        let mut next = vec![vec![0usize; 2]; n + 1];
        next[0][1] = (dp[0][1] + dp[1][0] + dp[1][1]) % d;
        for j in 1..n {
            if j == 1 {
                next[1][0] = (dp[1][0] + dp[2][0]) % d;
                next[1][1] = (dp[0][1] + dp[1][0] + 2 * dp[1][1] + dp[2][1]) % d;
            } else {
                next[j][0] = (dp[j - 1][0] + 2 * dp[j][0] + dp[j + 1][0]) % d;
                next[j][1] = (dp[j - 1][1] + 2 * dp[j][1] + dp[j + 1][1]) % d;
            }
        }
        if n > 1 {
            next[n][0] = (dp[n][0] + dp[n - 1][0]) % d;
            next[n][1] = (dp[n][1] + dp[n - 1][1]) % d;
        } else {
            next[1][1] = (dp[1][0] + dp[1][1] + dp[0][1]) % d;
        }
        dp = next;
    }
    let ans = dp.iter().fold(0, |ac, x| (ac + x[1]) % d);
    println!("{}", ans);
}


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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define mxn 300005
using namespace std;
//Laptop sucks

int main()
{
	FLASH
	int n;
	cin >> n;
	ll a[n + 2];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	ll ans = 0;
	ll cur = 1000,num = 0;
	int i = 0;
	while(i < n - 1 && a[i] > a[i + 1]){
		i++;
	}
	num = cur / a[i];
	cur -= num * a[i];
	while(i < n){
		while(i < n - 1 && a[i] <= a[i + 1]){
			i++;
		}
		cur += num * a[i];
		num = 0;
		while(i < n - 1 && a[i] >= a[i + 1]){
			i++;
		}
		if(a[i] < a[i + 1]){
			num = cur / a[i];
			cur -= num * a[i];
		}
		if(i >= n - 1)
			break;
	}
	if(num > 0){
		cur += num * a[n - 1];
	}
	cout << cur ;
	// cout << max(cur,(long long)1000);
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using ll = long long;

using namespace std;



int main() {
    int n;
    cin>>n;
    cout << n*n*n << endl;

    return 0;
}


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

#define MOD 1000000007

using ll = long long;
using namespace std;

int n, a[100000];
map<ll, ll> m;

ll modpow(ll a, ll b){
	ll res = 1;
	for(ll i = 0; i < b; ++i){
		res *= a;
		res %= MOD;
	}
	return res;
}


int main(){
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		m[a[i]]++;
	}
	
	for(int i = n%2+1; i < n; i += 2){
		if(m[i] != 2){
			cout << 0 << endl;
			return 0;
		}
	}

	if(m[0] != n%2){
		cout << 0 << endl;
		return 0;
	}
	
	printf("%lld\n", modpow(2,n/2));
}

Measured memory_bytes: 4608
n = int(input())
*p, = map(int, input().split())

cnt = 0
for i in range(n-2):
    list = [p[i], p[i+2]]
    mini = min(list)
    maxi = max(list)
    if mini < p[i+1] <= maxi:
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
#include <string>

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll=long long;
const ll mod = 1e9 + 7;


template<class T>
T gcd(T a, T b)
{
  if(a && b) {
    return gcd(min(a, b), max(a, b) % min(a, b));
  } else {
    return a;
  }
}

template<class T>
T lcm(T a, T b)
{
  return a / gcd(a, b) * b;
}

ll power(ll base, ll exponent, ll module)
{
  if(exponent % 2) {
    return power(base, exponent - 1, module) * base % module;
  } else if(exponent) {
    ll root_ans = power(base, exponent / 2, module);
    return root_ans * root_ans % module;
  } else {
    return 1;
  }
}

struct combination
{
  vector<ll> fact, inv;
  combination(int sz) : fact(sz + 1), inv(sz + 1)
  {
    fact[0] = 1;
    for(int i = 1; i <= sz; i++) {
      fact[i] = fact[i - 1] * i % mod;
    }
    inv[sz] = power(fact[sz], mod - 2, mod);
    for(int i = sz - 1; i >= 0; i--) {
      inv[i] = inv[i + 1] * (i + 1) % mod;
    }
  }
  ll P(int n, int r)
  {
    if(r < 0 || n < r) return 0;
    return (fact[n] * inv[n - r] % mod);
  }
  ll C(int p, int q)
  {
    if(q < 0 || p < q) return 0;
    return (fact[p] * inv[q] % mod * inv[p - q] % mod);
  }
};

template<typename T>
void print_vec(vector<T>& v)
{
  for(const auto& e: v) {
    cout << e << " ";
  }
  cout << endl;
}
template<typename T>
void print_2dvec(vector<vector<T>>& m)
{
  for(const auto& v: m) {
    for(const auto& e: v) {
      cout << e << " ";
    }
    cout << endl;
  }
}


int main(int argc, char const* argv[])
{
  int n;
  cin >> n;

  map<string, int> m = {
    {"11", 0}, {"12", 0}, {"13", 0}, {"14", 0}, {"15", 0}, {"16", 0}, {"17", 0}, {"18", 0}, {"19", 0},
    {"21", 0}, {"22", 0}, {"23", 0}, {"24", 0}, {"25", 0}, {"26", 0}, {"27", 0}, {"28", 0}, {"29", 0},
    {"31", 0}, {"32", 0}, {"33", 0}, {"34", 0}, {"35", 0}, {"36", 0}, {"37", 0}, {"38", 0}, {"39", 0},
    {"41", 0}, {"42", 0}, {"43", 0}, {"44", 0}, {"45", 0}, {"46", 0}, {"47", 0}, {"48", 0}, {"49", 0},
    {"51", 0}, {"52", 0}, {"53", 0}, {"54", 0}, {"55", 0}, {"56", 0}, {"57", 0}, {"58", 0}, {"59", 0},
    {"61", 0}, {"62", 0}, {"63", 0}, {"64", 0}, {"65", 0}, {"66", 0}, {"67", 0}, {"68", 0}, {"69", 0},
    {"71", 0}, {"72", 0}, {"73", 0}, {"74", 0}, {"75", 0}, {"76", 0}, {"77", 0}, {"78", 0}, {"79", 0},
    {"81", 0}, {"82", 0}, {"83", 0}, {"84", 0}, {"85", 0}, {"86", 0}, {"87", 0}, {"88", 0}, {"89", 0},
    {"91", 0}, {"92", 0}, {"93", 0}, {"94", 0}, {"95", 0}, {"96", 0}, {"97", 0}, {"98", 0}, {"99", 0},
  };

  string s, s2;
  for (int i = 1; i <= n; i++) {
    s = to_string(i);
    s2 += s[0];
    s2 += s[s.length() - 1];
    // cout << m[s2] << endl;
    if (s[s.length() - 1] != '0') {
      m[s2]++;
    }
    s2 = "";
  }

  ll ans = 0;
  for (auto iter = m.begin(); iter != m.end(); iter++) {
    // cout << "key: " << iter->first << ", value: " << iter->second << endl;
    s = iter->first;
    reverse(ALL(s));
    ans += iter->second * m[s];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import fractions
a,b,c,d = map(int,input().split())
def calc(n,x,y):
    cnt = n // x
    cnt += n//y
    lcm = x*y//fractions.gcd(x,y)
    cnt -= n//lcm
    return n - cnt

print(calc(b,c,d)-calc(a-1,c,d))


Measured memory_bytes: 5048
N, M = map(int, input().split())

oks = [True]*(N+1)

for i in range(M):
    a = int(input())
    oks[a] = False

dp = [0]*(N+1)

dp[0]=1
if oks[1]==True: dp[1] = 1

for i in range(2, N+1):
    if oks[i]==True:
        dp[i] = (dp[i-1] + dp[i-2]) % (1e9+7)

print(int(dp[N]))


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

#define ll long long
int main() {
  ll N;
  cin >> N;
  vector<ll> len(N);
  
  for (int i = 0; i < N; i++) {
    cin >> len[i];
  }
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      for (int k = j+1; k < N; k++) {
        ll a[3] = {len[i], len[j], len[k]};
        sort(a, a+3);
        
        if (a[0] == a[1] || a[1] == a[2]) continue;
        
        if (a[2] < a[0] + a[1]) ans++;
      }
    }
  }
  
  cout << ans << endl;
}

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

using namespace std;
struct as
{
    int x,y;
}pos[10];
struct node
{
    int x,y;
    int step;
};
bool vis[1010][1010];
char maze[1050][1050];
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int H,W,N;

bool check(int x,int y)
{
    if (x<=0 || x>H) return 1;
    if (y<=0 || y>W) return 1;
    if (vis[x][y]) return 1;
    if (maze[x][y] =='X')return 1;
    return 0;
}
int bfs(int m,int n)
{
    memset(vis,0,sizeof vis);
    int sx = pos[m].x, sy = pos[m].y;
    int gx = pos[n].x, gy = pos[n].y;
   // printf("%d %d\n",sx,sy);
   // printf("%d %d\n",gx,gy);
    queue<node> Q;
    node a,next;
    a.step = 0;
    a.x = sx, a.y =sy;
    Q.push(a);
    while(!Q.empty())
    {
        a = Q.front();
        Q.pop();
        if (a.x == gx && a.y == gy)
            return a.step;
        for(int i = 0; i < 4 ;i++)
        {
            int nx = a.x + dx[i];
            int ny = a.y + dy[i];
            if(check(nx,ny))
                continue;
            else
            {
                vis[nx][ny] =1;
                next.x = nx,next.y = ny,next.step = a.step+1;
                Q.push(next);
            }
        }
    }
    return 999999;
}

int main()
{
   // freopen("in.txt","r",stdin);
    while(cin>>H>>W>>N)
    {
        int sx,sy;
        for(int i = 1;i<=H;i++)
        {
            for(int j = 1; j <= W;j++)
            {
                cin>>maze[i][j];
                if (maze[i][j] >='1' && maze[i][j]<='9')
                {
                    pos[maze[i][j]-'0'].x = i;
                    pos[maze[i][j]-'0'].y = j;
                }
                if (maze[i][j]=='S')
                    sx=i,sy = j;
            }
        }

        pos[0].x = sx,pos[0].y = sy;
        int ans = 0;
        for(int i = 0;i<N;i++)
            ans += bfs(i,i+1);
        cout<<ans<<endl;
    }
    return 0;
}

/*
入力例 2
4 5 2
.X..1
....X
.XX.S
.2.X.

出力例 2
12
*/

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

int main() {
  int N, p = 0, w = 0, g = 0, y = 0;
  string a;
  cin >> N;

  for(int i = 0; i < N; i++){
    cin >> a;
    if(a == "P"){p++;}
    else if(a == "W"){w++;}
    else if(a == "G"){g++;}
    else if(a == "Y"){y++;}
  }
 
  if(p>=1 && w>=1 && g>=1 && y>=1){cout << "Four" << endl;}
  else{cout << "Three" << endl;}
}


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

int main(){
    string s;
    string samp="CODEFESTIVAL2016";
    int count=0;
    cin >> s;
    rep(i,s.length()){
        if(samp[i]!=s[i]){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,a[50]={},b[50]={},c[50]={},s=0,poz1,poz2;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];

    }
    for(int i=1;i<=n;i++){
        cin>>b[i];
        s=s+b[i];
    }
    for(int i=1;i<=n-1;i++){

        cin>>c[i];
    }
    for(int i=1;i<=n-1;i++){
            poz1=a[i];
            poz2=a[i+1];
            if(poz2-poz1==1){
                s=s+c[poz1];
            }
    }
    cout<<s;
    return 0;
}


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

#define ll long long

using namespace std;
enum verdict  {AC,WA,TLE,RE
};

int main()
{
	int n;
	cin>>n;
	int ans[4];
	for(int i=0;i<4;i++)
		ans[i] = 0;
	while(n-->0)
	{
		string str;
		cin>>str;
		if(str=="AC")
			ans[AC]++;
		else if(str=="WA")
			ans[WA]++;
		else if(str=="TLE")
			ans[TLE]++;
		else
			ans[RE]++;
	}
	for(int i=0;i<4;i++)
	{
		if(i==0)
			cout<<"AC x "<<ans[i]<<endl;
		else if(i==1)
			cout<<"WA x "<<ans[i]<<endl;
		else if(i==2)
			cout<<"TLE x "<<ans[i]<<endl;
		else
			cout<<"RE x "<<ans[i]<<endl;
	}
	return 0;
}

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

int main() {
    int i, j;

    int h, w;
    cin >> h >> w;
    
    vector<vector<char>> a(h, vector<char>(w));
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    
    vector<vector<char>> b(h + 2, vector<char>(w + 2, '#'));
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            b[i + 1][j + 1] = a[i][j];
        }
    }
    
    for (i = 0; i < h + 2; i++) {
        for (j = 0; j < w + 2; j++) {
            cout << b[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y))

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		int x, y, z;
		cin >> x >> y >> z;
		int ma = max(x, max(y, z));
		int mi = min(x, min(y, z));
		int cen = (ma != x && mi != x ? x : ma != y && mi != y ? y : z);
		if (ma * ma == mi * mi + cen * cen){
			cout << "YES" << "\n";
		}else{
			cout << "NO" << "\n";
		}
	}
	cout.flush();
}

Measured memory_bytes: 1112
// 入力マクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
        x: usize, y: usize, a: usize, b: usize, c: usize,
        p: [usize; a],
        q: [usize; b],
        r: [usize; c]
    }

    let mut apples = Vec::new();
    for e in p {
        apples.push((e, 'r'));
    }
    for e in q {
        apples.push((e, 'g'));
    }
    for e in r {
        apples.push((e, 'n'));
    }

    apples.sort_by(|a, b| b.0.cmp(&a.0));

    let mut ans = 0;
    let mut aed = 0;
    let mut ged = 0;
    let mut ned = 0;
    for (deli, col) in apples {
        if aed + ged + ned == x + y { break; }

        if col == 'r' {
            if aed >= x { continue; }
            else {
                ans += deli;
                aed += 1;
            }
        } else if col == 'g' {
            if ged >= y { continue; }
            else {
                ans += deli;
                ged += 1;
            }
        } else {
            ned += 1;
            ans += deli;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 13156
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int s, w;
    cin >> s >> w;
    if (w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long N, Q, K[100];
long long c1[1 << 20], c2[1 << 20], c3[1 << 20];
string S;

long long solve(long long border) {
	long long ans = 0; border--;
	long long tops = 0, kosuu = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'D') {
			kosuu += 1;
		}
		if (S[i] == 'M') {
			tops += kosuu;
		}
		if (S[i] == 'C') {
			ans += tops;
		}
		if (i >= border && S[i - border] == 'D') {
			long long val = c2[i + 1] - c2[i - border + 1];
			tops -= val;
			kosuu -= 1;
		}
	}
	return ans;
}

int main() {
	cin >> N >> S;
	for (int i = 1; i <= N; i++) {
		c1[i] = c1[i - 1]; c2[i] = c2[i - 1]; c3[i] = c3[i - 1];
		if (S[i - 1] == 'D') c1[i] += 1;
		if (S[i - 1] == 'M') c2[i] += 1;
		if (S[i - 1] == 'C') c3[i] += 1;
	}
	cin >> Q;
	for (int i = 1; i <= Q; i++) cin >> K[i];
	for (int i = 1; i <= Q; i++) cout << solve(K[i]) << endl;
	return 0;
}

Measured memory_bytes: 27668
n,k=map(int,input().split())
a=list(map(int,input().split()))
chk=[False]*n
x=0
visit=[0]
chk[x]=True
while chk:
    x=a[x]-1
    if chk[x]:
        break
    else:
        visit.append(x)
        chk[x]=True
l1=0
while visit[l1]!=x:
    l1+=1
l2=len(visit)-l1
if k>=l1:
    print(visit[l1+((k-l1)%l2)]+1)
else:
    print(visit[k]+1)

Measured memory_bytes: 95104
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double PI = 3.14159265358979;
const double E = 2.718281828459045;
const double root2 = sqrt(2);
typedef pair<int, int> P;
typedef unsigned int ui;
const ll key = 998244353;
int main() {
	int w, h;
	int dir1[4] = {1,0,-1,0};
	int dir2[4] = { 0,1,0,-1 };
	while (cin >> w >> h, w) {
		char lan[52][52]; char b[52][52]; char r[52][52];
		for (int i = 0; i < 52; i++) {
			for (int j = 0; j < 52; j++) {
				lan[i][j] = '0'; b[i][j] = '0'; r[i][j] = '0';
			}
		}
		string s;
		for (int i = 1; i <= h; i++) {
			cin >> s;
			for (int j = 1; j <= w; j++) {
				lan[i][j] = s[j-1];
			}
		}
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				if (lan[i][j] == 'W') {
					vector<P>v;
					v.push_back({ i,j });
					while (!v.empty()) {
						int x = v[0].first; int y = v[0].second; v.erase(v.begin());
						for (int k = 0; k < 4; k++) {
							if(lan[x+dir1[k]][y+dir2[k]]=='.'&&r[x+dir1[k]][y+dir2[k]]=='0'){
								r[x + dir1[k]][y + dir2[k]] = '1';
								v.push_back({ x + dir1[k],y + dir2[k] });
							}
						}
					}
				}
				else if (lan[i][j] == 'B') {
					vector<P>v;
					v.push_back({ i,j });
					while (!v.empty()) {
						int x = v[0].first; int y = v[0].second; v.erase(v.begin());
						for (int k = 0; k < 4; k++) {
							if (lan[x + dir1[k]][y + dir2[k]] == '.'&&b[x + dir1[k]][y + dir2[k]] == '0') {
								b[x + dir1[k]][y + dir2[k]] = '1';
								v.push_back({ x + dir1[k],y + dir2[k] });
							}
						}
					}
				}
			}
		}
		int bcnt = 0; int wcnt = 0;
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				if (r[i][j] == '1' && b[i][j] == '0') {
					wcnt++;
				}
				else if (r[i][j] == '0'&&b[i][j] == '1') {
					bcnt++;
				}
			}
		}
		cout << bcnt << " " << wcnt << endl;
	}
	return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;
  ll T;
  cin >> N >> T;
  ll pre = 0, sum = 0;
  rep(i,N){
    ll x;cin >> x;
    if(x<=pre) sum += x+T-pre;
    else sum += T;
    pre=x+T;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
using namespace std;
ll n;
char a;
int32_t main(){
cin>>a;
if(a=='A'){
    cout<<"T";
}else if(a=='T'){
cout<<'A';
}else if(a=='C'){
cout<<'G';
}else if(a=='G'){
cout<<'C';
}
return 0;}


Measured memory_bytes: 256
"use strict";

function binarySearch(arr, val) {
  let start = 0;
  let end = arr.length - 1;

  while (start <= end) {
    let mid = Math.floor((start + end) / 2);
    // console.log(mid);

    if (arr[mid] === val && (mid === 0 || arr[mid - 1] > val)) {
      return mid;
    }
    if (val >= arr[mid]) {
      end = mid - 1;
    } else {
      start = mid + 1;
    }
  }
  return -1;
}

function main(input) {
  const inputs = input.split("\n").filter(x => x !== "");
  const A = inputs[1].split(" ").map(Number);

  let sortedA = A.sort((a, b) => b - a);
  let count = 0;
  let num2n = Math.pow(2, sortedA[0].toString(2).length);

  let start, end;

  for (let index = 0; index < sortedA.length; index++) {
    let i = sortedA[index];
    if (i === -1) continue;
    sortedA[index] = Number.MAX_VALUE;

    while (num2n > 2 * i) {
      num2n = num2n / 2;
    }

    let j = num2n - i;
    let indexJ = binarySearch(sortedA, j);

    if (indexJ >= 0) {
      sortedA[indexJ] = sortedA[indexJ] + 0.1;
      count++;
    }

    // console.log({ i, j, indexJ, sortedA });
  }

  console.log(count);
}

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


Measured memory_bytes: 35476
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;
import java.util.AbstractMap.SimpleEntry;
import java.util.HashSet;
import java.util.Iterator;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int ans = 0;
        if (X == 3)
            ans += 100000;

        if (X == 2)
            ans += 200000;

        if (X == 1)
            ans += 300000;

        if (Y == 3)
            ans += 100000;

        if (Y == 2)
            ans += 200000;

        if (Y == 1)
            ans += 300000;

        if (X == 1 && Y == 1)
            ans += 400000;

        System.out.println(ans);
    }
}

Measured memory_bytes: 22996
n = int(input())
def cal(n):
    p = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            p.append([i,n//i])
    return p
a = cal(n)
t = 1
for i in range(len(a)):
    if 1 <= a[i][0] <= 9 and 1 <= a[i][1] <= 9:
        t = 0
        print('Yes')
        break
if t == 1:
    print('No')

Measured memory_bytes: 38256
import sys
from bisect import bisect

def solve():
    input = sys.stdin.readline
    N, M, V, P = map(int, input().split())
    A = [int(a) for a in input().split()]
    A.sort()
    border = A[N - P]

    low, high = -1, N
    while high - low > 1:
        mid = (low + high) //2
        point = A[mid] + M
        if point < border: low = mid
        elif mid >= N - P: high = mid
        else:
            space = (mid + P) * M
            for i in range(mid + 1, N - P + 1 ): space += point - A[i]
            if space >= M * V: high = mid
            else: low = mid
    print(N - low - 1)
    return 0

if __name__ == "__main__":
    solve()


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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  // freopen("in.txt", "r", stdin);
  int ans = 0, n;
  long long d;
  cin >> n >> d;
  for(int i=0; i<n; i++){
    long long x, y;
    cin >> x >> y;
    if(x*x + y*y <= d*d) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    ll n,a,b;
    cin >> n >> a >> b;

    ll c = n / (a+b);
    
    ll ans = 0;

    ans  += c*a;

    if(n-c*(a+b)>a){
        ans += a;
    } 
    else ans += n-c*(a+b);

    cout << ans ;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll a,b,c,d,e,ans=1;
ll x[500005],y[100005],z[100005];
bool p[500005]; 
 
int main(){
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x[i]>>y[i];
	}
	sort(x,x+n);
	reverse(x,x+n);
	sort(y,y+n);
	ll res=0,tmp=0;
	for(i=0;i<n/2+1;i++){
		tmp += x[i];
		res = max(res,tmp);
		//pe(tmp);
		tmp -= y[i];
		res = max(res,tmp);
		//pe(tmp);
	}
	el;
	tmp=0;
	for(i=0;i<n/2+1;i++){
		tmp -= y[i];
		//pe(tmp);
		res = max(res,tmp);
		tmp += x[i];
		//pe(tmp);
		res = max(res,tmp);
	}
	el;
	p(2*res);
	return 0;
}

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

#define int long long
double EPS = 1e-9;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, M;
  cin >> N >> M;

  priority_queue<double> Q;  
  for ( int i = 0; i < N; i++ ) {
    int a;
    cin >> a;
    Q.push(a);    
  }

  for ( int i = 0; i < M; i++ ) {
    double p = Q.top(); Q.pop();
    if ( p > EPS ) Q.push(p/2.0);    
  }

  int ans = 0;
  for ( int i = 0; i < N; i++ ) {
    double p = Q.top(); Q.pop();
    ans += (int)p;    
  }

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


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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> v(M);
  for (int i = 0; i < M; i++) cin >> v[i];

  int to_start = 0;
  int to_end = 0;
  for (int i : v) {
    if (i < X) to_start++;
    if (X < i) to_end++;
  }
  cout << min(to_start, to_end) << endl;
}


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

namespace AtCoder_Project_CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = ab[0], b = ab[1], c = ab[2], d = ab[3];

            if(Math.Abs(a-c)<=d||(Math.Abs(a-b)<=d && Math.Abs(b-c)<=d))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
using namespace std;
int a,b,c,xx,yy,rs;
int main()
{
	cin>>a>>b>>c>>xx>>yy;
	if(a+b<2*c)
	{rs=xx*a+yy*b;}
	else
	{
		if(xx>yy)
		{rs=2*c*yy;if(2*c<a)rs+=(xx-yy)*c*2;else rs+=(xx-yy)*a;
		}
		else 
		{rs=2*c*xx;if(2*c<b)rs+=(-xx+yy)*c*2;else rs+=(-xx+yy)*b;
		}
	}
	cout<<rs<<endl;
}

Measured memory_bytes: 256
//  RAKSHIT KADAM

 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!
 
// NUMERIC DEFINITIONS :
    #define INF 100000000000000005
    #define inf 1000000004
    #define MOD  1000000007
    #define mod 998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long
 
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
 
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 500003;
// ll fact[1000005];
//void facto()
//{
//    ll lim =1000005;fact[0]=1;
//    for(ll i=1;i<lim;i++)
//    {
//        fact[i]=(fact[i-1]*i)%MOD;
//    }
//}
//ll ncr(ll a,ll b)
//{
//    ll ret = 0;
//    ret = fact[a]*(modInverse(fact[b],MOD));
//    ret%=MOD;
//    ret*=modInverse(fact[a-b],MOD);
//    ret%=MOD;
//    return ret;
//}

void solve()
{
     
    ll c;cin>>c;
    if(c>=30)cout<<"Yes";
    else cout<<"No";
    
}
signed main()
{
   Need_for_speed(activated);
//
//    satisfy
//    {
//        solve();
//    }
//
   
    solve();
    
    return 0;
}
//Concentrate while implementing,,,!!!
 


Measured memory_bytes: 3604