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

using namespace std;

typedef long long ll;

const int MAXA = 10*40, MAXB = 10*40;
const int INF = 1000000;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N; cin >> N;
  int ma, mb; cin >> ma >> mb;
  int a[N+1], b[N+1], c[N+1];
  for(int i=1;i<=N;i++){
    cin >> a[i] >> b[i] >> c[i];
  }
  // i番目までを使って、suma = j, sumb = kとするときの最小コスト
  int dp[N+1][MAXA+1][MAXB+1];
  for(int i=0;i<=N;i++){
    for(int j=0;j<=MAXA;j++){
      for(int k=0;k<=MAXB;k++) dp[i][j][k] = INF;
    }
  }
  for(int i=0;i<=N;i++){
    dp[i][0][0] = 0;
  }
  for(int i=1;i<=N;i++){
    for(int j=0;j<=MAXA;j++){
      for(int k=0;k<=MAXB;k++){
        if(j - a[i] < 0 || k - b[i] < 0) dp[i][j][k] = dp[i-1][j][k];
        else dp[i][j][k] = min(dp[i-1][j][k], dp[i-1][j-a[i]][k-b[i]] + c[i]);
      }
    }
  }
  int ans = INF;
  for(int j=1;j<=MAXA;j++){
    if((mb * j) % ma != 0 || ((mb * j) / ma) > MAXB) continue;
    int k = (mb * j) / ma;
    ans = min(ans, dp[N][j][k]);
  }
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 25984
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.ForBlue.ABC_055
{
    class AtTemplate
    {
        static int n;
        static string pattern;

        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            n = int.Parse(Console.ReadLine());
            pattern = Console.ReadLine();

            var result = new char[n];

            result[0] = 'S';
            result[1] = 'S';
            if (OK(ref result))
            {
                Console.WriteLine(result);
                return;
            }
            result[0] = 'S';
            result[1] = 'W';
            if (OK(ref result))
            {
                Console.WriteLine(result);
                return;
            }
            result[0] = 'W';
            result[1] = 'S';
            if (OK(ref result))
            {
                Console.WriteLine(result);
                return;
            }
            result[0] = 'W';
            result[1] = 'W';
            if (OK(ref result))
            {
                Console.WriteLine(result);
                return;
            }

            Console.WriteLine(-1);
        }

        static bool OK(ref char[] result)
        {
            var firstResult = result[0];
            for (int i = 1; i < n; i++)
            {
                int nextNo = (i + 1) % n;
                if (pattern[i] == 'o')
                {
                    if (result[i - 1] == 'S')
                    {
                        result[nextNo] = result[i] == 'S' ? 'S' : 'W';
                    }
                    else
                    {
                        result[nextNo] = result[i] == 'S' ? 'W' : 'S';
                    }
                }
                else
                {
                    if (result[i - 1] == 'S')
                    {
                        result[nextNo] = result[i] == 'S' ? 'W' : 'S';
                    }
                    else
                    {
                        result[nextNo] = result[i] == 'S' ? 'S' : 'W';
                    }
                }
            }

            if (result[0] == firstResult)
            {
                if (pattern[0] == 'o')
                {
                    if (result[0] == 'S')
                    {
                        return result[1] == result[n - 1];
                    }
                    else
                    {
                        return result[1] != result[n - 1];
                    }
                }
                else
                {
                    if (result[0] == 'S')
                    {
                        return result[1] != result[n - 1];
                    }
                    else
                    {
                        return result[1] == result[n - 1];
                    }
                }
            }
            else
            {
                return false;
            }
        }
    }
}

Measured memory_bytes: 11860
while 1:
  n = input()
  if n==0: break
  D = {}
  for j in range(n):
    a,b,c,d,e,f,g,h,i = map(int, raw_input().split())
    D[(b+d+f+h)*60 + c+e+g+i] = a
  A = sorted(D)
  for i in [0,1,-2]: print D[A[i]]

Measured memory_bytes: 4724
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#include<random>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

vector<int>getst() {
	int N; cin >> N;
	vector<vector<int>>field(N, vector<int>(N));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			char c; cin >> c;
			if (c == 'o')field[i][j] = 1;
			else if (c == 'x')field[i][j] = -1;
			else field[i][j] = 0;
		}
	}
	int max_win=-1;
	int max_player;
	for (int i = 0; i < N; ++i) {
		int winnum = count_if(field[i].begin(), field[i].end(), [=](const int a) {return a >= 1; });
		if (max_win < winnum) {
			max_win = winnum;
			max_player = i;
		}
	}
	vector<int>anss(1, max_player);
	for (int i = 0; i < N; ++i) {
		if (field[i][max_player]==1) {
			anss.push_back(i);
		}
	}
	if (anss.size() >= 6)anss.push_back(max_player);
	return anss;
}
void putst(const vector<int>&anss) {
	random_device rnd;
	mt19937 mt(rnd());

	for (int i = 0; i < 1000; ++i) {
		int index = mt() % anss.size();
		cout << anss[index]+1 << endl;
		int dummy; cin >> dummy;
	}

}

