akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
using namespace std;

const int N = 2e5 + 5;

struct edge {
  int nxt, to;
} e[N];
int fir[N], a[N];

namespace Segment_Tree {
#define mid ((L + R) >> 1)
#define no ID(L, R)
#define lc ID(L, mid)
#define rc ID(mid + 1, R)
  int key[N << 1], lazy[N << 1];
  inline int ID(int L, int R) {return (L + R) | (L != R);}
  inline void PushDown(int L, int R) {
    if (!lazy[no] || L == R) return;
    lazy[lc] += lazy[no];
    lazy[rc] += lazy[no];
    key[lc] += lazy[no];
    key[rc] += lazy[no];
    lazy[no] = 0;
  }
  inline void PushUp(int L, int R) {
    key[no] = max(key[lc], key[rc]);
  }
  inline void Init(int L, int R) {
    lazy[no] = 0;
    if (L == R) {
      key[no] = L;
      return;
    }
    Init(L, mid);
    Init(mid + 1, R);
    PushUp(L, R);
  }
  inline void Add(int L, int R, int l, int r) {
    if (L == l && R == r) {
      key[no] ++;
      lazy[no] ++;
      return;
    }
    PushDown(L, R);
    if (r <= mid) Add(L, mid, l, r);
    else if (l > mid) Add(mid + 1, R, l, r);
    else {
      Add(L, mid, l, mid);
      Add(mid + 1, R, mid + 1, r);
    }
    PushUp(L, R);
  }
  inline int Max(int L, int R, int l, int r) {
    if (L == l && R == r) return key[no];
    PushDown(L, R);
    if (r <= mid) return Max(L, mid, l, r);
    else if (l > mid) return Max(mid + 1, r, l, r);
    else return max(Max(L, mid, l, mid), Max(mid + 1, R, mid + 1, r));
  }
#undef mid
#undef no
#undef lc
#undef rc
}
using namespace Segment_Tree;

