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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

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

    auto g  = make_vec<char>(H+1,W+1);
    auto g2 = make_vec<ll>(H+1,W+1);
    auto g3 = make_vec<ll>(H+1,W+1);
 
    vector<int> r_vec[2001];
    vector<int> c_vec[2001];
    REP(i,2001){
        r_vec[i].push_back(0);
        c_vec[i].push_back(0);
    }

    REP(i,H){ 
        string s;cin >> s;
        REP(j,W){
            g[i][j] = s[j];
            if(g[i][j]=='#'){
                r_vec[i].push_back(j+1);
                c_vec[j].push_back(i+1);
            }
        }
    }

    REP(i,2001){
        r_vec[i].push_back(W+1);
        c_vec[i].push_back(H+1);
    }

    REP(r,H) for(int i=1;i<r_vec[r].size();i++){
        int j = r_vec[r][i-1];
        while(j < r_vec[r][i] - 1) {
            g2[r][j] = r_vec[r][i] - r_vec[r][i-1] - 1;
            j++;
        }
    }

    REP(c,W) for(int i=1;i<c_vec[c].size();i++){
        int j = c_vec[c][i-1];
        while(j < c_vec[c][i] - 1) {
            g3[j][c] = c_vec[c][i] - c_vec[c][i-1] - 1;
            j++;
        }
    }

    ll ans=0;
    REP(i,H) {
        REP(j,W) {
            chmax(ans,g2[i][j]+g3[i][j]-1);
        }
    }

    pl(ans)

    return 0;
}

