akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#include <set>
#include <climits>
#define lli long long int
#define ll long long
#define mod 1000000007
#define pii pair<int,int>
#define mp make_pair
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
        int n;
        cin >> n;
        int p[n];
        int count = 0;
        rep(i, n){
                cin >> p[i];
        }
        for(int j = 1; j < n - 1; j++){
                if(p[j] < p[j-1] && p[j+1] < p[j]){
                        count++;
                }
                if(p[j] < p[j+1] && p[j-1] < p[j]){
                        count++;
                }
        }
        cout << count;
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>  // sort, 二分探索, etc
#include <iomanip>  // setprecision (浮動小数点の出力の誤差)
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cmath>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define cauto const auto&
#define UNIQUE(v) (v).erase( unique(all(v), (v).end() );
#define SZ(x) ((ll)(x).size()) // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define INF 1000000000000
#define MOD 1000000007
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

using namespace std;
using ll = long long;
using ull = unsigned long long;

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

const char newl = '\n';
const double PI = 3.14159265358979;

ll qp(ll a,ull b){ll ans=1;do{if(b&1u)ans*=a;a*=a;}while(b>>=1u);return ans;}
ll qp(ll a,ull b,ll mod){ll ans=1;do{if(b&1u)ans=ans*a%mod;a=a*a%mod;}while(b>>=1u);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll comb(int n, int r) {
    vector<vector<ll> > v(n+1, vector<ll>(r+1, 0));
    for(int i=0;i<n+1;i++) {v[i][0]=1; if(i < r+1)v[i][i]=1; }
    for(int i=1;i<n+1;i++) {for(int j=1;j<min(i,r+1);j++) {v[i][j]=v[i-1][j-1]+v[i-1][j];}}
    return v[n][r];
}

// INT_MAX   = 2.1e+09 (2147483647)
// LONG_MAX  = 9.2e+18 (9223372036854775807)
// LLONG_MAX = 9.2e+18 (9223372036854775807)


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

    double degree_m = m / 60.0;
    double degree_h = (h / 12.0 + degree_m / 12.0);
    double theta = abs(degree_m - degree_h) * 2 * PI;

    double x = sqrt((double)a * a + (double)b * b - 2.0 * a * b * cos(theta));

    cout << setprecision(15) << x << newl;

    return 0;
}


Measured memory_bytes: 3616
# AtCoder Beginner Contest 146 - B
# -*- encoding: UTF-8 -*-

n = int(input())
s = input()
result = ""

for c in s:
   o = ord(c) - 65
   d = (o + n) % 26 + 65
   dc = chr(d)
   result = result + dc

print(result)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,t;
  while(1){
  int ans = 0;
  int r[200]={};
  cin >> a >> b;
  if(a==0 && b==0) break;
  for(int i=0; i<a; i++){
    cin >> c;
    for(int i=0; i<c; i++){
      cin >> d;
      r[d]++;
    }
  }
  t = 0;
  for(int i=0; i<200; i++){
    if(r[i]>=b && ans < i && t < r[i]){
      ans = i;
      t = r[i];
    }
  }
  cout << ans << endl;
  }
  return 0;
}




Measured memory_bytes: 3084
#include<bits/stdc++.h>
long long int a[1000009];
using namespace std;
typedef long long int ll;
int main()
{
    ll i,j,n,k,t1,t,t2,s=0,c,a,b;
    map<string,ll>mp;
    map<string,ll>::iterator it;
    vector<ll> v;
    pair<char,ll>p;
    list<ll>l;
    string s1,s2;
    cin>>a>>b>>c;
    if(b-a==c-b)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
   // main();
    return 0;
}



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

