akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef map<int,int> mi;
typedef set<int> si;
typedef queue<int> qi;
typedef stack<int> sti;

#define  mod 1000000007 
#define  endl '\n'
#define  F first
#define  S second
#define  pb push_back
#define  mp make_pair
#define  mt make_tuple
#define f(i,a,b) for(int i=a;i<n;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)

template <typename T> void debug(T x) {  cout<<x<<endl;}
template <typename T> void debug(T x,T y) { cout<<x<<" "<<y<<endl;}
template <typename T> void debug(T a[]) { for(int i=0;i<a.size();i++) { cout<<a[i]<<" ";} cout<<endl; }
template <typename T> void debug(vector<T> a) { for(int i=0;i<a.size();i++) { cout<<a[i]<<" ";} cout<<endl; }
template <typename T> void debug(set<T> s) { for(T x:s) {  cout<<x<<" ";} cout<<endl;}
template <typename T> void debug(map<T,T> m) { for(auto i=m.begin();i!=m.end();i++) { cout<<i->first<<" "<<i->second;cout<<endl; }}
template <typename T> void debug(set<pair<T,T>> p) {for(auto x:p){     cout<<x.first<<" "<<x.second; cout<<endl; } }
template<typename T>  void debug(stack<T> s) { while(!s.empty()) {cout<<s.top()<<" "; s.pop();} cout<<endl; }
template <typename T> void debug(queue<T> q) {  while(!q.empty()) { cout<<q.front()<<" "; q.pop();}  cout<<endl; }

//                                        ****modulo operation****

inline ll add(ll a,ll b) { a+=b; if(a>=mod) return a-mod; return a; }
inline ll sub(ll a,ll b) { a-=b;  if(a-b<0)   return a+mod;  return a; }
inline ll mul(ll a,ll b)  {  return (a*b)%mod; }
inline ll divide(int a,int b) {  b=pow(b,mod-2); return (a*b)%mod; }
inline ll power(ll x,ll y) { ll ans=1; while(y) { if(y&1) ans*=x; x=x*x; y>>=1;} return ans;}
inline ll inv(ll x) {  return power(x,mod-2); }  

//*****************************************  code starts from here   ********************************************


void solve()
{
    ll a;
    long double b;
    cin>>a>>b;
    long double ans=a*b;
    cout<<(ll)ans<<endl;
  
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
    for(int i=1;i<=t;i++)
    {
        solve();
    }
    
}

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

int main()
{
  int64_t N, s;
  cin >> N;
  for (int i = 1; i <= N; i++)
  {
    s = (i * (i + 1)) / 2;
    if (s < N)
    {
      continue;
    }
    else if (s == N)
    {
      for (int j = 1; j <= i; j++)
      {
        cout << j << endl;
      }
      return 0;
    }
    else
    {
      int n = N;
      for (int j = i; j >= 1; j--)
      {
        if (n - j == 0)
        {
          cout << j << endl;
          return 0;
        }
        else if (n - j > 0)
        {
          n -= j;
          cout << j << endl;
        }
      }
    }
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		String t = scan.next();
		scan.close();
		int cnt =0;
		for(int i=0;i<s.length();i++) {
			if(s.charAt(i)!= t.charAt(i))cnt++;
		}
		System.out.println(cnt);

	}
}

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

