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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

ll H, W, K;
vector<ll> status(150, -1);
ll statusCount = 0;

void updateStatus() {
  bool check;
  for (int i = 0; i < pow(2, W - 1); i++) {
    check = true;
    for (int j = 0; j < W - 2; j++) {
      if ((i >> j & 1) && (i >> (j + 1) & 1)) {
        check = false;
      }
    }
    if (check) {
      status[statusCount] = i;
      statusCount++;
    }
  }
  return;
}

int main() {
  cin >> H >> W >>K;

  updateStatus();

  ll MOD = 1e9 + 7;
  vector<ll> cnt1(W, 0);
  cnt1[0] = 1;

  for (int i = 0; i < H; i++) {
    vector<ll> cnt2(W, 0);

    for (int j = 0; j < statusCount; j++) {
      int s = status[j];
      if (s & 1) {
        cnt2[0] = (cnt2[0] + cnt1[1]) % MOD;
      } else {
        cnt2[0] = (cnt2[0] + cnt1[0]) % MOD;
      }
      for (int k = 1; k < W - 1; k++) {
        if (s >> (k - 1) & 1) {
          cnt2[k] = (cnt2[k] + cnt1[k - 1]) % MOD;
        } else if (s >> k & 1) {
          cnt2[k] = (cnt2[k] + cnt1[k + 1]) % MOD;
        } else {
          cnt2[k] = (cnt2[k] + cnt1[k]) % MOD;
        }
      }
      if (W - 1 > 0) {
        if (s >> (W - 2) & 1) {
          cnt2[W - 1] = (cnt2[W - 1] + cnt1[W - 2]) % MOD;
        } else {
          cnt2[W - 1] = (cnt2[W - 1] + cnt1[W - 1]) % MOD;
        }
      }
    }
    cnt1 = cnt2;
    // SHOW(cnt1);
  }
  cout << cnt1[K - 1] << "\n";
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define MOD 1000000007
#define mod 1000003
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(a,b) for (int i = a ; i < b ; i++)
#define PI 3.1415926536

using namespace std ;

int main(){

    ios_base::sync_with_stdio(0);
    ll d , n ;
    cin >> d >> n ;
    ll sum = 1 ;
    ll x = d ;
    if ( d == 0 && n == 100 ){
        return cout << 101,0;
    }

    while ( x > 0){
        sum*=100 ;
        sum = sum%MOD ;
    //    cout << sum << endl ;
        x-- ;
    }
    //cout << sum ;
    sum*=n;
    if ( d ==1 && n==100){
        sum+=100 ;
    }
    else
    if ( d == 2 && n ==100){
        sum+=10000;
    }
    sum%MOD;
    cout << sum ;
    return 0 ;

}


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

int main(void){
    int n, k;
    long long ans;
    cin >> n >> k;
    ans = k;
    for (int i=0; i<n-1; i++){
        ans *= (k - 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
//#include<algorithm>
//#include<numeric>
#include<queue>
#include<cstdio>
using namespace std;
int main(){
  int n;
  cin >> n;
  int tmp;
  std::priority_queue<int, std::vector<int>, std::greater<int>> q;
  for (size_t i(0); i < n; ++i) {
    cin >> tmp;
    q.push(tmp);
  }
  
  double result;
  result = (double)q.top();
  q.pop();
  while (!q.empty()) {
    result += (double)q.top();
    result *= 0.5;
    q.pop();
  }

  
  cout << result;
  //printf("%lf\n", result);
  return 0;
}

Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <math.h>

int main(void) {
	char S[4];
	uint8_t count[3] = {0, 0, 0};

	scanf("%s", S);

	for (size_t idx = 0; idx < 3; idx++) {
		count[S[idx] - 'a']++;
	}

	printf("%s", count[0] * count[1] * count[2] != 0 ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 128
N,M=map(int,input().split())
D=[-1]*N
for i in range(M):
  s,c=map(int,input().split())
  s-=1
  if s==0 and c==0 and N>1: # 2桁以上の数で先頭が0
    print(-1)
    exit(0)
  if D[s]!=-1: # 初登場ではない
    if D[s]!=c: # 前回と異なる値
      print(-1)
      exit(0)
  D[s]=c
  
ans=""
if D[0]==-1: # 先頭が未定義
  if N==1:
    print(0)
  else:
    ans+="1"
elif D[0]==0:
  if N==1:
    print(0)
    exit(0)
  else:
    ans+="1"
else:
  ans+=str(D[0])
  
for i in range(1,N):
  if D[i]==-1:
    ans+="0"
  else:
    ans+=str(D[i])
    
print(ans)

    
    


Measured memory_bytes: 3064
n = int(input())
a = list(map(int,input().split()))
b = [0] * n
ans = 0
for i in range(n)[::-1]:
    t = 0
    j = (i+1)*2
    while j <= n:
        t += b[j-1]
        j += (i+1)
    if a[i] == 0:
        if t % 2 == 0:
            b[i] = 0
        else:
            b[i] = 1
            ans += 1
    else:
        if t % 2 == 0:
            b[i] = 1
            ans += 1
        else:
            b[i] = 0
print(ans)
l = []
for i in range(n):
    if b[i] == 1:
        l.append(str(i+1))
print(' '.join(l))

Measured memory_bytes: 22360
#include <stdio.h>
#define norm(X) ((X) * (X))

_Bool issq(int n);
int   dist(int i, int j);

int n, d;
int p[15][15];

int main()
{
    int ans = 0;

    scanf("%d %d", &n, &d);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            scanf("%d", &p[i][j]);
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (issq(dist(i, j))) {
                ans++;
            }
        }
    }

    printf("%d\n", ans);

    return 0;
}

_Bool issq(int n)
{
    int i = 0;
    while (i * i < n) i++;

    if (i * i == n) return 1;
    else return 0;
}

int dist(int i, int j)
{
    int dis = 0;
    
    for (int k = 0; k < d; k++) {
        dis += norm(p[i][k] - p[j][k]);
    }

    return dis;
}


Measured memory_bytes: 128
#include <stdio.h>

int n,count,is_odd;

int main() {
  scanf("%d", &n);
  int array[n];
  for (size_t i = 0; i < n; i++) {
    scanf("%d", &array[i]);
  }
  count = -1;
  do {
    count++;
    is_odd = 0;
    for (size_t i = 0; i < n; i++) {
      if(array[i] % 2 == 1){
        is_odd = 1;
        break;
      }
    }
    if (is_odd == 0) {
      for (size_t i = 0; i < n; i++) {
        array[i] = array[i] / 2;
      }
    }
  } while(is_odd == 0);
  printf("%d", count);
  return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp2
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int count = 0;
            for (int l = 1; l < 9; l++)
            {
                for (int r = l + 1; r <= 9; r++)
                {
                    if (l != r)
                    {
                        int[] ab = GetIntsCounts(N, l, r);
                        count += ab[0]*ab[1];
                    }
                }
            }

            count *= 2;

            for (int i = 1; i <= 9; i++)
            {
                int ab = GetIntsCount(N, i);
                count += (int)Math.Pow(ab, 2);
            }

            Console.WriteLine(count);
            Console.ReadLine();
        }

        static int[] GetIntsCounts(int limit,int L,int R)
        {
            int[] ans = {0,0 };
            for (int i = 1; i <= limit; i++)
            {
                int r = i % 10;
                int digit = (int)Math.Log10(i) + 1;
                int l = i / (int)(Math.Pow(10, digit - 1));
                if (r == R && l == L) ans[0]++;
                if (r == L && l == R) ans[1]++;

            }
            return ans;
        }

        static int GetIntsCount(int limit, int n)
        {
            int ans =0;
            for (int i = 1; i <= limit; i++)
            {
                int r = i % 10;
                int digit = (int)Math.Log10(i) + 1;
                int l = i / (int)(Math.Pow(10, digit - 1));
                if (r == n && l == n) ans++;

            }
            return ans;
        }
    }
}


Measured memory_bytes: 11220
function Main(input) {

	input = input.split("\n");
	var k = Math.pow(2,Number(input[1]));
	
	input = input[0].split(" ");
	
	input.sort(function(a,b){
		if(Number(a)<Number(b))return -1;
		if(Number(a)>Number(b))return 1;
		return 0;
	});
	
	var a = Number(input[0]);
	var b = Number(input[1]);
	var c = Number(input[2]);
	
	var ret = a + b + c * k;
	console.log(ret);
}

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


Measured memory_bytes: 7372
import sys

input = sys.stdin.readline

S = input()
S = S.replace('\n','')
s_list = list(S)

T = input()
T = T.replace('\n','')
t_list = list(T)

alpha_dict = {}
t_diff_count = [0 for i in range(27)]
s_diff_count = [0 for i in range(27)]

for i,c in enumerate(range(ord('a'),ord('z')+1)):
    alpha_dict[chr(c)] = i 

for i,s in enumerate(s_list):
    #if not s == t_list[i]:
    number = alpha_dict[s_list[i]]
    s_diff_count[number] += 1
    number = alpha_dict[t_list[i]]
    t_diff_count[number] += 1

for i,s in enumerate(s_list):
    number = alpha_dict[s_list[i]]
    s_count = s_diff_count[number] 
    number = alpha_dict[t_list[i]]
    t_count = t_diff_count[number]
    if not s_count == t_count:
        if t_count >= 2:
            print("No")
            exit(0)
        if s_count >= 2:
            print("No")
            exit(0)
print("Yes")    


Measured memory_bytes: 12768
s=list(map(int,input().split()))
c=0
def gcd(x,y):
  if y==0: 
    return x
  else:
    return gcd(y,x%y)
a=max(s)
b=min(s)
pri=[]
pri.append(1)
def primary(n):
    b = 2
    while b * b <= n:
        while n % b == 0:
            n //= b
            pri.append(b)
        b = b + 1
    if n > 1:
        pri.append(n)
    return
primary(gcd(a,b))
pp=0
for j in range(len(pri)-1):
  if pri[j]==pri[j+1]:
    pp+=1
print(len(pri)-pp)

Measured memory_bytes: 3064
N = int(input())
a = list(map(int,input().split()))
ans = 0
c = 0
for x in range(N-1):
  if a[x+1] <= a[x]:
    ans += 1
  elif c < ans:
    c = ans
    ans = 0
  else:
    ans = 0
if c < ans:
  c = ans
print(c)


Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll MOD = 1e9 + 7;
const long long INF = 1LL << 60;

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

    ll answer = 0;
    // for (int i = 0; i < n; i++)
    // {
    //     for (int j = i + 1; j < n; j++)
    //     {
    //         for (int k = j + 1; k < n; k++)
    //         {
    //             if (s.at(i) != s.at(j) && s.at(i) != s.at(k) && s.at(j) != s.at(k) && j - i != k - j)
    //                 answer++;
    //         }
    //     }
    // }

    for (int j = 1; j < n - 1; j++)
    {
        char middle_s = s.at(j);

        map<char, int> front_color, back_color;
        front_color['R'] = 0;
        front_color['G'] = 0;
        front_color['B'] = 0;
        back_color['R'] = 0;
        back_color['G'] = 0;
        back_color['B'] = 0;
        for (int i = 0; i < j; i++)
            front_color[s.at(i)]++;
        for (int k = j + 1; k < n; k++)
            back_color[s.at(k)]++;

        if (middle_s == 'R')
        {
            answer += front_color['G'] * back_color['B'];
            answer += front_color['B'] * back_color['G'];
        }
        else if (middle_s == 'G')
        {
            answer += front_color['R'] * back_color['B'];
            answer += front_color['B'] * back_color['R'];
        }
        else if (middle_s == 'B')
        {
            answer += front_color['R'] * back_color['G'];
            answer += front_color['G'] * back_color['R'];
        }

        for (int l = 1; l < max(j, n - j); l++)
        {
            if(j-l<0 || j+l>n-1)
                break;
            if (s.at(j - l) != s.at(j + l) && s.at(j - l) != s.at(j) && s.at(j + l) != s.at(j))
                answer--;
        }

        // cout << j << " " << middle_s << " " << answer << endl;
    }

    cout << answer << endl;
}


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

bool search(int i, int x, const vector<int> &a) {
  if (i == 0) {
    if (x == 0) return true;
    else return false;
  }
  if (search(i-1, x, a)) return true;
  if (search(i-1, x-a[i-1], a)) return true;

  return false;
}

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int X; cin >> X;
  for (int i = 0; i < X; ++i) {
    int v; cin >> v;
    if (search(n, v, a)) cout << "yes" << endl;
    else cout << "no" << endl;
  }

}



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