int main() {
	auto p = getst();
	putst(p);
	return 0;
}

Measured memory_bytes: 3380
a = [list(map(int,input().split())) for A in range(3)]
n = int(input())
for i in range(n) :
    b = int(input())
    for j in range(3) :
        if b in a[j] :
            a[j][a[j].index(b)] = 0
if a[0][0] == a[0][1] == a[0][2] :
    print("Yes")
elif a[1][0] == a[1][1] == a[1][2] :
    print("Yes")
elif a[2][0] == a[2][1] == a[2][2] :
    print("Yes")
elif a[0][0] == a[1][0] == a[2][0] :
    print("Yes")
elif a[0][1] == a[1][1] == a[2][1] :
    print("Yes")
elif a[0][2] == a[1][2] == a[2][2] :
    print("Yes")
elif a[0][0] == a[1][1] == a[2][2] :
    print("Yes")
elif a[2][0] == a[1][1] == a[0][2] :
    print("Yes")
else :
    print("No")


Measured memory_bytes: 9216
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define endl '\n'

const int max4 = 10004;
const int maxx = 100005;
const int max6 = 1000006;
const int lg5 = 17;

const int INF = 2 * 1000000007;
const long long INFLL = 4LL * 1000000000 * 1000000000;

/***************/

int powmod (int a, int b, int mod) {
    int res = 1; a %= mod;
    for (; b; b >>= 1) {
        if (b & 1) {
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
    }
    return res;
}

int gcd (int a, int b) {
    while (b > 0) {
        int t = a % b;
        a = b, b = t;
    }
    return a;
}

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

int is_prime (int n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (int i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/******Don't forget to use long long when needed!!******/

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, x;
    cin >> n;
    int sum = 0;
    for (int i = 1; i <= n; i++) {
        cin >> x, sum += x;
    }
    cout << sum - n << endl;
    return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    long long cur_max = 0, sum = 0;
    for (int i = 0; i < N; ++i) {
        long long A;
        cin >> A;
        if (A <= cur_max) {
            sum += (cur_max - A);
        } else {
            cur_max = A;
        }
    }
    cout << sum << '\n';
    return 0;
}

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

int main()
{
	int l = 0;
	string s, t = "";
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'B') {
			if (l > 0) l--;
		}
		else {
			t[l] = s[i];
			l++;
		}
	}
	for (int i = 0; i < l; i++) {
		cout << t[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>


using namespace std;

vector<int> a(100001, 0);

int main(){
	string N;
	cin >> N;
	if (N[0] == '9' || N[1] == '9') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
from collections import deque
from sys import setrecursionlimit

setrecursionlimit(1000000)


INF = float("inf")

d = deque()
# ---Input---#
# n = int(input())
h, w = map(int, input().split())

a = [["#" for _ in [INF] * (w + 1)] for _ in [INF] * ((h + 1))]
memo = [[0 for _ in [INF] * (w + 1)] for _ in [INF] * ((h + 1))]

for i in range(h + 1)[1:]:
    a[i] = list("#" + input())

memo[1][1] = 1
d = deque()
if a[2][1] == ".":
    d.append((2, 1))
if a[1][2] == ".":
    d.append((1, 2))


def dp(x, y):
    tmp = 0
    if a[x - 1][y] == ".":
        tmp = tmp + memo[x - 1][y]
    if a[x][y - 1] == ".":
        tmp = tmp + memo[x][y - 1]
    tmp = tmp % (10 ** 9 + 7)
    memo[x][y] = tmp
    return tmp


while len(d) > 0:
    x, y = d.popleft()
    if memo[x][y] == 0:
        dp(x, y)
        if x < h:
            if a[x + 1][y] == ".":
                d.append((x + 1, y))
        if y < w:
            if a[x][y + 1] == ".":
                d.append((x, y + 1))


ans = memo[h][w]

print("{}".format(ans))


Measured memory_bytes: 146056
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n;
  cin >> n ;
  cout << n+n*n+n*n*n << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
typedef long long ll;

ll n;
ll a[2 * 100005];

int main()
{
	ll ans = 0;

	scanf("%lld", &n);
	for (ll i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
	}

	a[0] = -1;
	for (ll i = n; i >= 0; i--) {
		if (a[i] - a[i - 1] > 1) {
			printf("-1\n");
			return 0;
		}
		else {
			if (a[i] > 0) {
				if (a[i] - a[i - 1] == 1) {
					ans++;
				} else {
					ans = ans + a[i];
				}
			}
		}
	}
	
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 1792
// ALDS1_11_C: Breadth First Search
#include <iostream>
#include <vector>
#include <algorithm>
#define INF 1000
bool debug = false;

std::vector<std::vector<int>> adjacency_list;
std::vector<int> node_distance;

void SetnodeRelationship() {
    int total; std::cin >> total;
    int max = total+1;
    /* initialize adjacency_list */
    adjacency_list.resize(max);
    for (int i=1; i<adjacency_list.size(); i++) {
        adjacency_list.at(i).resize(max);
        for (int j=1; j<adjacency_list.at(i).size(); j++) {
            adjacency_list.at(i).at(j) = 0;
        }
    }

    /* initialize node_distance */
    node_distance.resize(max);
    for (int i=1; i<node_distance.size(); i++) {
        node_distance.at(i) = INF;
    }

    /* set node relationship */
    for (int i=1; i<adjacency_list.size(); i++) {
        int node, outdegree; std::cin >> node >> outdegree;
        for (int j=0; j<outdegree; j++) {
            int tmp; std::cin >> tmp;
            adjacency_list.at(node).at(tmp) = 1;
        } 
    }
}

void BreadthFirstSearch(int node, int distance) {
    node_distance.at(node) = distance;

    /* Recerve */
    for (int i=1; i<adjacency_list.at(node).size(); i++) {
        /* have next vertex? */
        if (adjacency_list.at(node).at(i) == 1) {
            /* is the path to the next vertex SHORTEST distance? */
            if (node_distance.at(i) > distance+1) {
                if (debug) std::cout << "BreadthFirstSearch(" << i << ", " << distance+1 << ")\n";
                BreadthFirstSearch(i, distance+1);
            }
        }
    }
}

int main() {
    SetnodeRelationship();
    BreadthFirstSearch(1, 0);

    for (int i=1; i<node_distance.size(); i++) {
        if (node_distance.at(i) == INF) {
            node_distance.at(i) = -1;
        }
        std::cout << i << " " << node_distance.at(i) << "\n";
    }
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define taskname "A"
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int maxn = 2e5 + 5;

int n , a[maxn] , m;
ll s[maxn * 4] , lz[maxn * 4];
ll cnt[maxn * 4];
ll ans[maxn];

void Push(int x , int l , int r){
//    cout << l << " " << r << " " << x << " " << cnt[x] << " " << lz[x] << endl;
    if(l == r)return;
    lz[x * 2] += lz[x];
    lz[x * 2 + 1] += lz[x] + ((l + r) / 2 - l + 1) * cnt[x];
    cnt[x * 2] += cnt[x];
    cnt[x * 2 + 1] += cnt[x];
    lz[x] = cnt[x] = 0;
}

void update(int x , int l , int r , int L , int R , int delta){
//    Push(x , l , r);
//    cout << x << " " << l << " " << r << " " << L << " " << R << " " << delta << endl;
    if(L > r || l > R)return ;
    if(L <= l && r <= R){
        lz[x] += delta + l - L;
        cnt[x]++;
        return;
    }
    int mid = l + r >> 1;
    update(x * 2 , l , mid , L , R , delta);
    update(x * 2 + 1 , mid + 1 , r , L , R , delta);
}

void Build(int x , int l , int r){
    Push(x , l , r);
    if(l == r){
        ans[l] = lz[x];
        return;
    }
    int mid = l + r >> 1;
    Build(x * 2 , l , mid);
    Build(x * 2 + 1 , mid + 1 , r);
}

int main(){
    if(fopen(taskname".INP","r")){
        freopen(taskname".INP","r",stdin);
        freopen(taskname".OUT","w",stdout);
    }
    cin >> n >> m;
    for(int i = 1 ; i <= n ; ++i)cin >> a[i];
    ll res = 0;
    for(int i = 1 ; i < n ; ++i){
        if(a[i] <= a[i + 1]){
            update(1 ,1,m,a[i]+1,a[i+1],0);
//            cout << a[i] + 1 << " " << a[i + 1] << " " << 0 << endl;
            res += a[i + 1] - a[i];
        }else{
            update(1 , 1 , m , a[i]+1,m,0);
            update(1 , 1 , m , 1,a[i + 1],m - a[i]);
//            cout << a[i] + 1 << " " << m << " " << 0 << endl;
//            cout << 1 << " " << a[i + 1] << " " << m - a[i] << endl;
            res += m - a[i] + a[i + 1];
        }
    }
    Build(1,1,m);
    cout << res - *max_element(ans+1,ans+m+1);
}


Measured memory_bytes: 9984
using namespace std;

#include <stdio.h>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>

#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;

int n, k;

int test(int i, int cnt) {
    if (cnt == n) return i;
    return min(test(i + k, cnt + 1), test(i * 2, cnt + 1));
}

signed main() {
    //freopen("out.txt", "w", stdout);
    scanf("%lld%lld", &n, &k);
    printf("%lld\n", test(1, 0));
}


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

ans = 0
history_i = set()
for i in range(N-2):

    if S[i] in history_i:
        continue

    history_j = set()
    for j in range(i+1, N-1):

        if S[j] in history_j:
            continue

        history_k = set()
        for k in range(j+1, N):

            if S[k] in history_k:
                continue
            history_k.add(S[k])
            ans += 1
            if len(history_k) == 10:
                break
        
        history_j.add(S[j])
        if len(history_j) == 10:
            break

    history_i.add(S[i])
    if len(history_i) == 10:
        break

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, K;
  cin >> N >> K;
  vector<lint> a(N);
  REP(i, N) cin >> a[i];
  vector<lint> S(N+1);
  REP(i, N) S[i+1] += S[i] + a[i];
  vector<lint> Splus(N+1);
  REP(i, N) Splus[i+1] += Splus[i] + (a[i]>0 ? a[i] : 0);
  lint ans = 0;
  REP(i, N) {
    if(i+K > N) break; 
    if(Splus[i] + S[i+K]-S[i] + Splus[N]-Splus[i+K]> ans) ans = Splus[i] + S[i+K]-S[i] + Splus[N]-Splus[i+K];
    if(Splus[i] + Splus[N]-Splus[i+K] > ans) ans = Splus[i] + Splus[N]-Splus[i+K];
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

using namespace std;

int a,b;

int main()
{
    cin >> a >> b;
    if (a>8||b>8)
    {
        cout << ":(" << endl;
    }
    else cout<< "Yay!" << endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import permutations

N = int(input())
P = "".join(list(input().split()))
Q = "".join(list(input().split()))
#print("P:", P)

A = ""
for i in range(1, N + 1):
  A += str(i)
A = list(permutations(A, N))
A.sort()
#print("A:", A)

B = []
for i in range(len(A)):
  B.append("".join(A[i]))

for i in range(len(B)):
  if P == B[i]:
    a = i
  if Q == B[i]:
    b = i
    
print(abs(a-b))

Measured memory_bytes: 49264
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    n = int(sys.stdin.readline())
    a = int(sys.stdin.readline())
    b = int(sys.stdin.readline())
    c = int(sys.stdin.readline())
    d = int(sys.stdin.readline())
    e = int(sys.stdin.readline())

    ans = -(-n//min(a,b,c,d,e)) + 4

    print(ans)


Measured memory_bytes: 5712
#include <bits/stdc++.h>
#define ABS(x) ((x) >= 0 ? (x) : -(x))
#define int long long

using namespace std;



int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * c, max(a * d, max(b * c, b * d)));
}


Measured memory_bytes: 3688
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>

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 long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

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




int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	while (1) {
		ll W, H; scanf("%lld %lld", &W, &H);
		if (W == 0 && H == 0) break;
		vector<vector<ll>> yo(H, vector<ll>(W - 1));
		vector<vector<ll>> ta(H, vector<ll>(W));
		for (ll i = 0; i < H; i++) {
			for (ll j = 0; j < W - 1; j++) scanf("%lld", &yo[i][j]);
			if (i != H - 1) for (ll j = 0; j < W; j++) scanf("%lld", &ta[i][j]);
		}
		queue<pair<ll, ll>> q;
		q.emplace(0, 0);
		vector<vector<ll>> d(H, vector<ll>(W, -1));
		while (!q.empty()) {
			ll h, w; tie(h, w) = q.front();
			q.pop();
			if (h > 0 && ta[h-1][w] == 0 && d[h-1][w] == -1) {
				d[h - 1][w] = d[h][w] + 1;
				q.emplace(h - 1, w);
			}
			if (h < H - 1 && ta[h][w] == 0 && d[h + 1][w] == -1) {
				d[h + 1][w] = d[h][w] + 1;
				q.emplace(h + 1, w);
			}
			if (w > 0 && yo[h][w - 1] == 0 && d[h][w - 1] == -1) {
				d[h][w - 1] = d[h][w] + 1;
				q.emplace(h, w - 1);
			}
			if (w < W - 1 && yo[h][w] == 0 && d[h][w + 1] == -1) {
				d[h][w + 1] = d[h][w] + 1;
				q.emplace(h, w + 1);
			}
		}
		ll res = d[H - 1][W - 1];
		if (res == -1) res = -2;
		printf("%lld\n", res + 2);
	}
	return 0;
}


Measured memory_bytes: 3296
#include<bits/stdc++.h>
using namespace std;
int main()
{
  char a,b,c,d,e,f;int count=0;
  cin>>a>>b>>c>>d>>e>>f;
  if(a==d){count++;}
  if(b==e){count++;}
  if(c==f){count++;}
  cout<<count;
}

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

using namespace std;

int main()
{
    int i,j,x,n,A[200001],b[5],ans;
    cin>>n;
    for(i=0; i<n; i++)
        scanf("%d",&A[i]);
    if(n==2)
    {
        for(i=0;i<2;i++)
            cout<<A[1-i]<<endl;
    }
    else
    {
        for(i=0; i<2; i++)
        {
            b[i]=A[i];
            for(j=i+1; j<n; j++)
                if(b[i]<A[j])
                {
                    b[i]=A[j];
                    if(i==0)
                        x=j;
                }
            if(i==0)
            {
                ans=A[i];
                A[i]=b[i];
                A[x]=ans;
            }
        }
        for(i=0; i<n; i++)
        {
            if(i==x)
                cout<<b[1]<<endl;
            else
                cout<<b[0]<<endl;
        }
    }
}


Measured memory_bytes: 2432
#!/usr/bin/env python3
import sys


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    N = LI()
    print(N[0]*N[1])


# oj t -c "pypy3 main.py"
# acc s main.py -- --guess-python-interpreter pypy
main()


Measured memory_bytes: 61856
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\Users\Joeon\Desktop\IN.txt", "r", stdin);
//		freopen("C:\Users\Joeon\Desktop\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	string str = next<string>();
	rep(i, 0, str.length()) str[i] = 'x';
	cout<<str<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
A = np.array(input().split(), dtype=np.int32)
B = np.array(input().split(), dtype=np.int32)
 
def sum_count(A,B,x):
  # A,B is sorted. 
  # return count(a+b < x)
  C = np.searchsorted(B, x-A)
  return C.sum()
 
		
def f(t,A,B):
  power = 1<<t
  mask = (power<<1)-1
  AA = A & mask
  BB = B & mask
  AA.sort()
  BB.sort()

  x1,x2,x3 = (sum_count(AA,BB,v) for v in [power, 2*power, 3*power])
  zero_cnt = x1 + (x3-x2)
  return (N-zero_cnt)%2
  
answer = 0
for t in range(30):
	x = f(t,A,B)
	if x == 1:
		answer += 1<<t

print(answer)


Measured memory_bytes: 35872
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/

import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = 0;
		String s = sc.nextLine();
		String t = sc.nextLine();
		 
		int n = t.length();
		int i;
		for(i=0; i<n; i++)
		{
		    if(s.charAt(i) != t.charAt(i))
		        x++;
		}
		System.out.println(x);
	}
}


Measured memory_bytes: 42120
N, K, S = map(int, input().split())

base = 0
if S == 10 ** 9:
    base = 1
else:
    base = S + 1

L = [base] * (N - K)
for i in range(K):
    L.append(S)

for l in L:
    print(str(l) + ' ', end="")


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

//カードの構造体
struct Card {
    char suit;
    int value;
};

void print_array(int n,Card a[]){
    for(int i = 0; i < n; i++){
        cout << a[i].suit << a[i].value;
        if(i < n-1) cout << ' ';
    }
    cout << endl;
}

void Bubble_Sort(int n, Card A[]){
    //バブルソート
    int flag = 1;
    int i = 0;//未ソート部分の先頭インデクス
    while(flag){
        flag = 0;
        for(int j = n-1; j >= i+1 ; j--){
            if(A[j].value < A[j-1].value){
                swap(A[j], A[j-1]);
                flag = 1;
            }
        }
        i++;
    }
}

void Selection_Sort(int n, Card A[]){
    //選択ソート O(n**2)
    for (int i = 0; i < n-1; i++){
        int minj = i;
        for (int j = i; j < n; j++){
            if (A[minj].value > A[j].value) minj = j;
        }
        if (i != minj){
            swap(A[i], A[minj]);
        }
    }
}

//愚直法　O(n**4)
bool check_stable(int n, Card origin[], Card target[]){
    for (int i = 0; i < n; i++){
        for (int j = i+1; j < n; j++){
            for (int a = 0; a < n; a++){
                for (int b = a+1; b < n-1; b++){
                    if (origin[i].value == origin[j].value //数字が等しい組があった時
                        && origin[i].value == target[b].value
                        && origin[i].suit == target[b].suit
                        && origin[j].value == target[a].value
                        && origin[j].suit == target[a].suit){
                            return false;
                        }
                }
            }
        }
    }
    return true;
}

int main(){
    int N;
    Card B[36], S[36], O[36];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> B[i].suit >> B[i].value;
        S[i].suit = B[i].suit;
        S[i].value = B[i].value;
        O[i].suit = B[i].suit;
        O[i].value = B[i].value;
    }

    Bubble_Sort(N, B);
    Selection_Sort(N, S);
    print_array(N, B);
    cout << "Stable" << endl;//バブルソートはいつでも安定
    print_array(N, S);
    if(check_stable(N, O, S) == true){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] a = new long[N];
        long[] b = new long[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextLong();
        }
        for (int i = 0; i < N; i++) {
            b[i] = scan.nextLong();
        }
        long a_increment = 0;
        long b_increment = 0;
        for (int i = 0; i < N; i++) {
            if (a[i] == b[i]) {
                continue;
            }
            if (a[i] < b[i]) {
                a_increment += (a[i] - b[i]) / 2;
                continue;
            }
            b_increment += a[i] - b[i];
        }
        a_increment += b_increment;
        if (a_increment <= 0) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 42204
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define xh1(a,b) for(int i=a;i<b;i++)
#define xh2(a,b) for(int j=a;j<b;j++)
#define stlbl(a) for(it=a.begin();it!=a.end();it++)
#define dzkt int T;cin>>T;while(T--)
#define iosks std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int pow2(int a,int b) {int s=1; while(b) {if(b&1) s*=a; a*=a; b/=2; } return s;}
int gcd(int a,int b) {return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) {return a/gcd(a,b)*b; }
ll prime(ll x) {for(ll i=2;i<=sqrt(x+0.5);i++) if(x%i==0) return 0; return 1; }
const int N=1e6,inf=1e9+10;
const ll ma=1e18;
char ch[N];
ll vis[N],a[N];
vector<ll> vec;
int main()
{
    iosks;
    ll n;
    cin>>n;
    xh1(2,N) if(vis[i]==0) {vec.push_back(i); for(int j=i+i;j<N;j+=i) vis[j]=1;}
    xh1(0,vec.size()) while(n%vec[i]==0) {n/=vec[i],a[vec[i]]++;}
    ll ans=0;
    if(n!=1) ans=1;
    xh1(0,vec.size()){
        ll k=a[vec[i]];
        if(k==0) continue;
        ll j=sqrt(k)-1;
        while(j*(j+1)/2<=k) j++;
        ans+=j-1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 12084
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a < b){
			System.out.println("a < b");
		}else if(a > b){
			System.out.println("a > b");
		}else{
			System.out.println("a == b");
		}
		sc.close();
	}
}


Measured memory_bytes: 26116
import * as fs from 'fs';

const input = fs.readFileSync("/dev/stdin", "utf8").split("\n");

const a = +input[0]
const b = +input[1]

if (a + b == 3) {
  console.log(3)
} else if (a + b == 4) {
  console.log(2)
} else {
  console.log(1)
}

Measured memory_bytes: 7500
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	for (int i = 0; i < S.length(); i++) {
		if (i == 3) {
			cout << S[i] << " ";
		}
		else {
			cout << S[i];
		}
	}
	cout << endl;
}


Measured memory_bytes: 3620
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    N = int(inputs[0])
    A = string_to_int(inputs[1])
    B = string_to_int(inputs[2])
    C = string_to_int(inputs[3])
    A.sort()
    B.sort()
    C.sort()

    patterns = 0

    for b in B:
        ai = bisect.bisect_left(A, b)
        ci = bisect.bisect_right(C, b)
        patterns += ai * (N-ci)

    return patterns


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(4))
    print(ret)


Measured memory_bytes: 110700
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
map<ll, int> mp;
int main() {
    int n;
    ll t;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> t;
        mp[t] ++;
    }
    ll A[mp.size()];
    int i = 0;
    for (auto it = mp.rbegin(); it != mp.rend(); ++it) {
        if ((*it).second >= 2) A[i++] = (*it).first;
        if ((*it).second >= 4) A[i++] = (*it).first;
        if (i >= 2) break;
    }

    if (i >= 2) cout << A[0] * A[1] << endl;
    else cout << "0" << endl;
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int c = a * b, d = c % 2;
  if ( d == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}
  
  

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cctype>
#include <cassert>

using namespace std;

string S;
size_t cur = 0;

char readchar() {
  assert(cur < S.size());
  char ret = S[cur];
  cur++;
  return ret;
}

char peek() {
  assert(cur < S.size());
  return S[cur];
}

int digit() {
  assert(isdigit(peek()));
  int n = readchar() - '0';
  return n;
}

int number() {
  int n = digit();
  while(cur < S.size() && isdigit(peek()))
    n = n*10 + digit();
  return n;
}

int expression();

int factor() {
  if(peek() != '(') return number();
  cur++;
  int n = expression();
  assert(peek() == ')');
  cur++;
  return n;
} 

int term() {
  int a = factor();
  while(cur < S.size() && (peek() == '*' || peek() == '/')) {
    char op = readchar();
    int b = factor();
    if(op == '*') a *= b;
    else a /= b;
  }
  return a;
}



int expression() {
  int sum = term();
  while(cur < S.size() && (peek() == '+' || peek() == '-')) {
    char op = readchar();
    int b = term();
    if(op == '+') sum += b;
    else sum -= b;
  }
  return sum;
}

int parse() {
  return expression();
}

int main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> S;
    int a = parse();
    cout << a << endl;
    cur = 0;
  }
  return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

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<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int K, X; cin >> K >> X;
    if(500 * K >= X) Yes;
    else No;
} 
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