int main() {
  int ans = 0, n, m;
  scanf("%d%d", &n, &m);
  ans = max(ans, n - m);
  for (int i = 1, l, r; i <= n; i ++) {
    scanf("%d%d", &l, &r);
    e[i] = (edge){fir[l], r};
    fir[l] = i;
  }
  Segment_Tree::Init(0, m + 1);
  for (int i = 0; i <= m; i ++) {
    for (int j = fir[i]; j; j = e[j].nxt)
      Segment_Tree::Add(0, m + 1, 0, e[j].to);
    ans = max(ans, Segment_Tree::Max(0, m + 1, i + 1, m + 1) - m - i - 1);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 6528
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

list = [a, b, c, d, e]

sum = 0

f = 0
for i in range(1,10):
    if f == 0:
        for j in list:
            if j%10 == i:
                sum += j
                list.remove(j)
                f = 1
                break
        
for i in list:
    if i % 10 == 0:
        sum += i
    else:
        sum += i + 10 - (i % 10)

print(sum) 

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
from sys import stdin

d_in = lambda: int(stdin.readline())  # N = d_in()

N = d_in()


def factorize(n):
    """
    素因数分解

    Return
    ------
    fct : list
        [[素因数, 指数], ...] のリスト
            [[a_1, n_1], ..., [a_i, n_i], ...]
        n = a_1**n_1 * a_2**n_2 * ...
    """
    if n == 1:
        return [(1, 1)]
    fct = []
    b, e = 2, 0
    while b * b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def Sieve_of_Eratosthenes(x):
    """
    エラトステネスの篩を用いて素数列を返す
    2以上x未満の素数列を返す
    参考URL:
    https://qiita.com/peria/items/a4ff4ddb3336f7b81d50
    """
    primes = [2*i + 1 for i in range((x + 1) // 2)]
    primes[0] = 2
    n_primes = len(primes)
    sqrt_x = int((x + 0.1) ** 0.5)
    for i in range(1, (sqrt_x + 1) // 2):
        if not primes[i]:
            continue
        p = 2 * i + 1
        for j in range(2 * i * (i + 1), n_primes, p):
            primes[j] = False
    return list(filter(lambda x: x, primes))


primes = Sieve_of_Eratosthenes(100)
factor_dict = {i: 0 for i in primes}
for i in range(2, N+1):
    fct = factorize(i)
    for f in fct:
        factor_dict[f[0]] += f[1]


factor_num_list = list(factor_dict.values())
ans = 0

over_74 = len(list(filter(lambda x: x >= 74, factor_num_list)))
ans += over_74

over_24 = len(list(filter(lambda x: x >= 24, factor_num_list)))
over_2 = len(list(filter(lambda x: x >= 2, factor_num_list)))
ans += over_24 * (over_24 - 1)
ans += over_24 * (over_2 - over_24)

over_14 = len(list(filter(lambda x: x >= 14, factor_num_list)))
over_4 = len(list(filter(lambda x: x >= 4, factor_num_list)))
ans += over_14 * (over_14 - 1)
ans += over_14 * (over_4 - over_14)

over_4 = len(list(filter(lambda x: x >= 4, factor_num_list)))
over_2 = len(list(filter(lambda x: x >= 2, factor_num_list)))
between_2_4 = over_2 - over_4
ans += over_4 * (over_4 - 1) * (over_4 - 2) // 2
ans += over_4 * (over_4 - 1) * between_2_4 // 2

print(ans)


Measured memory_bytes: 3192
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){

    int a,b,t;

    cin >> a >> b >> t;

    int out = 0;

    for(int i = 1;i < t+1; ++i){
        if(i%a == 0){
            out += b;
        }
    }

    cout << out << endl;;

    return 0;
}

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

const int MAXN = 1e5 + 5;
int father[MAXN]; int sz[MAXN];

int grs;
void init(int n) {

    for (int i = 0; i <= n; ++i) {
        father[i] = i;
        sz[i] = 1;
    }
}

int find(int u) {

    return father[u] == u ? u : father[u] = find(father[u]);
}

void join(int u, int v) {

    int fatheru = find(u);
    int fatherv = find(v);
    if (fatheru == fatherv) return;
    father[fatheru] = fatherv;
    sz[fatheru] += sz[fatherv];
    sz[fatherv] = fatheru;
    grs--;
   // std::cout << grs;
}

int main(){
    int n,m;
    std::cin >> n >> m;
    grs = n;
    init(n + 1);
    int x,y,z;
    for(int i = 1; i <= m; ++ i){
        std::cin >> x >> y >> z;
        join(x,y);
    }
    std::cout << grs;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
const int MAXN = 100001;
const int MOD = 1000000007;
 
long fact[MAXN];
 
long long pw(long long a, int b) {
    if (b == 0) return 1;
    long long x = pw(a, b / 2);
    x *= x;
    x %= MOD;
    if (b % 2 == 0) return x;
    return x * a % MOD;
}
 
long long dv(long long a, long long b) {
    return a * pw(b, MOD - 2) % MOD;
}
 
long long c(int n, int k) {
    if (k > n) return 0;
    return dv(dv(fact[n], fact[k]), fact[n - k]);
}
 
int main() {
    fact[0] = 1;
    for (int i = 1; i < MAXN; i++) {
        fact[i] = fact[i - 1] * i % MOD;
    }
    int n;
    scanf("%d", &n);
    vector<int> a(n + 1);
    for (int i = 0; i < n + 1; i++) {
        scanf("%d", &a[i]);
        a[i]--;
    }
    vector<int> ind(n, -1);
    int i1 = -1, i2 = -1;
    for (int i = 0; i < n + 1; i++) {
        if (ind[a[i]] != -1) {
            i1 = ind[a[i]];
            i2 = i;
            break;
        } else {
            ind[a[i]] = i;
        }
    }
 
    const int MOD = 1000000007;
    for (int k = 1; k <= n + 1; k++) {
        long long cur = 0;
        // none of those
        cur += c(n - 1, k);
        // one
        cur += 2 * c(n - 1, k - 1);
        cur -= c(i1 + (n - i2), k - 1);
        // both
        if (k >= 2) {
            cur += c(n - 1, k - 2);
        }
 
        cout << (cur % MOD + MOD) % MOD << "\n";
    }
}

Measured memory_bytes: 2816
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"
#define ast(cond)           \
    do {                    \
        if((cond) == false) \
        {                   \
            if(debug_on)    \
            cerr << "ASSERT" << #cond " failed at line:" << __LINE__ << endl;   \
            exit(1);        \
        }                   \
    }while(0)


int main(int, char *[])
{
    int N;
    cin >> N;
    vector<int> A;
    A.push_back(0);
    vector<pair<int,int>> X;
    X.emplace_back(0, 0);
    for(int i = 1; i <= N; ++i)
    {
        int v;
        cin >> v;
        X.emplace_back(v, i);
        A.push_back(v);
    }
    sort(X.begin()+1, X.end(), [](pair<int,int>a, pair<int,int> b)->bool{return a.first < b.first;});
    for(int i = 1; i <= N; ++i)
    {
        const auto raw_med = X[(N-1+1)/2];
        if(A[i] > raw_med.first)
            cout << raw_med.first << endl;
        else /*if(A[i] >= raw_med.first)*/
            cout << X[(N-1+1)/2 + 1].first << endl;
    }

    return 0;
}


Measured memory_bytes: 5616
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main(){
ll n,k;
cin>>n>>k;
ll a=0,b=0;
for(ll i=1;i<=n;i++){
    if(i%k==0){
        a++;
    }
    if(i%k==k/2){
        b++;
    }
}
if(k%2==0){
    cout<<a*a*a+b*b*b<<endl;
}
else{
    cout<<a*a*a<<endl;
}
}









Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var a = sc.nextInt();
		var b = sc.nextInt();
		var h = sc.nextInt();
		var m = sc.nextInt();
		sc.close();

		var min = h * 60 + m;
		var d1 = (min % 720) / 720.0 * 360;
		var d2 = (min % 60) / 60.0 * 360;
		var d = (d1 - d2 + 360) % 360;
		d = Math.min(360 - d, d);

		var result = 0.0;
		if (d == 0) {
			result = Math.abs(a - b);
		} else if (d == 180) {
			result = a + b;
		} else if (d == 90) {
			result = calc(a,  b);
		} else if (d < 90) {
			var r = d / 180.0 * Math.PI;
			result = calc(a * Math.sin(r), (b - a * Math.cos(r)));
		} else {
			var r = (180 - d) / 180.0 * Math.PI;
			result = calc(a * Math.sin(r), (b + a * Math.cos(r)));
		}

		System.out.println(result);
	}

	private static double calc(double a, double b) {
		return Math.sqrt(a * a + b * b);
	}
}

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

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

  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2]) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


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

int main() {
    int n, d;
    cin >> n;
    set<int> s;
    for (int i = 0; i < n; i++) {
        cin >> d;
        s.insert(d);
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){

  int h,w,i,j,k=0;

  scanf("%d%d",&h,&w);

  while(h!=0&&w!=0){
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(i==0||i==h-1||j==0||j==w-1){
	  printf("#");
	}
	else printf(".");
      }
      printf("\n");
    }
    printf("\n");
    scanf("%d%d",&h,&w);
  }

  return 0;
}

