akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
from math import isinf
import itertools
n, e = map(int, stdin.readline().split())
d = [[float('inf')] * n for _ in range(n)]
for i in range(n):
    d[i][i] = 0
for i in range(e):
    u, v, c = map(int, stdin.readline().split())
    d[u][v] = c
for k, i, j in itertools.product(range(n), repeat=3):
    if d[i][j] > d[i][k] + d[k][j]:
        d[i][j] = d[i][k] + d[k][j]
for i in range(n):
    if d[i][i] < 0:
        print("NEGATIVE CYCLE")
        exit(0)
for di in d:
    print(' '.join(('INF' if isinf(dij) else str(dij) for dij in di)))

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

class D
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var js = new int[h[0]].Select(_ => read()).ToLookup(j => j[0], j => j[1]);

		var r = 0;
		var l = new List<int>();
		for (var i = 1; i <= h[1]; i++)
		{
			foreach (var b in js[i])
			{
				var k = l.BinarySearch(b);
				if (k < 0) k = ~k;
				l.Insert(k, b);
			}

			if (!l.Any()) continue;
			r += l.Last();
			l.RemoveAt(l.Count - 1);
		}
		Console.WriteLine(r);
	}
}


Measured memory_bytes: 25136
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        int result = 0;
        int[] array = a;
        int len = a.length;
        while (len == array.length) {
            len = array.length;
            array = Arrays.stream(array).filter(c -> c % 2 == 0).map(c -> c / 2).toArray();
            if (len == array.length) {
                result++;
            }
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 26964
use std::io;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();

    stdin.read_line(&mut buf).unwrap();

    let n: usize = buf.trim().parse().unwrap();

    let mut s: Vec<usize> = Vec::new();
    let mut sum: usize = 0;
    let mut non10: Vec<usize> = Vec::new();

    for i in 0..n {
        buf = String::new();
        stdin.read_line(&mut buf).unwrap();
        s.push(buf.trim().parse().unwrap());
        sum += s[i];
        if s[i] % 10 > 0 {
            non10.push(s[i]);
        }
    }

    non10.sort();
    if sum % 10 == 0 {
        if non10.len() == 0 {
            sum = 0;
        } else {
            sum -= non10[0];
        }
    }

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

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define maxn 500005
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fu(i,l,r) for(int i=(l);i<=(r);i++)
#define fd(i,l,r) for(int i=(l);i>=(r);i--)
#define Set set<int>
using namespace std;
#define Inf 2e8
#define int long long
#define P pair<int,int>
int n,m,a[maxn],b[maxn];
int z[maxn],y[maxn];

int32_t main()
{
    IOS;
    cin>>n;
    int sum=0,fu=0;
    int W=Inf;
    fu(i,1,n)
    {
        cin>>a[i];
        if(a[i]<0)fu++;
        sum+=abs(a[i]);
        W=min(abs(a[i]),W);
    }
    if(n==1)
    {
        cout<<abs(a[1]);
        return 0;

    }
    if(fu%2)cout<<sum-2*W;
    else cout<<sum;
    return 0;
}


Measured memory_bytes: 4352
def c_Otoshidama(N, Y):
    ans = ''

    for yukichi in range(0, 2001):
        for higuchi in range(0, 2001):
            noguchi = N - yukichi - higuchi
            if noguchi >= 0:
                if Y == yukichi * 10000 + higuchi * 5000 + noguchi * 1000:
                    return '{} {} {}'.format(yukichi, higuchi, noguchi)
    return '-1 -1 -1'
  
N,Y=[int(i) for i in input().split()]
print(c_Otoshidama(N, Y))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

struct COM{
  ll modbeki(ll x, ll nn){
    ll res = 1;
    while(nn > 0){
      if(nn & 1) res = res * x % MOD;
      x = x * x % MOD;
      nn >>= 1;
    }
    return res;
  }
  vll fact, ifact;
  COM(ll n): fact(n+1), ifact(n+1){
    assert(n < MOD);
    fact[0] = 1LL;
    for(ll i = 1; i <= n; i++) fact[i] = fact[i-1]*i%MOD;
    ifact[n] = modbeki(fact[n], MOD-2);
    for(ll i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i%MOD;
  }
  ll operator()(int n, int k){
    if(k < 0 || k > n) return 0;
    return fact[n]*ifact[k]%MOD*ifact[n-k]%MOD;
  }
};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  COM c(100010);
  ll N, K;
  cin >> N >> K;
  vll A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  sort(ALL(A));
  ll ans = 0;
  for(int i = 0; i < N; i++){
    ll plus = 0, minus = 0;
    if(i >= K - 1){
      plus += c(i, K-1);
      plus %= MOD;
    }
    if(i + K - 1 < N){
      minus += c(N-i-1, K-1);
      minus %= MOD;
    }
    ans += A.at(i) * (plus - minus) % MOD;
    (ans += MOD) %= MOD;
  }
  cout << ans << endl;
}

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

int main(void)
{
    int N,M,a,b;
    int rec[50];
    
    cin >> N >> M;

    rep(i,N)
        rec[i] = 0;

    rep(i,M){
        cin >> a >> b;
        rec[a-1]++;
        rec[b-1]++;
    }

    rep(i,N)
        cout << rec[i] << endl;

    
    return 0;
}

Measured memory_bytes: 3624
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class AC>void in(AC &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,x,ans,d[1005],l[1005];
int main(){
	in(n);in(x);
	for(int i=1;i<=n;i++)in(l[i]);
	for(int i=2;i<=n+1;i++){
		d[i]=d[i-1]+l[i-1];
		if(d[i]<=x)ans++;
	}
	if(x>=0)ans++;
	printf("%d\n",ans);
    return 0;
}

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

int n, ma, mb, ans, a[45], b[45], c[45], dp[45][405][405];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	
	cin >> n >> ma >> mb;

	for (int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}

	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= 400; j++) {
			for (int k = 0; k <= 400; k++) {
				dp[i][j][k] = 1e9;
			}
		}
	}

	dp[0][0][0] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= 400; j++) {
			for (int k = 0; k <= 400; k++) {
				if (dp[i-1][j][k] != 1e9) {
					dp[i][j][k] = min(dp[i][j][k], dp[i-1][j][k]);
					dp[i][j+a[i]][k+b[i]] = min(dp[i][j+a[i]][k+b[i]], dp[i-1][j][k] + c[i]);
				}
			}
		}
	}

	ans = 1e9;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= 400; j++) {
			for (int k = 0; k <= 400; k++) {
				if (dp[i][j][k] != 1e9) {
					int gcd = __gcd(j, k);
					if (gcd == 0) {
						continue;
					}

					if (ma == j/gcd && mb == k/gcd) {
						ans = min(ans, dp[i][j][k]);
					}
				}
			}
		}
	}

	if (ans == 1e9) {
		cout << "-1\n";
	}
	else {
		cout << ans << '\n';
	}
	
	return 0;
}

