akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(void){
    string S;
    cin >> S;
    bool flag1 = false; 
    bool flag2 = false;
    bool flag3 = false;
    if (S[0] == 'A')
    {
        flag1 = true;
    }
    
    for (int i = 2; i < S.size() - 1; i++)
    {
        if (S[i] == 'C')
        {
            flag2 = true;
        }
    }
    
    int flag3_cnt;
    int cnt = 0;
    for (int i = 1; i < S.size(); i++)
    {
        flag3_cnt = 0;
        for (char moji = 'a'; moji <= 'z'; moji++)
        {
            if (S[i] == moji)
            {
                flag3_cnt++;
            }
        }
        if (flag3_cnt != 0)
        {
            cnt++;
        }
    }
    if (cnt == S.size() - 2)
    {
        flag3 = true;
    }
    
    if (flag1 && flag2 && flag3)
    {
        cout << "AC" << endl;
    }
    else
    {
        cout << "WA" << endl;
    }
    
    return 0;
    
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

std::vector<size_t> make_vector(size_t n, size_t x) {
  return std::vector<size_t>(n, x);
}

template <class Tp>
std::vector<Tp> make_vector(size_t n, const Tp& x) {
  return std::vector<Tp>(n, x);
}

template <class... Ts>
auto make_vector(size_t n, size_t m, const Ts&... x) {
  return std::vector<decltype(make_vector(m, x...))>(n, make_vector(m, x...));
}

int main() {
  size_t N;
  scanf("%zu", &N);

  size_t x0 = 0;
  size_t y0 = 0;
  for (size_t i = 0; i < N; ++i) {
    int a;
    scanf("%d", &a);
    if (a <= 2) ++x0;
    if (a <= 1) ++y0;
  }

  auto dp = make_vector(N+1, N+1, N+1, 0.0);

  double n = N;
  for (size_t z = N+1; z-- > 0;) {
    for (size_t y = N+1; y-- > z;) {
      for (size_t x = N+1; x-- > y;) {
        if (x > 0)
          dp[x-1][y][z] += (dp[x][y][z] + (n / (n-z))) * (n-(x-1)) / (n-z);

        if (y > 0)
          dp[x][y-1][z] += (dp[x][y][z] + (n / (n-z))) * (x-(y-1)) / (n-z);

        if (z > 0)
          dp[x][y][z-1] += (dp[x][y][z] + (n / (n-(z-1)))) * (y-(z-1)) / (n-(z-1));
      }
    }
  }

  printf("%.12f\n", dp[x0][y0][0]);
}


Measured memory_bytes: 216832
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#define REP(i,n) for (int i=1;i<=(n);++i)
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,a,b) for (int i=(a);i>=(b);--i)
#define FEC(p,u) for (edge*p=head[u];p;p=p->nxt)
using namespace std;
typedef long long LL;

int n, L, Q, x[110000];
int a[110000][20];
int main(){
	scanf("%d", &n);
	REP(i,n) scanf("%d", x+i);
	scanf("%d%d", &L, &Q);
	REP(i,n) a[i][0] = upper_bound(x+i, x+n+1, x[i]+L)-x-1;
	FOR(j,1,17) REP(i,n) a[i][j] = a[a[i][j-1]][j-1];
	int u, v, ans;
	while (Q--){
		scanf("%d%d", &u, &v);
		if (u > v) swap(u, v);
		ans = 0;
		ROF(j,17,0) { 
			if (a[u][j] < v) {
				u = a[u][j];
				ans += 1<<j;
			}
		}
		printf("%d\n", ans+1);
	}
	return 0;
}


Measured memory_bytes: 9088
#include<stdio.h>


int main ()
{
	int N,a[100],flag;
	int i,j;
	int temp,count=0;

	scanf("%d",&N);

	for(i=0;i<N;i++){
		scanf("%d",&a[i]);
	}

	i = 0;
	for(i=0;i<N;i++){
		flag = 0;
		for(j=N-1;j>=i+1;j--){
			if(a[j] < a[j-1]){
				temp = a[j-1];
				a[j-1] = a[j];
				a[j] = temp;
				flag = 1;
				count++;
			}
		}
	}

	for(i=0;i<N;i++){
		printf("%d",a[i]);
		if(i == N-1)	printf("\n");
		else printf(" ");
	}
	printf("%d\n", count);

	return 0;
}

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