Measured memory_bytes: 572
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 10005

const int INF = 1e9+7;

int main(){

    int n,k;
    cin >> n >> k;
    vector<int> x(n,0),y(n,0),c(n,0);

    for(int i = 0;i < n;i++){
        char ch;
        cin >> x[i] >> y[i] >> ch;
        x[i] %= 2*k;
        y[i] %= 2*k;
        if(ch == 'W'){
            c[i] = 1;
        }
    }

    int white[k][k];//マス(x,y)を右上とした長方形に含まれている(白マスの数-黒マスの数)
    for(int i = 0;i < k;i++){
        for(int j = 0;j < k;j++){
            white[i][j] = 0;
        }
    }

    int black = 0;

    for(int i = 0;i < n;i++){
    
        c[i] += x[i]/k + y[i]/k;
        c[i] %= 2;
        x[i] %= k;
        y[i] %= k;
        if(c[i] == 1){
            white[x[i]][y[i]]++;
        }else{
            white[x[i]][y[i]]--;
        }
        if(c[i] == 0){
            black++;
        }
    }

    for(int i = 0;i < k;i++){
        for(int j = 1;j < k;j++){
            white[i][j] += white[i][j-1];
        }
    }
    

    for(int i = 1;i < k;i++){
        for(int j = 0;j < k;j++){
            white[i][j] += white[i-1][j];
        }
    }

    int ans = 0;
    for(int i = 0;i < k;i++){
        for(int j = 0;j < k;j++){
            int w = white[k-1][k-1] - white[i][k-1] - white[k-1][j] + white[i][j]*2 + black;
            ans = max(ans,max(w,n-w));
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 5376
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

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

	int f = 0;
	int x;
	map<char, int> p;
	for (int i = 0; i < s.size(); i++) {
		if (f == 0 && s[i] == 'A') {
			x = i;
			f = 1;
		}
		p[s[i]] = i;
	}

	cout << p['Z'] - x + 1 << endl;
}

Measured memory_bytes: 640
N,K=map(int,input().split())
D=list(input().split())
D.insert(0,0)
n=0
while True:
    n+=1
    ok=True
    for i in list(str(n)):
        if i in D:
            ok=False
            break
    if ok and N<=n:
        print(n)
        break

Measured memory_bytes: 3060
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod=MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}


int R, C, r, c, arr[505][505];
int val = 1e7;


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

    cin>>R>>C>>r>>c;
    if(R%r==0 && C%c==0){
    	cout<<"No";
    	return 0;
    }

    if(C % c != 0){

    	arr[1][1] = val;
    	arr[1][c] = -val-1;
    	for(int j=c+1;j<=C;j++)
    		for(int i=1;i<=r;i++)
    			arr[i][j] = arr[i][j-c];
    	for(int i=r+1;i<=R;i++)
    		for(int j=1;j<=C;j++)
    			arr[i][j] = arr[i-r][j];
    }
    else{

    	arr[1][1] = val;
    	arr[r][1] = -val-1;
    	for(int i=r+1;i<=R;i++)
    		for(int j=1;j<=c;j++)
    			arr[i][j] = arr[i-r][j];
    	for(int j=c+1;j<=C;j++)
    		for(int i=1;i<=R;i++)
    			arr[i][j] = arr[i][j-c];
    }


    cout<<"Yes"<<endl;
    for(int i=1;i<=R;i++){
    	for(int j=1;j<=C;j++)
    		cout<<arr[i][j]<<" ";
    	cout<<endl;
    }
    return 0;
}