Measured memory_bytes: 26880
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<=ll(b);++i)
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
map<char,int> 
count_same_elements(const vector<char>& v){map<char,int>cmap; for_each(v.begin(),v.end(),[&cmap](int x){cmap[x]++;}); return cmap; }
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A> bool
all_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]<1){flag=false;}; }return flag;}
template<class A> bool
any_of(const vector<A>& v){bool flag=false;rep(i,v.size()){ if(v[i]>0){flag=true; break;}; }return flag;}
template<class A> bool
none_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]>0){flag=false;}; }return flag;}
template<class T,class U>
void msg_with_compare(T A,T B,U A_greater_B,U A_eq_B,U A_less_B){
    if(A==B){cout<<A_eq_B<<"\n";}else if(A>B){cout<<A_greater_B<<"\n";}else{cout<<A_less_B<<"\n";}}
template<class B,class T>
void msg_with_boolean(B A,T true_msg,T false_msg){cout<< ( A? true_msg:false_msg);}
template<class B,class T>
void msg_with_boolean(B A1,B A2,T both_true_msg,T true_false_msg,T false_true_msg,T both_false_msg){
    if(A1){if(A2){cout<<both_true_msg;}else{cout<<true_false_msg;}
    }else{if(A2){cout<<false_true_msg;}else{cout<<both_false_msg;}}
}
template<class T>
void scan_vector(long long size,vector<T>& vector){
    vector.resize(size);
    for(long long i=0;i<size;++i){
        cin>>vector[i];
    }
}