Measured memory_bytes: 100992
#include <stdio.h>
#include <string.h>
int main()
{
    char s[1002];
    int i,h,len,j,n,k;
    scanf(" %[^\n]", s);
    len=strlen(s);
    for(i=0;i<len;i++){
        if(i==0) {
            k = s[i]-32;
            printf("%c",k);
        }
    }

    len=strlen(s);
    for(j=0;j<len;j++) {
        if (s[j] == ' ') {
            s[j] = s[j + 1];
            n=s[j]-32;
            printf("%c",n);}
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll A,B,C,X,Y,Z,i;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>A>>B>>C;
	for(i=0;i<1000000;i++)
	{
		if((A%2==1)||(B%2==1)||(C%2==1))
		{
			cout<<i<<"\n";
			return 0;
		}
		X=A/2;
		Y=B/2;
		Z=C/2;
		A=(Y+Z);
		B=(X+Z);
		C=(X+Y);
	}
	cout<<-1<<"\n";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, j, n) for (int i = j; i < (int)(n); i++)
#define brep(i, n) for (int i = n; i > 0; i--)
#define BREP(i, j, n) for(int i = n; i > j; i--)
#define TEST cout << "PASS" << endl
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 1e6 + 1e3 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
    int n, C;
    cin >> n >> C;
    int d[500][500];
    rep(i, C) rep(j, C) cin >> d[i][j];
    
    map<int, int> mp0, mp1, mp2;
    rep(i, n) rep(j, n){
        int c;
        cin >> c;
        c--;
        if((i + j) % 3 == 0) mp0[c]++;
        else if((i + j) % 3 == 1) mp1[c]++;
        else mp2[c]++;
    }
    int ans = INF;

    rep(i, C){
        int cnta = 0;
        for(P x : mp0) cnta += d[x.first][i] * x.second;
        rep(j, C){
            if(i == j) continue;
            int cntb = 0;
            for(P x : mp1) cntb += d[x.first][j] * x.second;
            rep(k, C){
                if(j == k || k == i) continue;
                int cntc = 0;
                for(P x : mp2) cntc += d[x.first][k] * x.second;
                ans = min(ans, cnta+cntb+cntc);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
    ll X;
    cin >> X;
    
    ll now = 100;
    ll year = 0;
    while (now < X) {
        ll add = now / 100;
        now += add;
        year++;
    }

    
    cout << year << endl;
    
}

Measured memory_bytes: 3632
//
// Created by TakahiroYamaji on 2020/08/15.
//
#include<iostream>
#include<string>
std::string S;
int main(){
    std::cin >> S;
    int ans = 0;
    if (S == "RRR"){
        ans = 3;
    }else if (S == "RRS"){
        ans = 2;
    }else if (S == "RSR"){
        ans = 1;
    }else if (S == "RSS"){
        ans = 1;
    }else if (S == "SRR"){
        ans = 2;
    }else if (S == "SRS"){
        ans = 1;
    }else if (S == "SSR"){
        ans = 1;
    }else if (S == "SSS"){
        ans = 0;
    }
    std::cout << ans << std::endl;
}



Measured memory_bytes: 3224
N,A,B = map(int, input().split())

cand = list(range(1, N+1))
cand = list(map(str, cand))
cand = list(map(lambda x: sum(map(int, x)), cand))
cand = list(map(lambda x: True if A <= x <= B else False, cand))

target = [x for x,t in zip(list(range(1, N+1)), cand) if t]
print(sum(target))

Measured memory_bytes: 3956
// E - Dist Max
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main(){
	int N; cin>>N;
	ll p_mn, m_mn = p_mn = 1e9 * 2;
	ll p_mx, m_mx = p_mx = -p_mn;
	while(N--){
		ll x, y; cin>>x>>y;
		ll p = x + y, m = x - y;
		p_mx = max(p_mx, p);
		p_mn = min(p_mn, p);
		m_mx = max(m_mx, m);
		m_mn = min(m_mn, m);
	}
	cout<< max(p_mx - p_mn, m_mx - m_mn) <<endl;
}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, K;
        public long[] X;
        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                K = line[1];
            }

            X = Input.ReadLongArray();

            long ans = long.MaxValue;
            for (int i = 0; i < N; i++)
            {
                if (i + K - 1 < N)
                {
                    long a = 0;
                    long MN = X[i];
                    long MX = X[i + K - 1];

                    if (MN >= 0)
                    {
                        a = MX;
                    }
                    else if (MX <= 0)
                    {
                        a = MN * (-1);
                    }
                    else
                    {
                        a = Math.Min(MX * 2 - MN, MX - MN * 2);
                    }

                    ans = Math.Min(ans, a);
                }
            }

            Console.WriteLine(ans);
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

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

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 22880
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let mut a: Vec<usize> = (0..3)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    a.sort();

    let two = a[2] - a[1];
    a[1] += two;
    a[0] += two;
    if (a[1] - a[0]) % 2 == 0 {
        println!("{}", two + (a[1] - a[0]) / 2);
    } else {
        println!("{}", two + (a[1] - a[0]) / 2 + 2);
    }
}


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

int main(){
    long long n, p;
    cin >> n >> p;
    if (n == 1){
        cout << p << endl;
        return 0;
    }
    long long ans = 1;
    for (int i = 2; (long long)i * i <= p; i++){
        int tmp = 0;
        while (p % i == 0){
            tmp++;
            p /= i;
            if (tmp >= n){
                ans *= i;
                tmp -= n;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define ii insert
#define ld long double
#define ppb pop_back
#define nuenxfiu ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define TT int testcases;cin>>testcases;while(testcases--)
#define mk make_pair
#define MAX ((int)2e9+17)
#define N 200005
#define mod ((int)1e9+7)
#define MOD 1000003
//int fact[1000007]={0};
int fpow(int n, int k, int p = mod) {int r = 1; while(k > 0) {if (k & 1) r = r * n%p; n = n * n%p; k = k >> 1;} return r;}
int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
int inv(int x) {return expo(x, mod-2);}
using namespace std;





void solve()
{
	int n;
	cin>>n;
	
	if(	n%1000)
	{
		cout<<1000-n%1000<<endl;
	}
	else
	cout<<0<<endl;
	
}
signed main()
{
    
	nuenxfiu
	//TT
	solve();
     return 0;
}

Measured memory_bytes: 3612
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next(), t = sc.next();
		int N = s.length();
		HashMap<Character, Character> StoT = new HashMap<>(s.length() + 1, 1);
		HashMap<Character, Character> TtoS = new HashMap<>(t.length() + 1, 1);
		for (int i = 0; i < N; i++) {
			// First Observation for every character in S they can only map to one unique
			// character of T
			if (StoT.containsKey(s.charAt(i)) && StoT.get(s.charAt(i)) != t.charAt(i)) {
				System.out.println("No");
				return;
			}
			// Second Observation for every character in T they can only map to one unique
			// character of S
			if (TtoS.containsKey(t.charAt(i)) && TtoS.get(t.charAt(i)) != s.charAt(i)) {
				System.out.println("No");
				return;
			}
			StoT.put(s.charAt(i), t.charAt(i));
			TtoS.put(t.charAt(i), s.charAt(i));
		}
		System.out.println("Yes");
	}
}

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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

int main() {
    string s; cin >> s;
    int k; cin >> k;
    int n = s.size();

    set<string> v;
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k; j++){
            v.insert(s.substr(i, j));
        }
    }

    auto ite = v.begin();
    for(int i = 1; i < k; i++) ite++;
    cout << *ite << endl;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

using Weight = int;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(void) {}
  Edge(int src, int dst) : src(src), dst(dst) {}
  Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void edges_to_graph(Graph &graph, const Edges &edges, const int vertices, const bool directed = true) {
  graph.clear(), graph.resize(vertices);
  for (const auto &e : edges) graph[e.src].emplace_back(e);
  if (!directed) for (const auto &e : edges) graph[e.dst].emplace_back(Edge(e.dst, e.src, e.weight));
}

void dfs(Graph &g, int v, int p, int u, vector<int> &route, bool &goal) {
  route.push_back(v);
  if (v == u) {
    goal = true;
    return;
  }
  for (const auto &e : g[v]) {
    if (e.dst == p) continue;
    dfs(g, e.dst, v, u, route, goal);
    if (goal) return;
  }
  route.pop_back();
}

void dfs2(Graph &g, int v, int p, int cnt, int &maxi) {
  maxi = max(maxi, cnt);
  for (const auto &e : g[v]) {
    if (e.dst == p) continue;
    dfs2(g, e.dst, v, cnt + 1, maxi);
  }
}

Graph graph;
int main(void) {
  int n, u, v;
  cin >> n >> u >> v;
  --u, --v;
  Edges edges(n - 1);
  vector<int> ab(n);
  rep (i, n - 1) {
    int a, b;
    cin >> a >> b;
    edges[i] = {--a, --b};
  }
  edges_to_graph(graph, edges, n, false);
  vector<int> route;
  bool goal = false;
  dfs(graph, v, -1, u, route, goal);
  int cnt  = route.size() / 2 - 1;
  int k    = route.size() - (cnt + 1);
  int newv = route[k];
  int newp = route[k - 1];
  int maxi = 0;
  dfs2(graph, newv, newp, cnt, maxi);
  if (route.size() & 1) ++maxi;
  cout << maxi << endl;
  return 0;
}

Measured memory_bytes: 14328
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut v: Vec< Vec< (usize, bool) >> = vec![vec![]; n];
    for i in 0..n {
        let a: usize = read();
        for _ in 0..a {
            let j: usize = read();
            let x: u8 = read();
            v[i].push((j-1, if x == 1 { true } else { false }));
        }
    }

    let mut ans: u8 = 0;

    for bit in 0..(1<<n) {
        let mut is_honest = vec![false; n];
        let mut cnt: u8  = 0;
        for i in 0..n {
            if bit & (1 << i) != 0 {
                is_honest[i] = true;
                cnt += 1;
            }
        }

        let mut ok = true;
        for i in 0..n {
            if !is_honest[i] {
                continue;
            }
            for j in 0..(v[i].len()) {
                if is_honest[v[i][j].0] != v[i][j].1 {
                    ok = false;
                    break;
                }
            }
            if !ok {
                break;
            }
        }
        
        if ok && ans < cnt {
            ans = cnt;
        }
    }

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

Measured memory_bytes: 4352
while True:
	try:
		y,x = map(int,input().split(" "))
		if y == 0 and x == 0:
			break
		for i in range(y):
			for j in range(x):
				if j == 0 or i == 0 or j == x-1 or i == y-1:
					print("#",end="")
				else:
					print(".",end="")
			print()
		print()
	except:
		break

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

int main(){
	string S, T, U;
	int A, B, comp = 0;

	cin >> S >> T;
	cin >> A >> B;
	cin >> U;

	if(S.compare(U) == 0) {
		A -= 1;
	}else if(T.compare(U) == 0){
		B -= 1;
	}

	cout << A << " " << B << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//Nページから成る書類を両面印刷したとき,必要な紙の枚数を返す
int main(){
 int N ;
  cin >> N ;
 if(N%2==0) {
  cout << N/2;
 }else{
  cout << (N+1)/2;
 }
}

Measured memory_bytes: 256
#include <stdio.h>

int dp[20][100005];
int x[100005];

int main(){
    int N;
    scanf("%d", &N);
    for(int i=1; i<=N; i++) scanf("%d", &x[i]);
    int L, Q;
    scanf("%d%d", &L, &Q);
    int ptr=1;
    for(int i=1; i<=N; i++){
        while(x[i]-x[ptr] > L) ptr++;
        dp[0][i] = ptr;
    }
    for(int i=1; i<20; i++){
        for(int j=1; j<=N; j++){
            dp[i][j] = dp[i-1][dp[i-1][j]];
        }
    }
    for(int query=0; query<Q; query++){
        int a, b;
        scanf("%d%d", &a, &b);
        if(b < a){
            int temp = b;
            b = a;
            a = temp;
        }
        int res=0;
        while(b > a){
            if(dp[0][b] <= a){
                res += 1;
                break;
            }
            for(int i=0; i<19; i++){
                if(dp[i+1][b] <= a){
                    b = dp[i][b];
                    res += (1<<i);
                    break;
                }
            }
        }
        printf("%d\n", res);
    }
    return 0;
}

Measured memory_bytes: 8960
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
vector<int>fri[100000],bro[100000];
int i2s[100000];
int cnt[100000];
int tmp;
int sbro[100000];
void dfs(int v){
    i2s[v]=tmp;
    for(int i=0;i<fri[v].size();i++)
        if(i2s[fri[v][i]]==-1)
            dfs(fri[v][i]);
}
signed main(){
    int n,m,k,a[100000],b[100000],c[100000],d[100000];
    cin>>n>>m>>k;
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        fri[--a[i]].push_back(--b[i]);
        fri[b[i]].push_back(a[i]);
    }
    for(int i=0;i<k;i++){
        cin>>c[i]>>d[i];
        bro[--c[i]].push_back(--d[i]);
        bro[d[i]].push_back(c[i]);
    }
    for(int i=0;i<n;i++)
        i2s[i]=-1;
    for(int i=0;i<n;i++){
        if(i2s[i]==-1){
            dfs(i);
            tmp++;
        }
    }
    for(int i=0;i<n;i++)
        cnt[i2s[i]]++;
    for(int i=0;i<n;i++)
        for(int j=0;j<bro[i].size();j++)
            if(i2s[i]==i2s[bro[i][j]])
                sbro[i]++;
    for(int i=0;i<n;i++)
        cout<<cnt[i2s[i]]-1-fri[i].size()-sbro[i]<<(i+1==n?'\n':' ')<<endl;
}

Measured memory_bytes: 18048
using static AddFunction;
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt64(ReadLine());
        long min = long.MaxValue;
        for(var i = (long)Sqrt(num)+1; i>0; i--)
        {
            if (num % i == 0 && min > BigDigit(i, num / i)) min = BigDigit(i, num / i);
        }
        WriteLine(min);
    }

    private static long BigDigit(long num1,long num2)
    {
        return Max(GetDigit(num1), GetDigit(num2));
    }
}