int gcd(int a, int b)
{
    int c;

    if (a < b) {
        a+=b; b=a-b; a-=b;
    }

    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}

int main(void){
    int n, t, a, h, ans;
    double tmp = 100000;
    cin >> n >> t >> a;
    for(int i = 0; i < n; i++) {
        cin >> h;
        if(tmp > abs(a - (t - h * 0.006))){
            tmp = abs(a - (t - h * 0.006));
            ans = i + 1;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;

int main(){

  string s;
  cin >> s ;

  int size=s.size();

  if(s.at(size-1)=='s'){
    cout << s << "es" << endl;
    return 0;
  }
  cout << s << 's' << endl;


}



Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
int main(){
  int n,i,len;
  char s[10001];
  scanf("%d",&n);
  scanf("%s",s);
  len=strlen(s);
  for(i=0; i<len; i++){
    s[i]=s[i]+n;
    if(s[i]>'Z'){
      s[i]=s[i]-26;
    }
  }
  printf("%s\n",s);
  return 0;
}


Measured memory_bytes: 128
#include <ext/rope>
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long
typedef vector<vector<ll>> mat;

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

    string s;
    cin >> s;

    map<char , int> mp;
    for(auto i : s)
        mp[i]++;

    bool f = 0 , ss = 0;
    for(auto i : mp)
        if(i.second == 2 && !f) f = 1;
        else if(i.second == 2) ss = 1;

    if(f && ss) cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 256
n = int(input())
count=0
flag=0
for num in range(n):
  i = list(map(int, input().split()))
  if i[0]==i[1]:
    count +=1
  else:
    count=0
  if count == 3:
    flag=1
if flag==0:
  print('No')
elif flag==1:
  print('Yes')

Measured memory_bytes: 9184
#include <iostream>
#include <vector>
#include <limits>

using namespace std;

int N, C;
vector<vector<int>> D, color, rem_colors(3), disorder(3);

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

	D.resize(C);
	for (int i = 0; i < C; i++) {
		D[i] = vector<int>(C);
		for (int j = 0; j < C; j++) {
			cin >> D[i][j];
		}
	}

	color.resize(N);
	rem_colors[0] = vector<int>(C, 0);
	rem_colors[1] = vector<int>(C, 0);
	rem_colors[2] = vector<int>(C, 0);
	for (int i = 0; i < N; i++) {
		color[i] = vector<int>(N);
		for (int j = 0; j < N; j++) {
			cin >> color[i][j];
			color[i][j]--;
			//同色になるべきセルの各色の個数を保持
			rem_colors[(i + j) % 3][color[i][j]]++;
		}
	}

	//剰余集合をある色にしたときの違和感を計算
	disorder[0] = vector<int>(C, 0);
	disorder[1] = vector<int>(C, 0);
	disorder[2] = vector<int>(C, 0);
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < C; j++) {
			for (int k = 0; k < C; k++) {
				disorder[i][j] += rem_colors[i][k] * D[k][j];
			}
		}
	}

	//組み合わせを全列挙して最小を探す
	int ans = numeric_limits<int>::max();

	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			for (int k = 0; k < C; k++) {
				if (i != j && j != k && k != i
					&& ans > disorder[0][i] + disorder[1][j] + disorder[2][k]) {
					ans = disorder[0][i] + disorder[1][j] + disorder[2][k];
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main()
{
  double a, b, C, S = 0, L = 0, h = 0, rad;

  scanf("%lf %lf %lf", &a, &b, &C);

  rad = C * acos(-1) / 180;

  h = b * sin(rad);

  S = a * h / 2;

  L = sqrt(pow(a, 2) + pow(b, 2) - (2 * a * b * cos(rad))) + a + b;

  printf("%lf\n%lf\n%lf\n", S, L, h);
}


Measured memory_bytes: 3452
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll h, w;
    cin >> h >> w;

    map<ll, ll> a;
    rep(i, 0, h){
        rep(j, 0, w){
            char tmp;
            cin  >> tmp;
            a[tmp]++;
        }
    }

    ll p = 0, q = 0, r = 0;
    fore(x, a){
        p += x.second / 4;
        x.second -= x.second / 4 * 4;
        q += x.second / 2;
        x.second -= x.second / 2 * 2;
        r += x.second / 1;
    }

    if(h % 2 == 0 && w % 2 == 0){
        if(p * 4 == h * w){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else if(h % 2 == 1 && w % 2 == 1){
        if((h - 1) * (w - 1) <= p * 4){
            q += (p * 4 - (h - 1) * (w - 1)) / 2;
            if(r == 1){
                if(q * 2 == h + w - 2){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
        cout << "No" << endl;
        return 0;
    }else if(h % 2 == 0 && w % 2 == 1){
        if((h) * (w - 1) <= p * 4){
            q += (p * 4 - (h) * (w - 1)) / 2;
            if(q * 2 == h){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
        return 0;
    }else if(h % 2 == 1 && w % 2 == 0){
        if((h - 1) * (w) <= p * 4){
            q += (p * 4 - (h - 1) * (w)) / 2;
            if(q * 2 == w){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
        return 0;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k,l;
  string s;
  cin >> k>>s;
  l=s.size();
  if(k>=l){
    cout<<s;
  }
  else{
    for(int i=0;i<k;i++){
      cout<<s.at(i);
    }
    cout<<"...";
  }
  return 0;
}

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

c0 = 0
c1 = 0
c2 = 0
c3 = 0
for i in range(n):
    s = input()
    if s == "AC":
        c0 += 1
    elif s == "WA":
        c1 += 1
    elif s == "TLE":
        c2 += 1
    else:
        c3 += 1

print("AC x", c0)
print("WA x", c1)
print("TLE x", c2)
print("RE x", c3)


Measured memory_bytes: 9064
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    int ans = 1e9;
    for (int i = 0; i + t.size() - 1 < s.size(); i++) {
        int cnt = 0;
        for (int j = i, k = 0; k < t.size(); j++, k++) {
            cnt += (s[j] != t[k]);
        }
        ans = min(ans, cnt);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
 

int main() {
	string s;
	cin>>s;
	string ch[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
	for(ll i=0;i<7;i++){
		if(s==ch[i]){
			cout << 7-i;
			return 0;
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,k,i,amin=1e9;
  cin >> n >> k;
  vector<int> h(n,0);
  for (i=0;i<n;i++) cin >> h.at(i);
  sort(h.begin(),h.end());
  for (i=0;i<n-k+1;i++) amin=min(amin,h.at(i+k-1)-h.at(i));
  cout << amin << endl;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
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 int INF = 1e9;


int main() {
    int N,K;
    string S;
    cin >> N >> K;
    cin >> S;
    char tmp = S[0];
    for (int i = 1; i < N; i++) {
        if (S[i] != tmp && K > 0) {
            S[i] = tmp;
            int j = i+1;
            K--;
            while (j < N && S[j] != S[i]) {
                S[j] = S[i];
                j++;
            }
            tmp = S[i];
        }
    }
    int count = 0;
    for (int i = 0; i < N-1; i++) {
        if (S[i] == S[i+1]) count++;
    }
    cout << count << endl;
    
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		String total = scanner.nextLine();
		if(total.length()%2 != 0) {
			System.out.println("No");
			return;
		}
		for(int i =0; i<total.length(); i++) {
			if(i%2==0) {
				if(!"h".equals(total.substring(i, i+1))) {
					System.out.println("No");
					return;
				}
			}else {
				if(!"i".equals(total.substring(i, i+1))) {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}	
	
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    cin>>S;
    
    bool North=false;
    bool West=false;
    bool South=false;
    bool East=false;
    
    for(int i=0;i<S.size();i++){
        if(S[i]=='N')North=true;
        else if(S[i]=='W')West=true;
        else if(S[i]=='S')South=true;
        else East=true;
    }
    
    if(North==South&&West==East)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------
// 入力
int N;

// DP テーブル
double dp[310][310][310];
double rec(int i, int j, int k) {
    if (dp[i][j][k] >= 0) return dp[i][j][k];
    if (i == 0 && j == 0 && k == 0) return 0.0;

    double res = 0.0;
    if (i > 0) res += rec(i-1, j, k) * i;
    if (j > 0) res += rec(i+1, j-1, k) * j;
    if (k > 0) res += rec(i, j+1, k-1) * k;
    res += N;
    res *= 1.0 / (i + j + k);

    return dp[i][j][k] = res;
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    cin >> N;
       int one = 0, two = 0, three = 0;
       for (int i = 0; i < N; ++i) {
           int a; cin >> a;
           if (a == 1) ++one;
           else if (a == 2) ++two;
           else ++three;
       }

       // 初期化
       memset(dp, -1, sizeof(dp));

       // 答え
       cout << fixed << setprecision(10) << rec(one, two, three) << endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 233088
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;
#define INF 2147483647

struct Segment_Tree{
    private:
        int n;
        vector<int> node;
    public:
        Segment_Tree(vector<int> v){
            int size = v.size();
            n = 1; while(n < size) n *= 2;
            node.resize(2*n-1, INF);
            
            for(int i=0;i<size;i++) node[n+i-1] = v[i];
            for(int i=n-2;i>=0;i--) node[i] = min(node[2*i+2],node[2*i+1]);
        }

        void update(int x, int val){
            x += (n-1);
            node[x] = val;
            while(x > 0){
                x = (x-1)/2;
                node[x] = min(node[2*x+1], node[2*x+2]);
            }
        }

        int get(int a, int b, int k=0, int l=0, int r=-1) {
            if(r < 0) r = n;
            if(r <= a || b <= l) return INF;
            if(a <= l && r <= b) return node[k];
            int vl = get(a, b, 2*k+1, l, (l+r)/2);
            int vr = get(a, b, 2*k+2, (l+r)/2, r);
            return min(vl, vr);
        }
};

int main(){
    int n,q; cin >> n >> q;
    vector<int> v(n);
    for(int i=0;i<n;i++) v[i] = INF;
    struct Segment_Tree st(v);
    for(int i=0; i<q;i++){
        int c,x,y; cin >> c >> x >> y;
        if(c==0) st.update(x,y);
        else cout << st.get(x,y+1) << endl;
    }
    return 0;
}


Measured memory_bytes: 4688