int main() {
  int sum,a,k;
  string S;
  cin >> S;
  k = S.size();
  int i;
  for(i;i<k;i++){
   if(S.at(i) == 'o'){
    sum = sum + 1;
   }
  }
  a = sum + (15-k);
  if (a >= 8){
    cout << "YES" << endl;
  }
  else if(a < 8){
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
/*s1190073  Rina Sato
File name: prog2b.c
This program is Selection Sort program.*/

#include<stdio.h>
int main(void){
  int A[100],temp=0,count=0,mini=0,N,i,j;
  scanf("%d",&N);
  for(i = 0 ; i < N ; i++){
    scanf("%d",&A[i]);
  }
  
  /*compare figures*/
  for(i = 0 ; i < N ; i++){
    mini = i;
    for(j = i+1 ; j < N ; j++){
      if(A[j] < A[mini]){ /*find the smallest figure from A[i+1] to A[N-1]*/ 
	mini = j;
      }         
    }
    temp = A[i];    /*exchange A[i] for A[mini]*/
    A[i] = A[mini];
    A[mini] = temp;
    if(A[i] != A[mini]) count++; /*count a number of exchange*/
  }
  
  for(j = 0 ; j < N ; j++){
    printf("%d",A[j]);
    if(j < N-1){ /*make space between figures*/
      printf(" ");
    }
  }
  printf("\n%d\n",count);
  return 0;
}

Measured memory_bytes: 0
@in1=split / /, in();
$in2=in();
for($i=0;$i<$in1[1];$i++){
($f,$t)=split / /, in();
$f--;$t--;
${$in3[$f]}[@{$in3[$f]}]=$t;
${$in3[$t]}[@{$in3[$t]}]=$f;
}

for($i=0;$i<$in1[0];$i++){
foreach $op (@{$in3[$i]}){
if(substr($in2,$op,1)eq"A"){
$a[$i]++;
}else{$b[$i]++;}
}
}

for($i=0;$i<$in1[0];$i++){
if($a[$i] ==0 or $b[$i] ==0 ){
$tgt{$i}=1;}
}

while(%tgt>0){
%nexttgt=();
foreach $i (keys(%tgt)){
if($flag[$i]==1){
next;
}
if($a[$i] ==0 or $b[$i] ==0)
{
$flag[$i]=1;
foreach $j (@{$in3[$i]}){
$nexttgt{$j}=1;
if(substr($in2,$i,1)eq"A"){
$a[$j]--;
}else{$b[$j]--;}
}
}
}
%tgt=%nexttgt;
}
for($i=0;$i<$in1[0];$i++){
if(!defined $flag[$i])
{print "Yes";exit;}
}
print "No";
sub in {
$t = <STDIN>;
$t =~ s/[¥r¥n]+//;
return $t;
}


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

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

    int n;
    cin >> n;

    int a[n];
    rep(i, n) cin >> a[i];

    int ptr = 0;
    int res = 0;
    bool flg = false;

    rep(i, 2*n){
        if(a[ptr]==2){
            ++res;
            flg = true;
            break;
        }
        ptr = a[ptr]-1;
        ++res;
    }

    if(flg) cout << res << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!

ll _find(int d,int n){
    return n<100 ? pow(100,d)*n : 101*pow(100,d);
}

void solve(){
    
    
    int n;
    cin>>n;
    map<string,int> f;
    for(int i=0;i<n;i++){
        string s;cin>>s;
        f[s]++;
    }
    
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
        string s;cin>>s;
        f[s]--;
    }
    int ans=0;
    for(auto P:f){
        ans=max(ans,P.Se);
    }
    cout<<ans<<endl;
}

int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 3604
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k;
  int a,m,n,o,p,q,s,t,u;
  double r;
  cin>>m;
  for(i=0;i<m;i++){
    cin>>p>>n>>o;
    a=0;
    for(j=0;j<o;j++){
      cin>>q>>r>>s;
      t=p;
      if(q){
	for(k=0;k<n;k++){
	  t+=(int)(t*r);
	  t-=s;
	}
	a=max(a,t);
      }else{
	u=0;
	for(k=0;k<n;k++){
	  u+=(int)(t*r);
	  t-=s;
	}
	a=max(a,t+u);
      }
    }
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
# coding: utf-8

# https://atcoder.jp/contests/abc097/tasks/arc097_b
# 15:36-15:48 give up => hint
# 15:53-16:16　RE(recursion overflow)
# 16:16-16:43 done


def main():
    N, M = map(int, input().split())
    p = list(map(int, input().split()))
    p = [num-1 for num in p]
    x, y = [None] * M, [None] * M
    for i in range(M):
        x[i], y[i] = map(int, input().split())
        x[i] -= 1  # 0-index
        y[i] -= 1  # 0-index

    edges = {node: [] for node in range(N)}
    for xi, yi in zip(x, y):
        edges[xi].append(yi)
        edges[yi].append(xi)

    ans = 0
    check_node = [None] * N
    for start in range(N):
        if check_node[start] is not None:
            continue

        indexes = []
        numbers = []
        queue = [start]
        queue_i = 0
        while queue_i < len(queue):
            node = queue[queue_i]
            if check_node[node] is not None:
                queue_i += 1
                continue

            check_node[node] = 1
            indexes.append(node)
            numbers.append(p[node])
            
            for edge in edges[node]:
                if check_node[edge] is None:
                    queue.append(edge)
            
            queue_i += 1

        ans += len(set(indexes) & set(numbers))

    return ans


print(main())


Measured memory_bytes: 53580
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <stdlib.h>
long long N,W;
static long long  h[100001][3];
static long long  dp[101][100001];
long long Wg[1000],Val[1000];
long long  INF = INT_MAX;

int 
chmin(long long  *a, long long b) 
{
	 if (*a > b){
		 *a = b; //	printf("%ld\n",*a);
		 return 1; 
	 }
	 return 0;
}

int 
chmax(long long *a, long long b) 
{
	 if (*a < b){
		 *a = b; //	printf("%ld\n",*a);
		 return 1; 
	 }
	 return 0;
}

int 
main(){
	long long A,B,max = -1000;
	scanf("%lld%lld",&A,&B);
	chmax(&max,A+B);
	chmax(&max,A-B);
	chmax(&max,A*B);

	printf("%lld\n",max);
 return 0;
}

Measured memory_bytes: 128
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N = int(input())
    S = [input().strip() for _ in range(N)]
    res = 0
    for a in range(N):
        f = True
        for i in range(N):
            for j in range(N):
                if S[(i - a) % N][j] != S[(j - a) % N][i]:
                    f = False
                    break
            if not f:
                break
        if f:
            res += N
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 74636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

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

    ll n; cin >> n;

    string ans = "";

    while (n > 0) {
        --n;
        ll x = n%26;
        ans += 'a'+x;
        n /= 26;
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3644
INF = float('inf')

N = int(input())
h = list(map(int, input().split()))
h = [0] + h

dp = [INF for i in range(N + 1)]
# 1-indexed, 1 -> N
dp[1] = 0

for i in range(2, N + 1):
    if i > 2:
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
    else:
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1])
print(dp[N])


Measured memory_bytes: 13980
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,n) for(int i = 0;i<(n);i++);
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 100100100100100;
ll gcd(ll a,ll b) {//a>b
	if (a < b)swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
int main() {
	ll N;
	cin >> N;
	vector<ll> A(N);
	vector<ll> B(N - 1);
	for (int i = 0; i < N - 1; i++) cin >> B[i];
	if (N == 2) cout << B[0] * 2 << endl;//N = 2は分けた
	else {
		A[N - 1] = B[N - 2];//
		A[0] = B[0];//
		A[1] = B[0];//３つ数字を決める
		for (int i = 1; i < N - 1; i++) {//2 2 1
			if (A[i] > B[i]) A[i] = B[i];
			A[i + 1] = B[i];
		}
		ll ans = 0;
		for (int i = 0; i < N; i++) ans += A[i];
		cout << ans << endl;
	}
}


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

using namespace std;

int A, B, C, X, Y;

int main() {
  cin >> A >> B >> C >> X >> Y;
  int res = (int)2e9;
  for (int i = 0; i <= 2 * max(X, Y); ++i) {
    res = min(res, C * i + max(0, (X - i / 2)) * A + max(0, (Y - i / 2)) * B);
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using vi = vector<int>;
using i64 = int64_t;

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

int cnt = 0;

template <typename T>
void print(vector<T> v) {
  REP(i, v.size()) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
}

void merge(vi &A, int left, int mid, int right) {
  auto n1 = mid - left;
  auto n2 = right - mid;
  vi L(n1 + 1), R(n2 + 1);
  copy(A.begin() + left, A.begin() + mid, L.begin());
  copy(A.begin() + mid, A.begin() + right, R.begin());
  L[n1] = INF;
  R[n2] = INF;
  int i = 0, j = 0;
  FOR(k, left, right) {
    ++cnt;
    A[k] = (L[i] <= R[j]) ? L[i++] : R[j++];
  }
}

void merge_sort(vi &A, int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    merge_sort(A, left, mid);
    merge_sort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main() {
  int n;
  cin >> n;
  vi S(n);
  REP(i, n) cin >> S[i];
  merge_sort(S, 0, n);
  print(S);
  cout << cnt << endl;
}


Measured memory_bytes: 6880
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void dfs(int s,vvint &adj,vector <bool> &vis){
	vis[s] = 1;
	for(int u : adj[s]){
		if(!vis[u]) dfs(u,adj,vis);
	}
	return;
}

void solve(){
	int n,m;
	cin >> n >> m;
	vector <pair <int,int>> p(m);
	for(int i = 0;i < m;++i){
		int a,b;
		cin >> a >> b;
		--a,--b;
		p[i] = {a,b};
	}
	int out = 0;
	for(int i = 0;i < m;++i){
		vvint adj(n);
		for(int j = 0;j < m;++j){
			if(j == i) continue;
			adj[p[j].first].push_back(p[j].second);
			adj[p[j].second].push_back(p[j].first);
		}
		vector <bool> vis(n,0);
		dfs(0,adj,vis);
		for(int i = 0;i < n;++i){
			if(!vis[i]){
				++out;
				break;
			}
		}
	}
	cout << out << newl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
#include <complex>
#include <cassert>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define deb(a) cerr<< #a << "= " << (a)<<"\n";

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef complex<double> base;
typedef vector<int> vi;
typedef pair<int,int> pii;

template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream; }
ll fpow(ll x, ll p, ll m){ll r=1; for (;p;p>>=1){ if (p&1) r=r*x%m; x=x*x%m; } return r;}
ll inv(ll a, ll b){ return a<2 ? a : ((a-inv(b%a,a))*b+1)/a%b; }
int gcd(int a, int b){ if (!b) return a; return gcd(b,a%b);}
ll gcd(ll a, ll b){ if (!b) return a; return gcd(b,a%b);}


int N,M,a[100100];
bool v[100100];

vi g[100100];

void dfs(int nod, vi& val){
	val.pb(a[nod]);
	v[nod]=1;
	
	for (int nxt : g[nod])
		if (!v[nxt])
			dfs(nxt,val);
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> N >> M;
	
	int i;
	for (i=0; i<N; i++)
		cin >> a[i];
	
	
	for (i=0; i<M; i++){
		int x,y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	
	vi left;
	ll res=0,K=0;
	for (i=0; i<N; i++)
		if (!v[i]){
			vi val;
			K++;
			dfs(i,val);
			
			sort(all(val));
			res+=val[0];
			
			for (int j=1; j<(int)val.size(); j++)
				left.pb(val[j]);
		}
	
	if (K==1){
		cout << 0 << "\n";
		return 0;
	}
	
	
	if (left.size()<K-2){
		cout << "Impossible\n";
	}
	else {
		sort(all(left));
		for (i=0; i<K-2; i++)
			res+=left[i];
			
		cout << res << "\n";
	}
	return 0;
}



Measured memory_bytes: 7416
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const ll MAX= 3e5+100;

ll a[MAX];
int main(){
	fastio;
	ll n,k,ans=0;
	cin>>k>>n;
	f(i,0,n) cin>>a[i];
	sort(a,a+n);
	ll x=a[0];
	f(i,0,n-1) a[i]=a[i+1]-a[i];

	a[n-1] = k - a[n-1] + x;
	sort(a,a+n);
	ll sum=0;
	f(i,0,n-1) sum+=a[i];
	cout<<sum<<endl;
  	return 0;	
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;

/**
 * D_Carousel
 */
public class Main {
    public static void main(String[] args) {
        InputReader ir = new InputReader();
        OutputWriter ow = new OutputWriter();

        solve(ir, ow);

        ow.flush();
    }

    private static void solve(InputReader ir, OutputWriter ow) {
        int N = ir.nextInt(), M = ir.nextInt();

        int[] votes = new int[N];
        int totalVotes = 0;

        for (int i = 0; i < N; i++) {
            votes[i] = ir.nextInt();
            totalVotes += votes[i];
        }

        double limit = (double) totalVotes / (4 * M);

        int count = 0;

        for (int i = 0; i < N; i++) {
            if (votes[i] >= limit) {
                count++;
            }
        }

        ow.print((count >= M) ? "Yes" : "No");
    }
}

////////////////// IO //////////////////////

class InputReader {
    private BufferedReader br;
    private StringTokenizer st;

    InputReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        return st.nextToken();
    }

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

    long nextLong() {
        return Long.parseLong(next());
    }
}

class OutputWriter {
    private BufferedWriter bw;

    OutputWriter() {
        bw = new BufferedWriter(new OutputStreamWriter(System.out));
    }

    void print(String s) {
        try {
            bw.write(s, 0, s.length());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void println() {
        try {
            bw.newLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void println(String s) {
        print(s);
        println();
    }

    void print(int x) {
        print(Integer.toString(x));
    }

    void println(int x) {
        println(Integer.toString(x));
    }

    void print(long l) {
        print(Long.toString(l));
    }

    void println(long l) {
        println(Long.toString(l));
    }

    void print(Object o) {
        print(o.toString());
    }

    void println(Object o) {
        println(o.toString());
    }

    void flush() {
        try {
            bw.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 21588
s=input()
s=s[::-1]
t=""
flag=False

while(len(s)>0):
  if(s[0:5]=="maerd" or s[0:5]=="esare"):
    s=s[5:]
  elif(s[0:7]=="remaerd"):
    s=s[7:]
  elif(s[0:6]=="resare"):
    s=s[6:]
  else:
    break
  if(len(s)==0):
    flag=True
    
if(flag):
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

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

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll n;
	cin >> n;
	vll x(n), y(n), h(n);
	vll zx, zy;
	rep(i, 0, n) {
		cin >> x[i] >> y[i] >> h[i];
	}

	vector<vll> c;
	rep(i, 0, 101) {
		rep(j, 0, 101) {
			vll tmp(3);
			tmp[0] = i;
			tmp[1] = j;
			tmp[2] = -1;
			c.push_back(tmp);
		}
	}

	rep(i, 0, n) {
		if (h[i] != 0) {
			vector<vll> d;
			rep(j, 0, c.size()) {
				ll lh = abs(x[i] - c[j][0]) + abs(y[i] - c[j][1]) + h[i];
				if (lh >= 1) {
					if (c[j][2] == -1) {
						c[j][2] = lh;
						d.push_back(c[j]);
					}
					else if (c[j][2] == lh) {
						d.push_back(c[j]);
					}
				}
			}
			c = d;
		}
		else {
			zx.push_back(x[i]);
			zy.push_back(y[i]);
		}
	}
	rep(i, 0, zx.size()) {
		vector<vll> d;
		rep(j, 0, c.size()) {
			if (abs(zx[i] - c[j][0]) + abs(zy[i] - c[j][1]) >= c[j][2]) {
				d.push_back(c[j]);
			}
		}
		c = d;
	}

	rep(i, 0, c.size()) {
		cout << c[i][0] << " " << c[i][1] << " " << c[i][2] << endl;
	}
	return 0;

}


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

int N;
int L = 0,R = 0;
char S[110];

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        scanf(" %c",&S[i]);
        if(S[i] == '(')
        {
            R++;
        }
        else
        {
            if(R == 0)
            {
                L++;
            }
            else
            {
                R--;
            }
        }
    }
    for(int i = 0; i < L; i++)
    {
        printf("%c",'(');
    }
    for(int i = 0; i < N; i++)
    {
        printf("%c",S[i]);
    }
    for(int i = 0; i < R; i++)
    {
        printf("%c",')');
    }
    printf("\n");
    return 0;
}


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

typedef long long ll;

int main() {
	int N; cin >> N;
	vector<int> D(N);
	map<int,int> Dm;
	for (int i = 0; i < N; i++) {
		cin >> D[i];
		Dm[D[i]]++;
	}
	int M; cin >> M;
	vector<int> T(M);
	for(int i=0; i<M; i++) cin >> T[i];

	for (int i = 0; i < M; i++) {
		if (Dm[T[i]] > 0) {
			Dm[T[i]]--;
		}
		else {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;
}

Measured memory_bytes: 11136
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		int x = a * b;
		int y = (a + b) * 2;

		System.out.print(x);
		System.out.print(" ");
		System.out.print(y);
		System.out.println("");

		scan.close();
	}
}


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

int main () {
  long N;
  cin >> N;
  vector<string> S(N);
  vector<char> s(N);
  long m = 0, a = 0, r = 0, c = 0, h = 0;
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
    s.at(i) = S.at(i).at(0);
    if (s.at(i) == 'M') m++;
    else if (s.at(i) == 'A') a++;
    else if (s.at(i) == 'R') r++;
    else if (s.at(i) == 'C') c++;
    else if (s.at(i) == 'H') h++;
  }
  long ans = m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h;
  cout << ans << endl;
}

Measured memory_bytes: 6272
from sys import stdin
import math
import fractions
from collections import deque
import itertools

INF = 10 ** 10

# H <= 2000, W <= 2000
# H*W -> O(4*10^6)
H, W = [int(x) for x in stdin.readline().rstrip().split()]
S = [stdin.readline().rstrip() for _ in range(H)]

# L[i][j]: i行目j列目に明かりを置いたときにそこから左方向に照らされるマスの個数
#          (i行目j列目のマスを含む)
L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]

# L
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            L[i][j] = 0
            continue

        if j == 0:
            L[i][j] = 1
        # j >= 1
        else:
            L[i][j] = L[i][j-1] + 1

# R
for i in range(H-1, -1, -1):
    for j in range(W-1, -1, -1):
        if S[i][j] == "#":
            R[i][j] = 0
            continue

        if j == W-1:
            R[i][j] = 1
        else:
            R[i][j] = R[i][j+1] + 1

# U
for j in range(W):
    for i in range(H):
        if S[i][j] == "#":
            U[i][j] = 0
            continue

        if i == 0:
            U[i][j] = 1
        else:
            U[i][j] = U[i-1][j] + 1

# D
for j in range(W-1, -1, -1):
    for i in range(H-1, -1, -1):
        if S[i][j] == "#":
            D[i][j] = 0
            continue

        if i == H-1:
            D[i][j] = 1
        else:
            D[i][j] = D[i+1][j] + 1


ans = -INF

for i in range(H):
    for j in range(W):
        ans = max(ans, L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3)

# for DEBUG
#print(*S, sep="\n")
#print(L)
#print(R)
#print(D)
#print(U)

print(ans)

Measured memory_bytes: 187632
#include<bits/stdc++.h>
using namespace std;
inline void chmin(int& a, int b) { a = min(a, b); }

const int INF = INT_MAX;
const int MAX_N  = 1000000;
const int BACKET = sqrt(MAX_N);

 
int main()
{
  int N, Q;
  int A[MAX_N];
  int small[MAX_N / BACKET + 1];
  fill_n(A, MAX_N, INF);
  fill_n(small, MAX_N / BACKET + 1, INF);
   
  scanf("%d %d", &N, &Q);
  
  while(Q--) {
    int t, a, b;
    scanf("%d %d %d", &t, &a, &b);
    if(t == 0) {
      int curr = a / BACKET;
      A[a] = b;
      small[curr] = INF;
      for(int i = 0; i < BACKET; i++) chmin(small[curr], A[curr * BACKET + i]);
    } else {
      int begin = (a + BACKET - 1) / BACKET;
      int end   = b / BACKET;
      int ret = INF;
      if(begin >= end) {
        for(int i = a; i <= b; i++) chmin(ret, A[i]);
      } else {
        for(int i = begin * BACKET - 1; i >= a; i--) chmin(ret, A[i]);
        for(int i = begin; i < end; i++) chmin(ret, small[i]);
        for(int i = end * BACKET; i <= b; i++) chmin(ret, A[i]); 
      }
      printf("%d\n", ret);
    }
  }
}

Measured memory_bytes: 5100
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.HashMap;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            long s = 0;
            Map<Long, Integer> m = new HashMap<>();
            m.put(0L, 1);
            long ans = 0;
            for (int i = 0; i < n; i++) {
                s += in.nextInt();
                int v = 0;
                if (m.containsKey(s)) {
                    v = m.get(s);
                    ans += v;
                }
                m.put(s, v + 1);
            }
            out.println(ans);
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

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

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

    }
}



Measured memory_bytes: 52544
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m; cin>>n>>m;
    vector <int> x(n+1), y(m+1);
    cin>>x[0]>>y[0];
    for(int i=1;i<=n;i++){
        cin>>x[i];
    }
    for(int i=1;i<=m;i++){
        cin>>y[i];
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    bool war = false;
    for(int i=-100;i<=100;i++){
    if(i>x[n]&&i<=y[0]) war = true;
    }
    if(war) cout<<"No War"<<endl;
    else cout<<"War"<<endl;
}

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

int main(){
    string s;
    cin>>s;
    int cnt=1;
    char prev=s[0];
    for(int i=0;i<s.size();i++){
        if(s[i]!=prev){
            cnt++;
            prev=s[i];
        }
    }
    cout<<cnt-1<<endl;
    return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;

  int ans = 0;
  rep (i, n) {
    int h;  cin >> h;
    if (h >= k) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
"use strict";

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

function main(input) {
  const [firstLine, ...routes] = input.split("\n");
  const start = 1;
  const [goal, routeCount] = firstLine.split(" ").map(Number);

  const hasStart = [];
  const hasGoal = [];
  let ans = "IMPOSSIBLE";
  for(let i = 0; i < routeCount; i++) {
    const [a, b] = routes[i].split(" ").map(Number);
    if(a === start) {
      hasStart[b] = true;
      if(hasGoal[b]) {
        ans = "POSSIBLE";
        break;
      }
    } else if(b === goal) {
      hasGoal[a] = true;
      if(hasStart[a]) {
        ans = "POSSIBLE";
        break;
      }
    }
  }

  console.log(ans);
}

Measured memory_bytes: 53284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const double PI = 3.1415926535;

int main() {
    double a, b, x; cin >> a >> b >> x;
    cout << setprecision(20);
    if (x <= a * a * b / 2) {
        double t = (2 * x) / (a * b);
        cout << atan(b/t) * 180 / PI << endl;
    }
    else {
        double t = 2 * (a * a * b - x) / (a * a);
        cout << atan(t/a) * 180 / PI << endl;
    }
}

Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var a, b int

	fmt.Scan(&a, &b)

	if b > a {
		a, b = b, a
	}

	for {
		if a%b == 0 {
			break
		}
		a, b = b, a%b
	}
	fmt.Println(b)
}



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

int partition(vector<int> &vec,int p,int r){
  int x,i,j;

  x = vec.at(r);
  i = p - 1;
  for(j=p;j<r;j++){
    if(vec.at(j) <= x){
      i++;
      swap(vec.at(i),vec.at(j));
    }
  }
  swap(vec.at(i+1),vec.at(r));
  return i + 1;
}

int main(){
  int i,q,n;

  cin >> n; vector<int> vec(n);
  for(i=0;i<n;++i){
    cin >> vec.at(i);
  }
  q = partition(vec,0,n-1);
  for(i=0;i<n-1;++i){
    if(i == q) cout << "[";
    cout << vec.at(i);
    if(i == q) cout << "]";
    cout << " ";
  }
  cout << vec.at(n-1) << endl;
  return 0;
}



Measured memory_bytes: 3132
from itertools import product

H, W, K = map(int, input().split())
grid = [input() for _ in range(H)]
ans = 0
for h, w in product(range(1 << H), range(1 << W)):
    temp = 0
    for i in range(H):
        if (h & (1 << i)):
            for j, c in enumerate(grid[i]):
                if (w & (1 << j)) and c == '#': temp += 1
    if temp == K: ans += 1
print(ans)

Measured memory_bytes: 9196
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define I(n) scanf("%d", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

int mat,k,n,ret[300001];

int main(){
    I(k); I(n);

    if (k%2){
        REP(i,n){ ret[i] = (k+1)/2;}
        mat = n-1;
        REP(i,n/2){
            if (ret[mat] == 1){
                ret[mat] = 0;
                mat--;
            } else {
                ret[mat] -= 1;
                FOR(j,mat+1,n){
                    ret[j] = k;
                }
                mat = n-1;
            }
        }
    } else {
        mat = n-1;
        REP(i,n){ ret[i] = k;}
        ret[0] = k/2;
    }
    REP(i,mat){ cout << ret[i] << " " ;}
    cout << ret[mat] << endl;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int n,m,fa[100005],a[100005],b[100005],t,x,y;
long long s;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
int find(int r){return fa[r]?fa[r]=find(fa[r]):r;}
int main(){
	n=read(),m=read();
	if(m==n-1) return 0*puts("0");
	for(int i=1;i<=n;++i) a[i]=read(),s+=a[i];
	for(int i=1;i<=m;++i){
		x=read(),y=read();
		x=find(x+1),y=find(y+1);
		s-=max(a[x],a[y]);
		b[++t]=max(a[x],a[y]);
		if(a[x]>a[y]) fa[x]=y;else fa[y]=x;
	}
	if(t<n-m-2) return 0*puts("Impossible");
	sort(b+1,b+t+1);
	for(int i=1;i<=n-m-2;++i) s+=b[i];
	printf("%lld",s);
}
//既然输入的都是树，并且要求加的边的点权最小，不妨将每一棵树考虑成一棵小根树
//显然最优的情况就是把每一棵树的顶点和剩下最小的n-m-2个点连接
//用并查集维护根最小，先把所有点加入sum，每次加入边的时候找它们所在树的根都，把大的点从sum里删除并并入小的点所在的树 
//最后剩下的sum一定是所有树的根的和
//排序一下剩下的点，取最小的n-m-2个点计入sum即为答案 

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s, t; cin >> s >> t;
    int n = s.length();
    vector<VI> wh(26);
    FOR(i, 0, n)wh[s[i] - 'a'].push_back(i);
    ll ans = 0;
    int now = -1;
    each(c, t) {
        if (wh[c - 'a'].empty()) {
            cout << "-1\n";
            return 0;
        }
        auto itr = lower_bound(all(wh[c - 'a']), now + 1);
        if (itr == wh[c - 'a'].end()) {
            ans += n;
            now = wh[c - 'a'].front();
        }
        else now = *itr;
    }
    cout << ans + now + 1 << "\n";
}

Measured memory_bytes: 1228
#include <stdio.h>

int
main(void)
{
  int count;
  char str[256];
  int R = 0;
  int B = 0;
  
  scanf("%d", &count);
  scanf("%s", str);
  
  for (int i = 0; i < count; i++) {
    if (str[i] == 'R')
      R++;
    else
      B++;
  }
  
  if (R > B)
    printf("Yes");
  else
    printf("No");

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

unordered_map<ll, ll> prim(ll a) {
    unordered_map<ll, ll> ans;
    ll x = 2;
    while(x * x <= a){
        if (a % x == 0) {
            ans[x]++;
            a /=x;
        }
        else {
            x++;
        }
    }
    ans[a]++;
    return ans;
}

ll myPow(ll x, ll n) {
    if (n == 0)
        return 1;
    if (n % 2 == 0)
        return myPow(x * x, n / 2);
    else
        return x * myPow(x, n - 1);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b, c;
    cin >> a >> b >> c;
    auto P = prim(a);
    auto P2 = prim(b);
    for (auto& p : P2) {
        P[p.first] += p.second;
    }

    bool is_all = true;
    ll ab = 1;
    for (auto& p : P) {
        if (p.second % 2 != 0) {
            is_all = false;
            break;
        }
        ab *= myPow(p.first, (p.second / 2));
    }
    if (is_all == true) {
        if (a + 2 * ab + b == c) {
            cout << "No" << endl;
            return 0;
        }
    }
    if ((c- a - b) > 0 && (4 * a * b )< (c - a- b) * (c - a - b)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
  string a,b;
  cin >> a >> b;
  if (a.at(0)==b.at(2) && a.at(1)==b.at(1) && a.at(2)==b.at(0))cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
<?php
list($a, $b, $c, $d, $e, $f) = explode(" ", trim(fgets(STDIN)));

for($i = 0; $i * 100 * $a <= $f; $i++){
    for($j = 0; $i * 100 * $a + $j * 100 * $b <= $f; $j++){
        $map[$i * 100 * $a + $j * 100 * $b] = true;
    }
}
$keys = array_keys($map);
sort($keys);

for($i = 0; $i * $c <= $f; $i++){
    for($j = 0; $i * $c + $j * $d <= $f; $j++){
        $map2[$i * $c + $j * $d] = true;
    }
}
$keys2 = array_keys($map2);
sort($keys2);

$max = -1;
$maxD = 0;
$maxS = 0;
foreach($keys as $w){
    foreach($keys2 as $s){
        if($w == 0)continue;
        if($w + $s > $f)continue;
        $den = $s / ($w + $s);
        if($den > $max && $s / $w <= $e / 100){
            $maxW = $w;
            $maxS = $s;
            $max = $den;
        }
    }
}
echo ($maxW + $maxS)." ".$maxS;


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

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;

ll gcd(ll a, ll b) {
    if (a < b) {
        swap(a, b);
    }

    /* ユークリッドの互除法 */
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int64_t t = __pow_mod(n, p / 2, mod);
        return (t * t) % mod;
    }
    return (n * (__pow_mod(n, p - 1, mod) % mod)) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    int64_t res = __pow_mod(n, p, mod);
    if (res == 0) {
        res = mod;
    }
    return res;
}

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> A) {
    sort(A.begin(),A.end());
    auto iter = unique(A.begin(), A.end());
    if (iter == A.end()) {
        cout << YES << endl;
    } else {
        cout << NO << endl;
    }


}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
    long long N;
    std::cin >> N;
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        std::cin >> A[i];
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#define MOD 1000000007

typedef long long ll;
using namespace std;

int main(void) {
    //ll a=0,b=0,c=0;
    //ll i=0,j=0;
    int n=0,k=0;
    string s;
    cin >> n >> k;
    cin >> s;
    s[k-1]+=32;
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
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;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;

void solve()
{
	int s, w;
	cin >> s >> w;
	if(s<=w)
		cout << "unsafe";
	else
		cout << "safe";
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  int n, x, y;
  cin >> n >> x >> y;
  int l[3000];
  for(int i=0; i<n-1; i++){
    for(int j=i+1; j<n; j++){
      int l1=j-i-1;
      int l2=abs(x-i-1)+abs(y-j-1);
      int l3=abs(x-j-1)+abs(y-i-1);
      l[min({l1, l2, l3})]++;
    }
  }
  for(int i=0; i<n-1; i++){
    cout << l[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double lb;
const ll MOD=1;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
void IOS(){	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return ;}

ll dp[100005][5],n,u[100205][5];

ll f(int w,int type){
	if(w>=n)return 0;
	if(dp[w][type]!=-1)return dp[w][type];
	ll tmp=0;
	REP(i,3){
		if(i==type)continue;
		tmp=max(u[w][i]+f(w+1,i),tmp);
	}
	return dp[w][type]=tmp;
}

int main(){
	IOS();
	memset(dp,-1,sizeof(dp));
	cin>>n;
	REP(i,n){
		REP(j,3){
			cin>>u[i][j];
		}
	}
	cout<<max(max(u[0][0]+f(1,0),u[0][1]+f(1,1)),u[0][2]+f(1,2));
	return 0;
}

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


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

    
    if (A+B>=10) {
        cout<<"error";
    }
    
    else
    {
        cout<<A+B;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()


black = [0]*(N+1)
for i in range(N):
    if S[i] == "#":
        black[i+1] = black[i]+1
    else:
        black[i+1] = black[i]

ans = N
for i in range(N+1):
    tmp = (black[N-i]-black[0])+(i-(black[N]-black[N-i]))
    ans = min(tmp, ans)
print(ans)


Measured memory_bytes: 11144