public static class AddFunction
{
  public static long GetDigit(long num)
    {
        return num == 0 ? 1 : (long)Math.Log10(num) + 1;
    }
}

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

def dfs(s, mx):
    if len(s) == n:
        print(s)
    else:
        for c in [chr(ord('a') + i) for i in range(ord(mx) - ord('a') + 1)]:
            dfs(s + c, chr(ord(mx) + 1) if c == mx else mx)

dfs('', 'a')

Measured memory_bytes: 4412
n,k=map(int,input().split())
p=10**9+7
S=[1]*(n+1)
for i in range(2,n+1):
    S[i]=i*S[i-1]
for i in range(1,k+1):
    b=S[k-1]//(S[i-1]*S[k-i])
    r=S[n-k+1]//(S[i]*S[n-k+1-i])
    print(b*r%p)

Measured memory_bytes: 5748
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int
 
#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))
 
typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;
 
typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;
 
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;
 
namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}
 
signed main() {
    int m;
    while(cin >> m, m) {
        int mi = INF;
        repq(i,0,100) repq(j,0,1000) {
            int x = i*i*i + j*j;
            if(x > m) continue;
            else {
                int y = m - x;
                // printf("i = %lld, j = %lld, y = %lld\n", i, j, y);
                mi = min(mi, i + j + y);
            }
        }
        cout << mi << endl;
    }
    return 0;
}