long long gcd(long long x, long long y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

long long lcm(long long x, long long y)
{
    if (x == 0 || y == 0)
        return 0;
    return x / gcd(x, y) * y;
}

int dfs(int N, int K, int sum)
{
    if (N == 0)
        return sum;

    return min(dfs(N - 1, K, sum * 2), dfs(N - 1, K, sum + K));
}

int main()
{
    int N, K;
    cin >> N >> K;
    cout << dfs(N, K, 1) << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;
 
 
public class Main {

	static long MOD = 1_000_000_007;
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		//int N = Integer.parseInt(sc.next());
		//long L = Long.parseLong(sc.next());
		int INF = Integer.MAX_VALUE;
		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		//int N = A.length;
		//int N = Integer.parseInt(sc.next());
		Set<Character> set = new HashSet();
		char c1=c[0];
		char c2='b';
		int count_c1 = 1;
		int count_c2 = 0;
		boolean flag = true;
		
		for(int i=1; i<4; i++){

			if(c2=='b' && c1!=c[i])c2 =c[i];
			if(c[i]!=c1 && c[i]!=c2)flag= false;
			if(c[i]==c1){
				count_c1++;
			}
			if(c[i]==c2){
				count_c2++;
			}
		}
		String ans = null;
		if(false){
			ans = "No";
		}else if(count_c1 == 2 && count_c2 == 2){
			ans = "Yes";
		}else{
			ans = "No";
		}
		
		System.out.println(ans);
		
	}
	static long lcm (long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (c/b);
	}
}



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

int main(){
  unsigned long long x,c=0;
  double a;
  cin>>x;
  a=100;
  while(x>a){
    a = floor(a*1.01);
    c++;
  }
  cout<<c;
  return 0;
}

Measured memory_bytes: 3636
fun main(args: Array<String>) {
  val s = readLine()!!.toList()
  val k = readLine()!!.toInt()

  val s1 = s.toMutableList()
  var cnt1 = 0L
  for (i in 1 until s.size) {
    val a = s1[i - 1]
    val b = s1[i]
    if (a == b) {
      s1[i] = '_'
      cnt1++
    }
  }

  val s2 = s.toMutableList()
  s2[0] = '_'
  var cnt2 = 1L
  for (i in 1 until s.size) {
    val a = s2[i - 1]
    val b = s2[i]
    if (a == b) {
      s2[i] = '_'
      cnt2++
    }
  }


  if (k == 1) {
    println(cnt1)
    return
  }
  if (s1.first() != s1.last() || cnt1 == cnt2) {
    println(cnt1 * k)
    return
  }
  if (s1.first() != s2.last()) {
    println((cnt1 + cnt2) * (k / 2) + cnt1 * (k % 2))
  } else {
    println(cnt1 + cnt2 * (k - 1))
  }
}


Measured memory_bytes: 33832
while True :
    n = int(input())
    if n == 0 :
        break
    
    ice = list([0] * 10)
    for i in range(n) :
        ice[int(input())] += 1
    

    for i in range(10) :
        if ice[i] > 0 :
            for j in range(ice[i]) :
                print("*", sep="", end="")
            print()
        else :
            print("-")
    
        
        


Measured memory_bytes: 7584
fn main() {
    let s: String = read();
    if s == "A" {
        println!("T");
    } else if s == "T" {
        println!("A");
    } else if s == "C" {
        println!("G");
    } else {
        println!("C");
    }
}





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

// 標準入力から一行を読み取り、指定の型に変換する関数
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

// 標準入力からn行を読み取り、各行を空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec2<T: std::str::FromStr>(n: u64) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

// 10進数での各桁の和
pub fn sum_dights(x: isize) -> isize {
    if x % 10 == 0 {
        return 0
    }
    let m = x % 10;
    m + sum_dights((x - m) / 10)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define MAX_V 1000
long long dp[110][110*MAX_V];
#define INF 1001001001001001

int main() {
    int N,W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    for(int i=0; i<N; ++i) cin >> w[i] >> v[i];

    for(int j=1; j<=N*MAX_V; ++j) dp[0][j] = INF;
    dp[0][0] = 0;
    for(int i=0; i<N; ++i) {
        for(int j=0; j<=N*MAX_V; ++j) {
            if(v[i] > j) dp[i+1][j] = dp[i][j];
            else dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]] + w[i]);
        }
    }
    int res = 0;
    for(int i=0; i<=N*MAX_V; ++i) if(dp[N][i] <= W) res = i;
    cout << res << endl;
}

Measured memory_bytes: 88192
#include <cstdio> 
#include <iostream> 
 
using namespace std; 
 
int main(void) 
{ 
  int a; 
  double b, c; 
 
  while (scanf("%d,%lf,%lf", &a, &b, &c) != EOF){ 
    int d = 0; 
    d = b / (c * c); 
    if (d >= 25.00){ 
      cout << a << endl; 
    } 
  } 
 
  return (0); 
}

Measured memory_bytes: 1232
#include <iostream>
#include <algorithm>

using namespace std;

int m[110][110] = {};

int main(void){
    // Here your code !
    int w,h,n;
    cin >> w >> h >> n;
    for(int i = 0; i < n; i++){
        int x,y,a;
        cin >> x >> y >> a;
            if(a == 1){
                
                for(int j = 0; j < h; j++){
                    for(int k = 0; k < x; k++){
                        m[j][k] = true;
                    }
                }
                
            }else if(a == 2){
                
                for(int j = 0; j < h; j++){
                    for(int k = x; k < w; k++){
                        m[j][k] = true;
                    }
                }
                
            }else if(a == 3){
                
                for(int j = 0; j < y; j++){
                    for(int k = 0; k < w; k++){
                        m[j][k] = true;
                    }
                }
                
            }else if(a == 4){
                
                for(int j = y; j < h; j++){
                    for(int k = 0; k < w; k++){
                        m[j][k] = true;
                    }
                }
            }
        
    }
    
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(!m[i][j])ans++;
        }
    }
    cout << ans << endl;
}


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

//https://qiita.com/tubo28/items/e6076e9040da57368845
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")
}