int main(){
  vector<int> v(5);
  int time_sum = 0, min=10;
  for(int i=0; i<5;i++){
    cin >> v[i];
    time_sum += (((v[i] - 1)/10) + 1)*10;
    if((v[i] % 10) < min && v[i] % 10 != 0){
      min = v[i] % 10;
    }
  }
  
  if(min == 10)cout << time_sum << endl;
  else cout << time_sum + min - 10 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	string str;
	cin >> str;
	int k;
	scanf("%d",&k);
	for(int i=0;i<str.size();i++){
		int d=str[i]-'a';
		if(d>0){
			int step=26-d;
			if(k>=step){
				k-=step;
				str[i]='a';
			}
		}
	}
	if(k>0){
		int nex=str[str.size()-1]-'a'+k;
		nex%=26;
		str[str.size()-1]=nex+'a';
	}
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 512
import collections


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def main():
    n = int(input())
    factor_counts = collections.Counter(prime_factorize(n))

    result = 0

    for _, c in factor_counts.items():
        current_c = c
        n = 1
        while current_c >= n:
            current_c = current_c - n
            result += 1
            n += 1

    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9464
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
struct edge{
	int to,next;
};
int n,res;
struct Tree{
	int fa[N],dep[N];
	edge e[N*2];
	int head[N],tot,rt;
	void add(int x,int y){
		e[++tot]=(edge){y,head[x]};
		head[x]=tot;
	}
	void dfs(int x){
		for (int i=head[x];i;i=e[i].next)
			if (e[i].to!=fa[x]){
				fa[e[i].to]=x;
				dep[e[i].to]=dep[x]+1;
				dfs(e[i].to);
			}
	}
	void init(int n){
		memset(head,0,sizeof(head));
		tot=dep[rt]=fa[rt]=0;
		for (int i=1;i<n;i++){
			int x,y;
			scanf("%d%d",&x,&y);
			add(x,y); add(y,x);
		}
		dfs(rt);
	}
	int dis(int x,int y){
		int ans=0;
		for (;x!=y&&ans<3;ans++)
			if (dep[x]>dep[y])
				x=fa[x];
			else y=fa[y];
		return ans==3;
	}
}A,B;
int dfs(int x){
	int ans=B.dep[x];
	for (int i=A.head[x];i;i=A.e[i].next){
		int to=A.e[i].to;
		if (to==A.fa[x]) continue;
		if (B.dis(x,to)) return 2e9;
		if (A.dep[to]<B.dep[to])
			ans=max(ans,dfs(to));
	}
	return ans;
}
int main(){
	scanf("%d%d%d",&n,&A.rt,&B.rt);
	A.init(n); B.init(n);
	int ans=dfs(A.rt);
	printf("%d\n",ans>1e9?-1:ans*2);
}

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

int N;
int t[100000], x[100000], y[100000];

void input() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> t[i] >> x[i] >> y[i];
}

int main() {
    input();
    int x_pos = 0;
    int y_pos = 0;
    int diff = 0;
    int flg = 1;
    int bt = 0;

    for(int i = 0; i < N;i++){
        diff = abs(x_pos - x[i]) + abs(y_pos - y[i]);
        if(diff <= t[i] && (diff % 2) == ((t[i] - bt) % 2)){
            x_pos = x[i];
            y_pos = y[i];
        } else {
            cout << "No" << endl;
            flg = 0;
            break;
        }
        bt = t[i];
    }
    if(flg){
        cout << "Yes" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    int n;
    scanf("%d", &n), n %= 10;
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9) printf("hon\n");
    else if(n == 0 || n == 1 || n == 6 || n == 8) printf("pon\n");
    else printf("bon\n");
    return 0;
}

Measured memory_bytes: 3688
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    int x,y;
    x=a;
    if(x>b) x=b;
    if(x>c) x=c;
    y=d;
    if(y>e) y=e;
    cout<<y+x-50;
    cout<<endl;
}



Measured memory_bytes: 3088
import java.util.Arrays;
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            
            int[] l = new int[3];
            
            for (int j = 0; j < 3; j++) {
                l[j] = sc.nextInt();
            }
            
            Arrays.sort(l);

            if ((l[2]*l[2]) == ((l[1]*l[1])+(l[0]*l[0]))) {
                System.out.println("YES");
            }
            else{
                System.out.println("NO");
            }
        }
    }
}

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

using namespace std;

int main(int argc, char *argv[]) {
    string s;
    cin >> s;
    char prev = 'Z';
    bool bad(false);
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == prev) {
            bad = true;
            break;
        }
        prev = s[i];
    }

    cout << ((bad) ? "Bad" : "Good") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LLong_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;



int main() {
    int n,k=1,re;
    bool ch = false;
    cin >> n;
    vector<int> data(n);
    rep(i,n) {
        cin >> re;
        if(re == k) {
            ch = true;
            k++;
        }
    }
    if(ch) {
        cout << n - (k - 1)  << endl;
    } else {
        cout << "-1" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
  int N, M; cin >> N >> M;
  vector<pair<int, int>> AB(N);
  for (int i = 0; i < N; ++i) {
    cin >> AB[i].first >> AB[i].second;
  }

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

  unsigned long sum = 0;
  for (int drink_num = M, i = 0; drink_num > 0;) {
    sum += AB[i].first;
    drink_num--;
    AB[i].second--;

    if (AB[i].second == 0) {
      i++;
    }
  }

  cout << sum << endl;
}

Measured memory_bytes: 1152
import java.util.BitSet;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			BitSet routeTo1 = new BitSet(n), routeToN = new BitSet(n);
			IntStream.range(0, m).forEach(i -> {
				int a = scanner.nextInt() - 1;
				int b = scanner.nextInt() - 1;
				if (0 == Math.min(a, b)) {
					routeTo1.set(Math.max(a, b), true);
				}
				if (n - 1 == Math.max(a, b)) {
					routeToN.set(Math.min(a, b), true);
				}
			});
			int count = (int) IntStream.range(1, n - 1).filter(i -> routeTo1.get(i) && routeToN.get(i)).count();
			System.out.println((count > 0) ? "POSSIBLE" : "IMPOSSIBLE");
		}
	}
}