Measured memory_bytes: 2980
import scala.io.StdIn._
object Main extends App {
  val n = readInt
  val x = readLine.split(" ").map(_.toInt)
  var min = Int.MaxValue
  for (i <- x.min to x.max) {
    val h = x.foldLeft(0) { (acc, v) =>
      acc + math.pow(v - i, 2).toInt
    }
    min = math.min(min, h)
  }
  println(min)
}


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

int main() {
    int N;
    string S;
    cin >> N >> S;
    ll R = 0, G = 0, B = 0;

    rep(i, N) {
        if(S.at(i) == 'R') R++;
        else if(S.at(i) == 'G') G++;
        else B++;
    }

    ll ans = R * G * B;

    for(int i = 0; i < N - 2; i++) {
        for(int j = 1; i + 2 * j < N; j++) {
            if(S.at(i) != S.at(i + j) && S.at(i) != S.at(i + 2 * j) && S.at(i + j) != S.at(i + 2 * j)) ans--;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3608
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;

LL a,b,c;

string ans = "No";

void solve(){
	if(a+b-c<0){
		if((a+b-c)*(a+b-c)>4*a*b){
			ans = "Yes";
		}
	}
}
 
int main(){
	cin >> a >> b >> c;
 
	solve();

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

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Parking
            var line = ReadLine();
            int N = line[0];
            int A = line[1];
            int B = line[2];

            if (A * N < B)
            {
                Console.WriteLine(A * N);
            }
            else
            {
                Console.WriteLine(B);
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 11220
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const int big=1e9+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
int main(void){
	string str;cin>>str;
	int i,n,ans;n=str.size();ans=n;
	for(i=0;i<n-1;i++){
		if(str[i]!=str[i+1]){mineq(ans,max(i+1,n-i-1));}
	}
	cout<<ans<<endl;
	RE;
}

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

int main() {
  int n; cin >> n;
  vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int p = 0, c = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == p) c++;
    else {
      if (c & 1) ans++;
      p = a[i];
      c = 1;
    }
  }
  cout << (c & 1 ? ans + 1 : ans) << endl;
}

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#include <unordered_set>

//#define _USE_MATH_DEFINES
//#include <math.h>


#include <vector>
#include <list>

#include <set>
#include <map>

#include <unordered_map>

#include <queue>

#include <string>

#include <vector>

#define sqr(x) (x) * (x)

#include <algorithm>
#include <functional>

#include <bitset>

#include <functional>

#include <chrono>

typedef unsigned int u32;
typedef int i32;

typedef unsigned long long int u64;
typedef long long int i64;

typedef uint16_t u16;
typedef int16_t i16;

typedef uint8_t u8;
typedef int8_t i8;


using namespace std;
using namespace std::chrono;

struct less_key
{
    bool operator() (pair<i64, i64> p1, pair<i64, i64> p2)
    {
        return (p1.first < p2.first || (p1.first == p2.first && p1.second < p2.second));
    }
};

struct pair_hash
{
    std::size_t operator()(const pair<i64, i64>& k) const
    {
        return static_cast<size_t>(k.first ^ k.second);
    }
};


#include <random>

const i64 mod = 1000000007ll;
const i64 inf = 10000000000000007ll;

const i64 mod2 = 998244353ll;

const double eps = 0.00000001;

int main() {
    i64 a, b;
    cin >> a >> b;

    cout << a + b / 2;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()

{

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

if(a==b){
    cout<<"Draw"<<endl;
}

else if (a==1){
    cout<<"Alice"<<endl;
}

else if(b==1){
    cout<<"Bob"<<endl;
}
else if(a>b){
    cout<<"Alice"<<endl;
}

else {
    cout<<"Bob"<<endl;
}
    return 0;
}


Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(
            new InputStreamReader(System.in));
        int i = 1;
        while (true) {
            int data = Integer.parseInt(br.readLine());
            if (data == 0)
                break;
            System.out.println("Case " + i + ": " + data);
            i++;
        }
    }
}

Measured memory_bytes: 31812
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
int main(){
  int a,b;
  int ans;
  string s;
  cin>>a>>b;
  if(a<=2*b)ans=0;
  else ans=a-2*b;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return (ans.x+m)%m;
}
int fact[N];
void calfac(int n ){
fact[0] = 1;
for(int i = 1 ; i <= n+2; i++){
 fact[i] = (((fact[i-1]%mod)*(i%mod))%mod + mod)%mod;
}
 }
int calc(int n , int r){
 if(r > n)return 0;
 if(r == n)return 1;
 int ans = 1;
 ans = ((ans%mod)*(fact[n])%mod + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[n-r] , mod)%mod) + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[r] , mod)%mod) + mod)%mod;
 return (ans+mod)%mod;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int k , x;