//a:対象配列 p:分割する左端のインデックス r:分割する右端のインデックス、基準値のインデックス
fn partition(a:&mut Vec<u32>, p:usize, r:usize) -> usize{
    //基準値設定
    let x = a[r];
    //左側に分割するインデックス
    let mut i = p;
    //左端から右端までを基準値と比較し、基準値以下であれば左側に移動する
    //このとき基準値以上の値が右側に移動する
    for j in p..r{
        if a[j] <= x {
            //基準値以下と基準値より大きい値をswap
            a.swap(i,j);
            i = i + 1;
        }
    }
    //基準値を境界に挿入する
    a.swap(i,r);
    i
}

fn main(){
    let n: usize = read();
    let mut a: Vec<u32> = (0..n).map(|_| read()).collect();

    let p = partition(&mut a, 0, n-1);
    for i in 0..a.len(){
        if i == p {
            print!("[{}]",a[i]);
        }else{
            print!("{}",a[i]);
        }
        if i != a.len() - 1{
            print!(" ");
        }else{
            println!("");
        }
    }

}



Measured memory_bytes: 5048
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int b[107];
int a[107];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<n;++i)
        cin>>b[i];
    a[1]=a[2]=b[1];
    for(int i=2;i<n;++i){
        if(a[i]>b[i])
            a[i]=b[i];
        a[i+1]=b[i];
    }
    int sum=0;
    for(int i=1;i<=n;++i)
        sum+=a[i];
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cctype>
#include<algorithm>
const int N=300007,M=100007;
int read(){int x=0,c=getchar();while(!isdigit(c))c=getchar();while(isdigit(c))x=x*10+c-48,c=getchar();return x;}
struct node{int l,r;}a[N];
int n,m,ans[M],t[M];
void add(int p,int v){for(;p<=m;p+=p&-p)t[p]+=v;}
void upd(int l,int r){add(l,1);if(r<m)add(r+1,-1);}
int ask(int p){int s=0;for(;p;p^=p&-p)s+=t[p];return s;}
int main()
{
    n=read(),m=read();
    for(int i=1;i<=n;++i) a[i].l=read(),a[i].r=read();
    std::sort(a+1,a+n+1,[](node&a,node&b){return a.r-a.l<b.r-b.l;});
    for(int i=1,p=1,s;i<=m;++i)
    {
	for(s=0;p<=n&&a[p].r-a[p].l<i;++p) upd(a[p].l,a[p].r);
	for(int j=i;j<=m;j+=i) s+=ask(j);
	printf("%d\n",n-p+1+s);
    }
}


Measured memory_bytes: 3584
n, m = map(int, input().split())

num = [-1 for _ in range(n)]

for _ in range(m):
    s, c = map(int, input().split())
    s -= 1

    if n >= 2 and s == 0 and c == 0:
        print(-1)
        exit()
    
    elif  num[s] != -1 and num[s] != c:
        print(-1)
        exit()
    else:
        num[s] = c

if num[0] == -1 and n != 1:
    num[0] = 1
elif num[0] == -1 and n == 1:
    num[0] = 0

num = ["0" if n == -1 else str(n) for n in num]

print("".join(num))

Measured memory_bytes: 9212
"use strict";
let input = require("fs").readFileSync("/dev/stdin", "utf8");
let len = input.split("\n")[0];
let str = input.split("\n")[1];
let ary = [];
for(let i = 1; i < len; i ++) {
    ary.push([str.slice(0, i).split(""), str.slice(i).split("")]);
}
let output = ary.map(row => Array.from(new Set(row[0])).reduce((p, c) => row[1].indexOf(c) === -1 ? p : p + 1, 0)).reduce((p, c) => p > c ? p : c);

console.log(output);

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<vector<string>> ans(N, vector<string>(0));
  
  for (int i = 0; i < M; i++) {
    int p;
    string result;
    cin >> p >> result;
    ans[p-1].push_back(result);
  }
  
  int count_ac = 0;
  int count_wa = 0;
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < ans[i].size(); j++) {
      if (ans[i][j] == "AC") {
        count_ac++;
        count_wa += j;
        break;
      }
    }
  }
  
  cout << count_ac << " " << count_wa << endl;
  
  return 0;
}


Measured memory_bytes: 10368
n=int(input())
h=list(map(int,input().split()))

count=0
ans=-1
for i in range(n-1):
  if h[i+1] <= h[i]:
    count+=1
  else:
    ans=max(ans,count)
    count=0
ans=max(ans,count)
  
print(ans)
  