Measured memory_bytes: 3584
#include<iostream>
#include<vector>

struct Chainber{
	int color, size;
};

std::vector<Chainber> v;

int water(int uChain, int lChain){
	int res = 0;

	for(;uChain>=0&&lChain<v.size();uChain--,lChain++){
		if((v[uChain].color == v[lChain].color) && (v[uChain].size + v[lChain].size >= 4)){
			res += v[uChain].size + v[lChain].size;
		}
		else{
			break;
		}
	}

	return res;
}

int fish(int i, int abs){
	int res = 0, uChain = i-1, lChain = i+1;
	res = v[i].size + 1;
	v[i+abs].size--;
	if(!v[i+abs].size){
		if(i+abs*2 >= 0 && v[i].color == v[i+abs*2].color){
			res += v[i+abs*2].size;
			*(abs<0?&uChain:&lChain) = i+abs*3;
		}else{
			*(abs<0?&uChain:&lChain) = i+abs*2;
		}
	}

	res += water(uChain, lChain);

	v[i+abs].size++;

	return res;
}

int main(){
	int n;
	while(std::cin >> n, n){
		v.clear();

		int prev_color = 0, size = 0;
		for(int i=0;i<n;i++){
			int color;
			std::cin >> color;
			if(prev_color != color && prev_color){
				v.push_back({prev_color, size});
				size = 0;
			}
			size++;
			prev_color = color;
		}
		v.push_back({prev_color, size});
						
		int minChara = n;

		for(int i=0;i<v.size();i++){
			if(v[i].size >= 3){
				minChara = std::min(minChara, n - (v[i].size + 1));
			}
		}

		if(v.size() >= 3){
			for(int i=1;i<v.size()-1;i++){
				int destroyChara = 0,
					upperChara = i-1, lowerChara = i+1;
				//v[i]が両辺一個を変える
	
				if(v[i].size >= 3){

					minChara = std::min(minChara,
															n - std::max(fish(i, -1),
																					 fish(i, 1)));
				}
			}
			
		}
		std::cout << minChara << std::endl;
	}
}

Measured memory_bytes: 1328
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
 
 
 
 
 
 
 







int dp[200][200];
int x[100][100],y[100][100];
int main()
{
     int n;
     cin>>n;
     int a[n];
     
     for(int i=0;i<n;i++){
          cin>>a[i];
          for(int j=0;j<a[i];j++){
               cin>>x[i][j]>>y[i][j];
          }
     }
     int ans=0;
     for(int bits=1;bits<(1<<n);bits++){
          bool ok=true;
          for(int i=0;i<n;i++){
               if(!(bits&(1<<i)))continue;
               for(int j=0;j<a[i];j++){
                    if(((bits>>(x[i][j]-1))&1)^y[i][j])ok=false;
               }
          }
          if(ok){
               ans=max(ans,setbits(bits));
          }
     }
     cout<<ans;
}


























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

typedef pair<int, int> pii;
typedef long long ll;

int N, Q;
struct Edge {
    int u, v, w;
    bool operator <(const Edge &i) const {
        return w < i.w;
    }
};
vector<Edge> edge;
vector<ll> upd;
vector<ll> cost;

struct DSU {
    vector<int> par, rnk;
    void init() {
        par.clear();
        rnk.clear();
        for(int i = 0; i < N; i++) {
            par.push_back(i);
            rnk.push_back(0);
        }
    }
    int f(int u) {
        if(u == par[u]) return u;
        else return par[u] = f(par[u]);
    }
    void mrg(int u, int v) {
        u = f(u);
        v = f(v);
        if(u == v) return;
        if(rnk[u] < rnk[v]) swap(u, v);
        par[v] = u;
        if(rnk[u] == rnk[v]) rnk[u]++;
    }
} dsu;