cin>>k>>x;
if(k*500 >= x){
 cout<<"Yes"<<endl;
}
else{
 cout<<"No"<<endl;
}
}


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

nM = 0
nA = 0
nR = 0
nC = 0
nH = 0
Ans = 0

for i in range(N):
    S = input()
    Word = S[0]
    
    if Word =='M':
        nM += 1 
    elif Word =='A':
        nA += 1 
    elif Word =='R':
        nR += 1 
    elif Word =='C':
        nC += 1 
    elif Word =='H':
        nH += 1 

Ans = nM * (nA * (nR + nC + nH) + nR * (nC + nH) + nC * nH) + nA * (nR * (nC + nH) + nC * nH) + nR * nC * nH

print(Ans)


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

using namespace std;

typedef vector<int> vi;

vi getPrimes(int n) {
  /*
   * n以下の素数を全て返す
   * アルゴリズムにはエラトステネスの篩を用いる
   */
  vi res;
  bool isPrime[n+1];
  isPrime[0] = isPrime[1] = false;
  for (int i = 2; i <= n; i++) isPrime[i] = true;
  for (int i = 2; i <= n; i++) {
    if (isPrime[i]) {
      res.push_back(i);
      for (int j = i*2; j <= n; j += i) isPrime[j] = false;
    }
  }
  return res;
}