Measured memory_bytes: 94832
#include <iostream>
#include <string>
#include <ctype.h>

int main() 
{
    unsigned int goods = 0;
    unsigned int num = 0;

    std::cin >> goods;
    if (1 > goods || 10000 < goods)
    {
        std::cout << "Error" << std::endl;
        return -1;
    }
    num = goods % 1000;

    if (0 == num) {
        std::cout << "0" << std::endl;
    }
    else
    {
        num = 1000 - num;
        std::cout <<  num;
    }
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf = 10e17;
int findLowerBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{

    auto low = lower_bound(arr.begin(),
                           arr.end(), p);

    return low - arr.begin();
}
int findUpperBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{
    auto up = upper_bound(arr.begin(),
                          arr.end(), p);

    return up - arr.begin();
}
bool vis[200005];
vector<int> vec[100005];
int child[100005];
void dfs(int node)
{
    vis[node] = 1;
    for (int i = 0; i < vec[node].size(); i++)
    {
        if (!vis[vec[node][i]])
        {
            dfs(vec[node][i]);
            child[node] += child[vec[node][i]];
        }
    }
}
void belman(int n, int m, vector<pair<int, pair<int, int>>> vec, int dis[])
{
    for (int i = 0; i <= n + m - 1; i++)
    {
        for (int j = 0; j < vec.size(); j++)
        {
            int u = vec[j].second.first;
            int v = vec[j].second.second;
            int w = vec[j].first;

            if (dis[u] + w < dis[v])
            {
                dis[v] = dis[u] + w;
            }
        }
    }
}
int fun(int a, int b)
{
    if (a > b)
        return 0;
    if (a == b)
        return 1;
    else
    {
        return fun(a + 1, b) + fun(a, b - a);
    }
}
int32_t main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

    int n, m;
    char str;
    cin >> n >> str >> m;
    if (str == '+')
        cout << n + m << "\n";
    else
    {
        cout << n - m << "\n";
    }

    return 0;
}


Measured memory_bytes: 5992
#!/usr/bin/env perl

use strict;
use warnings;

my $s = <>;
chomp $s;

my $found_a = -1;
my $found_z = -1;
my $cnt = 0;

for my $c (split //, $s) {
    if ($c eq 'A' && $found_a == -1) {
        $found_a = $cnt;
    }
    if ($c eq 'Z') {
        $found_z = $cnt;
    }
    $cnt++;
}

print $found_z - $found_a + 1, "\n";


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

