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

int main() {
  int N, A;
  cin >> N;
  int count = 0;
  int COUNT = 50;
  for (int i = 0; i < N; i++){
    cin >> A;
    count = 0;
    while (A % 2 == 0){
      A /= 2;
      count++;
    }
    if (count < COUNT)
      COUNT = count;
  }
  cout << COUNT << endl;
}

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

typedef long long ll;

using namespace std;

const ll MOD = 1e9 + 7;

string s;
int c1, c2, ans, n;

int main()
{
    cin >> n >> s; ans = n;
    for (int i = 0; i < n; i++) c2 += (s[i] == '.');
    ans = min(ans, c1 + c2);
    for (int i = 0; i < n; i++)
    {
        c1 += (s[i] == '#');
        c2 -= (s[i] == '.');
        ans = min(ans, c1 + c2);
    }
    cout << ans;
}


Measured memory_bytes: 640
//bit全探索
#include<bits/stdc++.h>
using namespace std;

int main(){
    string s;
    cin>>s;
    //cout<<s.size()<<endl;
    vector<int> v;

    int tmp=stoi(s);
    for(int i=0; i<s.size(); i++){
        //v[i]=tmp%10;
        v.insert(v.begin(),tmp%10);
        tmp=tmp/10;
        //cout<<v[i]<<" ";
    }
    /*
    cout<<v.size()<<endl;
    for(auto a:v){
        cout<<a<<" ";
    }
    */
    //cout<<(1<<s.size()-1)<<endl;
    for(int bits=0; bits<=(1<<s.size()-1); bits++){
        int result=v[0];
        string ans=to_string(v[0]);
        //cout<<"bits "<<bits<<endl;
        for(int i=0; i<s.size()-1; i++){
            //cout<<"i"<<i<<endl;
            if(bits>>i&1){
                result+=v[i+1];
                ans+="+"+to_string(v[i+1]);         
            }else{
                result-=v[i+1];
                ans+="-"+to_string(v[i+1]);
            }
        }
        /*
        cout<<ans<<endl;
        cout<<result<<endl;
        */

        if(result==7){
            cout<<ans<<"=7"<<endl;
            break;
        }
    }
    return 0;
}

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

typedef long long ll;