ll n,x;
string s,t;
void input(){
    cin>>s>>t;
}
void src(){
    bool f=false;
    rep(i,s.length()){
        s.insert(s.begin(),s.back()); s.pop_back();
        if(s==t){ f=true;break;}
    }
    msg_with_boolean(f,"Yes","No");
}   

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
use std::cmp::min;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let mut edges = vec![];
    for i in 0..n {
        let w1: u64 = sc.read();
        let w2: u64 = sc.read();
        edges.push((w1, true, i));
        edges.push((w2, false, i));
    }

    edges.sort();
    let mut ans = 1 << 60;

    let e1 = edges.iter().take(n).cloned().collect();
    if let Some(a) = count(e1) {
        ans = min(ans, a);
    }

    let mut e2 = edges.iter().take(n - 1).cloned().collect::<Vec<_>>();
    e2.push(edges[n]);
    if let Some(a) = count(e2) {
        ans = min(ans, a);
    }
    let mut e2 = edges.iter().take(n - 2).cloned().collect::<Vec<_>>();
    e2.push(edges[n - 1]);
    e2.push(edges[n]);
    if let Some(a) = count(e2) {
        ans = min(ans, a);
    }
    let mut e2 = edges.iter().take(n - 1).cloned().collect::<Vec<_>>();
    e2.push(edges[n + 1]);
    if let Some(a) = count(e2) {
        ans = min(ans, a);
    }

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

fn count(edges: Vec<(u64, bool, usize)>) -> Option<u64> {
    let n = edges.len();

    let mut used = vec![false; n];
    let mut right_count = 0;
    let mut sum = 0;
    for (w, is_right, i) in edges.into_iter() {
        used[i] = true;
        if is_right {
            right_count += 1;
        }
        sum += w;
    }

    if used.iter().any(|&u| !u) || right_count == 0 || right_count == n {
        Some(sum)
    } else {
        None
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

using namespace std;
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
const int N=1e9+5;///1e18+5

void solve()
{
   string s;
   cin>>s;
   if(s[0]=='R' and s[1]=='R' and s[2]=='R')
   {
       cout<<3<<endl;
   }
   else if(s[0]=='R' and s[1]=='R' and s[2]!='R')
   {
       cout<<2<<endl;
   }
   else if(s[0]!='R' and s[1]=='R' and s[2]=='R')
   {
       cout<<2<<endl;
   }
   else if(s[0]!='R' and s[1]!='R' and s[2]!='R')
   {
       cout<<0<<endl;
   }
   else
   {
       cout<<1<<endl;
   }

}


int main()
{
    //freopen("input.txt","r",stdin);
    IO;
    int tc=1;
    //cin>>tc;
    while(tc--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.File;
import java.util.*;

public class Main {

    public static StringBuilder output = new StringBuilder();

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int arr[] = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        Solver solver = new Solver();
        solver.solve(arr);
        System.out.println(output);
    }

}

class Solver {
    public void solve(int arr[]) {
        int ans = Integer.MAX_VALUE;
        for (int i = -100; i <= 100; i++) {
            // Try each number to find min
            int curr = 0;
            for (int j = 0; j < arr.length; j++) {
                curr += (arr[j] - i) * (arr[j] - i);
            }
            ans = Math.min(curr, ans);
            // arr[idx] - i
        }
        Main.output.append(ans);
    }
}

Measured memory_bytes: 36012
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //ATTENTION: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/
int A, B;
/**********************************/

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

    if(A%3==0 || B%3==0 || (A+B)%3==0) {
        cout << "Possible" << endl;
    }
    else {
        cout<< "Impossible" << endl;
    }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

class MinCostFlow:
    """ 最小費用流(ダイクストラ版)：O(F*E*logV) """

    INF = 10 ** 18

    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]

    def add_edge(self, fr, to, cap, cost):
        G = self.G
        G[fr].append([to, cap, cost, len(G[to])])
        G[to].append([fr, 0, -cost, len(G[fr])-1])

    def flow(self, s, t, f):
        from heapq import heappush, heappop

        N = self.N; G = self.G
        INF = MinCostFlow.INF

        res = 0
        H = [0] * N
        prv_v = [0] * N
        prv_e = [0] * N

        while f:
            dist = [INF] * N
            dist[s] = 0
            que = [(0, s)]

            while que:
                c, v = heappop(que)
                if dist[v] < c:
                    continue
                for i, (w, cap, cost, _) in enumerate(G[v]):
                    if cap > 0 and dist[w] > dist[v] + cost + H[v] - H[w]:
                        dist[w] = r = dist[v] + cost + H[v] - H[w]
                        prv_v[w] = v; prv_e[w] = i
                        heappush(que, (r, w))
            if dist[t] == INF:
                return INF

            for i in range(N):
                H[i] += dist[i]

            d = f; v = t
            while v != s:
                d = min(d, G[prv_v[v]][prv_e[v]][1])
                v = prv_v[v]
            f -= d
            res += d * H[t]
            v = t
            while v != s:
                e = G[prv_v[v]][prv_e[v]]
                e[1] -= d
                G[v][e[3]][1] += d
                v = prv_v[v]
        return res

N = INT()
A = LIST()

mcf = MinCostFlow(N*2+2)
s = N * 2
t = N * 2 + 1
for i, a in enumerate(A):
    mcf.add_edge(s, i, 1, 0)
    mcf.add_edge(N+i, t, 1, 0)
    for j in range(N):
        # 完全順列なので、A[i] == i のペアには辺を張れない
        if a == j+1:
            continue
        cost = a * abs(i - j)
        mcf.add_edge(i, N+j, 1, cost)

res = mcf.flow(s, t, N)
print(res)



Measured memory_bytes: 8444
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=5e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
  }


int n,k,c;
string s;
vi nax;

void solve() {
     int n,k,c;
     cin>>n>>k>>c;
     string s;
     cin>>s;
   
     vi a,b;
     
     for(int i=0;i<n;i++) {
		   if(s[i]=='o') {
			     a.pb(i);
			     i+=c;
			   }
		 }
		 
	 for(int i=n-1;i>=0;i--) {
		   if(s[i]=='o') {
			     b.pb(i);
			     i-=c;
			   }
		 }
	  
	  
	  rep(i,0,k) {
		    if(a[i]==b[k-i-1]) {
				   cout<<a[i]+1<<endl;
				}
		  }
	  	 
		 
              
}

    
int32_t main() {
	cool;
	int t=1;	

	//cin>>t;
	while(t--)
	  solve();

  return 0;	   
}


Measured memory_bytes: 8096
import java.util.Scanner;

public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		int h,w;
		h = sc.nextInt();
		w = sc.nextInt();
		while(h != 0 && w != 0){
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					System.out.print("#");
				}
				System.out.println("");
			}
			System.out.println("");
			h = sc.nextInt();
			w = sc.nextInt();
		}
	}
}

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