int main(){
  int a,b,c,k;
  cin >>a >>b >>c >>k;
  ll ans = 0;
  if(a>=k) ans = k;
  if(a+b<=k) {
      int l = k-(a+b);
      ans = a;
      rep(i,l) ans--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3564
import sys
from operator import itemgetter #sortedの対象を決めたい
from fractions import gcd #最大公約数求めたい
from math import ceil, floor, sqrt #小数点切り上げ、切り捨て、平方根求めたい
from copy import deepcopy #参照で影響されないコピーが作られる
from collections import Counter, deque #要素ごとの出現回数を数える。双方向アクセス可能データ型
import heapq
from functools import reduce
sys.setrecursionlimit(200000)

input = sys.stdin.readline
# template



n = int(input())

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

total = 0
for i in a:
    total += 1/i

print(1/total)




Measured memory_bytes: 5044
#include <cstdio>
#include <cstring>
#include <algorithm>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
using namespace std;

void counting_sort(int a[], const int len, const int maxv)
{
   int cnt[maxv + 1] = {-1};
   int ret[len];

   rep(i, len) ++cnt[ a[i] ];
   reps(i, 1, maxv) cnt[i] += cnt[i-1];

   for(int i=len-1; i>=0; --i){
      int& p = cnt[ a[i] ];
      ret[p] = a[i];
      --p;
   }

   memcpy( a, ret, sizeof(ret) );
   return ;
}

main()
{
   int N, a[2000001], maxv = 0;
   scanf("%d", &N);

   rep(i, N)
      scanf("%d", a+i),
      maxv = max( maxv, a[i] );

   counting_sort(a, N, maxv);

   rep(i, N) printf("%d%c", a[i], i+1 < N ? ' ' : '\n' );
}




Measured memory_bytes: 18308
#include <stdio.h>

int main(int argc, char *argv[])
{
	int a, b;
	while (fscanf(stdin, "%d %d", &a, &b) != -1) {
		int c, d;
		for (c=a+b, d=0; c>0; c/=10, d++);
		printf("%d\n", d);
	}
	return 0;
}

Measured memory_bytes: 604
# -*- coding: utf-8 -*-

from collections import deque


test = ""
#test = \
"""
8
1 2
2 3
2 4
2 5
4 7
5 6
6 8
"""
test = list(reversed(test.strip().splitlines()))
if test:
    def inp():
        return test.pop()
else:
    def inp():
        return input()
    

n = int(inp())
edges = [0] * (n-1)
for i in range(n-1):
    edges[i] = tuple(map(int, inp().split()))


adjacency_list = [[] for i in range(n+1)]
for edge in edges:
    adjacency_list[edge[0]].append(edge[1])
    adjacency_list[edge[1]].append(edge[0])


max_order = max(len(i) for i in adjacency_list)


tag_dict = {1: 0}
edge_dict = dict()
nodeQ = deque([1])

while len(nodeQ):
    current_node = nodeQ.popleft()
    tag = tag_dict[current_node]
    
    a_list = [a for a in adjacency_list[current_node] if current_node < a]
    for (i, a) in enumerate(a_list):        
        tag_dict[a] = (tag + i) % (max_order) + 1
        edge_dict[(current_node, a)] = tag_dict[a]
        nodeQ.append(a)
             
print(max_order)
for edge in edges:
    print(edge_dict[edge])

Measured memory_bytes: 49896
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main(){
    int N; cin >> N;
    vector<int> d(N);
    for(int i = 0; i < N; i++) cin >> d[i];
    int M; cin >> M;
    vector<int> t(M);
    for(int i = 0; i < M; i++) cin >> t[i];
 
    sort(d.begin(), d.end());
    sort(t.begin(), t.end());
 
    int cnt = 0;
    for(int i = 0; i < N; i++)
    {
        if(d[i] == t[cnt]) cnt++;
        if(cnt == M)
        {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 4804
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

template <typename T>
vector<T> Dijkstra(int s, vector<vector<pair<int, T>>>& G,
                   /*vector<int> & prev,*/ const T INF = 1e9) {
    using P = pair<T, int>;
    int V = G.size();
    vector<T> dist(V, INF);
    priority_queue<P, vector<P>, greater<P>> que;
    dist[s] = 0;
    que.emplace(0, s);
    // prev.assign(V, -1);
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (dist[v] < p.first) continue;
        for (int i = 0; i < (int)G[v].size(); i++) {
            int to = G[v][i].first;
            T cost = G[v][i].second;
            if (dist[to] > dist[v] + cost) {
                dist[to] = dist[v] + cost;
                // prev[to] = v;
                que.emplace(dist[to], to);
            }
        }
    }
    return dist;
}

signed main() {
    int h, w;
    cin >> h >> w;
    int sy, sx, gy, gx;
    cin >> sy >> sx;
    cin >> gy >> gx;
    sy--;
    sx--;
    gy--;
    gx--;
    string s[h];
    rep(i, h) {
        cin >> s[i];
    }
    using P = pair<int, int>;
    vector<vector<P>> G(h * w);
    rep(i, h) {
        rep(j, w) {
            if(s[i][j]=='.'){
                for (int y = -2; y <= 2; y++){
                    for (int x = -2; x <= 2; x++){
                        int t = abs(y) + abs(x);
                        if (t == 0) continue;
                        int ny = i + y, nx = j + x;
                        if (ny < 0 || h <= ny || nx < 0 || w <= nx) continue;
                        if (s[ny][nx] == '#') continue;
                        if (t == 1) {
                            G[i * w + j].emplace_back(ny * w + nx, 0);
                        }else{
                            G[i * w + j].emplace_back(ny * w + nx, 1);
                        }
                    }
                }
            }
        }
    }
    auto dist = Dijkstra(sy * w + sx, G, INF);
    cout << (dist[gy * w + gx] != INF ? dist[gy * w + gx] : -1) << endl;
    return 0;
}

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


int main() {
  int N,sum=0; 
  cin>>N;
  int fN=N;

  while(true){
    int a=N%10;
    sum+=a;
    N=N/10;
    if(N<10){
      sum+=N;
      break;
    }
  }
  if(fN%sum==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String[] args)throws IOException {
		InputStreamReader read=new InputStreamReader(System.in);
		BufferedReader in=new BufferedReader(read);
		String s=in.readLine();
		if(s.charAt(2)==s.charAt(3) && s.charAt(4)==s.charAt(5))
		System.out.println("Yes");
		else
		System.out.println("No");
	}
}


Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[9];
  for(int i=0;i<9;i++) cin>>a[i];
  int b=a[0]-a[1],c=a[0]-a[2];
  if(a[3]-a[4]==b&&a[3]-a[5]==c&&a[6]-a[7]==b&&a[6]-a[8]==c)cout<<"Yes";
else cout<<"No";
}

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

namespace cswork {
    class Program {
        static void Main (string[] args) {
            // ontest166.Q6 ();
                        List<long> l = ReadList ();
            long s = l[0];
            long w = l[1];

            if (s <= w) {
                Write ("unsafe");
            } else {
                Write ("safe");
            }
            Exit ();
        }

        public static void Write (string str) {
            Console.WriteLine (str);
        }

        public static void Write (int i) {
            Console.WriteLine (i);
        }

        public static void Write (double d) {
            Console.WriteLine (d);
        }

        public static string ReadStr () {
            return Console.ReadLine ();
        }

        public static int ReadInt () {
            return int.Parse (Console.ReadLine ());
        }

        public static long Read () {
            return long.Parse (Console.ReadLine ());
        }

        public static double ReadDouble () {
            return double.Parse (Console.ReadLine ());
        }

        public static void Exit () { }

        public static List<string> ReadListStr () {
            return new List<string> (ReadStr ().Split (" "));
        }

        public static List<long> ReadList () {
            return ReadListStr ().ConvertAll (x => long.Parse (x));
        }
    }
}

Measured memory_bytes: 27784
package main

import "fmt"

func main(){
	var A, B, C int
	fmt.Scan(&A, &B, &C);

	if A == B && A != C || A == C && A != B || B == C && A != B || B == C && A != C {
		fmt.Println("Yes");
	}else {
		fmt.Println("No");
	}

	
}

Measured memory_bytes: 512
#include<stdio.h>
#define max (m+n)>(m*n)?(m+n):(m*n)
int main()
{
	int n,m;
	while(~scanf("%d %d",&m,&n))
	{
		printf("%d\n",(m-n)>(max)?(m-n):(max));	
	}
	return 0;
}

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

# 辺を保持しつつ根を見つける
edge = [set() for _ in range(N+1)]
indim = [0] * (N+1)
parent = [-1] + [0] * N
for _ in range(N-1+M):
  a, b = map(int, input().split())
  parent[b] = a
  edge[a].add(b)
  indim[b] += 1
root = parent.index(0)

# 根から幅優先でたどっていく
ans = [-1] * (N+1)
q = set([root])
while len(q):
  nq = set()
  for p in q:
    for c in edge[p]:
      indim[c] -= 1
      if indim[c] == 0:
        nq.add(c)
        ans[c] = p
  q = nq

for i in range(1, N+1):
  print(ans[i] if ans[i] > 0 else 0)

Measured memory_bytes: 45692
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll a[310],y,z = 0,b;
vector<ll> v,w;
int main(){
    int i,j,n;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
        z ^= a[i];
    }
    z ^= a[0]^a[1];
    b = a[0];
    ll sum = a[0] + a[1];
    for(i=0;i<=50;i++){
        if(z & (1LL<<i)){
            sum -= (1LL<<i);
        }else{
            v.push_back(i);
        }
    }
    if(sum<0 || sum&1){
        cout << -1 << endl;
        return 0;
    }
    //cout << "b " << endl;
    sum /= 2;
    for(i=50;i>=0;i--){
        if(z & (1LL<<i)) continue;
        if(sum>=(1LL<<i)){
            sum -= (1LL<<i);
            w.push_back(i);
        }
    }
    if(sum!=0){
        cout << -1 << endl;
        return 0;
    }
    //cout << " a " << endl;
    for(i=0;i<w.size();i++){
        int d = w[i];
        //cout << "  c " << d << endl;
        a[0] -= (1LL<<d);
    }
    if(a[0]<0){
        cout << -1 << endl;
        return 0;
    }
    //cout << a[0] << endl;
    for(i=50;i>=0;i--){
        bool flag = true;
        for(j=0;j<v.size();j++){
            if(v[j]==i) flag = false;
        }
        if(!flag) continue;
        if(a[0] >= (1LL<<i)) a[0] -= (1LL<<i);
    }
    if(b==a[0]){
        cout << -1 << endl;
        return 0;
    }
    cout << a[0] << endl;
}

Measured memory_bytes: 3640
import java.util.*;
import java.util.Scanner;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    Map <Integer,Integer> map = new TreeMap<>();

    for(int i=1 ; i<=n ; i++){
      map.put(sc.nextInt(),i);
    }

    for(int i=1 ; i<=n ; i++){
      System.out.print(map.get(i)+" ");
    }
  }
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    if(
            (a == 5 && b == 5 && c == 7) || 
            (a == 5 && b == 7 && c == 5) || 
            (a == 7 && b == 5 && c == 5) 
      )cout << "YES";
    else cout << "NO";
}