Measured memory_bytes: 20436
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  int n, q;
  cin >> n >> q;
  list<int> ls[1000];
  rep(qi, q)
  {
    int type;
    cin >> type;
    if (type == 0)
    {
      int t, x;
      cin >> t >> x;
      ls[t].push_back(x);
    }
    else if (type == 1)
    {
      int t;
      cin >> t;
      for (auto itr = ls[t].begin(); itr != ls[t].end(); itr++)
        cout << (itr == ls[t].begin() ? "" : " ") << *itr;
      cout << endl;
    }
    else
    {
      int s, t;
      cin >> s >> t;
      ls[t].splice(ls[t].end(), ls[s]);
    }
  }

  return 0;
}



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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  for (int i = 0; i < N; i++) cin >> P[i];
  vector<int> Q = P;
  sort(Q.begin(), Q.end());

  int count = 0;
  for (int i = 0; i < N; i++) {
    if (P[i] != Q[i]) count++;
  }

  if (count <= 2) {
    cout << "YES";
  } else {
    cout << "NO";
  }

  return 0;
}


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

struct UnionFind{
    vector<int> par;
    vector<int> sizes;

    UnionFind(){}
    UnionFind(int n):par(n),sizes(n,1){ rep(i,n)par[i]=i; }

    //find root of x
    int find(int x){
        if(x!=par[x]) par[x] = find(par[x]);
        return par[x];
    }

    void unite(int x,int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
    }

    bool same(int x,int y){ return find(x) == find(y); }
    int size(int x){ return sizes[find(x)]; }
};


typedef priority_queue<ll, vector<ll>, greater<ll> > PQ;
// typedef  PQP;
vector<ll> a;
vector<PQ> pq;
priority_queue<pair<int,int>> choose;
UnionFind uf;


// pqのサイズのどちらかが0ならimpossible
void merge(int x,int y){
    assert(!uf.same(x,y));
    x = uf.find(x);
    y = uf.find(y);
    if(pq[x].size() < pq[y].size()){
        swap(x,y);
    }

    // pq[x].size() >= pq[y].size()
    // merge x <- y
    while(pq[y].size()){
        pq[x].push(pq[y].top());
        pq[y].pop();
    }

    uf.unite(x,y);
    int z = uf.find(x);
    // ufのルートに合わせる
    if(z != x){
        assert(pq[z].size()==0);
        pq[z].swap(pq[x]);
    }
}