int main() {

  int N;
  cin >> N;
  vi primes = getPrimes(60000);
  int i = 0;
  for (int i = 0; i < primes.size(); i++) {
    if (primes[i]%5 == 1) {
      N--;
      cout << primes[i];
      if (N == 0) {
        cout << endl;
        return 0;
      }
      else cout << " ";
    }
  }
}

Measured memory_bytes: 384
S = list(set(list(input())))
c = 0
for i in S:
    if i == "N":
        c += 1
    elif i == "W":
        c += 2
    elif i == "S":
        c -= 1
    else:
        c -= 2
if c == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <unordered_map>
using namespace std;


int main(){
    int n;
    cin >> n;
    int h[n];
    for (int i = 0; i < n; i++){
        cin >> h[i];
    }
    bool is_possible = true;
    for (int i = n - 2; i >= 0; i--){
        if (h[i] > h[i + 1]){
            if (h[i] - h[i + 1] == 1){
                h[i]--;
            }
            else{
                is_possible = false;
            }
        }
    }
    if (is_possible){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
#define BIG 998244353

int main()
{
  long long int anss=1;
  int a,tem=0;
  cin>>a;
  int ans[a];
  for(int t=0;t<a;t++)
  cin>>ans[t];
  vector<int> n;
  if(ans[0]!=0)
    tem=1;
  sort(ans,ans+a);
  for(int t=0;t<a-1;t++)
  {
    if(ans[t+1]-ans[t]>1)
    {
       tem=1;
       break;
    }
  }
  if(ans[1]==0)
  tem=1;
  if(tem)
  {
    cout<<0;
    return 0;
  }
  tem=1;
  int count1=0,arr=0;
  for(int t=1;t<a;t++)
  {
    if(ans[t]==tem)
    count1++;
    else
    {
    n.push_back(count1);
    count1=0;
    tem++;
    t--;
    }
  }
  n.push_back(count1);
  for(int t=0;t<n.size()-1;t++)
  {
    for(int j=0;j<n[t+1];j++)
    anss=anss*n[t]%BIG;
  }
  cout<<anss;
}

Measured memory_bytes: 1276
import sys
input=sys.stdin.readline
from math import ceil
input()
A=list(map(int,input().split()))
maxA=max(A)
minA=min(A)
if minA!=ceil(maxA/2):
    print('Impossible')
else:
    if maxA%2:
        for i in range(minA,maxA+1):
            if i==minA:
                if A.count(i)!=2:
                    print('Impossible')
                    break
            else:
                if A.count(i)<2:
                    print('Impossible')
                    break
        else:
            print('Possible')
    else:
        for i in range(minA,maxA+1):
            if i==minA:
                if A.count(i)!=1:
                    print('Impossible')
                    break
            else:
                if A.count(i)<2:
                    print('Impossible')
                    break
        else:
            print('Possible')

Measured memory_bytes: 3064
def main
  answers = []
  loop do
    str,pattern = gets.chomp.split(' ')
    break if pattern.eql?('X')

    answers << case pattern
    when 'U'
      conversion_to_upper_camel_case(str)
    when 'L'
      conversion_to_lower_camel_case(str)
    when 'D'
      conversion_to_snake_case(str)
    end
  end

  answers.each {|answer|puts answer}
end

def split_word str
  words = []
  word = ''
  str.length.times do |i|
    if str[i].match(/_/)
      words << word
      word = ''
    elsif str[i].match(/[A-Z]/)
      words << word unless i == 0
      word = str[i]
    else
      word << str[i]
    end
  end
  words << word
  words
end

def to_first_char_upcase word
  result_word = ''
  word.length.times do |i|
    if i == 0
      result_word << word[i].upcase
    else
      result_word << word[i].downcase
    end
  end
  result_word
end

def conversion_to_upper_camel_case str
  conversion_word = ''
  words = split_word(str)
  words.each do |word|
    conversion_word << to_first_char_upcase(word)
  end
  conversion_word
end

def conversion_to_lower_camel_case str
  conversion_word = ''
  words = split_word(str)
  words.each_with_index do |word, i|
    if i == 0
      conversion_word << word.downcase
    else
      conversion_word << to_first_char_upcase(word)
    end
  end
  conversion_word
end

def conversion_to_snake_case str
  words = split_word(str)
  words.each.map{|word|word.downcase}.join('_')
end

main

Measured memory_bytes: 6128
def main():
    N, M = (int(i) for i in input().split())
    AB = [[int(i) for i in input().split()] for j in range(N)]
    from collections import defaultdict
    dic = defaultdict(list)
    for a, b in AB:
        dic[a].append(-b)
    AB.sort()
    from heapq import heapify, heappop, heappush
    h = dic[1][:]
    heapify(h)
    ans = 0
    for d in range(1, M+1):
        # Aiがd以下のうち、Bi最大の仕事を受ける
        if d != 1:
            for v in dic[d][:]:
                heappush(h, v)
        if h:
            ans += -heappop(h)
    print(ans)


if __name__ == '__main__':
    main()


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


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

    int AC = 0, WA = 0, TLE = 0, RE = 0; 
    while(N--){
        string s;
        getline(cin, s);

        if(s == "AC") AC++;
        else if(s == "WA") WA++;
        else if(s == "TLE") TLE++;
        else if(s == "RE") RE++;
    }

    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#define N 101

void build();
void  set();
int M[N],m[N][N],p[N],r[N],limit;

int main(void){
  int i,x;
  scanf("%d",&limit);
  for(i=0;i<limit;i++){
    scanf("%d%d",&r[i],&p[i]);
  }
  build();
  set();
  printf("%d\n",m[0][limit-1]);
  return 0;
}

void build(){
  int i,j;
  for(i=0;i<limit;i++){
      for(j=0;j<limit;j++){
          m[i][j]= 100000000;
      }
  }
  for(i=0;i<limit;i++){
    m[i][i]=0;
  }
}

void set(){
  int i,k,j,ct;
   for(i=0;i<limit;i++){
       for(j=0;j<limit;j++){
           m[i][j] = 100000000;
       }
   }
   for(i=0;i<limit;i++) m[i][i] = 0;
   for(i=1;i<limit;i++){
       for(j=0;j+i<limit;j++){ 
           for(k=0;k<i;k++){
               ct = m[j][j+k] + m[j+k+1][j+i] + r[j] * p[j+k] * p[j+i];
               if(m[j][j+i] > ct) m[j][j+i] = ct;
           } 
       }
   }
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, s, e) for (int i = s; i < e; i++)
#define endl '\n'
int main()
{
    int N;
    cin >> N;
    int m = N % 10;
    switch (m)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        /* code */
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;
    case 3:
        cout << "bon" << endl;
    default:
        break;
    }
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
    string s;
    cin>>s;
    if(s=="ABC")cout<<"ARC"<<endl;
    if(s=="ARC")cout<<"ABC"<<endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String str[]=new String[6];
		int n=sc.nextInt();
		for(int i=0;i<6;i++){
			str[i]="";
		}
		while(n--!=0){
			double d=sc.nextDouble();
			if(185.0<=d){
				str[5]+="*";
			}
			else if(180.0<=d){
				str[4]+="*";
			}
			else if(175.0<=d){
				str[3]+="*";
			}
			else if(170.0<=d){
				str[2]+="*";
			}
			else if(165.0<=d){
				str[1]+="*";
			}
			else{
				str[0]+="*";
			}
		}
		for(int i=0;i<6;i++){
			System.out.println((i+1)+":"+str[i]);
		}
	}
}