Measured memory_bytes: 256
def main():
    n = int(input())
    nums = [0]
    for i in range(1, n + 1):
        d = i
        count = 0
        while d != 0:
            d, amari = divmod(d, 2)
            if amari != 0:
                break
            count += 1
        nums.append(count)
    if n == 1:
        print(1)
    else:
        print(nums.index(max(nums)))


if __name__ == '__main__':
    main()

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

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; }
const ll INF = 1LL << 60;

//Write From this Line

int main()
{
	int a[32] ={	1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k; 
	cin >>  k; 
	--k;
	cout << a[k] << endl;
}


Measured memory_bytes: 256
r, g, b, n = map(int, input().split())

colors = sorted([r, g, b])

cnt = 0
for i in range(n // colors[2] + 1):
  for j in range((n - i*colors[2]) // colors[1] + 1):
    if (n - i*colors[2] - j*colors[1]) % colors[0] == 0:
      cnt += 1
        
print(cnt)

Measured memory_bytes: 3060
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

A, B, C = MAP()
print("Yes" if A == B == C else "No")

Measured memory_bytes: 5148
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	char c=getchar();int x=0,f=1;
	while(c<'0'||c>'9'){ if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return x*f;
}
int n,a[205],ans;
int main(){
	n=read();
	for(int i=1;i<=n*2;++i){
		a[i]=read();
	}
	sort(a+1,a+2*n+1);
	for(int i=1;i<=n;++i){
		ans+=a[i*2-1];
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//  
//

#include <bits/stdc++.h>
#include <random>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;

//#define __DBG__



void solve(void){
  
  ll H,W;
    
  cin >> H >> W;
  
  if(H==1||W==1){
    cout << 1 << endl;
    return;
  }
  
  ll he = (H+1)/2;
  ll we = (W+1)/2;
  
  ll ho = H-he;
  ll wo = W-we;
  
  ll sum = we * he + wo * ho;
  
  cout << sum << endl;
  
  return;
}


int main(int argc, const char * argv[]) {


    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
 
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
 
struct cmp{
    bool operator()(const string &a,const string &b){
        int brackets_a=0;
        for(auto i : a) if(i==')') brackets_a--; else brackets_a++;
        int brackets_b=0;
        for(auto i : b) if(i==')') brackets_b--; else brackets_b++;
        if(brackets_a==brackets_b) return a.size()<b.size();
        return brackets_a>brackets_b;    
    }
};
 
int32_t main(){
    int n;cin>>n;
    vector<string> v(n);
    vector<string> vs;
    int idx=0;
    string only_openings;
    string only_closings;
    for(auto &i : v) {
        cin>>i;
        string s;
        stack<char> st;
        for(auto j : i){
            if(st.empty()) st.push(j);
            else if(j==')'&&st.top()=='(') st.pop();
            else st.push(j);
        }
        while(!st.empty()) s.push_back(st.top()),st.pop();
        reverse(s.begin(),s.end());
        if(s.empty()) continue;
        if(s.front()=='('&&s.back()=='(') only_openings+=s;
        else if(s.front()==')'&&s.back()==')') only_closings+=s;
        else vs.push_back(s);
    }
    sort(vs.begin(),vs.end(),cmp());
 
    string ans_str=only_openings;
    for(auto i : vs) ans_str+=i;
    ans_str+=only_closings;
    // cout<<ans_str<<"\n";
    int brackets=0;
    for(auto i : ans_str) if(i=='(') brackets++; else{ brackets--; if(brackets<0){cout<<"No\n";exit(0);}}
    if(brackets==0) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define rept(i,n) for(ll (i)=0;(i)<=(ll)(n);(i)++)
#define reps(i,s,n) for(ll (i)=(s);(i)<(ll)(n);(i)++)
#define repst(i,s,n) for(ll (i)=(s);(i)<=(ll)(n);(i)++)
#define repr(i,n) for(ll (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\???
// .???.:( ^??^)?????????.???.:( ^??^)?????????.???.:( ^??^)?????????.???.:( ^??^)?????????.???.:( ^??^)?????????
// ?????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\??????????????????

int n, m, c[20], dp[22][55555];

int main() {
	cin >> n >> m;
	rep(i,m) cin >> c[i];
	rept(i,m) fill(dp[i], dp[i]+n+1, inf);
	dp[0][0] = 0;
	rep(i,m) {
		rept(j,n) {
			if (j<c[i]) dp[i+1][j] = dp[i][j];
			else dp[i+1][j] = min(dp[i][j], dp[i+1][j-c[i]]+1);
		}
	}
	cout << dp[m][n] << ln;
}

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

signed main(){
  string S;
  cin>>S;
  int ans=0;
  rep(i,3){
    if(S[i]=='1')ans+=1;
  }
  cout<<ans<<endl;
  return 0;
}

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




int main(){
	int t =1;
	//cin >> t;
	while(t--){
		int n;
		cin>>n ;
		int a=n ;
		int ans=n ;
		n*=a ;
		ans+=n ;
		n*=a ;
		ans+=n ;
		cout<<ans<<endl ;

		}





	return 0 ;
	}





Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

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

ll powMod(ll n, ll k, ll m) {
	if (k == 0) {
		return 1;
	} else if (k % 2 == 1) {
		return powMod(n, k - 1, m) * n % m;
	} else {
		ll t = powMod(n, k / 2, m);
		return t * t % m;
	}
}

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

	if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,int> PP;
typedef pair<ll,int> Pli;

//-----------------------------------------------------------------------------

int h,w,n;
P p1,p2;
vector<Pli> vec;
int flg[100010];

ll conv(P p) {
	ll res=0;
	if(p.fi==0) res=w*2+h*2-p.se;
	else if(p.se==0) res=p.fi;
	else if(p.fi==w) res=w+p.se;
	else res=w*2+h-p.fi;
	return res;
}

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

	cin>>w>>h>>n;
	REP(i,n) {
		cin>>p1.fi>>p1.se>>p2.fi>>p2.se;
		if((p1.fi==0||p1.fi==w||p1.se==0||p1.se==h)&&
		   (p2.fi==0||p2.fi==w||p2.se==0||p2.se==h)) {
			vec.pb(Pli(conv(p1),i));
			vec.pb(Pli(conv(p2),i));
		}
	}
	sort(ALL(vec));
	//for(auto v:vec) cout<<v.fi<<' '<<v.se<<endl;
	int sz=(int)vec.size(),cnt=0;
	REP(i,sz) {
		int now=vec[i].se;
		if(flg[now]!=0) {
			if(flg[now]!=cnt) {
				cout<<"NO"<<endl;
				return 0;
			}
			cnt--;
		}
		else {
			flg[now]=++cnt;
		}
	}

	cout<<"YES"<<endl;

	return 0;
}


Measured memory_bytes: 6256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	vector<int> v(N);
	REP(i, N) cin >> v[i];
	sort(ALL(v));
	
	int ans = 0;
	REP(i, N) FOR(j, i + 1, N) FOR(k, j + 1, N) ans += v[i] != v[j] && v[j] != v[k] && v[k] < v[i] + v[j];
	cout << ans << endl;
	return 0;
}


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

int main(){

    int a,b,c,d,e,k;

    cin >> a >> b >> c >> d >> e >> k;

    if(e-a > k){
        cout << ":(" << endl;
    } else{
        cout << "Yay!" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//Radhe Radhe
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//using namespace boost::multiprecision;
//#include<boost/math/common_factor.hpp>
#include <ext/numeric>
using namespace __gnu_cxx;
using namespace std;
#define int long long
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define array(a,n) int a[n]; for(int i=0;i<n;i++) cin>>a[i];
#define loop(i,a,b,x) for(int i=a;i<b;i+=x)
const int MOD = 1000000007;

int dp[3010][3030];
int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) {
        int n;
        cin >> n;
        int a[n];
        for (int i = 0; i < n; i++)
            cin >> a[i];
        for (int i = n - 1; i >= 0; i--)
            for (int j = i; j < n; j++)
                if (i == j)
                    dp[i][j] = a[i];
                else
                    dp[i][j] = max((a[i] - dp[i + 1][j]), (a[j] - dp[i][j - 1]));
        cout << dp[0][n - 1] << endl;
    }
    return 0;

}



Measured memory_bytes: 70144
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define ll long long
#define int long long
#define pb push_back
using namespace std; 

const ll N = 1e6 + 100, OO = 1e10 + 10, M = 1e9 + 7, lg = 20;
typedef pair <int, int> pii;
int a[N];

int32_t main() {
	int n, k, q;
	cin >> n >> k >> q;
	for(int i = 0; i < q; i++) {
		int x;
		cin >> x;
		a[x]++;
	}
	for(int i = 1; i <= n; i++) {
		a[i] = a[i] - q + k;
		if(a[i] > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1536
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func rScan() []rune {
	return []rune(Scan())
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}
func bOut(f bool, x string, y string) {
	if f {
		fmt.Println(x)
	} else {
		fmt.Println(y)
	}
}
func mod(x, d int) int {
	x %= d
	if x < 0 {
		x += d
	}
	return x
}
func iSSPrint(x []int) {
	fmt.Println(strings.Trim(fmt.Sprint(x), "[]"))
}

var lp int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, lp)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a := iSScan(n)
	x, y := 0, 0
	z := 0
	ans := 0
	for y != n {
		if z&a[y] == 0 {
			z ^= a[y]
			y++
			ans += y - x
		} else {
			z ^= a[x]
			x++
		}
	}
	fmt.Println(ans)
}


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

using std::max; using std::swap; using std::abs; using std::priority_queue; using std::queue; using std::bitset; using std::make_tuple; 
using std::istream; using std::ostream; using std::fixed; using std::greater; using std::tuple; using std::tie; using std::make_pair;
using std::cout; using std::cerr; using std::endl; using std::lower_bound; using std::upper_bound; using std::deque; using std::min; 
using std::map; using std::string; using std::fill; using std::copy; using std::sort; using std::unique; using std::unordered_set; 
using std::multiset; using std::nth_element; using std::min_element; using std::max_element; using std::vector; using std::set; 
using std::unordered_map; using std::pair; using std::next_permutation; using std::reverse; using std::rotate; using std::cin; 
using std::iota; using std::function; using std::shuffle; using std::iter_swap;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

int const INF = 100 + (int) 1e9;
ll const INFL = 100 + (ll) 1e18;
ld const PI = 3.141592653589793238462643L;
std::mt19937 mt19937(960172);

ll rnd(ll x, ll y) { static auto gen = std::bind(std::uniform_int_distribution<ll>(), mt19937); return gen() % (y - x + 1) + x; }
bool is_prime(ll x) { if (x <= 1) return 0; for (ll y = 2; y * y <= x; ++y) if (x % y == 0) return 0; return 1; }
ll sqr(int a) { return (ll) a * a; } ld sqr(ld a) { return a * a; } ll sqr(ll a) { return a * a; }
ll gcd(ll a, ll b) { while (b > 0) { ll t = a % b; a = b; b = t; } return a; }




void solve() {

    string s;
    cin >> s;
    
    int ans = 0;
    int bal = 0;
    
    for (char x : s) {
        if (bal == 0) {
            ++bal;
            if (x != 'g') {
                --ans;
            }
        } else {
            --bal;
            if (x == 'g') {
                ++ans;
            }
        }
    }

    cout << ans << '\n';
}



int main() {
    
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    
    cout.precision(15);
    cout << fixed;
    cerr.precision(6);
    cerr << fixed;
    
    int tcn = 1;
    for (int tn = 1; tn <= tcn; ++tn)
        solve();
    
#ifdef LOCAL
    cerr << "time: " << (ll) clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
}

Measured memory_bytes: 512
n,m,l = map(int,input().split())

A = [list(map(int,input().split())) for _ in range(n)]
B = [list(map(int,input().split())) for _ in range(m)]

ans = [[0]*l for _ in range(n)]

for i in range(n):
    for j in range(l):
        tmp = 0
        for k in range(m):
            tmp += A[i][k] * B[k][j]
        ans[i][j] = tmp

for i in range(n):
    print(*ans[i])


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

template<class T> ostream& operator<<(ostream &os, vector<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T> ostream& operator<<(ostream &os, set<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, map<T , R> V){
	os << "[ ";
	for(auto v  : V) os << "(" << v.first << ":" << v.second << ")";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, pair<T , R> V){
	return os << "(" << V.first << "," << V.second << ")";
}

#define cerr cout
#define TRACE
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1<<" | ";
        __f(comma+1, args...);
    }
    clock_t clk=clock();
    #define checktime() cout<<"\nTime Elapsed : "<<float(clock()-clk)/CLOCKS_PER_SEC<<endl
#else
    #define trace(...);
    #define checktime();
#endif
/*---------------------------Defines----------------------*/
typedef long long int ll;
typedef long double ld;
#define pll pair<ll,ll>
#define pb push_back
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vbl vector<bool>
#define vvll vector<vll>
#define vld vector<ld>
#define vb vector<bool>
#define vc vector<char>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
/*-----------------------Modular Arithmetic---------------*/
inline ll add(ll x,ll y,ll mod){x+=y; if(x>=mod) return x-mod; return x;}
inline ll sub(ll x,ll y,ll mod){x-=y; if(x<0) return x+mod; return x;}
inline ll mul(ll x,ll y,ll mod){return (x*1ll*y)%mod;}
inline ll power(ll x,ll y,ll mod){ll ans=1; while(y){if(y&1) ans=mul(ans,x,mod); x=mul(x,x,mod); y>>=1;} return ans;}
inline ll inv(ll x,ll mod){return power(x,mod-2,mod);}
/*-----------------------------Code begins----------------------------------*/

const ll INF = 1e18;

void solve(){
    ll n;cin>>n;
    ld ans=1;
    for(ll i=0;i<n;i++){
        ll x;cin>>x;
        // trace((ld)x*ans);
        if(x==0) ans=0;
        if(ans!=-1) ans*=x;
        if(ans>INF) ans=-1;
    }
    cout<<(ll)ans<<"\n";
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<fixed<<setprecision(25);
    ll t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

bool check(const string S, const ll start, const ll end){
  ll head = start-1;
  ll tail = end-1;
  while(head<tail){
    if(S[head]!=S[tail]) return false;
    head++;
    tail--;
  }
  return true;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string S;
  IN(S);
  ll N = S.size();

  if(check(S, 1, N) && check(S, 1, (N-1)/2) && check(S, (N+3)/2, N)){
    OUT("Yes");
  }else{
    OUT("No");
  }

  return 0;
}

Measured memory_bytes: 256