int main(void){
    int n,m;
    cin>>n>>m;
    a.resize(n);
    uf = UnionFind(n);
    pq.resize(n);
    rep(i,n) {
        cin>>a[i];
        pq[i].push(a[i]);
    }
    rep(_,m){
        int x,y;
        cin>>x>>y;
        merge(x,y);
    }

    rep(i,n){
        if(pq[i].size()){
            choose.push({pq[i].size(), i});
        }
    }

    ll res = 0;
    while(choose.size()>=2){
        int x,y;
        x = choose.top().second; choose.pop();
        y = choose.top().second; choose.pop();
        res += pq[x].top() + pq[y].top();
        pq[x].pop(); pq[y].pop();
        merge(x,y);
        int z = uf.find(x);
        if(pq[z].size()==0){
            if(uf.size(z) != n){
                cout<<"Impossible"<<endl;
                return 0;
            }
            break;
        }
        choose.push({pq[z].size(), z});
    }
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 10744
import sys
input = sys.stdin.readline

_n = int(input())
_xylist = [list(map(int, input().split())) for _ in range(_n)]


def distance(a, b):
    return(abs(a[0] - b[0]) ** 2 + abs(a[1] - b[1]) ** 2) ** 0.5


def chker(xylist):
    now = xylist[0]
    remain = xylist[1:]
    pathsum = 0

    while remain:
        for item in remain:
            pathsum += distance(now, item)

        now, remain = remain[0], remain[1:]

    return pathsum


print(chker(_xylist) * 2 / _n)


Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main(){
  string s;
  cin>>s;
  int max=0;
  int start=0,end=0;
  while(start < s.size()){
    while(end < s.size() && (s[end] == 'A' || s[end]=='C'||s[end]=='G'||s[end]=='T')) end++;
    if(end - start > max) max = end -start;
    start = end+1;
    end = start;
  }

  cout << max << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++)
#define per(i,j,k) for(int i=(int)j;i>=(int)k;i--)
using namespace std;
typedef long long LL;
const int N=110000;
int fa[N],n;
int head[N],np[N],p[N],tot;
int f[N];
int q[N],m;
void dp(int x){
    if(!head[x])return;
    for(int u=head[x];u;u=np[u])dp(p[u]);
    m=0;
    for(int u=head[x];u;u=np[u])q[++m]=f[p[u]];
    sort(q+1,q+1+m);
    rep(i,1,m)f[x]=max(f[x],q[i]+m-i+1);
}
int main(){
    scanf("%d",&n);
    rep(i,2,n){
        scanf("%d",&fa[i]);
        ++tot;p[tot]=i;np[tot]=head[fa[i]];head[fa[i]]=tot;
    }
    dp(1);
    printf("%d\n",f[1]);
    return 0;
}




Measured memory_bytes: 5376
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

int main() {
    
    int N;
    string S;
    cin >> N >> S;
    int out = 0;
    for(int i=0;i<N-2;i++){
        if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') out++;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

d = {}
for st in s:
    if st not in d:
        d[st] = 0
    d[st] += 1
for st in t:
    if st not in d:
        d[st] = 0
    d[st] -= 1

print(max(0, max(d.values())))


Measured memory_bytes: 9088
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int c[][] = new int[3][3];
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				c[i][j] = sc.nextInt();
			}
		}

		int b[] = {c[0][0] - 0, c[0][1] - 0, c[0][2] - 0};
		int a[] = {0, c[1][0] - b[0], c[2][0] - b[0]};

		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (c[i][j] != a[i] + b[j]) {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 24916
using System;
using System.Linq;

namespace tst
{
    class Program
    {
        public static void Main()
        {
            string[] In1 = Console.ReadLine().Split(' ');
            int n = int.Parse(In1[0]);
            int m = int.Parse(In1[1]);
            int[] P = new int[m];
            string[] S = new string[m];
            for (int i = 0; i < m; i++)
            {
                string[] In2 = Console.ReadLine().Split(' ');
                P[i] = int.Parse(In2[0]);
                S[i] = In2[1];
            }
            int cnt = 0;//クリアした数
            int penalty = 0;//ペナルティ数
            //解き終わったindexの保存//defalutはfalse
            //bool[] Q = Enumerable.Repeat<bool>(false,n).ToArray();
            bool[] Q = new bool[n]; 
            //何回間違えたか//defalutは0
            int[] WA = new int[n];
            for (int i = 0; i < m; i++)
            {
                int index = P[i]-1;
                if (Q[index] == false)//正解してない
                {
                    if (S[i] == "AC")//正解
                    {
                        Q[index] = true;
                        cnt++;
                        penalty += WA[index];
                    }
                    else//失敗
                    {
                        WA[index]++;
                    }
                }
            }
            Console.WriteLine("{0} {1}", cnt, penalty);

        }

    }
}

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

#define maxn 100010

typedef long long ll;
typedef long double ld;
const int MAXI=INT_MAX;
const ll MAXL=LLONG_MAX;

int n, l, h, ans;

int main(){
    //freopen("TASK.inp","r",stdin);
    //freopen("TASK.out","w",stdout);
    ios_base::sync_with_stdio(0);

    cin >> n;

    if (n % 1000 == 0) cout << 0 << '\n';
    else {
        l = n / 1000;
        ans = (l * 1000 + 1000) - n;
        cout << ans << '\n';
    }

    return 0;
}


Measured memory_bytes: 3600
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

string rev(string s) {
    reverse(s.begin(), s.end());
    return s;
}

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

    int n;
    cin >> n;
    vector<int> t(n);
    for (int i = 0; i < n; i++) {
        cin >> t[i];
    }
    int m;
    cin >> m;
    vector<int> p(m), x(m);
    for (int i = 0; i < m; i++) {
        cin >> p[i] >> x[i];
    }

    int all = accumulate(t.begin(), t.end(), 0);

    for (int i = 0; i < m; i++) {
        cout << all - t[p[i] - 1] + x[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import math
D, G = map(int, input().split())
PCS = [ list(map(int, input().split())) + [(i+1)*100] for i in range(D)]

def main():
    ans = float('inf')
    for i in range(1<<D): # pattern i
        g = G
        cnt = 0
        for d in range(D):
            if i & (1<<d): # Solve d
                g -= PCS[d][0]*PCS[d][2] + PCS[d][1]
                cnt += PCS[d][0]
        if g<=0:
            ans = min(ans, cnt)
            continue

        # Not done
        for d in range(D-1, -1, -1):
            if i & (1<<d):
                continue # Solved
            # Not yet
            n = math.ceil(g/PCS[d][2])
            if n>=PCS[d][0]:
                break
            g -= n*PCS[d][2]
            cnt += n
            break
        if g<=0:
            ans = min(ans, cnt)

            
    return ans

print(main())
            

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d,x,a,cnt=0;
  cin>>n>>d>>x;
  for(int i=0;i<n;i++){
    cin>>a;
    for(int j=0;a*j+1<=d;j++){
      cnt++;
    }
  }
  cout<<cnt+x<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <string>
#include <vector>
#include <map>


using namespace std;

int main() {
    cin.tie(0);
    string s;
    cin>>s;
    int ans=0;
    for(char c:s){
        if(c=='o')ans++;
    }
    // cout<<ans;
    if(ans+(15-s.size())>=8)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N;
string S[202020];
map<string, int> M;
vector<pair<int, string>> V;
vector<string> VS;

int main()
{
    cin >> N;
    rep(i, 0, N)
    {
        cin >> S[i];
        M[S[i]]++;
    }

    for (auto e : M)
    {
        V.push_back(make_pair(e.second, e.first));
    }

    sort(V.begin(), V.end(), greater<pair<int, string>>());
    int cnt = V[0].first;
    for (auto e : V)
    {
        if (e.first == cnt)
        {
            VS.push_back(e.second);
        }
        else
        {
            break;
        }
    }
    reverse(VS.begin(), VS.end());
    for (auto e : VS)
    {
        cout << e << endl;
    }
}

Measured memory_bytes: 34288
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  int n; cin >> n;
  vector<long long> l(n);
  for(int i=0; i<n; i++) cin >> l[i];
  sort(all(l));
  int cnt = 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 (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
        if (l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;


  return 0;
}

// EOF

Measured memory_bytes: 3620
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define m_p make_pair
#define sz(x) (int)x.size()
#define line cerr<<"--------------------\n";
#define see(x) cerr<<x<<" "
#define seeln(x) cerr<<x<<endl
#define out(x) cerr<<#x<<" = "<<x<<" "
#define outln(x) cerr<<#x<<" = "<<x<<endl
#define outarr(x,l,r) cerr<<#x"["<<l<<"-"<<r<<"] = "; for (int _i=l;_i<=r;++_i) cerr<<x[_i]<<" ";cerr<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define gc() getchar()
//char buf[1<<23],*p1=buf,*p2=buf;
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <class T> void read(T &x)
{
    x=0; char c=gc(); int flag=0;
    while (c<'0'||c>'9') flag|=(c=='-'),c=gc();
    while (c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=gc();
    if (flag) x=-x;
}
template <class T> inline T _max(T a,T b){return a>b ? a : b;}
template <class T> inline T _min(T a,T b){return a<b ? a : b;}
template <class T> inline bool checkmax(T &a,T b){return b>a ? a=b,1 : 0;}
template <class T> inline bool checkmin(T &a,T b){return b<a ? a=b,1 : 0;}
const int N=10005;
const ll inf=1000000000000000000LL;
int a[2],b[2];
void init()
{
	for (int i=1;i<=2;++i) read(a[i]);
	for (int i=1;i<=2;++i) read(b[i]);
	ll ans=-inf;
	for (int i=1;i<=2;++i)
	{
		for (int j=1;j<=2;++j)
		{
			checkmax(ans,(ll)a[i]*b[j]);
		}
	}
	printf("%lld\n",ans);
}

void solve()
{
}

int main()
{
	init();
	solve();
	return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int ans = 0;
  if (A >= B)
  {
    ans += A;
    A--;
  } else
  {
    ans += B;
    B--;
  }
  ans += max(A, B);
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3632
n,w1=map(int,input().split())
dp=[]
for i in range(n):
    temp=[]  
    for j in range(w1+1):
          temp.append(-1)
    dp.append(temp)
# dp=[[-1]*(w1+1)]*n
dp.append([0]*(w1+1))
# print(dp)
w=[]
v=[]
for i in range(n):
  a,b=map(int,input().split())
  v.append(a)
  w.append(b)

for i in range(n-1,-1,-1):
  for j in range(w1+1):
    # print(i,j,dp[i][j],dp[i+1][j],dp[i+1][j-w[i]],v[i])    
    
    if j<w[i]:
      dp[i][j]=dp[i+1][j]
    else:
      dp[i][j]= max(dp[i+1][j],dp[i+1][j-w[i]]+v[i])
    # print(dp)
print(dp[0][w1])


Measured memory_bytes: 24724
/*
author : seryu
title : CODE FESTIVAL 2016 Final_"Exactly N points"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
    int n;
    cin >> n;
    int k = 1;
    while (true)
    {
        if(k*(k-1) < 2*n && 2*n <= k*(k+1))
        {
            break;
        }
        k++;
    }
    int s = k*(k+1)/2;
    s -= n;
    reps(i, k)
    {
        if(i != s)
        {
            cout << i << endl;
        }
    }
    return;	
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define mod 1000000007
#define PI acos(-1)
#define fi first
#define se second
#define lowbit(x) (x&(-x))
#define mp make_pair
#define pb push_back
#define ins insert
#define si size()
#define E exp(1.0)
#define fixed cout.setf(ios::fixed)
#define fixeds(x) setprecision(x)
#pragma GCC optimize(2)
using namespace std;
inline ll read(){ll s=0,w=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();return s*w;}
void put1(){ puts("YES") ;}void put2(){ puts("NO") ;}void put3(){ puts("-1"); }
ll qp(ll a,ll b, ll p){ll ans = 1;while(b){if(b&1){ans = (ans*a)%p;--b;}a =
(a*a)%p;b >>= 1;}return ans%p;}ll Inv(ll x,ll p){return qp(x,p-2,p);}
ll Cal(ll n,ll m,ll p){if (m>n) return 0;ll ans = 1;for(int i = 1; i <= m; ++i)
ans=ans*Inv(i,p)%p*(n-i+1)%p;return ans%p;}

const int manx=3e5+5;



int main(){
    ll a=read(),b=read();
    ll c=a*b;
    if(a==1||b==1) cout<<1;
    else if(c&1) cout<<c/2+1;
    else cout<<c/2;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 100005;
// const int MAX = 8;
const int mod = 1000000007;
/* struct for mod Calculation*/
struct mint {
    ll x;
    mint(ll x = 0):x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
/* global variables */
vector<vector<int> > G(MAX, vector<int>());
int N, K;
/* function */
void bfs() {
    stack<int> q;
    q.push(0);
    vector<ll> visited(MAX);
    visited[0] = 1;
    mint ans = K;
    while (!q.empty()) {
        int from = q.top(); q.pop();
        int cnt = from ? K - 2 : K - 1;
        for (int to : G[from]) {
            if (visited[to] != 0) continue;
            visited[to] = 1;
            q.push(to);
            ans *= cnt;
            cnt--;
        }
    }

    for (int i = 0; i < N; i++) { ans *= visited[i];}
    cout << ans.x << '\n';
}
/* main */
int main(){
    cin >> N >> K;
    int u, v;
    for (int i = 0; i < N - 1; i++) {
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    bfs();
}


Measured memory_bytes: 7288
#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 <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

int dx[]={1, 0, -1, 0};
int dy[]={0, -1, 0, 1};

int main(){
    int n; cin>>n;
    string s; cin>>s;
    vector<int> cnt(26, 0);
    for(int i=0; i<n; i+=2){
        cnt[s[i] - 'a']++;
    }

    sort(cnt.begin(), cnt.end(), greater<int>());

    set<int> st;
    int ans = 0;
    int pcnt = -1;
    for(int i=0; i<26; i++){
        int num = cnt[i];
        if(num == 0) break;
        int sum = 0;
        while(i + 1 < n && num == cnt[i + 1] && num != 1){
            i++;
            sum++;
        }

        pcnt++;
        if(sum == 0){
            if(num == 1) ans++;
            else ans += 3;
        }
        else{
            ans += (sum + 1) * 2 + 3;
        }
    }

    cout << ans + pcnt << endl;
}


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

using namespace std;

int main() {
  #ifdef _OFFLINE_
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  long long q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;
  long long t = min(q * 8, min(h * 4, min(s * 2, d)));
  long long ans = n / 2 * t;
  n %= 2;
  t = min(q * 4, min(h * 2, s));
  ans += n * t;
  cout << ans;
}

Measured memory_bytes: 256
import itertools

 
input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]
N,M,Q = Line[0],Line[1],Line[2]

l = list(range(1, M+1))

# print(l)

q_list = []

for _ in range(Q):
    input_line = input()
    Line = input_line.split()
    Line = [int(s) for s in Line]
    q_list.append(Line)

p_list = list(itertools.combinations_with_replacement(l, N))

max_point = 0

for i in p_list:
    # print(i)
    now_point = 0
    for x in q_list:
        # print("-------", x)
        if i[x[1]-1] - i[x[0]-1] == x[2]:
            now_point += x[3]
            # print(now_point)
    if now_point > max_point:
        max_point = now_point
    # print(max_point,now_point)
print(max_point)

Measured memory_bytes: 21620
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;
    cin>>a>>b;
    cout<<(a+b)%24<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
using namespace std;



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

	long long N;
	vector<long long> trans(5);
	long long tmp;

	cin >> N;
	REP(i, 5) {
		cin >> trans[i];
	}
	
	tmp = *min_element(trans.begin(), trans.end());

	tmp = (N + (tmp - 1)) / tmp;

	cout << tmp + 4 << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	
	static int w;
	static int h;
	
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		
		while(true){
			
			w = sc.nextInt();
			h = sc.nextInt();
			if(w == 0 && h == 0){
				break;
			}
			sc.nextLine();
			int[][] map = new int[w][h];
			String line;
			int x = 0;
			int y = 0;
			
			for(int i = 0; i < h; i++){
				line = sc.nextLine();
				for(int j = 0; j < w ; j++){
					if(line.charAt(j) == '.'){
						map[j][i] = 1;
					}else if(line.charAt(j) == '#'){
						map[j][i] = 0;
					}else if(line.charAt(j) == '@'){
						map[j][i] = 2;
						x = j;
						y = i;
					}
				}
			}
			
			map = Sosaku(x , y, map);
			
			int sum = 0;
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					if(map[j][i] == 2){
						sum++;
					}
				}
			}
			
			System.out.println(sum);
		}
		
	}

	private static int[][] Sosaku(int x, int y, int[][] map) {
		if(x < w - 1 && map[x + 1][y] == 1){
			map[x + 1][y] = 2;
			map = Sosaku(x + 1, y, map);
		}
		if(x > 0 && map[x -1][y] == 1){
			map[x - 1][y] = 2;
			map = Sosaku(x - 1, y, map);
		}
		if(y < h - 1 && map[x][y + 1] == 1){
			map[x][y + 1] = 2;
			map = Sosaku(x, y + 1, map);
		}
		if(y > 0 && map[x][y - 1] == 1){
			map[x][y - 1] = 2;
			map = Sosaku(x, y - 1, map);
		}
		return map;
	}

}

Measured memory_bytes: 12000
a = input().split()
A = int(a[0])
B = int(a[1])
K = int(a[2])
cd = []
i = 1
if A < B:
    big = B
else:
    big = A
while i <= big:
    if A % i == 0 | B % i == 0:
        cd.append(i)
    i += 1

print(cd[len(cd) - K])

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := map[int]int{}
	aa := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
		m[aa[i]] = i
	}

	sort.Ints(aa)
	ans := 0
	for i := 0; i < n; i++ {
		if (m[aa[i]]-i)%2 == 0 {
			continue
		}
		ans++
	}
	fmt.Fprintln(writer, ans>>1)
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>

using namespace std;

bool is_palindrome(const string &s) {
  bool res = true;
  for (int i = 0; i < s.size() / 2; i++) {
    if (s[i] != s[s.size() - i - 1]) {
      res = false;
      break;
    }
  }

  return res;
}

int solve(string &s, int l, int r) {
  if (l >= r) {
    return 0;
  }

  char l_ch = s[l], r_ch = s[r];
  if (l_ch == r_ch) {
    return solve(s, l + 1, r - 1);
  } else if (l_ch != 'x') {
    return solve(s, l, r - 1) + 1;
  } else {
    return solve(s, l + 1, r) + 1;
  }
}

int main(int argc, const char *argv[]) {
  string s;
  cin >> s;

  string s2;
  copy_if(s.begin(), s.end(), back_inserter(s2),
          [](char ch) { return ch != 'x'; });
  if (!is_palindrome(s2)) {
    cout << -1 << '\n';
    return 0;
  }

  cout << solve(s, 0, s.size() - 1) << '\n';
  return 0;
}

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }
    sort(h.begin(),h.end());
    int diff=INT32_MAX;
    int tdif;
    for(int i = 0; i < n-k+1; i++) {
        tdif=h[i+k-1]-h[i];
        diff=min(diff,tdif);
    }
    cout << diff << "\n";
    return 0;
}

Measured memory_bytes: 640
from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)

def scc(V, E):
    g = defaultdict(list)
    rg = defaultdict(list)
    for u, v in E:
        g[u].append(v)
        rg[v].append(u)


    o = []
    done = set()
    for u in V:
        if u in done:
            continue

        s = [(u, True)]
        while s:
            u, f = s.pop()
            if f:
                if u in done:
                    continue
                done.add(u)
                s.append((u, False))
                for v in g[u]:
                    if v in done:
                        continue
                    s.append((v, True))
            else:
                o.append(u)

    done = set()
    ans = []
    while o:
        u = o.pop()
        if u in done:
            continue

        s = [u]
        vv = [u]
        done.add(u)
        while s:
            u = s.pop()
            for v in rg[u]:
                if v in done:
                    continue
                vv.append(v)
                s.append(v)
                done.add(v)
        ans.append(vv)


    return ans


def atcoder_practice2_g():
    N, M = map(int, input().split())

    E = []
    for _ in range(M):
        a, b = map(int, input().split())
        E.append((a, b))
    V = list(range(N))
    vv = scc(V, E)
    print(len(vv))
    for r in vv:
        print(len(r), *r)


def test():
    g = {
        1: [2],
        5: [2],
        2: [4, 3],
        3: [4, 7, 6],
        4: [5, 8],
        6: [9],
        7: [8],
        8: [9],
        9: [7, 10],
        10: []
    }

    V = list(range(1, 11))
    E = []
    for u, e in g.items():
        for v in e:
            E.append((u, v))

    vv = scc(V, E)
    for r in vv:
        print(r)


if __name__ == "__main__":
    # test()
    atcoder_practice2_g()


Measured memory_bytes: 336604