int main() {
    scanf("%d %d", &N, &Q);
    upd = vector<ll>(N, 1e18);
    for(int i = 0; i < Q; i++) {
        int a, b, c; scanf("%d %d %d", &a, &b, &c);

        edge.push_back({a, b, c});
        upd[a] = min(upd[a], (ll)c + 1);
        upd[b] = min(upd[b], (ll)c + 2);
    }
    cost = vector<ll>(N, 1e18);
    for(int i = 0; i < N; i++) {
        cost[i] = min(cost[i], upd[i]);
        cost[i] = min(cost[i], cost[ (i + N - 1) % N ] + 2);
    }
    for(int i = 0; i < N; i++) {
        cost[i] = min(cost[i], cost[ (i + N - 1) % N ] + 2);
        edge.push_back({i, (i + 1) % N, cost[i]});
    }
    sort(edge.begin(), edge.end());
    ll ans = 0;
    dsu.init();
    for(int i = 0; i < edge.size(); i++) {
        int u = edge[i].u;
        int v = edge[i].v;
        int w = edge[i].w;
        if(dsu.f(u) == dsu.f(v)) continue;
        ans += w;
        dsu.mrg(u, v);
    }
    cout << ans;
}


Measured memory_bytes: 12268
from collections import defaultdict

n = int(input())
d = defaultdict(int)

for i in range(n):
    s = input()
    d[s] += 1

print('{} x {}'.format('AC',d['AC']))
print('{} x {}'.format('WA',d['WA']))
print('{} x {}'.format('TLE',d['TLE']))
print('{} x {}'.format('RE',d['RE']))


Measured memory_bytes: 70020
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n,m;
map<ll,ll> mp;

int main(){
	cin >> n;
	rep(i,n){
		ll num;
		cin >> num;
		mp[num]++;
	}
	cin >> m;
	bool f = 1;
	rep(i,m){
		ll num;
		cin >> num;
		if(mp[num] == 0)f = 0;
		mp[num]--;
	}
	if(f)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 12800
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(string, S);
    YES(S <= "2019/04/30", "Heisei", "TBD");
}

Measured memory_bytes: 256
import scala.io.StdIn.{readInt,readLine}

object Main {
  def scan(s:Array[Int],cnt:Int):(Array[Int],Int) = {
    val m = s.groupBy(_.self).map(i=>i._1->i._2.length)
    val mapped = s.map{ m(_) }
    if(mapped.sameElements(s)) (mapped,cnt)
    else
      scan(mapped,cnt+1)
  }
  def main(args:Array[String]) = {
    var n = 0
    while({n=readInt;n}!=0) {
      val s = readLine.split(" ").map(_.toInt)
      val r = scan(s,0)
      println(r._2)
      println(r._1.mkString(" "))
    }
  }
}

Measured memory_bytes: 46900
/*
    author  : real_rpg  
    country : India
    time    : 00:51:12 IST
*/
 
#include "bits/stdc++.h" 
#define ll long long
#define ld long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define fld(i,a,b,c) for(ld i=a; i<b; i+=c)
#define fl(i,a,b,c) for(ll i=a; i<b; i+=c)
#define rfl(i,a,b,c) for(ll i=a; i>=b; i-=c) 
#define endt (double)(clock() - tStart)/CLOCKS_PER_SEC
#define rep(i,n) fl(i,0,n,1)
#define rep1(i,n) fl(i,1,n+1,1)
#define rrep(i,n) rfl(i,n-1,0,1)
#define sas int tt; cin >> tt; rep(tc,tt) 
#define pb  push_back
#define ep emplace_back
#define F first
#define S second
using namespace std; 
const int md = 1e9 + 7;
const int MAX = 1e5 + 5;
const int MAXN = 1e6 + 5;

void solve() {  
	ll n,kk; cin>>n>>kk;
	
	if(kk&1) {
		ll kkk=n/kk;
		cout<<kkk*kkk*kkk;
	} else {
		ll kkk=kk/2;
		ll tot=n/kkk;
		if(tot&1) {
			ll a1=tot/2;ll a2=a1+1;
			cout<<(a1*a1*a1)+(a2*a2*a2);
		} else {
			ll a1=tot/2;ll a2=a1;
			cout<<(a1*a1*a1)+(a2*a2*a2);
		}
	}

}

int main() {             
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); cout.tie(NULL); 
    //clock_t tStart = clock(); 
    solve(); 
    //printf("\n%.6f\n", endt);
    return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <float.h>