string solve(vector<int>& xs, int k){
    //Testa todos os pares distintos de antenas
    for(int i=0;i<5;i++)
        for(int j=i+1;j<5;j++)
            if(xs[j] - xs[i] > k)
                return ":(";
    
    return "Yay!";
}

int main(){
    vector<int> xs(5);

    for(int i=0;i<5;i++)
        cin>>xs[i];
    
    int k;
    cin>>k;

    auto ans = solve(xs,k);

    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cctype>
using namespace std;
 
typedef long long LL;
 
#define MOD 1000000007LL
 
LL expr();
LL term();
 
const char *P;
 
LL expr(){
    LL x = term();
    while(*P == '>' && P[1] == '>' && (P[2] == 'S' || isdigit(P[2]))){
        P += 2;
        LL y = term();
        x >>= min(y, 63LL);
    }
    return x;
}
 
LL term(){
    LL x = 0;
    if(*P == 'S'){
        P += 2;
        x = expr();
        x = x * x % MOD;
        ++P;
    }
    else{
        char *endp;
        x = strtoll(P, &endp, 10);
        P = endp;
    }
    return x;
}
 
int main(){
    string s;
    while(getline(cin, s), s[0] != '#'){
        s.erase(remove(s.begin(), s.end(), ' '), s.end());
        P = s.c_str();
        cout << expr() << endl;
    }
}

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

int main(void) {
	int cities, size, a, b;
	cin >> cities >> size;
	vector<int> roads(cities);
	for (int i = 0; i < size; i++) {
		cin >> a >> b;
		roads.at(a - 1)++; roads.at(b - 1)++;
	}
	for (int i = 0; i < cities; i++)  cout << roads.at(i) << endl;

}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    string s; cin >> s;
    int cnt = 0, ans = 0;
    for(int i = 0; i < s.size(); ++i) {
        if(!(s[i] == 'A' || s[i]=='T'||s[i]=='C'||s[i]=='G')) {
            chmax(ans, cnt);
            cnt = 0;
            continue;
        }
        cnt++;
    }
    chmax(ans,cnt);
    cout << ans << '\n';

    // printf("ExcutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N, X, T;
    cin >> N >> X >> T;
    ll ans = 0;
    ll tako = 0;
    while (tako < N)
    {
        tako += X;
        ans += T;
    }
    putout(ans);
    return 0;
}