Measured memory_bytes: 12000
n,k,*b=`dd`.split.map &:to_i;a=[];n.times{|i|s=0;(i...n).map{|j|a<<s+=b[j]}};40.downto(r=0){|i|o=1<<i;a.count{|e|r+o&e==r+o}<k||r+=o};p r

Measured memory_bytes: 12448
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}


int ng[500];
int dp[500];

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s;
    cin >> s;
    ll k;
    cin >> k;
    int i = 0;
    while(s[i] == '1'){
        i++;
    }
    if(k <= i) print(1);
    else print(s[i]);

    

}



Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

/* UnionFind */

struct UnionFind{
  vector<int> data, tree_size;
  UnionFind(int s):data(s,-1),tree_size(s,1) {}
  
  int root(int x){
    if(data[x]==-1) return x;
    return data[x]=root(data[x]);
  }
  
  bool set(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y) return false;
    data[y]=x;
    tree_size[x] += tree_size[y];
    tree_size[y] = 0;
    return true;
  }
  
  bool check(int x,int y){
    x=root(x);
    y=root(y);
    return x==y;
  }
  
  int size(int x){
    return tree_size[root(x)];
  }
  
};


int n,m;
vector<pair<int,pair<int,int> > > vec;

int main(){

  scanf("%d%d",&n,&m);
  
  for(int i=0;i<m;i++){
    int s,d,c;

    scanf("%d%d%d",&s,&d,&c);
    s--; d--;
    vec.push_back({c,{s,d}});
  }

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

  UnionFind uf(n);

  int l = 0, r = 0;
  int sqrtM = (int)sqrt(m);

  int ans1 =0, ans2=0;
  
  for(int i=1;i<=10000;i++){

    while(r < m && vec[r].first == i) r++;

    for(int j=l;j<r;j+=sqrtM){
      UnionFind uf2 = uf;

      for(int k=j+sqrtM;k<r;k++){
        uf2.set(vec[k].second.first, vec[k].second.second);
      }

      for(int k=j;k<min(r,j+sqrtM);k++){
        UnionFind uf3 = uf2;

        for(int w=j;w<min(r,j+sqrtM);w++){
          if(k == w) continue;
          uf3.set(vec[w].second.first, vec[w].second.second);
        }

        if(!uf3.check(vec[k].second.first, vec[k].second.second)){
          ans1++;
          ans2+=vec[k].first;
        }
        
      }

      for(int k=j;k<min(r,j+sqrtM);k++){
        uf.set(vec[k].second.first, vec[k].second.second);
      }
    }
    
    l = r;
  }

  printf("%d %d\n",ans1, ans2);
  
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  int a=0;
  for(int i=0;i<2;i++){
    if(s.at(i)==s.at(i+1))  {a++;break;}
  }
  if(s.at(0)==s.at(2)) a++;
  if(a!=0) cout << "No" << endl;
  else cout << "Yes"  << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int MOD = 1e9 + 7;

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

int main() {
	int n, a;
	cin >> n >> a;
	vector<int> x(n);
	for (int i = 0; i < n; i++) cin >> x[i];

	vector<vector<vector<ll>>> dp(60, vector<vector<ll>>(2510, vector<ll>(60, 0)));
	dp[0][0][0] = 1;

	ll ans = 0;
	for (int k = 0; k <= n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= 2505; j++) {
				dp[i + 1][j][k] = dp[i][j][k];
				if (j >= x[i] && k > 0) dp[i + 1][j][k] += dp[i][j - x[i]][k - 1];
			}
		}
	}

	for (int i = 1; i <= n; i++) ans += dp[n][a * i][i];
	cout << ans << endl;
}