int main(){
    int n,x;
    cin >> n >> x;
    vector<int> a(n);
    for(int i =0; i <n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(i == n - 1){
            if(x == a[i])
            cnt++;
        }
        if(i < n - 1){
            if(x >= a[i]){
                cnt++;
                x -= a[i];
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[1000];
string st;
int main()
{
	int x=0,n,m=0;;;
	cin>>n>>st;

	for(int i=0 ; i<st.size() ;i++)
	{

			if( st[i] == 'D' )
            {
				x--;

            }
         else
         {
				x++;


         }
			m= max ( x , m ) ;
	}
 cout<<m;
 	return 0;
}


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

int main()
{
    int n, a, b;

#if true
    cin >> n >> a >> b;
#else
    n = 4;
    a = 2;
    b = 7;

    n = 20;
    a = 50;
    b = 50;
#endif
    int train = n * a;
    int taxi = b;
    cout << (train > taxi ? taxi : train) << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

char crs[maxN];
int poss[maxN], n, m;

bool testea(int num) {
	string str = to_string(num);
	for(int i = 0; i < m; i++)
		if(str[poss[i]] != crs[i]) return false;
	return true;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	cin >> n >> m;
	for(int i = 0; i < m; i++)
		cin >> poss[i] >> crs[i], poss[i]--;
	int ans = -1;
	int pot = 1;
	while(n--) pot *= 10;
	for(int i = pot / 10; ans == -1 && i < pot; i++)
		if(testea(i)) ans = i;
	if(pot == 10 && testea(0)) ans = 0;
	cout << ans << '\n';
}


Measured memory_bytes: 384
#include <stdio.h>

int main(){
        int W, H, x, y, r;

        do{
                scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
        }while(!(-100 <= x && x <= 100 || -100 <= y && y <= 100 || 0 <= W && W <= 100 || 0 <= H && H <= 100 || 0 <= r || r <= 100));

        if(W <= x || H <= y || x-r < 0 || y-r < 0)
                puts("No");
        else
                puts("Yes");

        return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
vector<ll>vec[1000006];
ll ans=0;
ll vis[1000006],val[1000006];
ll dfs(ll k)
{
  ll ma=0;
  vis[k]=1;
  for(ll j:vec[k])
  {
    if(vis[j]==0)
      ma=max(ma,dfs(j)+1);
    else
      ma=max(ma,val[j]+1);
   }
   val[k]=ma;
   ans=max(ans,ma);
  return ma;
}
int main(void)
{
  ll n,i,m,x,y;
  cin>>n>>m;
  for(i=0;i<m;i++)
  {
    cin>>x>>y;
    vec[x].push_back(y);
  }
  memset(vis,0,sizeof(vis));
  memset(val,0,sizeof(val));
  for(i=1;i<=n;i++)
  {
    if(vis[i]==0)
      dfs(i);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 44416
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cstring>
#include <stdio.h>
#include <string.h>
using namespace std;
#define ll long long



int main() {

    ll n;
    ll k;
    cin>>n>>k;

    string s;
    cin>>s;

    ll total_count = 0;
    for(int i = 0; i < n; i++) {
        if(s[i] == 'L' && i - 1 >= 0 && s[i - 1] == 'L') {
            total_count++;
        }

        if(s[i] == 'R' && i + 1 < n && s[i + 1] == 'R') {
            total_count++;
        }
    }

    if(total_count + k*2 < n - 1) {
        cout<<total_count+k*2<<'\n';
    }
    else {
        cout<<n - 1<<'\n';
    }

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int x,y,blank;
    while (1) {
        cin >> x >>y;
        if (x==0&&y==0) {
            break;
        }
        if (x >y) {
            blank = y;
            y=x;
            x=blank;
        }
        cout << x <<" "<< y << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    var s = mutableListOf<String>()
    (1..N).forEach {
        val str = readLine()!!
        s.add(str.toCharArray().sorted().toString())
    }


    val countMap = hashMapOf<String, Long>()
    s.forEach {
        val string = it.toString()
        if (countMap.contains(string)) {
            countMap[string] = countMap[string]!! + 1L
        } else {
            countMap[string] = 1
        }
    }

    var answer = 0L
    countMap.entries
            .filter { it.value > 1 }
            .forEach {
                val size = it.value
                answer += size * (size - 1L) / 2L
            }
    println(answer)
}

Measured memory_bytes: 80896
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        int f = scanner.nextInt();
        int r = scanner.nextInt();
        while (m != -1 || f != -1 || r != -1) {
            if (m == -1 || f == -1 || (m + f) < 30) {
                System.out.println("F");
            } else if (30 <= (m + f) && (m + f) < 50 && r < 50) {
                System.out.println("D");
            } else if (50 <= (m + f) && (m + f) < 65 || 30 <= (m + f) && (m + f) < 50 && r >= 50) {
                System.out.println("C");
            } else if (65 <= (m + f) && (m + f) < 80) {
                System.out.println("B");
            } else {
                System.out.println("A");
            }
            m = scanner.nextInt();
            f = scanner.nextInt();
            r = scanner.nextInt();
        }
    }
}



Measured memory_bytes: 26468
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;
typedef std::vector<std::vector<int>> vvi;
struct P { int x; int y; };

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

int H, W, D; 
std::vector<int> dp;
std::vector<P> UA;

int sol(int a) {
  if ( a == (a%D) ) return 0;
  if ( dp[a] != -1 ) return dp[a];
  int b = a - D;
  P ap = UA[a];
  P bp = UA[b];
  return dp[a] = sol(b) + std::abs(ap.x-bp.x) + std::abs(ap.y-bp.y);
}

// Work case.
int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::cin >> H >> W >> D;

  dp.resize(H*W+1, -1);
  UA.resize(H*W+1);
  vvi A(H, std::vector<int>(W));

  rep(i,H) rep(j,W) {
    std::cin >> A[i][j];
    UA[A[i][j]] = { i, j };
  }

  int Q; std::cin >> Q;
  rep(i,Q) {
    int L,R; std::cin >> L >> R;
    std::cout << sol(R) - sol(L) << std::endl;
  }

  return 0;
}


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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


string s;
int N;
string s1,s2;
int cnt;
int temp;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >>N;
    cin >> s;

    for ( int i = 0; i < N - 1; i++){

        if( i > 0 && s1.find(s[i]) == string::npos ){ s1.push_back( s[i]);

        }
        else if ( i == 0){
            s1.push_back( s[0]);
        }

        for(int j = i + 1; j < N ;j++){

            if( j > i && s2.find(s[j]) ==  string::npos){  s2.push_back( s[j] );

            }
            else if( j == i + 1){ s2.push_back( s[j]);
            }
        }

        //dump(s1);
        //dump(s2);

        for ( int j1 = 0; j1 < s1.size() ;j1++){

            for( int j2 = 0; j2 < s2.size(); j2++){

                /*if( s2.find( s1[j1] )) {
                    temp++;
                }*/

                if( s1[j1] == s2[j2]){
                    temp++;
                }
                //dump(j1);
                //dump(temp);
            }


        }

        cnt = max( temp, cnt);

        s2.erase( s2.begin(), s2.end());
        temp = 0;

    }
;
    cout << cnt << endl;



    return 0;
}


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

class UnionFind{
    private:
        vector<int> parent,rank,tree_w;
        int tree_num;
    public:
        UnionFind(int size){
            tree_num=size;
            for (int i=0; i<size; i++){
                parent.push_back(i);
                rank.push_back(0);
                tree_w.push_back(1);
            }
        }

        int findset(int x){
            return x==parent[x] ? x : parent[x]=findset(parent[x]);
        }

        void unite(int x,int y){
            x=findset(x);y=findset(y);
            if (x==y) return;
            if (rank[x]>rank[y]) swap(x,y);
            parent[x]=y;
            tree_num-=1;
            tree_w[y]+=tree_w[x];
            if (rank[x]==rank[y]) rank[y]+=1;
        }

        bool same(int x,int y){
            return findset(x)==findset(y);
        }

        int tree_number(){
            return tree_num;
        }

        int tree_weight(int x){
            return tree_w[findset(x)];
        }
};

int n,q;
int main(){
    cin >> n >> q;
    UnionFind uf(n);
    for(int i=0; i<q; i++){
        int c,x,y;
        cin >> c >> x >> y;
        if(c==0) uf.unite(x,y);
        else cout << uf.same(x,y) << endl;
    }
    return 0;
}

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

bool is_prime(int x) {
	if (x <= 1)return false;
	for (int i = 2; i*i <= x ; i++)
		if (x % i == 0) return false;
	
		return true;

}

int main() {
	int x;
	cin >> x;

	int p = x;
	while (!is_prime(p))p++;
	
	cout << p << endl;
	return 0;
}

Measured memory_bytes: 3620
// ConsoleApplication.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdio.h"
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int binarySearch(vector<int> v, const int num) {
	int first = 0, last = v.size();
	while (first < last) {
		const int mid = static_cast<int>(floor(0.5 * static_cast<double>(first + last)));
		const int middleValue = v.at(mid);
		if (middleValue == num) {
			return mid;
		}
		else if (middleValue < num) {
			first = mid + 1;
		}
		else {
			last = mid;
		}
	}
	return v.size();
}

int main()
{
	int n;
	cin >> n;
	vector<int> S(n);
	for (int& i : S) cin >> i;

	int q;
	cin >> q;
	vector<int> T(q);
	for (int& i : T) cin >> i;
	
	cout << count_if(T.begin(), T.end(), [&](const int num) {return S.size() != binarySearch(S, num); }) << endl;

	
	return 0;
}


Measured memory_bytes: 3864
#include <stdio.h>
#include <math.h>

int main(void){
    int n=0;
    int i=0;
    int s[1000]={0};
    double heikin,bunsan,hensa;

    while(1){
        heikin=0.0;
        bunsan=0.0;
        hensa=0.0;
        
        scanf("%d",&n);
        if(n==0){
            break;
        }
        n*=1.0;
        for(i=0;i<n;i++){
            scanf("%d",&s[i]);
            s[i]*=1.0;
            heikin+=s[i];
        }
        heikin/=n;

        for(i=0;i<n;i++){
            bunsan+=pow(s[i]-heikin,2);
        }
        bunsan/=n;
        hensa=pow(bunsan,0.5);
        printf("%.8f\n",hensa);
    }
    return 0;
}


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



int main(){
    int n;
    cin >> n;
    if(n%2 == 0){
        float f =(float) n/2;
        f = f / (float)n;
        cout <<setprecision(10) << f << endl;
    }else{
        float f =n/2 + 1;
        f = f / (float)n;
        cout <<setprecision(10) << f << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
void cs(int k);

int A[2000001];
int B[2000001];
int n;

// length is n
main(){

  int i,k=0;
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
    if(A[i]>k) k=A[i];
  }
  // setting is finished

  cs(k);

  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i!=n) printf(" ");
  }
  printf("\n");

  return 0;
}

void cs(int k){
  int C[k+1];
  int i,j,len;
  for(i=0; i<=k; i++)
    C[i] = 0;

  for(j=1; j<=n;j++)
    C[A[j]]++;

  for(i=1; i<=k; i++)
    C[i] = C[i] + C[i-1];

  for(j=n; j>=1; j--){

    B[C[A[j]]] = A[j];
    C[A[j]] = C[A[j]]-1;

  }

}

Measured memory_bytes: 15000
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef int keytype;

void quicksort_des(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] > x) i++;
        while (x > a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort_des(a, first , i - 1);
    if (j + 1 < last) quicksort_des(a, j + 1, last);
}

int main(){
    int k, n;
    int a[200000] = {0};

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

    int dist[200000] = {0};
    for(int i = 0; i < n; ++i){
        if(i < n - 1) dist[i] = a[i+1] - a[i];
        else dist[i] = k - a[i] + a[0];
    }

    quicksort_des(dist, 0, n-1);
    int sum = 0;
    for(int i = 1; i < n; ++i){
        sum += dist[i];
    }

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

    return 0;
}


Measured memory_bytes: 3288
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector<double> vd;
typedef std::vector<std::string> vs;
typedef std::vector<pii> vpii;
typedef std::vector<vi> vvi;
typedef std::vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { rep(i,v.size()) is >> v[i]; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(const int &s = 0, const int &d = 0, const Weight &w = 0) : src(s), dst(d), weight(w) {}
};

typedef std::vector<Edge> Edges;
typedef std::vector<Weight> Array;
typedef std::vector<Array> Matrix;

class Graph {
  std::vector<Edges> g;

public:
  Graph(const int &size = 0) : g(size) {}
  int size() const { return g.size(); }
  const Edges &operator[](const int &i) const { return g[i]; }
  void addArc(const int &src, const int &dst, const Weight &w = 1) { g[src].emplace_back(src, dst, w); }
  void addEdge(const int &node1, const int &node2, const Weight &w = 1) {
    addArc(node1, node2, w);
    addArc(node2, node1, w);
  }
};

template<int inf = std::numeric_limits<Weight>::max() / 8> std::pair<std::vector<Weight>, std::vector<int>> dijkstra(const Graph &g, const int &src) {
  using state = std::pair<Weight, int>;
  std::priority_queue<state, std::vector<state>, std::greater<state>> q;
  std::vector<Weight> dist(g.size(), inf);
  std::vector<int> via(g.size());
  dist[src] = 0;
  q.emplace(0, src);
  while (q.size()) {
    Weight d;
    int v;
    std::tie(d, v) = q.top();
    q.pop();
    if (dist[v] < d) continue;
    for (auto &e : g[v]) {
      if (cmin(dist[e.dst], dist[v] + e.weight)) {
        via[e.dst] = v;
        q.emplace(dist[e.dst], e.dst);
      }
    }
  }
  return {dist, via};
}

main {
  int n, m;
  cin >> n >> m;
  Graph t(n);
  char gomi;
  rep(i, m) {
    int a, b, c, d;
    cin >> a >> gomi >> b >> gomi >> c >> gomi >> d;
    --a, --b;
    t.addArc(a, b, c);
    t.addArc(b, a, d);
  }
  int s, g, v, p;
  cin >> s >> gomi >> g >> gomi >> v >> gomi >> p;
  --s, --g;
  vector<Weight> dist1 = dijkstra(t, s).first;
  vector<Weight> dist2 = dijkstra(t, g).first;
  cout << v - p - dist1[g] - dist2[s] << endl;
}

Measured memory_bytes: 3100
#include "bits/stdc++.h"
using namespace std;
const long long INF = (long long)(1e18) + 1;
int main() {
	int N;
	long long K;
	cin >> N >> K;
	vector<long long>A(N);
	for (int n = 0; n < N; ++n) {
		cin >> A[n];
	}
	//小さい順にソート
	sort(A.begin(), A.end());
	long long l = -INF;
	long long r = INF;	
	while (l + 1 < r) {
		long long x = (l + r) / 2;
		bool check = [&] {
			long long tmp = 0;
			for (int n = 0; n < N; ++n) {
				if (A[n] < 0) {
					int l = -1;
					int r = N;
					while (l + 1 < r) {
						int c = (l + r) / 2;
						if (A[c] * A[n] < x) {
							r = c;
						}
						else {
							l = c;
						}
					}
					tmp += (long long)(N - r); 
				}
				else {
					int l = -1, r = N;
					while (l + 1 < r) {
						int c = (l + r) / 2;
						if (A[c] * A[n] < x) l = c; else r = c;
					}
					tmp += (long long)r; 
				}
				if (A[n] * A[n] < x) {
					tmp--;
				}
			}
			tmp /= 2; 
			return tmp < K;
		}();
		if (check) {
			l = x;
		}
		else {
			r = x;
		}
	}
	cout << l << endl;
	return 0;
}

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

import numpy as np

N = int(input())
S_list = [input().rstrip() for _ in range(N)]

S_ab_number = [i.count('AB') for i in S_list]
S_b_start_number = [1 if i[0] == 'B' and i[-1] != 'A' else 0 for i in S_list]
S_a_end_number = [1 if i[-1] == 'A' and i[0] != 'B' else 0 for i in S_list]
S_both_number = [1 if i[-1] == 'A' and i[0] == 'B' else 0 for i in S_list]

if sum(S_both_number) == 0:
    print(sum(S_ab_number) +  min(sum(S_b_start_number),sum(S_a_end_number)))
elif sum(S_b_start_number) == 0 and sum(S_a_end_number) != 0:
    print(sum(S_ab_number) + sum(S_both_number))
elif sum(S_b_start_number) != 0 and sum(S_a_end_number) == 0:
    print(sum(S_ab_number) + sum(S_both_number))
elif sum(S_b_start_number) == 0 and sum(S_a_end_number) == 0:
    print(sum(S_ab_number) + sum(S_both_number) - 1)
else:
    print(sum(S_ab_number) + sum(S_both_number) + 1 + min(sum(S_b_start_number)-1,sum(S_a_end_number)-1))




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

int main() {
    int m, f, r;

    do{
        cin >> m >> f >> r;

        if (m == -1 || f == -1){
            if (m == -1 && f == -1 && r == -1) break;
            else cout << "F" << endl;
        }
        else if ((80<=(m+f))) cout << "A" << endl;
        else if ((65<=(m+f)) && ((m+f)<80)) cout << "B" << endl;
        else if ((50<=(m+f)) && ((m+f)<65)) cout << "C" << endl;
        else if ((30<=(m+f)) && ((m+f)<50)) {
            if (50<=r) cout << "C" << endl;
            else cout << "D" << endl;
        }
        else if (((m+f)<30)) cout << "F" << endl;
        else cout << "No such score!" << endl;
    } while (1);


    return 0;
}

Measured memory_bytes: 3100
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int a,b,c,d,e,f;
    while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF)
    {
         if(a>=c)
         e=a;
         else
         e=c;
         if(b<=d)
         f=b;
         else
         f=d;
         if(e>=f)
         cout<<"0"<<endl;
         else
         cout<<f-e<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
int M=1e9+7;
int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s;
	int t=1;
	//cin>>t;
	while(t--){
		//vector<int> v;map<int,int> mp;set<int> st;
		int ans=0;
		int n;
		cin>>n;
		for(int i=1;i<=n;i++) 
		for(int j=1;j<=n;j++)
		for(int k=1;k<=n;k++) ans+=(__gcd(i,__gcd(j,k)));
		//int a[n];rep(i,n) cin>>a[i];
		cout<<ans;
	}
	return 0;
}




Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    map<int,int> a;
    for(int i = 0; i < n; i++){
        int b;
        cin >> b;
        a[b]++;
    }

    int ans = 0;
    for(int i = 1; i < 100000; i++){
        ans = max(a[i -1] + a[i] + a[i + 1], ans);
    }
    cout << ans << endl;
    }

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	
	VI ys(1100000);

	for(ll j=1;j<=n;j++){
		rep2(i, 1, n){
			if(j *i >n) break;
			ys[i*j]++;
		}
	}
	ll ans = 0;
	rep2(i, 1, n){
		int su = n-i;
		ll sm = ys[su];
		ans +=sm;
	}
	cout <<ans <<"\n";
	
	
	return 0;
}



Measured memory_bytes: 7420
s=input()
mae=int(s[:2])
ato=int(s[2:])
if 1<=mae<=12:
    if 1<=ato<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=ato<=12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 38384
solve :: [Double] -> [Double]
solve [a,b,c] =
    let s = (1/2) * a * b * sin (c*pi/180.0) in
    let l = a + b + sqrt (a^2 + b^2 - 2*a*b*cos(c*pi/180)) in
    let h = b * sin (c*pi/180.0) in
    [s,l,h]

main = interact (unlines . map show . solve . map read . words)


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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(std::string S) {
  if (S.size() == 2) {
    cout << S << endl;
  } else {
    cout << string(S.rbegin(), S.rend()) << endl;
  }
}

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


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

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

    static class RGBCards {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int r = in.nextInt();
            int g = in.nextInt();
            int b = in.nextInt();

            int n = r * 100 + g * 10 + b;

            if (n % 4 == 0) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }
}



Measured memory_bytes: 21844