Measured memory_bytes: 3628
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class AProduct {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            if ((a * b) % 2 == 0) {
                out.print("Even");
            } else {
                out.print("Odd");
            }
        }

    }
}


Measured memory_bytes: 21844
import java.io.*;
import java.util.*;

public class Main {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        int[] time = new int[101];
        int a = in.nextInt();
        int b = in.nextInt();
        for (int i = a; i < b; i++) {
            time[i]++;
        }
        int c = in.nextInt();
        int d = in.nextInt();
        for (int i = c; i < d; i++) {
            time[i]++;
        }
        int cnt = 0;
        for (int i = 0; i < 101; i++) {
            if(time[i] == 2) cnt++;
        }
        System.out.println(cnt);
    }
}

@SuppressWarnings("serial")
class MultiSet<T> extends HashMap<T, Long>{
    @Override public Long get(Object key){return containsKey(key)?super.get(key):0L;}
    public void add(T key,long v){put(key,get(key)+v);}
    public void add(T key){put(key,get(key)+1);}
    public void sub(T key){final long v=get(key);if(v==1)remove(key);else put(key,v-1);}
    public MultiSet<T> merge(MultiSet<T> set)
    {MultiSet<T>s,l;if(this.size()<set.size()){s=this;l=set;}else{s=set;l=this;}
        for(Entry<T,Long>e:s.entrySet())l.add(e.getKey(),e.getValue());return l;}
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    k = k-1;
    string s;
    cin >> s;
    if(s.at(k)=='A'){
        s.at(k) = 'a';
    }else if(s.at(k)=='B'){ 
        s.at(k) = 'b';
    }else{
        s.at(k) = 'c';
    }
    cout << s << endl;
}