Measured memory_bytes: 77952
#include<cstdio>
#include<algorithm>
#define maxn 100005
using namespace std;
int n,nxt[maxn],rak[maxn],fa[maxn];
struct chj{
	int x,id;
	bool operator <(const chj b)const{return x<b.x;}
}a[maxn],b[maxn];
inline char nc(){
	static char buf[100000],*L=buf,*R=buf;
	return L==R&&(R=(L=buf)+fread(buf,1,100000,stdin),L==R)?EOF:*L++;
}
inline int read(){
	int ret=0,f=1;char ch=nc();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=nc();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=nc();
	return ret*f;
}
int main(){
	n=read();
	for (int i=1;i<=n;i++) a[i]=(chj){read(),i};
	for (int i=1;i<=n;i++) b[i]=(chj){read(),i};
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	for (int i=1;i<=n;i++)
	if (a[i].x>b[i].x){printf("No");return 0;}
	for (int i=1;i<=n;i++)
	if (a[i].id==b[i].id){printf("Yes");return 0;}
	for (int i=1;i<n;i++)
	if (b[i].x>=a[i+1].x){printf("Yes");return 0;}
	for (int i=1;i<=n;i++) rak[a[i].id]=i;
	for (int i=1;i<=n;i++) nxt[i]=rak[b[i].id];
	int x=nxt[1],num=1;
	while (x!=1) x=nxt[x],num++;
	if (num<n){printf("Yes");return 0;}
	printf("No");
	return 0;
}

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

int n, a[20];

int solve(int i, int m) {
    if(m==0) 
    return true;
    if(i>=n) 
    return false;
    int res= solve(i+1,m) || solve(i+1,m-a[i]);
    return res;
}

int main() {
    int q ,m[200];
    cin >> n;
    for(int i=0; i<n; i++) cin >> a[i];
    cin >> q;
    for(int i=0; i<q; i++) cin >> m[i];

    for(int i=0; i<q; i++) {
        if(solve(0, m[i])) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}


Measured memory_bytes: 3104