int main(void)
{
  int i=0;
  long double v,floar;

  while(scanf("%Lf", &v) != EOF && i<50){
    floar = (v*v/98)+1;  
    if(floar - (int)floar > LDBL_EPSILON){
      floar++;
    }
    printf("%d\n", (int)floar);
    i++;  
  }
  return 0;
}

Measured memory_bytes: 2760
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  int n;
  cin >> n;
  vector<string>w(n);
  set<string>check;
  string temp;
  rep0(i,n){
    cin >> temp;
    check.insert(temp);
    w[i] = temp;
  }
  char now = w[0][0];
  bool ans = true;
  rep0(i,n){
    if(now != w[i][0])ans = false;
    now = w[i][w[i].size() - 1];
  }
  if(ans && check.size() == n)cout << "Yes" << endl;
  else puts("No");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define y0 yy
#define y1 Yy
#define yn YY
#include <assert.h>
#include <algorithm>
#include <vector>
using namespace std;

int n, k;
bool f[15];

bool check(int x) {
	while (x != 0) {
		if (f[x % 10]) return false;
		x /= 10;
	}
	return true;
}

int main() {
	scanf("%d %d", &n, &k);
	for (int i = 0; i < k; i++) {
		int d;
		scanf("%d", &d);
		f[d] = true;
	}
	while (!check(n)) n++;
	printf("%d\n", n);
#ifdef LOCAL_MSVC_DEBUG
	system("pause");
#endif
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
  int a=0,b=0,n,p[8],q[8],da=4,db=4;
  bool bb=true,cc=true;
  cin>>n;
  vector<int> m(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
    m[i]=i;
  }
   for(int i=0;i<n;i++){
    cin>>q[i];
  }
  
  do{
    bb=true; cc=true;
    for(int i=0;i<n;i++){
      if(p[i]!=m[i]+1)bb=false;
      if(q[i]!=m[i]+1)cc=false;
    }
    if(da!=5)a++;
    if(db!=5)b++;
    if(bb==true)da=5;
    if(cc==true)db=5;
  }while(next_permutation(m.begin(),m.end()));
    cout<<fabs(a-b)<<endl;
  return 0;
}

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

using namespace std;

int hextod(char a,char b){
    int ret=0;
    if(isdigit(b))ret+=b-'0';
    else ret+=10+b-'a';
    if(isdigit(a))ret+=16*(a-'0');
    else ret+=16*(10+a-'a');
    return ret;
}

int main(){
    while(true){
        char un;
        cin>>un;
        if(un=='0')break;
        char r1,r2,g1,g2,b1,b2;
        cin>>r1>>r2>>g1>>g2>>b1>>b2;
        int r,g,b;
        r=hextod(r1,r2);
        g=hextod(g1,g2);
        b=hextod(b1,b2);

        vector<vector<int>> iro(8,vector<int>(3));
        for (int i = 0; i < 8; ++i) {
            if(i%2==0)iro[i][0]=0;
            else iro[i][0]=255;
            if(i%4==0||i%4==1)iro[i][1]=0;
            else iro[i][1]=255;
            if(i<4)iro[i][2]=0;
            else iro[i][2]=255;
        }
        vector<string> ironame={"black","blue","lime","aqua","red","fuchsia","yellow","white"};
        int ans=-1;
        long long mdist=numeric_limits<int>::max();
        for (int i = 0; i < 8; ++i) {
            long long td=0;
            td+=(r-iro[i][2])*(r-iro[i][2]);
            td+=(g-iro[i][1])*(g-iro[i][1]);
            td+=(b-iro[i][0])*(b-iro[i][0]);
            if(td<mdist){
                ans=i;
                mdist=td;
            }
        }
        cout<<ironame[ans]<<endl;
    }

    return 0;
}


Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
 
const int MAX = 1000000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
  int n,a,b;
  cin >> n>>a>>b;
  long c=modpow(2,n,MOD);
  long ca=1;
  rep(i,a){
    ca=ca*(n-i)%MOD*modpow(a-i,MOD-2,MOD)%MOD;
  }
  long cb=1;
  rep(i,b){
    cb=cb*(n-i)%MOD*modpow(b-i,MOD-2,MOD)%MOD;
  }
  c=(c-ca-cb+2*MOD-1)%MOD;
  
    cout<<c<<endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{

  int a,b,c;
  cin >> a;
  cin >> b;
  
  if(a==1){
   if(b==2){
     c=3;
   }else{
   	 c=2;
   }
  }else if(a==2){
   if(b==1){
     c=3;
   }else{
   	 c=1;
   }   
  }else if(a==3){
   if(b==1){
     c=2;
   }else{
   	 c=1;
   }   
  }
  
  cout << c;
  
  return 0;
}

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