Measured memory_bytes: 256
import itertools

N = int(input())
S = [input() for i in range(N)]

ppl = [0 for i in range(5)]
for i in S:
    if i[0] == 'M':
        ppl[0] += 1
    elif i[0] == 'A':
        ppl[1] += 1
    elif i[0] == 'R':
        ppl[2] += 1
    elif i[0] == 'C':
        ppl[3] += 1
    elif i[0] == 'H':
        ppl[4] += 1

combi = [i for i in ppl if i != 0]

ans = 0
if len(combi) < 3:
    pass
else:
    combinations = list(itertools.combinations(combi, 3))
    for i in combinations:
        ans += i[0] * i[1] * i[2]

print(ans)


Measured memory_bytes: 9772
let input = readLine()!.split(separator: " ").map { Int($0)! }
let N = input[0]
let K = input[1]
var S = Array(readLine()!)

S[K - 1] = Character(UnicodeScalar(S[K - 1].unicodeScalars.first!.value + 32)!)

print(String(S))


Measured memory_bytes: 8260
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <ostream& out = cout, class... T> void prints(T&&...){ }
template <ostream& out = cout, class... T> void printd(T&&...){ }
template <ostream& out = cout, class... T> void printde(T&&...){ }
template <ostream& out = cout, class... T> void printb(T&&...){ }
template <ostream& out = cout, class... T> void printArr(T&&...){ }
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> v(1e5 + 10);
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        a++;
        v[a - 1]++;
        v[a]++;
        v[a + 1]++;
    }
    cout << *max_element(v.begin(), v.end()) << '\n';
    return 0;
}


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

using namespace std;