const int maxn = 1e5 + 5;

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

  int N, M; cin >> N >> M;
  vector<pair<int, int>> in(N);
  for (auto& x : in) {
    cin >> x.first >> x.second;
  }
  sort(in.begin(), in.end());
  ll ans = 0;
  for (auto& x : in) {
    ans += min(M, x.second) * (ll)x.first;
    M -= min(M, x.second);
    if (M == 0) break;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    int co=1;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        if((co*2<=(co+k))){
            co=co*2;
        }
        else{
            co+=k;
        }
    }
    cout << co << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
    int n;
    cin >> n;
    int x = 0;
    if(n/100 == 7){
        x = 1;
    }
    else if((n%100)/10 == 7){
        x = 1;
    }
    else if(((n%100)%10) == 7){
        x = 1;
    }
 
    if(x == 1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
  int H,W,K;
  cin >> H >> W >> K;
  vector<string>c(H);
  for(int i = 0 ; i < H ; i++){
  	 cin >> c[i];
  }
  
  int ans = 0;
  
  for(int i = 0 ; i < (1<<H) ; i++){
  	for(int j = 0 ; j < (1<<W) ; j++){
      
      int cnt = 0;
    	for(int h = 0 ; h < H ; h++){
        	for(int w = 0 ; w < W ; w++){
            	if(i&(1<<h)||j&(1<<w))continue;
              	if(c[h][w]=='#')cnt++;
            }
        }	
      if(cnt == K)ans++;
      
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, i, a, b, c;
    cin >> n;
    long dp[n][3];
    cin >> a >> b >> c;
    dp[0][0] = a;
    dp[0][1] = b;
    dp[0][2] = c;
    for(i=1;i<n;++i) {
        cin >> a >> b >> c;
        dp[i][0] = a + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c + max(dp[i-1][1], dp[i-1][0]);
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    return 0;
}

Measured memory_bytes: 5948
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <utility>

using namespace std;

typedef pair<int, int> pii;

struct UF {
    vector<int> data;

    UF(int n) {
        data.resize(n, -1);
    }

    int root(int i) {
        return data[i] < 0 ? i : data[i] = root(data[i]);
    }

    int size(int i) {
        return -data[root(i)];
    }

    void unite(int x, int y) {
        x = root(x), y = root(y);

        if (x == y) return ;

        if (size(x) < size(y)) swap(x, y);

        data[x] += data[y];
        data[y] = x;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

int N, M;

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

    while (cin >> N >> M, N) {
        UF uf(N);

        vector<pair<int, pii>> edges;

        for (int i = 0; i < M; ++i) {
            int s, t, c; cin >> s >> t >> c;

            --s, --t;

            edges.push_back(make_pair(c, pii(s, t)));
        }

        sort(begin(edges), end(edges));

        vector<int> a;

        for (pair<int, pii> e : edges) {
            int cost = e.first;
            pii info = e.second;
            if (!uf.same(info.first, info.second)) {
                uf.unite(info.first, info.second);
                a.push_back(cost);
            }
        }

        sort(begin(a), end(a));

        cout << a[a.size() / 2] << endl;
    }
}

Measured memory_bytes: 3292
function Main(input) {
    input = input.split(" ");
    var a = parseInt(input[0]);
    var b = parseInt(input[1]);
    var c = parseInt(input[2]);
    if (a < b && b < c) {
        console.log("Yes");
    }else  {
        console.log("No");
   }}
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug() {
    var input = document.getElementById("input").value;
    Main(input);
}

//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15096
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end() 
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int A,B;
    cin >> A >> B;
    cout << A*B <<endl;
}


Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 25 18:20:35 2020
"""

import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
N, K = map(int,input().split())
A = np.array(list(map(int,input().split())))

dp = [True for i in range(K + 1)]
for i in range(K, -1, -1):
    if dp[i]:
        for a in A:
            if i - a >= 0:
                dp[i - a] = False

#    print(i, dp[i],A+i,dp[A+i])
#print(dp)

if dp[0]:
    ans = 'Second'
else:
    ans = 'First'
print(ans)

Measured memory_bytes: 13540
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxm=3e5+5;
pair<int,int>p[maxm];
int r[maxm],c[maxm];
int n,m,k;
signed main(){
    cin>>n>>m>>k;
    for(int i=1;i<=k;i++){
        int x,y;cin>>x>>y;
        p[i]={x,y};
        r[x]++,c[y]++;
    }
    int ma1=-1,num1=0;
    for(int i=1;i<=n;i++)ma1=max(ma1,r[i]);
    for(int i=1;i<=n;i++)num1+=(r[i]==ma1);
    int ma2=-1,num2=0;
    for(int i=1;i<=m;i++)ma2=max(ma2,c[i]);
    for(int i=1;i<=m;i++)num2+=(c[i]==ma2);
    int cnt=0;
    for(int i=1;i<=k;i++){
        int x=p[i].first,y=p[i].second;
        cnt+=(r[x]==ma1&&c[y]==ma2);
    }
    cout<<ma1+ma2-(cnt==num1*num2)<<endl;
    return 0;
}


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

using namespace std;
long long n,w;
long long wr[105],ar[105];
long long mem[105][100005];

long long solve(long long ind,long long curw){
    if(ind==n){
        return 0;
    }
    if(mem[ind][curw]!=-1){
        return mem[ind][curw];
    }
    long long ch1=solve(ind+1,curw),ch2=0;
    if(curw>=wr[ind]){
        ch2=solve(ind+1,curw-wr[ind])+ar[ind];
    }
    return mem[ind][curw]=max(ch1,ch2);
}

int main() {
    //freopen("input.in", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>w;
    memset(mem,-1,sizeof mem);
    for(int i=0;i<n;i++){
        cin>>wr[i]>>ar[i];
    }
    cout<<solve(0,w)<<endl;
    return 0;
}

Measured memory_bytes: 82304
n=int(input())
l=[int(i) for i in input().split()]
count=abs(l[0])
for ii in range(1,n):
    count+=abs(l[ii]-l[ii-1])
count+=abs(l[n-1])
suml=count  
for j in range(n):
    if j==0:
        print(suml-abs(l[0])-abs(l[1]-l[0])+abs(l[1]))
    elif j!=n-1:
        print(suml-abs(l[j]-l[j-1])-abs(l[j+1]-l[j])+abs(l[j+1]-l[j-1]))
    else:
        print(suml-abs(l[n-1]-l[n-2])-abs(l[n-1])+abs(l[n-2]))
        

Measured memory_bytes: 63980
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
  int n;
  cin >> n;
  bool ans = false;

  for (int i=1; i<=9; i++) {
    if (n/i<=9 && n%i==0) ans = true;
  }

  cout << (ans? "Yes" : "No") << endl;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <sstream>
#define MAX 100000
using namespace std;

struct Queue{
    int head;
    int tail;
    int q[MAX];

    void initialize(){
        head = 0;
        tail = 0;
    }
    bool isEmpty(){
        return (head == tail);
    }
    bool isFull(){
        return (head == (tail+1)%MAX);
    }
    void enqueue(int x){
        if(isFull()){
            cout << "queue overflow\n";
            //exit(0);
        }
        q[tail] = x;
        if(tail == MAX-1){
            tail = 0;
        }
        else{
            tail += 1;
        }
    }
    int dequeue(){
        if(isEmpty()){
            cout << "queue underflow\n";
            //exit(0);
        }
        int x = q[head];
        if(head == MAX-1){
            head = 0;
        }
        else{
            head += 1;
        }
        return x;
    }
};

void calc(Queue q_name, string name[], Queue q_time, int quantum){
    int t_sum = 0;
    while(q_name.head != q_name.tail){
        if(q_time.q[q_time.head] <= quantum){
            t_sum += q_time.dequeue();
            cout << name[q_name.dequeue()] << " " << t_sum << '\n';
        }
        else{
            t_sum += quantum;
            q_name.enqueue(q_name.q[q_name.head]);
            q_time.enqueue(q_time.q[q_time.head]-quantum);

            if(q_name.head == MAX-1){
                q_name.head = 0;
                q_time.head = 0;
            }
            else{
                q_name.head += 1;
                q_time.head += 1;
            }
        }
    }
}

int main(){
    Queue q_name, q_time;
    int num, quantum;
    string name[MAX];
    int t;

    q_name.initialize();
    q_time.initialize();

    cin >> num >> quantum;
    for(int i=0; i<num; i++){
        cin >> name[i] >> t;
        q_name.enqueue(i);
        q_time.enqueue(t);
    }

    calc(q_name, name, q_time, quantum);

    return 0;
}


Measured memory_bytes: 7444
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define NUM_MAX 200000

int desc(const void *a1, const void *a2) {
    return *(int*)a2 - *(int*)a1;
}

int main(void) {
    int num, k;
    get_int2(&num, &k);
    static int arr[NUM_MAX];
    fget_array(arr, num);
    
    int i;
    static int map[NUM_MAX+1];
    for(i = 0; i < num; i++) {
        map[arr[i]]++;
    }

    qsort(map, NUM_MAX+1, sizeof(int), desc);

    int ans = 0;
    for(i = k; i <= NUM_MAX; i++) {
        ans += map[i];
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 2556
n = int(input())

s = input()

ans = set()
for i in range(10):
    a = s.find(str(i))
    if a == -1:
        continue
    for j in range(10):
        b = s.find(str(j), a+1)
        if b == -1:
            continue
        for k in range(10):
            if s.find(str(k), b+1) != -1:
                ans.add(str(i)+str(j)+str(k))
print(len(ans))


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

using namespace std;

int main(){
  int N, W;
  cin >> N >> W;
  vector<string> shps(W+5,"#");
  // stringで入力を受け取ると、文章になってしまうのでcharを利用
  vector<vector<char>> a(N,vector<char>(W));

  // for(int i=0;i<W;i++)cout << shps.at(i);
  // cout << endl;
  for(int i=0;i<N;i++){
    for(int j=0;j<W;j++){
      cin >>a.at(i).at(j);
    }
  }
  
  // 出力
  for(int i=0;i<W+2;i++)cout << shps.at(i);
  cout << endl;
  for(int i = 0;i<N;i++){
    for(int j = 0;j<W;j++){
      if(j==0){cout << "#";}    
      cout << a.at(i).at(j);
      // cout << j;
    }
    
    cout << "#" << endl;
  }
  for(int i=0;i<W+2;i++)cout << shps.at(i);
  cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b[10000],d,i;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&b[i]);
  }
  d=a-1;
  for(i=d;i>=0;i--){
    if (i>0)printf("%d ",b[i]);
    else printf("%d",b[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2124
def main():
    W, H, N = map(int, input().split())

    field = [[1] * W for _ in range(H)]
    for _ in range(N):
        x, y, a = map(int, input().split())
        if a == 1:
            for x1 in range(0, x):
                for y1 in range(H):
                    field[y1][x1] = 0
        elif a == 2:
            for x1 in range(x, W):
                for y1 in range(H):
                    field[y1][x1] = 0
        elif a == 3:
            for y1 in range(H - y, H):
                for x1 in range(W):
                    field[y1][x1] = 0
        elif a == 4:
            for y1 in range(H - y):
                for x1 in range(W):
                    field[y1][x1] = 0

    print(sum(sum(line) for line in field))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,n;
	cin>>n;
	ld ar[n+1];
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	sort(ar+1,ar+n+1);

	ld s=0;
	for(i=2;i<=n;i++){
		ar[i]=(ar[i]+ar[i-1])/2.0;
	}
	cout<<fixed<<setprecision(10)<<ar[n];
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+7;

int main(){
    char c;
    cin >> c;
    ll v=c-'a';
    if(v<0){
        cout << 'A' << endl;
    }
    else{
        cout << 'a' << endl;
    }
} 

Measured memory_bytes: 3632
import java.util.Scanner;

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

		int n = sc.nextInt();

		int[] v = new int[n];
		int[] c = new int[n];

		int total = 0;

		for(int i = 0; i < n; i++) {
			v[i] = sc.nextInt();
		}

		for(int i = 0; i < n; i++) {
			c[i] = sc.nextInt();
		}

		for(int i = 0; i < n; i++) {
			if(v[i] > c[i]) {
				total += v[i] - c[i];
			}
		}

		System.out.println(total);
	}
}

Measured memory_bytes: 22228
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
using namespace std;
using ll = long long;
using Lf = long double;
using plong = pair<ll,ll>;
const int MOD = 1000000007;
bool field[100][100];
int main(){
    ll A,B;cin>>A>>B;
    for(ll i=0;i<100;i++){
        for(ll j=0;j<100;j++){
            if(i<50)field[i][j] = true;
            else field[i][j] = false;
        }
    }
    ll x=0,y=0,a=0;
    while(a<A-1){
        field[x][y] = false;
        a++;
        y+=2;
        if(y>=100){
            x+=2;
            y=1;
        }
    }
    x=51;y=0;
    ll b=0;
    while(b<B-1){
        field[x][y] = true;
        b++;
        y+=2;
        if(y>=100){
            x+=2;
            y=1;
        }
    }
    cout<<100<<" "<<100<<endl;
    for(ll i=0;i<100;i++){
        for(ll j=0;j<100;j++){
            cout<<(field[i][j]?"#":".");
        }
        cout<<"\n";
    }


}

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

int n, m, l, r, ansL, ansR = 1e9;

int main() {
    cin >> n >> m;
    rep(i, m) {
        cin >> l >> r;
        ansL = max(ansL, l);
        ansR = min(ansR, r);
    }
    cout << max(ansR - ansL + 1, 0) << endl;
}

Measured memory_bytes: 256
arr = gets.chomp!.split(" ")
max = 1
k = arr[0].to_i
a = arr[1].to_i
b = arr[2].to_i
if (k-1) < a || (b-a) <= 2 then
    puts k+1
else
    k -= (a-1)
    max += (a-1)


    max += ((k / 2) * (b-a))
    if k % 2 == 1 then max +=1 end
    puts max
end
    


Measured memory_bytes: 1788
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main() {

    int a, b, c; cin >> a >> b >> c;
    int k; cin >> k;

    rep(i,k) {
        if (a >= b) {
            b *= 2;
        } else {
            c *= 2;
        }
    }

    if (a < b && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    
    


    return 0;
}



Measured memory_bytes: 3628
#include <cstdio>
int N, K, l, r, a[1000009], v[1000009], p[1000009];
int main() {
	scanf("%d %d", &N, &K);
	for (int i = 0; i < N; i++) scanf("%d", &a[i]);
	for (int i = 0; i < K; i++) {
		while (l != r && v[r - 1] >= a[i]) r--;
		v[r] = a[i], p[r++] = i;
	}
	for (int i = K; i <= N; i++) {
		printf(i == N ? "%d\n" : "%d ", v[l]);
		if (p[l] == i - K) l++;
		while (l != r && v[r - 1] >= a[i]) r--;
		v[r] = a[i], p[r++] = i;
	}
	return 0;
}


Measured memory_bytes: 14300
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通り実装したソースコード
 */
public class Main {

	/** パーを表す文字 */
	private static final char PA = 'p';

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.next().toCharArray();
			int p = (int) IntStream.range(0, s.length).filter(i -> PA == s[i]).count();
			System.out.println(s.length / 2 - p);
		}
	}
}


Measured memory_bytes: 39700
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    S = str(input().strip())

    cnt = 0
    color = '_'
    for s in S:
        if s == color:
            continue
        cnt += 1
        color = s

    return cnt

if __name__ == '__main__':
    print(main())

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

long case2_2(long K, long A, long B, long now) {
  if (now < A) {
    K -= A - now;
  }
  if (K < A + 1) return 0;
  long q = K / 2;
  long ans = (B - A) * q;
  if (K % 2) ans++;
  return ans;
}

long case1(long K, long A, long B) {
  if (K < A + 1) return 0;
  long ans = B; K -= A + 1;
  long q = K / (A + 2);
  ans += q * B; K -= (A + 2) * q;
  return ans + max(K, case2_2(K, A, B, ans));
}

long case2(long K, long A, long B) {
  if (K < A + 1) return 0;
  long ans = B; K -= A + 1;
  long q = K / 2;
  ans += (B - A) * q;
  if (K % 2) ans++;
  return ans;
}

int main() {
  long K, A, B;
  cin >> K >> A >> B;
  if (B <= A + 1) {
    cout << K+1 << endl;
    return 0;
  }
  long c1 = case1(K, A, B), c2 = case2(K, A, B);
  cout << max({K+1, c1, c2}) << endl;
}

Measured memory_bytes: 256
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N, M, X = map(int, input().split())
    A = [tuple(map(int, input().split())) for _ in [0] * N]

    ans = float('inf')
    for mask in range(1, 1 << N):
        book = []
        for i in range(N):
            if mask & 1 << i:
                book.append(A[i])
        yen = 0
        m = [0] * M
        for a in book:
            yen += a[0]
            for i, v in enumerate(a[1:]):
                m[i] += v
        for i in m:
            if i < X:
                break
        else:
            ans = min(ans, yen)
    if ans == float('inf'):
        print(-1)
    else:
        print(ans)


main()


Measured memory_bytes: 9228
#include<stdio.h>
#include<stdlib.h>

char a[110],b[110];
void f(int x){puts(x?"Isono-kun":"Nakajima-kun");exit(0);}
int main(){
	int n;
	scanf("%d ",&n);
	char s[110];
	for(int i=0;i<n;i++)scanf("%s",s),a[i]=s[0];
	for(int i=0;i<n;i++)scanf("%s",s),b[i]=s[0];
	int aa=0,bb=0;
	for(int i=0;i<n;i++){
		if(a[i]=='k'&&b[i]=='k'){
			if(aa!=bb){
				f(aa>bb);
				return 0;
			}
			aa=bb=0;
		}else if(a[i]=='k'&&b[i]=='t'){
			f(aa!=0);
		}else if(a[i]=='k'&&b[i]=='m'){
			if(aa==0)f(0);
			if(aa==5)f(1);
			aa=0;
		}else if(a[i]=='t'&&b[i]=='k'){
			f(bb==0);
		}else if(a[i]=='t'&&b[i]=='t'){
			aa+=aa<5;
			bb+=bb<5;
		}else if(a[i]=='t'&&b[i]=='m'){
			aa+=aa<5;
		}else if(a[i]=='m'&&b[i]=='k'){
			if(bb==0)f(1);
			if(bb==5)f(0);
			bb=0;
		}else if(a[i]=='m'&&b[i]=='t'){
			bb+=bb<5;
		}else if(a[i]=='m'&&b[i]=='m'){
		}
	}
	puts("Hikiwake-kun");
}


Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	int n, i, j, k, maxx = 0, x = 0;
	cin >> n >> s;
	for (auto ch : s) {
		if (ch == 'I') x++;
		if (ch == 'D') x--;
		maxx = max(maxx, x);
	}
	cout << maxx;


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  ll d, t, s;
  cin >> d >> t >> s;
  if (d <= t * s) cout << "Yes\n";
  else cout << "No\n";
  return (0);
}


Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int main() {
	int N, H;
	cin >> N >> H;
	vector<int> a(N), b(N);
	rep(i, 0, N)cin >> a[i] >> b[i];
	r_sort(a);
	r_sort(b);
	int i = 0;
	while (i < N && b[i] >= a[0] && H > 0)H -= b[i++];
	printf("%d\n", (H > 0 ? (H - 1) / a[0] + 1 : 0) + i);
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
  long long N, sum=0;
  scanf("%lld", &N);
  long long a[N+2], b[N+1];
  scanf("%lld", &a[0]);
  for(int i=0; i<N; i++){
    scanf("%lld",&a[i+1]);
  }
  for(int i=0; i<N; i++){
    scanf("%lld", &b[i]);
  }
  for(int i=0; i<N; i++){
    if(a[i]>=b[i]){
      sum+=b[i];
      b[i]=0;
    }else{
      sum+=a[i];
      b[i]=b[i]-a[i];
    }
    if(a[i+1]>=b[i]){
      sum+=b[i];
      a[i+1]-=b[i];
      if(a[i+1]<0) a[i+1]=0;
    }else{
      sum+=a[i+1];
      a[i+1]=0;
    }
  }
  printf("%lld", sum);
}
    

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

int main(void)
{
  int n, l;
  std::cin >> n >> l;

  std::vector<std::string> s(n);
  for (int i = 0; i < n; i++) {
    std::cin >> s.at(i);
  }

  std::sort(s.begin(), s.end());

  for (std::string i : s) {
    std::cout << i;
  }

  printf("\n");

  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)

#define Rep(j,n) for(int j=0;j<(int)(n);++j)

#define int long long

using namespace std;

signed main()
{
  int x=0,y=0;
  cin >> x;
int vv[x];
rep(i,x){
  vv[i]=0;
cin >> vv[i];
}
sort(vv,vv+x);
vv[x-1]/=2;
rep(i,x){
  y+=vv[i];
}
cout << y << '\n';
}


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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int R;
    cin >> R;
    cout << setprecision (23) << 2 * R * M_PI << endl;
    return 0;
}

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

struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E') b=s[0] , s[0]=s[3] , s[3]=s[5] , s[5]=s[2] , s[2]=b;
    if(c=='W') b=s[0] , s[0]=s[2] , s[2]=s[5] , s[5]=s[3] , s[3]=b;
    if(c=='N') b=s[0] , s[0]=s[1] , s[1]=s[5] , s[5]=s[4] , s[4]=b;
    if(c=='S') b=s[0] , s[0]=s[4] , s[4]=s[5] , s[5]=s[1] , s[1]=b;
    s[5]--;
  }
  bool valid(){
    int a=s[0]+s[5];
    int b=s[1]+s[4];
    int c=s[2]+s[3];
    r(i,6)if(s[i]<0) return 0;
    return a<=b+c && b<=a+c && c<=a+b;
  }
  bool END(){
    int a=s[0]+s[5];
    int b=s[1]+s[4];
    int c=s[2]+s[3];
    return !(a+b+c);
  }
};

int a[6];
Dice D;

string S[]={"E","EE","EN","ES","EW","N","NE","NN","NS","NW","S","SE","SN","SS","SW","W","WE","WN","WS","WW",};
#define Ssz 20

string ch(){
  r(i,6) D.s[i]=a[i];
  string res="";

  int cnt = 0;
  
  while(1){
    Dice tmp;
    int flag = 0;
    
    r(i,Ssz){
      tmp=D;
      
      r(j,S[i].size()){
	tmp.roll(S[i][j]);
      }
      
      if(tmp.valid()){
	cnt += S[i].size();
	flag = 1;
	D=tmp;
	res += S[i];
	break;
      }
    }
    if(!flag)return "NG";
    if(D.END())break;
    //cout<<cnt<<endl;
  }

  return res;
}

int main(){
  while(1){
    Dice D;
    int sum=0;
    
    r(i,6)cin>>a[i],sum+=a[i];
    if(sum==0)break;

    int L,R;
    cin>>L>>R;
    
    string ans="Z";
    
    do{
      string s=ch();
      if(s=="NG")continue;
      ans = min( ans , s );
      //cout<<ans<<endl;
    }while(next_permutation(a,a+6));

    if(ans=="Z")cout<<"impossible"<<endl;
    else cout<<ans.substr(L-1,R-L+1)<<endl;
  }
}



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

int main(){
  int i;
  int N;
  float x, sum;
  string u;
  cin >> N;
  for(i=0;i<N;i++){
    cin >> x >> u;
    if(u=="BTC") x *= 380000;
    sum += x;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
n = int(input())
bluedict = {}
for i in range(n):
    word = input()
    if bluedict.get(word) == None:
        bluedict[word] = 1
    else:
        bluedict[word] += 1

m = int(input())
reddict = {}
for i in range(m):
    word = input()
    if reddict.get(word) == None:
        reddict[word] = 1
    else:
        reddict[word] += 1

m = 0
for blueword in bluedict.keys():
    c = 0
    c += bluedict[blueword]
    if reddict.get(blueword) != None:
        c -= reddict[blueword]
    m = max(m,c)

print(m)

Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
 
#define rep for(int i = 0;i<n;i++)
const int MOD = 1000000007;
 
int main(){
    int n; cin >> n;
   int a[n],b[n],c[n-1];
   int ans = 0;
   rep{
       cin >> a[i];
   }
   rep{
       cin >> b[i];
       ans += b[i];
   }
   for(int i = 0;i<n-1;i++){
       cin >> c[i];
   }
   for(int i = 1;i<n;i++){
        if(a[i-1]+1 == a[i]){
            ans += c[a[i-1]-1];
        }
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

n = INT()
arr = []
for i in range(n):
    a = INT()
    arr.append(a)
b = Counter(arr)
c = set(arr)
ans = len(c)
for i in c:
    if b[i] % 2 == 0:
        ans -= 1
print(ans)

Measured memory_bytes: 83032
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
    
    int n,x,m[100];
    cin>>n>>x;
    for(int i=0;i<n;i++){
        cin>>m[i];
    }
    
    int sum;
    for(int i=0;i<n;i++){
        sum+=m[i];
    }
    
    x=x-sum;
    
    sort(m,m+n);
    
    
    cout<<n+(x/m[0])<<endl;
    
    return 0;
}








Measured memory_bytes: 256
fn main(){
    let foo : i64 = 1000000007;
    let mut line = String::new();
    let stdin = std::io::stdin();
    stdin.read_line(&mut line).expect("Could not read line");;
    let p : Vec<_> = line.trim().split(' ').collect();
    let n : i64 = p[0].parse().unwrap();
    let mut x : i64 = 1;
    for i in 1..n + 1 {
        x = (x * i) % foo;
    } 
    println!("{}", x);
}


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

int ans[510][510];
char p[4]={'R', 'Y', 'G', 'B'};

int main() {
	int H, W, d;
	cin >> H >> W >> d;
	if(d%2){
	    for(int i=0; i<H; ++i){
	        for(int j=0; j<W; ++j){
	            ans[i][j]=(i+j)%2;
	        }
	    }
	}else{
	    for(int i=1-H; i<W; ++i){
	        for(int j=max(-i, 0); j<H && i+j<W; ++j){
	            ans[j][i+j] = ((i+1000)/d)%2 + (((i+2*j)/d)%2)*2;
	        }
	    }
	}
	for(int i=0; i<H; ++i){
	    for(int j=0; j<W; ++j){
	        cout << p[ans[i][j]];
	    }
	    cout << endl;
	}
	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

	vector<vector<int>> dp(N, vector<int>(3, 0));
	for (int i = 0; i < N; ++i) {
		vector<int> a(3);
		for (auto &x : a) {
			cin >> x;
		}
		if (i == 0) {
			dp[0] = a;
		}
		else {
			for (int j = 0; j < 3; ++j) {
				for (int k = 0; k < 3; ++k) {
					if (j != k) {
						dp[i][k] = max(dp[i][k], dp[i - 1][j] + a[k]);
					}
				}
			}
		}
	}

	int ans = *max_element(dp.back().begin(), dp.back().end());
	cout << ans << endl;
}

Measured memory_bytes: 7680
class Sambonmatsu
  def initialize
    @x = 0
    @y = 0
    @direct = 90
  end

  def calc
    while(input = $stdin.gets) do
      direct, rotate = input.chomp.split(',').map(&:to_i)
      if direct == 0 && rotate == 0
        break 
      end
      step(direct)
      @direct -= rotate
    end
    puts @x.truncate
    puts @y.truncate
  end

  def step(direct)
    thita = (@direct/360.0)*2*Math::PI
    @x += direct*Math.cos(thita)
    @y += direct*Math.sin(thita)
  end
end

s = Sambonmatsu.new
s.calc

Measured memory_bytes: 2448
#include <iostream>

using namespace std;

string s;

int main() {
    cin >> s;
    int size = s.size();
    int n = size / 2 + size % 2;
    int iterator = 0;
    for (int cnt = 0; cnt < n; cnt++) {
        cout << s[iterator];
        iterator += 2;
    }
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in);
		while(in.hasNext())
		{
			char ch[]=in.next().toCharArray();
			int n=in.nextInt();
			int ans=0;
			while(n-->0)
			{
				char ri[]=in.next().toCharArray();
				char ri2[]= new char[ri.length*2];
				for(int i=0;i<ri.length;i++)
					ri2[i]=ri[i];
				for(int i=0;i<ri.length;i++)
					ri2[i+ri.length]=ri[i];
				boolean ju=false;
				for(int i=0;i<=ri.length;i++)
				{
					for(int j=0;j<ch.length;j++)
					{
						if(ri2[i+j]==ch[j])
							ju=true;
						else
						{
							ju=false;
							break;
						}
					}
					if(ju)
						break;
				}
				if(ju)
					ans++;
			}
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v.at(i);
    
    vector<int> tani(100010);
    for(int i = 0; i < n/2; i++) {
        int k = v.at(2*i);
        tani.at(k)++;
    }
    
    int x1 = -1, x2 = -1;
    int p1 = -1, p2 = -1;
    for(int i = 0; i < 100010; i++) {
        if(tani.at(i)>=x1) {
            x2 = x1;
            x1 = tani.at(i);
            p2 = p1;
            p1 = i;
        }
        else if(tani.at(i)>=x2) {
            x2 = tani.at(i);
            p2 = i;
        }
    }
    
    vector<int> yama(100010);
    for(int i = 0; i < n/2; i++) {
        int k = v.at(2*i+1);
        yama.at(k)++;
    }
    
    int y1 = -1, y2 = -1;
    int q1 = -1, q2 = -1;
    for(int i = 0; i < 100010; i++) {
        if(yama.at(i)>=y1) {
            y2 = y1;
            y1 = yama.at(i);
            q2 = q1;
            q1 = i;
        }
        else if(yama.at(i)>=y2) {
            y2 = yama.at(i);
            q2 = i;
        }
    }
    
    if(p1!=q1) cout << n - x1 - y1 << endl;
    else cout << n - max(x1 + y2, x2 + y1) << endl;
}

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

int main(){
  
  int N, t = 0;
  int B =0;
  cin >> N;
  for (int i = 0; i<N; i++){
    string S;
    cin >> S;
    if(S == "Y"){
      t = 1;
      break;
    }
  }
  if( t == 0)
    cout <<"Three"<<endl;
  else 
    cout <<"Four"<<endl;
}
      

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	cin>>N;
	cout<<(N+1)/2<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int s = -b + c;
    if (s <= 0) {
        cout << "delicious" << endl;
    }
    else if (s <= a) {
        cout << "safe" << endl;
    }
    else {
        cout << "dangerous" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	int n,m; cin >> n >> m;
    vl a(n), b(m);
    rep(i,n) scanf("%lld",&a[i]);
    rep(i,m) scanf("%lld",&b[i]);
    auto c = convolution(a, b);
    rep(i,n+m-1){
        cout << c[i] << " ";
    }
    cout << "\n";
}

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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;


int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;

    s[k-1]=s[k-1]+32;
    cout << s << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        boolean[][] card = new boolean[4][13];
        Scanner scanner = new Scanner(System.in);

        int max = scanner.nextInt();
        String m;
        int num;
        for(int i = 0; i < max; i++){
            m = scanner.next();
            num = scanner.nextInt();

            if(m.equals("S")){
                card[0][num-1] = true;
            }else if(m.equals("H")){
                card[1][num-1] = true;
            }else if(m.equals("C")){
                card[2][num-1] = true;
            }else if(m.equals("D")){
                card[3][num-1] = true;
            }
        }

        for(int i = 0; i < card.length; i++){
            for(int ii = 0; ii < card[i].length; ii++){
                if(!card[i][ii]){
                    switch (i){
                        case 0:
                            System.out.println("S " + (ii+1));
                            break;
                        case 1:
                            System.out.println("H " + (ii+1));
                            break;
                        case 2:
                            System.out.println("C " + (ii+1));
                            break;
                        case 3:
                            System.out.println("D " + (ii+1));
                            break;
                    }
                }
            }
        }
        scanner.close();
    }
}



Measured memory_bytes: 26196
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (X, Y): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let x = if X == 1 {
        300000
    } else if X == 2 {
        200000
    } else if X == 3 {
        100000
    } else {
        0
    };
    let y = if Y == 1 {
        300000
    } else if Y == 2 {
        200000
    } else if Y == 3 {
        100000
    } else {
        0
    };

    let ans = if X == 1 && Y == 1 {
        x + y + 400000
    } else {
        x + y
    };

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


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	for(int i =13;i<=10000;i++)
	{
		if(i*8/100==a&&i*10/100==b)
		{
			cout<<i;
			return 0;
		}
	}
	cout<<-1;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  ll n;
  cin>>n;
  vector<ll> a(n),b(n);
  rep(i,n){
    cin>>a[i]>>b[i];
  }
  
  sort(all(a));
  sort(all(b));
  
  if(n%2==0){
    n/=2;
    cout<<(b[n]+b[n-1])-(a[n]+a[n-1])+1<<endl;
  }
  
  else{
    n/=2;
    cout<<b[n]-a[n]+1<<endl;
  }
}
  
  

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    int a, b; cin >> a >> b;

    cout << (a < 2 * b ? 0 : a - 2 * b);
}


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

long long h, w;
int main()
{
	std::cin >> h >> w;

	if (h % 3 == 0 || w % 3 == 0) {
		std::cout << 0 << std::endl;
		return 0;
	}

	long long ans = 10000000000;
	for (int c = 0; c < 2; ++c) {
		for (long long i = 1, end = (w + 2 - 1) / 2; i <= end; ++i) {
			long long s1, s2, s3;
			s1 = i * h;
			s2 = (w - i)*(h / 2);
			s3 = h * w - s1 - s2;
			ans = std::min(ans, std::max({ s1,s2,s3 }) - std::min({ s1,s2,s3 }));

			s2 = ((w - i) / 2)*h;
			s3 = h * w - s1 - s2;
			ans = std::min(ans, std::max({ s1,s2,s3 }) - std::min({ s1,s2,s3 }));
		}
		std::swap(h, w);
	}

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


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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
template<typename T>
void pr(T a){
  cout<<a<<endl;
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  //ll a;cin>>a;
  ll a,b;cin>>a>>b;
  //ll a,b,c;cin>>a>>b>>c;
  //ll a,b,c,d;cin>>a>>b>>c>>d;
  //string s;cin>>s;
  //ll n;cin>>n;string s;cin>>s;
  cout<<(a+b-1)/b<<endl;
  return 0;
}

Measured memory_bytes: 256
# 標準入力を s, w に分解
n = gets.chomp.to_i
a = gets.split.map(&:to_i)
s = [0] + a.map{ |a| 0 }
# p n,a,s

# 部下の人数を集計
a.each do |ae|
  s[ae - 1] += 1
end

# 解答
s.each do |se|
  puts se
end

Measured memory_bytes: 34516