using namespace std;

int main()
{
	int n, m, i, x, max=0;

	cin >> n;

	int sum[n];
	for(i=0; i<n; i++) sum[i] = 0;

	string s[n];
	for(i=0; i<n; i++)
	{
		cin >> s[i];

		for(x=0; x<=i; x++)
		{
			if(i==x) sum[i]++;
			else if(s[x] == s[i])
			{
				sum[x]++;
				i--;
				n--;
				break;
			}
		}
	}

	cin >> m;

	string t[m];

	for(i=0; i<m; i++)
	{
		cin >> t[i];

		for(x=0; x<=n; x++)
		{
			if(s[x] == t[i])
			{
				sum[x]--;
				break;
			}
		}
	}

	for(i=0; i<n; i++)
		if(max < sum[i]) max = sum[i];

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
/*
मनस्वी म्रियते कामं कार्पण्यं न तु गच्छति ।
अपि निर्वाणमायाति नानलो याति शीतताम् ॥
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define p2d(v) for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v) for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v) for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
#define test3(x,y,z) cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define test4(w,x,y,z) cout << #w " = " << w << " " << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
    ll n;
    cin>>n;

    vl v(n);

    forn(i,0,n)
    {
        cin>>v[i];
    }    

    sort(v.rbegin(),v.rend());
    
    ll total = v[0];

    ll j = 1;
    ll count = 0;

    for(ll i = 2; i < n; i++)
    {
        if(count == 2)
        {
            count = 0;
            j++;
        } 
        total += v[j];
        count++;
    }

    cout<<total;






    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n, k;cin >> n >> k;
    string s;cin >> s;
    s[k-1] = s[k-1]-'A'+'a';
    cout << s << endl;
    return 0;
}


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

#define rep(i, n) for(int i=0; i<n; i++)

int n;
int A, B, C;
int D[111];
int res;
int sum;
int price;

int main(int argc, char *argv[])
{
  cin >> n;
  cin >> A >> B;
  cin >> C;
  rep(i, n) cin >> D[i];

  sort(D, D + n, greater<int>());

  sum = C;
  price = A;
  rep(i, n){
    sum += D[i];
    price += B;
    res = max(res, sum / price);
  }

  cout << res << endl;
  
  return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    char a,b; cin >> a >> b;
    if(a==b) cout << "H" << endl;
    else cout << "D" << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>

using namespace std;

int main()
{
    // 整数の入力
    long long  N,K,i,a_i,result,temp;
    cin >> N;
    long long* number1 = new long long[N+1];
    long long* number2 = new long long[N+1];
    number1[0] = 0;
    number2[0] = 0;
    for (i = 1;i<= N;i++){
        cin >> temp;
        number1[i] = number1[i-1] + temp;
    }

    for (i = 1;i<= N;i++){
        cin >> temp;
        number2[i] = max(number1[i] + temp,number2[i-1] + temp);
    }

    cout << number2[N] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
	char str[21], new_str[21];
	scanf("%s", &str);
	
	int i;
	for(i=0; i<21; i++){
		new_str[i]='\0';
	}
	
	for(i=0; i<20; i++){
		if(str[i]=='\0' || str[i]=='\n'){break;}
		new_str[20-i]=str[i];
	}
	
	for(i=0; i<21; i++){
		if(new_str[i]!='\0'){printf("%c", new_str[i]);}
	}
	
	printf("\n");
	return 0;
}

Measured memory_bytes: 0
lis1 = []
lis2 = []
lis3 = []
count = 0
flag = 0
for num in input().split():
    lis1.append(int(num))
for num in input().split():
    lis2.append(int(num))
for num in input().split():
    lis3.append(int(num))
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            if lis1[0] - a1 == lis2[0] - a2 == lis3[0] - a3:
        	    if lis1[1] - a1 == lis2[1] - a2 == lis3[1] - a3:
		            if lis1[2] - a1 == lis2[2] - a2 == lis3[2] - a3:
             	 		print("Yes")
             	 		flag = 1
             	 		break
        if flag == 1:
            break
    if flag == 1:
        break
    if a1 == 100 and flag == 0:
      	print("No")

Measured memory_bytes: 3064
function Main(input){
  var N = input.split('\n')[0].split(' ')[0];
  var K = input.split('\n')[0].split(' ')[1];

  N = parseInt(N,10);
  K = parseInt(K,10);

  var count = 0;

  var h = input.split('\n')[1].split(' ');
  for(i=0;i<N;i++){
    var a = parseInt(h[i],10);
    if(K <= h[i]){
      count++;
    }
  }

  console.log(count);
}

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

Measured memory_bytes: 16716
import sys
input = sys.stdin.readline
n=int(input())
a = [int(input()) for i in range(n)]
a.append(0)
ans = 0
tmp = 0
for i in range(n+1):
  if a[i]!=0:
    tmp += a[i]
  else:
    ans += tmp//2
    tmp = 0
print(ans)

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

  int a;
  string s;
  cin >> a >> s;
  
  if(a>=3200){
    cout << s <<endl;
  }else{
    cout << "red"<< endl;
  }
}
 

Measured memory_bytes: 256
temp = input().split()
n, k = int(temp[0]), int(temp[1])
temp = input().split()
r, s, p = int(temp[0]), int(temp[1]), int(temp[2])

t = input()
ans = ""
for i in range(k):
    l = [t[j] for j in range(i, len(t), k)]
    # print(l)
    txt = ''.join(l)
    txt = txt.replace("rr", "r*")
    txt = txt.replace("ss", "s*")
    txt = txt.replace("pp", "p*")
    ans += txt
    # print(ans)

print(p*ans.count('r') + r*ans.count('s') + s*ans.count('p'))


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1); // cos(pi) = -1
const double eps = 1e-9;
struct point{
    double x, y;
    point(double _x = 0,double _y=0){
        x=_x;
        y=_y;
    }
};
double dist(point a,point b){
    return sqrt((a.x-b.x) * (a.x-b.x)
              + (a.y-b.y) * (a.y-b.y));
}
point a[305];
const double r = 1;
int solve(int n){
    for(int i=1;i<=n;i++)   cin >> a[i].x >> a[i].y;

    int answer = 1;

    for(int i=1;i<=n;i++){
        vector < pair<double, double> > lst;

        for(int j=1;j<=n;j++){
            if (dist(a[i], a[j]) > r * 2)   continue;
            if (i == j) continue;

            double alpha = atan2(a[j].y - a[i].y,
                                 a[j].x - a[i].x);

            if (alpha < 0)  alpha += pi * 2;

            double beta = acos(dist(a[i], a[j]) / 2 / r);

            double goc1 = alpha + beta;
            double goc2 = alpha - beta;
            if (goc1 > goc2)    swap(goc1, goc2);

            if (goc1 < 0)
                lst.push_back({0, goc2}),
                lst.push_back({goc1 + pi*2, pi*2});
            else if (goc2 > pi * 2)
                lst.push_back({0, goc2 - pi*2}),
                lst.push_back({goc1, pi*2});
            else
                lst.push_back({goc1, goc2});
        }
        vector <pair<double,int> > query;

        for(auto v: lst)
            query.push_back({v.first, 1}),
            query.push_back({v.second + eps, -1}),

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

        int current = 1;
        for(auto v: query){
            current += v.second;
            answer = max(answer, current);
        }
    }
    return answer;
}

int main(){
    int n;
    while (cin >> n){
        if (!n) break;
        cout << solve(n) << endl;
    }
}



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

int main() {
    int n;
    cin >> n;
    map<string, ll> S;

    ll ans = 0;
    rep(i, n) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        S[s]++;
    }

    for (auto s: S) {
        if (s.second == 1) continue;
        ans += s.second * (s.second-1) / 2;
    }

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


Measured memory_bytes: 11136
import math
def yakusu(n):
    count = 0
    for i in range(1,int(math.sqrt(n))+1+1):
        if n % i == 0:
            count += 2
    return count
N = int(input())
c = 0
for i in range(1,N+1,2):
    if yakusu(i) == 8:
        c+=1

print(c)


Measured memory_bytes: 9140
#include <stdio.h>
int main (){

// DECLARAÇÃO
int A,B,X; 

// INSTRUÇÕES
scanf ("%d %d %d",&A,&B,&X);

if (A > X)
    printf ("NO\n");
else if (A+B < X)
    printf ("NO\n");
else
    printf ("YES\n");

return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define out(a) cout << a << endl
using namespace std;
typedef long long ll;

int main() {
    ll N;
    cin >> N;
    vector<ll> buka(N, 0);
    rep(i, N-1){
        ll a;
        cin >> a;
        buka.at(a-1)++;
    }
    for(ll i : buka) out(i);
}




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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll inf = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/



int main(){
    fIO

    string s;
    cin >> s;

    if(s[0] == 'S') cout << "Cloudy";
    else if(s[0] == 'C') cout << "Rainy";
    else cout << "Sunny";

}







Measured memory_bytes: 256