int main(void) {
  
  int N;
  
  cin >> N;
  
  int *H = new int[N];
  
  for(int ii = 0;ii < N; ii++) {
    cin >> H[ii];
  }
  
  int NotLookFlag = 0;
  int canLookFlag = 1;
  for(int jj = 1; jj < N;jj++) {
    NotLookFlag = 0;
    for(int kk = 0;kk < jj; kk++) {
      if(H[kk] > H[jj]) {
        NotLookFlag++;
      }
    }
    if(NotLookFlag == 0 ) {
      canLookFlag++;
    }
  }
  
  printf("%d", canLookFlag);
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 2000000
int main(void){
  int i,max=-1000000000;
  int min;
  int n,R[N];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&R[i]);
  }

  min = R[0];
  for(i=1;i<n;i++){
    if(R[i] - min > max) max = R[i] - min;
    if(R[i] < min) min = R[i];
  }

  printf("%d\n",max);
}


Measured memory_bytes: 2628
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = long long;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[51][52];
ll all[51];
ll p[51];

signed main(){
	IOS;
	string s;
	cin >> s;
	ll n = s.size();
	if((s[0] == s[n - 1]) ^ (n % 2 == 0))dump("Second");
	else dump("First");
}	

Measured memory_bytes: 512
#include <iostream>

using namespace std;

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

    if (N % 2 == 0) {
        out = 0.5;
    }
    else {
        out = (N / 2 + 1) / double(N);
    }

    cout << out << endl;

    return 0;
}

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

using namespace std;

int main() {
  long long n;
  cin >> n;
  auto ans = 0ll;
  for (auto d = 10ll; d <= n; d *= 5) ans += n / d;
  cout << (n & 1 ? 0 : ans) << endl;
  return 0;
}


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

// 黒板にnumsCount個の整数が書かれている
// 書かれた数全てが偶数であるとき、全てを2で割る操作をする
// 最大で何回操作を行えるか調べる
int main() {
    
    // 書かれた数の総数
    int numsCount;
    cin >> numsCount;
    
    int nums[numsCount];
    
    for (int i = 0; i < numsCount; i++) {
	    cin >> nums[i];
	   // cout << nums[i];
    }
    
    int devideCounter = 0;
    while(true) {
        for (int i = 0; i < numsCount; i++) {
            // 2で割った余りが1なら、その以上操作できないのでループを抜ける
	        if(nums[i] % 2 == 1) {
	            goto outOfLoops;
	        } else {
	            nums[i] /= 2;
	        }
        }
        // 全部割れたらdevideCounterを1増やす
        devideCounter++;
    }
    outOfLoops:
    
    cout << devideCounter << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PA;
#define INF (1<<30)
int main(){
  int n,m,k,a,b,l;
  vector<PA> vec[3001];
  scanf("%d %d %d",&n,&m,&k);
  for(int i=0;i<m;i++){
    scanf("%d %d %d",&a,&b,&l);
    vec[a].push_back(PA(l,b));
    vec[b].push_back(PA(l,a));
  }
  int s;
  int min_cost[3001];
  fill(min_cost,min_cost+3001,INF);
  priority_queue<PA,vector<PA>,greater<PA> > pq;
  for(int i=0;i<k;i++){
    scanf("%d",&s);
    min_cost[s] = 0;
    pq.push(PA(0,s));
    while(!pq.empty()){
      PA p = pq.top();
      pq.pop();
      for(int j=0;j<vec[p.second].size();j++){
	int next_cost = p.first + vec[p.second][j].first;
	int next_to = vec[p.second][j].second;
	if(min_cost[next_to] > next_cost){
	  min_cost[next_to] = next_cost;
	  pq.push(PA(next_cost,next_to));
	}
      } 
    }
  }
  int ans = 0;
  for(int i=1;i<=n;i++){
    ans = max(ans,min_cost[i]);
    for(int j=0;j<vec[i].size();j++){
      if(abs(min_cost[i]-min_cost[vec[i][j].second]) != vec[i][j].first){
	ans = max(ans,(min_cost[i]+min_cost[vec[i][j].second]+vec[i][j].first+1)/2);
      }
    }
  }
  printf("%d\n",ans);
  return (0);
}



Measured memory_bytes: 5996
n = int(input())
A = list(map(int, input().split()))
mod = 10**9+7

if n%2 == 1:
    m = (n+1)//2
    l =[0]*m
    for i in range(n):
        if (n-A[i]-1)%2 != 0:
            print(0)
            exit()
        else:
            id = (n-A[i]-1)//2
            l[id] += 1
    #print(l)
    ans = 1
    for i in range(m):
        #print(i, ans)
        if i != m -1:
            if l[i] != 2:
                print(0)
                exit()
            else:
                ans *= l[i]
                ans %= mod
        else:
            if l[i] != 1:
                print(0)
                exit()
            else:
                ans *= l[i]
                ans %= mod
    print(ans)

else:
    m = n//2
    l =[0]*m
    for i in range(n):
        if (n-A[i]-1)%2 != 0:
            print(0)
            exit()
        else:
            id = (n-A[i]-1)//2
            l[id] += 1
    #print(l)
    ans = 1
    for i in range(m):
        #print(i, ans)
        if l[i] != 2:
            print(0)
            exit()
        else:
            ans *= l[i]
            ans %= mod
    print(ans)


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

// 配列move i, j
const int mi[] = {-1, 0, 1, 0};
const int mj[] = {0, -1, 0, 1};

int main() {
    int h, w;
    cin >> h >> w;
    int si, sj;
    cin >> si >> sj;
    int ti, tj;
    cin >> ti >> tj;
    --si; --sj; --ti; --tj;
    vector<string> s(h);
    for (int i=0; i<h; i++) cin >> s[i];
    const int INF = 1e9;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    deque<pair<int, int>> q;
    dist[si][sj] = 0;
    q.emplace_back(si, sj);
    while (!q.empty()) {
        int i = q.front().first;
        int j = q.front().second;
        int d = dist[i][j];
        q.pop_front();
        for (int v=0; v<4; v++) {
            int ni = i+mi[v]; int nj = j+mj[v];
            if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if (s[ni][nj] == '#') continue;
            if (dist[ni][nj] <= d) continue;
            dist[ni][nj] = d;
            q.emplace_front(ni, nj);
        }
        // puella i, j
        for (int pi=-2; pi <= 2; pi++) {
            for (int pj=-2; pj<=2; pj++) {
                int ni = i+pi; int nj = j+pj;
                if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
                if (s[ni][nj] == '#') continue;
                if (dist[ni][nj] <= d+1) continue;
                dist[ni][nj] = d+1;
                q.emplace_back(ni, nj);
            }
        }
    }
    if (dist[ti][tj] < INF) cout << dist[ti][tj] << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 9512
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{

    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            int ret = 0;
            if (S == "RRR")
            {
                Console.WriteLine(3);
            }else if (S.Contains("RR"))
            {
                Console.WriteLine(2);
            }else if (S.Contains("R"))
            {
                Console.WriteLine(1);
            }
            else
            {
                Console.WriteLine(0);
            }
        }
    }
}

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

using namespace std;
int n, m;
const int N = 1e5 + 7;
pair<int, int> prs[N];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> prs[i].second >> prs[i].first;
    }
    sort(prs, prs + n, greater<>());
    set<int> ss;
    for (int i = 0; i < m; ++i) {
        ss.insert(i + 1);
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        auto it = ss.lower_bound(prs[i].second);
        if (it == ss.end()) continue;
        ss.erase(it);
        ans += prs[i].first;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760
N = int(input())
S = list(tuple(map(int, input().split())) for _ in range(N))
A = []
if N == 1:
    print(1)
else:
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            a, b = S[i]
            c, d = S[j]
            for k in range(len(A)):
                e, f, g = A[k]
                if e == a-c and f == b-d:
                    A[k] = (e, f, g+1)
                    break
            else:
                A.append((a-c, b-d, 1))
    print(N-max(list(x[2] for x in A)))




Measured memory_bytes: 9012
#include<bits/stdc++.h>
using namespace std;
int N, tmp, answer;
vector<int> P;
int main(){
 cin >> N;
 for(int i = 0; i < N; i++){
  cin >> tmp;
	P.push_back(tmp);
 }sort(P.begin(), P.end());
  reverse(P.begin(), P.end());

 for(int i = 0; i < N; i++){
  if(i == 0)answer += P[i]/2;
	else answer += P[i];
 }
 cout << answer << endl;
 return 0; 
};


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define PI 3.14159265358979

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int n,s;
ll m,p[1234567];

ll search(ll x){
	int l,r,mid;
	if(x>m){
		return 0ll;
	}
	l = 0; r = s;
	while((r-l)>1){
		mid = (l+r)/2;
		if(x+p[mid]>m){
			r = mid;
		}else{
			l = mid;
		}
	}
	return ((x+p[r]>m)?(x+p[l]):(x+p[r]));
}

int main(void){
	int i,j;
	ll ans;
	cin >> n >> m;
	while(!(n==0&&m==0ll)){
		ans = 0ll; s = n*n+n+1;
		for(i=0; i<n; ++i){
			cin >> p[i];
		}
		for(i=0; i<n; ++i){
			for(j=0; j<n; ++j){
				p[n+i*n+j] = p[i]+p[j];
			}
		}
		p[s-1] = 0ll;
		sort(p,p+s);
		for(i=0; i<s; ++i){
			ans = max(ans,search(p[i]));
		}
		cout << ans << endl;
		cin >> n >> m;
	}
	return 0;
}



Measured memory_bytes: 10892
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>

using namespace std;

typedef long long LL;

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

int main()
{
    LL a, b;
    cin >> a >> b;
    
    LL d = gcd(a, b);
    
    int cnt = 1;
    for(int i = 2; i <= d / i; i ++)
        if(d % i == 0)
        {
            cnt ++;
            while(d % i == 0)  d /= i;
        }
    if(d > 1)  cnt ++;
    printf("%d", cnt);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>

int main(){
    int a,b,c;
    std::cin>>a>>b>>c;
    int sum=0;
    int cnt=1;
    while(1){
        if(sum>=c)break;
        else{
            if(cnt%7==0){
            sum=sum+a+b;
            
            //std::cout<<"sum="<<sum<<" cnt="<<cnt<<"\n";
            cnt++;
        }
        else{
            sum+=a;
           // std::cout<<"sum="<<sum<<" cnt="<<cnt<<"\n";
            cnt++;
        }

        }
        
    }
    std::cout<<cnt-1<<"\n";
}


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

digit_dict = {digit: '*' for digit in range(1, N + 1)}

for _ in range(M):
  s, c = map(int, input().split())
  
  if digit_dict[s] == '*':
    digit_dict[s] = c
  elif digit_dict[s] != c:
    print(-1)
    exit()

if len(digit_dict) == 1:
  for key, value in digit_dict.items():
    if value != '*':
      continue

    digit_dict[key] = 0
else:
  
  for key, value in digit_dict.items():
    if key == 1 and value == 0:
      print(-1)
      exit()

    if value != '*':
      continue

    if key == 1:
      digit_dict[key] = 1
    else:
      digit_dict[key] = 0

print(''.join(list(map(str, digit_dict.values()))))

Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<utility>
#include<random>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-2;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

struct edge { int to, cap, rev, id; };
vector<edge> G[100000];
bool used[100000];
void add_edge(int from, int to, int cap, int id) {
	G[from].push_back(edge{ to, cap, (int)G[to].size(),id });
	G[to].push_back(edge{ from, 0, (int)G[from].size() - 1,id + 1000 });
	swap(from, to);
	G[from].push_back(edge{ to, cap, (int)G[to].size(),id });
	G[to].push_back(edge{ from, 0, (int)G[from].size() - 1,id + 1000 });
}
int dfs(int v, int t, int f) {
	if (v == t)return f;
	used[v] = true;
	for (int i = 0; i < (int)G[v].size(); i++) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, mod);
		if (f == 0)return flow;
		flow += f;
	}
}
int par[1000];
int c[1000];
int main() {
	int n, m; cin >> n >> m;
	rep(i, m) {
		int a, b; cin >> a >> b; a--; b--;
		add_edge(a, b, 1, i);
		par[i] = a;
	}
	int s, t; cin >> s >> t; s--; t--;
	int ans = max_flow(s, t);
	rep(i, n) {
		rep(j, G[i].size()) {
			int id = G[i][j].id;
			if (G[i][j].id >= 1000)continue;
			else {
				if (G[i][j].cap == 1)continue;
				if (G[i][j].to == par[id])c[id]++;
				else c[id]--;
			}
		}
	}
	int cnt = 0;
	vector<int> v;
	rep(i, m) {
		if (c[i] > 0) {
			cnt++; v.push_back(i);
		}
	}
	cout << ans << endl;
	cout << cnt << endl;
	rep(i, cnt) {
		cout << v[i] + 1 << endl;
	}
	//stop
	return 0;
}


Measured memory_bytes: 5648
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N;
  std::cin >> N;
  std::vector< ll > va(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }

  ll suma = 0LL;
  ll sumb = 0LL;
  std::sort(va.begin(), va.end(), std::greater<>());
  for (ll i = 0; i < N; i++) {
    if (i % 2 == 0) suma += va[i];
    else sumb += va[i];
  }

  ll ans = suma - sumb;
  print(ans);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>

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

int main(){

	int n;
	string name;
	cin >> n >> name;
	int cnt = 0;

	while(n--){
		string old;
		cin >> old;
		for(int i=0; i<old.size(); i++){
			bool flag = false;
			for(int j=1; j<old.size(); j++){
				string tar;
				for(int k=i; k<old.size(); k+=j){
					tar += old[k];
				}
				if(~tar.find(name)){ cnt++; flag = true; break;}
			}
			if(flag) break;
		}
	}
	cout << cnt << endl;

	return 0;	
}

Measured memory_bytes: 1212
"""
References: <https://www.hamayanhamayan.com/entry/2020/03/22/231629>
"""
import sys
from itertools import product

input = sys.stdin.readline


def main():
    H, W, K = map(int, input().split())
    S = [None] * H
    for i in range(H):
        S[i] = input().rstrip()

    ans = float("inf")
    for comb in product(range(2), repeat=(H - 1)):
        n_cut = sum(comb)
        if n_cut >= ans:
            continue

        group = []
        g_id = 0
        for c in comb:
            group.append(g_id)
            if c == 1:
                g_id += 1
        group.append(g_id)

        w = 0
        while w < W:
            count = [0] * (g_id + 1)
            next_w = w
            for x in range(w, W):
                over_K = False
                for y in range(H):
                    if S[y][x] == "1":
                        count[group[y]] += 1
                        if count[group[y]] > K:
                            over_K = True
                            break
                if over_K:
                    break
                next_w += 1

            # Impossible: over K in one column
            if next_w == w:
                n_cut = float("inf")
                break
            w = next_w

            if over_K:
                n_cut += 1
            if n_cut >= ans:
                break

        if n_cut < ans:
            ans = n_cut

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    ll N;
    cin >> N;
    ll a = 1,b = 0;;
    vl aa;
    aa.pb(1);
    while (b+a*26 < N) {
        a *= 26;
        b += a;
        aa.pb(a);
        //cout << a csp b << endl;
    }
    aa.pb(a*26);
    string ans = "";
    N-=b;
    rep(i,int(aa.size())-1){
        
        ll bb = aa[int(aa.size())-i-2];
        ll aaa = (N-1)/bb;
        N -= aaa*bb;
        ans += (char)(int('a')+int(aaa));
        
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
using namespace std;

bool isCoprime( int a, int b ){
	while( a != b ){
		if( a > b )	a -= b;
		else		b -= a;
	}
	return a==1;
}

int nextAlpha( int a ){
	while(1){
		if( isCoprime( 26, ++a ) ){
			break;
		}
	}
	return a;
}

bool check( string str, int a, int b ){
	for( int i=0; i<str.length(); i++ ){
		if( 'a'<=str[i]&&str[i]<='z' )	str[i] = ((a*(str[i]-'a')+b) % 26) + 'a';
	}
	if( (str.find("this")!=string::npos)||(str.find("that")!=string::npos) ){
		cout << str << endl;
		return true;
	}
	return false;
}

int main(){
	int n;
	string line;
	
	getline( cin, line );
	sscanf( line.c_str(), "%d", &n );
	
	for( int i=0; i<n; i++ ){
		int a=2, b;
		getline( cin, line );
		for(;;a=nextAlpha(a)){
			for( b=0; b<26; b++ ){
				if( check( line, a, b ) ){
					break;
				}
			}
			if( b < 26 )	break;
		}
	}
	return 0;
}

Measured memory_bytes: 0
/*     *******************Bismillahir Rahmanir Rahim************************
                          **************************
                          #    MD. ASFAKUL GHANI   #
                          #       *ProMAGFAT*      #
                          #         CSE-25         #
                          #JAHANGIRNAGAR UNIVERSITY#
                          #                        #
                          &&&&&&&&&&&&&&&&&&&&&&&&&#
*/

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

#define pi 2*acos(0.0)
#define ll long long
#define modulo 1000003
#define dd double
#define PI 3.14159265358979
#define p_b push_back

//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ll for_binarySearch(ll a,ll b,ll aa[],ll x){while(a<=b){ll mid=(a+b)/2;if(aa[mid]==x) return 1;else if(aa[mid] > x) b=mid-1;else a=mid+1;}return -1;}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ll for_gcd(ll a,ll b){if(a==0) return b;else return for_gcd(b%a,a);}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ll for_prime(ll x){for (ll i=2;i*i<=x;i++){if(x%i==0) return 0;}return 1;}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
void for_swap(char *x,char *y){char temp;temp=*x;*x=*y;*y=temp;}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ll for_big_mod(ll b,ll p,ll m){if(p==0) return 1;else if(p%2==0){ll k=for_big_mod(b,p/2,m);return (k*k)%m;}else return ((b%m)*(for_big_mod(b,p-1,m)))%m;}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ll for_josephus(ll n,ll k){if(n==1) return 1;return (for_josephus(n-1,k)+k-1)%n+1;}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ll for_gcdExtended(ll a,ll b,ll *x,ll *y){if(a==0){*x=0;*y=1;return b;}ll x1,y1;ll gcd=for_gcdExtended(b%a,a,&x1,&y1);*x=y1-(b/a)*x1;*y=x1;return gcd;}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

ll a1[100005];
int main()
{
   ll n,m;
   ll p=0;
   cin >> n;
   for (ll i=0; i<n; i++){
    cin >> m;
    if (m&1) p++;
   }
   if (p&1) cout << "NO" << endl;
   else cout << "YES" << endl;

    //main();
    return 0;
}


Measured memory_bytes: 256