akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // C - HonestOrUnkind2

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt(); // 人数
        int[] a = new int[n]; // 証言数
        int[][] x = new int[n][n]; // 誰に対して？
        int[][] y = new int[n][n]; // 証言
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            for (int j = 0; j < a[i]; j++) {
                x[i][j] = sc.nextInt();
                y[i][j] = sc.nextInt();
            }
        }
        //        System.out.println("x=" + Arrays.deepToString(x));
        //        System.out.println("y=" + Arrays.deepToString(y));

        ArrayList<int[]> ptn = new ArrayList<>();
        for (int j = 0; j < 2; j++) {
            setPtn(0, j, new int[n], ptn);
        }

        int max = 0;
        int count = 0;
        for (int[] idx : ptn) {
            //            System.out.println("idx=" + Arrays.toString(idx));
            count = 0;
            for (int i = 0; i < n; i++) {
                //                System.out.println("idx[i]=" + idx[i] + " (i=" + i + ")");
                if (idx[i] == 0) { // 不親切な人のときバイパス
                    continue;
                }
                for (int j = 0; j < n; j++) {
                    //                    System.out.println("x[i][j]=" + x[i][j] + " (i=" + i + " ,j=" + j + ")");
                    //                    System.out.println("y[i][j]=" + y[i][j] + " (i=" + i + " ,j=" + j + ")");
                    if (x[i][j] == 0) {
//                        System.out.print("count:");
//                        System.out.println("idx=" + Arrays.toString(idx));
                        count++;
                        break;
                    } else {
                        //                        System.out.println("idx[x[i][j] - 1]=" + idx[x[i][j] - 1]);
                        if (idx[x[i][j] - 1] == y[i][j]) {
//                            System.out.println("x[i][j]=" + x[i][j] + " (i=" + i + " ,j=" + j + ")");
//                            System.out.println("y[i][j]=" + y[i][j] + " (i=" + i + " ,j=" + j + ")");
                        } else {
                            i = n;
                            count = 0;
                            break;
                        }
                    }
                }
            }
            if (max < count)
                max = count;
        }

        System.out.println(max);
    }

    static void setPtn(int d, int c, int[] idx, List<int[]> ptn) {
        idx[d] = c;
        if (idx.length - 1 > d) {
            for (int l = 0; l < 2; l++) {
                setPtn(d + 1, l, idx, ptn);
            }
        } else {
            int[] tmpidx = idx.clone();
            ptn.add(tmpidx);
        }
    }

}

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

const int MAX = 100000;
const int NIL = -1;

int n;
std::vector<int> G[MAX];
int state[MAX];

void dfs(int u, int id) {
  	
	stack<int> S;
	S.push(u);
	state[u] = id;
	
	while( !S.empty() ) {
		int t = S.top();S.pop();
		for( int i = 0; i < G[t].size(); i++ ) {
			int v = G[t][i];
			if(state[v] == NIL ) {
				state[v] = id;
			    S.push(v);
		    }
		}
		
	}	

}

void assignState(){
	int id = 1;
	for(int i = 0; i < n; i++ ) state[i] = -1;
	for(int u = 0; u < n; u++ ) {
		if( state[u] == NIL ) dfs(u, id++);
	}
}
int main() {
	int s, t, m, q;
    cin >> n >> m;
    
    for( int i = 0; i < m; ++i) {
    	cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    
    assignState();

    cin >> q;

    for( int i = 0; i < q; i++ ){
    	cin >> s >> t;
    	if( state[s] == state[t] ) cout << "yes" << endl;
    	else cout << "no" << endl;
    }

    return 0;
}


Measured memory_bytes: 9008
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
 
s = sum(b)
for i in range(len(a)-1):
    if a[i] + 1 == a[i+1]:
        s = s + c[a[i]-1]
print(s)

Measured memory_bytes: 3060
package main
import "fmt"
 
func main() {
    var A int
    fmt.Scan(&A)
var yebi int = A/3600 
A -= yebi*3600
var hoge  int = A/60
A -= hoge*60 
    fmt.Print(yebi)
   fmt.Print(":")
   fmt.Print(hoge)
   fmt.Print(":")
   fmt.Println(A)
}


Measured memory_bytes: 1160
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 a,b,c,d,e,k;
	cin >> a >> b >> c >> d >> e >> k;
	cout << (e - a > k ? ":(" : "Yay!") << endl;
	return 0;
}


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

using namespace std;

int main() {
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1;
	cin >> h2 >> m2;
	cin >> k;
	m1 += h1 * 60;
	m2 += h2 * 60;
	printf("%d\n", max(0, m2 - m1 - k));
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int i,a=0,b=0;
	for(i=0;i<3;++i){
		if(s[i]=='A')++a;
		else ++b;
	}
	if(a and b)cout<<"Yes";
	else cout<<"No";
} 

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

int main(){
  int K, S;
  cin >> K >> S;
  
  int ans = 0;
  for(int i=0; i<=K; i++)
    for(int j=0; j<=K; j++){
      int z = S - i - j;
      0 <= z && z <= K ? ans++ : 0;
    }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;
string s;

int main(){
  cin >> s;
  string use = "";
  int n = s.size();
  for(int i=n-1;i>=0;i--) use.push_back(s.at(i));
  int s_c = 0, use_c = 0, ans = 0;
  while(!(s_c == n || use_c == n)){
    if(s.at(s_c) == use.at(use_c)){
      s_c++; use_c++;
      if(s_c == n || use_c == n) ans += abs(s_c - use_c);
    }else{
      if((s.at(s_c) != 'x' )&&(use.at(use_c) != 'x')){
        cout << -1 << endl;
        return 0;
      }
      if(s.at(s_c) == 'x'){
        s_c++; ans++;
        if(s_c == n){
          cout << -1 << endl;
          return 0;
        }
      }
      if(use.at(use_c) == 'x'){
        use_c++; ans++;
        if(use_c == n){
          cout << -1 << endl;
          return 0;
        }
      }      
    }
  }
  cout << ans/2 << endl;
}

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

int main(void)
{
	unsigned int n;
	char buf[256];
	int ans[10];
	
	
	while (fgets(buf, 256, stdin) != NULL){
		n = atoi(buf);
		
		int count = 0;
		for (int i = 0; i < 10; i++){
			if ((n & (1 << i)) != 0){
				ans[count++] = 1 << i;
			}
		}
		printf("%d", ans[0]);
		for (int i = 1; i < count; i++){
			printf(" %d", ans[i]);
		}
		puts("");
	}
	
	return (0);
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

int main() {
	vi a = { 0,1,3,1,2,1,2,1,1,2,1,2,1 };
	makei(x);
	makei(y);
	yn(a[x] == a[y]);
}

Measured memory_bytes: 256
combi :: Int -> Int -> Int
combi n s
    | s <= 45   = (combis !! (n - 1)) s
    | otherwise = 0
    where
        combi1 :: Int -> Int
        combi1 s1 = if elem s1 [0 .. 9] then 1 else 0
        combi2 s2 = sum [1 | k1 <- [0 .. 9], k2 <- [k1 + 1 .. 9], k1 + k2 == s2]
        combi3 s3 = sum [1 | k1 <- [0 .. 9], k2 <- [k1 + 1 .. 9], k3 <- [k2 + 1 .. 9], k1 + k2 + k3 == s3]
        combi4 s4 = sum [1 | k1 <- [0 .. 9], k2 <- [k1 + 1 .. 9], k3 <- [k2 + 1 .. 9],
            k4 <- [k3 + 1 .. 9], k1 + k2 + k3 + k4 == s4]
        combi5 s5 = sum [1 | k1 <- [0 .. 9], k2 <- [k1 + 1 .. 9], k3 <- [k2 + 1 .. 9],
            k4 <- [k3 + 1 .. 9], k5 <- [k4 + 1 .. 9],  k1 + k2 + k3 + k4 + k5 == s5]
        combi6 s6 = combi4 (45 - s6)
        combi7 s7 = combi3 (45 - s7)
        combi8 s8 = combi2 (45 - s8)
        combi9 s9 = combi1 (45 - s9)
        combis = [combi1, combi2, combi3, combi4, combi5, combi6, combi7, combi8, combi9]

main :: IO ()
main = interact $ unlines . map show . map (\[n, s] -> combi n s) . map (map read) . map words . takeWhile (/= "0 0") . lines

Measured memory_bytes: 4068
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long int lli;

int main(int argc, char const *argv[]) {
  int n,m;
  cin >> n >> m;
  vector<pair<lli,lli>> ab, cd;
  for (size_t i = 0; i < n; i++) {
    lli a, b;
    cin >> a >> b;
    ab.push_back(make_pair(a,b));
  }
  for (size_t i = 0; i < m; i++) {
    lli c, d;
    cin >> c >> d;
    cd.push_back(make_pair(c,d));
  }
  vector<int> ans;
  for (size_t i = 0; i < n; i++) {
    lli dis = 1<<30;
    int idx;
    for (size_t j = 0; j < m; j++) {
      lli man = abs(ab[i].first-cd[j].first)+abs(ab[i].second-cd[j].second);
      if (man < dis) {
        dis = man;
        idx = j;
      }
    }
    ans.push_back(idx+1);
  }
  for (size_t i = 0; i < n; i++) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

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

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

  int r = 0, g = 0, b = 0;
  rep(i, n) {
    if (s[i] == 'R') ++r;
    if (s[i] == 'G') ++g;
    if (s[i] == 'B') ++b;
  }

  ll ans = (ll)r * (ll)g * (ll)b;

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int k = 2 * j - i;
      if (k >= n) continue;
      if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) --ans;
    }
  }

  cout << ans << '\n';
  return 0;
}


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

using namespace std;

int main() {
    
    long long int n, i, a[200001], b[200001];
    cin>>n;
    for(i=1;i<=n;i++)
    scanf("%lld %lld", &a[i], &b[i]);
    sort(a+1, a+(n+1));
        
        sort(b+1, b+(n+1));
    if(n%2)
    {
        
        printf("%lld", b[(n+1)/2]-a[(n+1)/2]+1);
    }
    else
    {
        printf("%lld", (b[n/2+1]+b[n/2])-(a[n/2]+a[n/2+1])+1);
    }
}

Measured memory_bytes: 6940
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DEBUG 0
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;

signed main() {
	for (string s; cin >> s;) {
		int ans = 0;
		char prev = s[0];
		rep(i, 1, s.size()) {
			if (s[i] != prev) {
				ans++;
				prev = s[i];
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll N,K,R,S,P,sum=0;
  cin>>N>>K>>R>>S>>P;
  string T;
  cin>>T;
  for(ll i=0;i<N;i++){
    if(i<K){
      if(T.at(i)=='r'){sum+=P;}
      if(T.at(i)=='s'){sum+=R;}
      if(T.at(i)=='p'){sum+=S;}
    }else if(i>=K){
      if(i+K>=N){
        if(T.at(i-K)!=T.at(i)){
          if(T.at(i)=='r'){sum+=P;}
          if(T.at(i)=='s'){sum+=R;}
          if(T.at(i)=='p'){sum+=S;}
        }
      }else if(i+K<N){
        if(T.at(i-K)!=T.at(i)){
          if(T.at(i)=='r'){sum+=P;}
          if(T.at(i)=='s'){sum+=R;}
          if(T.at(i)=='p'){sum+=S;}
        }
        else if(T.at(i-K)==T.at(i)){
          if(T.at(i+K)==T.at(i)){
            if(T.at(i)=='r'){T.at(i)='p';}
            if(T.at(i)=='s'){T.at(i)='r';}
            if(T.at(i)=='p'){T.at(i)='s';}
          }
        }
      }
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, string> P;
typedef tuple<int, string, string> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int a, b, c;

bool solve() {
    return min(a, b) < c && c < max(a, b);
}

void input() {
    cin >> a >> b >> c;
}

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

    input();
    cout << (solve()?"Yes":"No") << endl;
}


Measured memory_bytes: 3116
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define moder 1000000007
#define double long double
#define INF LLONG_MAX/10000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
signed main() {
	int k;
	cin >> k;
	cout << 50 << endl;
	vector<int> vec;
	int cnt = k / 50;
	k %= 50;
	rep(i, 50)vec.push_back(49 + cnt);
	rep(i, k) {
		vec[i] += 50;
		rep(j, 50) {
			if (i != j)vec[j]--;
		}
	}
	rep(i, 49)cout << vec[i] << " ";
	cout << vec[49] << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力

		int a = sc.nextInt();
		int b = sc.nextInt();
		if(b%a == 0){
			System.out.println(a + b);
		}else{
			System.out.println(b - a);
		}
	}
}



Measured memory_bytes: 21844
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      String s = next();
      myout(s.lastIndexOf("Z") - s.indexOf("A") + 1);
	}
	//Method addition frame start


  
	//Method addition frame end
}


Measured memory_bytes: 36824
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
#include <set>
#include <map>
#include <unordered_map>
#include <cassert>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

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

    int ans = 0;
    for(int i=0; i<s.size(); i++){
        if(i%2==0 && s[i]!=s[0]) ans++;
        if(i%2!=0 && s[i]==s[0]) ans++;
    }
    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3744
#include <iostream>

using namespace std;
long double a[1010],b = 0;
int main(){
	cout.precision(20);
	int i,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
		b += 1/a[i];
	}
	cout << 1/b << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc095/tasks/arc096_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    // A, Bのみ買う
    int ans = A * X + B * Y;
    // ABピザのみ買う
    ans = min(ans, 2 * C * max(X, Y));
    // ABピザでA, Bの最小個数のみ買って、足りない分を買う
    if (X < Y) {
        ans = min(ans, 2 * C * min(X, Y) + B * (Y - X));
    } else {
        ans = min(ans, 2 * C * min(X, Y) + A * (X - Y));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
# coding: utf-8
# Your code here!
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
n = int(input())
li = input().split()
l = list(set(li))
#print(li)
#print(l)
if len(l)==len(li):
    print("YES")
else:
    print("NO")
    
    






Measured memory_bytes: 94340
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
cnt=[0,0,0]
for i in range(n):
  if p[i] <= a:
    cnt[0]+=1
  elif p[i] <= b:
    cnt[1]+=1
  else:
    cnt[2]+=1
print(min(cnt))

Measured memory_bytes: 9104
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  if(n%11==0){
    cout<<(n/11)*2<<endl;
  }else if(n%11<=6){
    cout<<(n/11)*2+1<<endl;
  }else{
    cout<<(n/11)*2+2<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
n = int(input())
s = 'a'

def func(s, count, cc):
    if count == n:
        print(s)
        return
    for i in range(min(count, cc) + 1):
        func(s + chr(ord('a') + i), count + 1, max(i+1, cc))

func(s, 1, 1)

Measured memory_bytes: 4412
#include<stdio.h>

int main(void)
{
  int n[3];
  int count_5=0,count_7=0;

  scanf("%d %d %d",&n[0],&n[1],&n[2]);
  for(int i=0;i<3;i++){
    if(n[i]==7){
      count_7++;
    }else if(n[i]==5){
      count_5++;
    }
  }

  if(count_5==2&&count_7==1){
    puts("YES");
  }else{
    puts("NO");
  }
  return 0;
}


Measured memory_bytes: 128
H, W, A, B = map(int, open(0).read().split())
MOD = 10**9+7

factorials = [1] * (H + W + 1)
inv_factorials = [1] * (H + W + 1)

for i in range(H + W):
    factorials[i+1] = factorials[i] * (i + 1) % MOD

inv_factorials = list(map(lambda n: pow(n, -1, MOD), factorials))

def modcomb(m, n, mod):
    return factorials[m] * inv_factorials[n] % MOD * inv_factorials[m - n] % MOD
 
total = modcomb(H + W - 2, W - 1, MOD)
 
for i in range(B):
    total -= modcomb(H - A - 1 + i, i, MOD) * modcomb(A - 1 + W - 1 - i, W - 1 - i, MOD) % MOD
    total %= MOD
 
print(total)

Measured memory_bytes: 26388
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

void solve(int n,int m){
    int a[m];
    rep(i,m)cin>>a[i];
    sort(a,a+m);
    if(a[0]!=0){
        int ans=0,cur=0;
        int pre=-1;
        rep(i,m){
            if(a[i]==pre+1){
                ans=max(ans,++cur);
                ++pre;
            }
            else {
                pre=a[i];
                cur=1;
                ans=max(ans,cur);
            }
        }
        cout<<ans<<endl;
        return ;
    }
    else {
        int ans=0,cur=0;
        int pre=-1;
        int ok=0;
        vector<pair<int,int>> st;
        int idx1=1,idx2=1;
        while(idx1<m){
            while(idx2<m&&a[idx2]+1==a[idx2+1])idx2++;
            st.push_back({idx1,idx2});
            idx1=++idx2;
        }
        int k=st.size();
        rep(i,k)ans=max(st[i].second-st[i].first+2,ans);
        rep(i,k-1){
            if(a[st[i].second]+2==a[st[i+1].first])ans=max(ans,st[i+1].second-st[i].first+2);
        }
        cout<<ans<<endl;
        return ;
    }
}


int main(){
    int n,m;
    while(1){
        cin>>n>>m;
        if(n==0)break;
        solve(n,m);
    }
    return 0;
}


Measured memory_bytes: 3560
s = input()
n = len(s)
cn0 = 0
cn1 = 0
for i in range(n):
    if s[i] != str(i % 2):
        cn0 += 1
for i in range(n):
    if s[i] != str((i+1)%2):
        cn1 += 1
print(min(cn0, cn1))

Measured memory_bytes: 73496
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author rn-sshawish
 */
public class Main{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println((input.nextInt() * input.nextInt())% 2 ==0 ?"Even": "Odd");
        
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTG(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using ld = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  VI A(n);
  REP(i, n) cin >> A[i];
  int a = MAX(A);
  int ct = 0;
  REP(i, n) if (A[i] == a) ct++;
  PII b = PII(0, 0);
  int tmp = (a-1)/2 + 1;
  REP(i, n)
  {
    if (ct == 1 && A[i] == a) continue;
    if (A[i] < tmp) b = max(b, PII(A[i], A[i]));
    else b = max(b, PII(a - A[i], A[i]));
  }
  cout << a << " " << b.second << endl;

  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define int long long
#define double long double
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, a[25], q, m[210];
bool ans[210];
set<int> st;
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	cin >> q;
	rep(i, q)cin >> m[i];
	rep(i, ((ll)1 << n)) {
		int sum = 0;
		rep(j, n) {
			if ((i >> j) & 1)sum += a[j];
		}
		rep(j, q)if (sum == m[j])ans[j] |= true;
	}
	rep(i, q) {
		if (ans[i])puts("yes");
		else puts("no");
	}
	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define mod 1000000007
#define inf 1e17
using namespace std;

int main() 
{ 

   int n;
   cin>>n;
   vector<int>vec;
   for(int i=0;i<n;i++)
   {
      int x;
      cin>>x;
      vec.pb(x);
   }
   vector<int>dp(n+1,0);
   dp[0] = 0;
   dp[1] = abs(vec[0]-vec[1]);
   for(int i=2;i<n;i++)
   {
      dp[i] = min(dp[i-1] + abs(vec[i]-vec[i-1]),abs(vec[i]-vec[i-2])+dp[i-2]);
   }
   cout<<dp[n-1]<<endl;
   

} 

Measured memory_bytes: 1144
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

vector<lint> primearray(lint N) {
	//N以下の素数を列挙
	vector<lint> R;
	vector<bool> prime;
	for (int i = 0; i <= N; i++) {
		prime.push_back(true);
	}
	if (N < 2) {
		return R;
	}
	prime[0] = false;
	prime[1] = false;
	for (lint i = 2; i * i <= N; i++) {
		if (!prime[i])continue;
		for (int j = 2 * i; j <= N; j += i) {
			prime[j] = false;
		}
	}
	for (lint i = 0; i < prime.size(); i++) {
		if (prime[i]) {
			R.push_back(i);
		}
	}
	return R;
}

int main() {
	lint N;
	while (cin >> N) {
		cout << primearray(N).size() << endl;
	}
}


Measured memory_bytes: 4692
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int H, A;
	cin >> H >> A;

	cout << (H + A - 1) / A << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#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>;
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; }

//mintを使って定義すれば、modを常に取り続けてくれる。

const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i=1; i<=n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for(int i=n; i>= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if(k<0 || k>n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
} c(200005);


int main(){
    int n, m, k;
    cin >> n >> m >> k;

    mint ans = 0;
    mint col = m;
    for(int x=n-1; x>=0; --x){
        mint now = col;
        now *= c(n-1,x); 
        if(x<=k) ans += now;
        col *= m-1;
    }
    cout << ans << "\n";
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> mochi(N);
  rep(i,N)
    cin >> mochi.at(i);
  stable_sort(mochi.begin(),mochi.end());
  int nandan=0,bottom=0;
  rep(i,N){
    if(mochi.at(i)>bottom){
      bottom = mochi.at(i);
      nandan++;
    }
  }
  cout << nandan << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
template <class T>
void extgcd(T a, T b, T &x, T &y) {
	T r0 = a, r1 = b, r2;
	T a0 = 1, a1 = 0, a2;
	T b0 = 0, b1 = 1, b2;
	while (r1 > 0) {
		T q1 = r0 / r1;
		T r2 = r0 - q1 * r1;
		T a2 = a0 - q1 * a1;
		T b2 = b0 - q1 * b1;
		r0 = r1, r1 = r2;
		a0 = a1, a1 = a2;
		b0 = b1, b1 = b2;
	}
	x = a0, y = b0;
}
int main() {
	int p, q, x, y;
	cin >> p >> q;
	extgcd(p, q, x, y);
	cout << x << ' ' << y << endl;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  
  /*
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  */
  
  cout << t+s << "\n";

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

typedef long long ll;

using namespace std;

template<typename T> ll count(vector<T>& v, const T n) {
    return count(v.begin(), v.end(), n);
}
template<typename T> ll count(vector< vector<T> >& v, const T n) {
    return accumulate(v.begin(), v.end(), 0LL, [n](ll init, vector<T> i) { return init + count(i, n); });
}

int main() {
    int w, h, n, x, y, a;
    cin >> w >> h >> n;
    vector< vector<bool> > b(h, vector<bool>(w));
    for (int i = 0; i < n; ++i) {
        cin >> x >> y >> a;
        switch (a) {
            case 1: for (int i = 0; i < h; ++i) fill(b.at(i).begin(), b.at(i).begin() + x, 1); break;
            case 2: for (int i = 0; i < h; ++i) fill(b.at(i).begin() + x, b.at(i).end(), 1); break;
            case 3: for (int i = 0; i < y; ++i) fill(b.at(i).begin(), b.at(i).end(), 1); break;
            case 4: for (int i = y; i < h; ++i) fill(b.at(i).begin(), b.at(i).end(), 1); break;
        }
    }
    cout << count(b, false) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <utility>
using namespace std;

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

  if(b - a >= 2 * k){
    for(int i = 0; i < k; i++){
      cout << a + i << endl;
    }
    for(int i = k - 1; i >= 0; i--){
      cout << b - i << endl;
    }
  }
  else{
    for(int i = a; i <= b ; i++){
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		solve();
	}

	private static void solve() {
		Scanner scn = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int m = scn.nextInt();
		for(int k=0;k<m;k++){
			int fund = scn.nextInt();
			int year = scn.nextInt();
			int n = scn.nextInt();
			int summax = 0;
			for(int i=0;i<n;i++){
				int sm = scn.nextInt();
				double per = scn.nextDouble();
				int fine = scn.nextInt();
				int crt = fund;
				int outcrt = 0;
				for(int s=0;s<year;s++){
					if(sm==0){//??????
						outcrt+=crt*per;
						crt=crt-fine;
					}else if(sm==1){//??????	
						crt = (int) (crt*per+crt-fine);
					}
				}
				if(crt+outcrt>summax){
					summax=crt+outcrt;
				}
			}
			out.println(summax);
		}
		out.flush();
		
	}

}

Measured memory_bytes: 55332
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
	cin>>s;
	for(int i=1;i<=4;i++)cout<<s[i-1];
	cout<<' ';
	for(int i=5;i<=12;i++)cout<<s[i-1];
	cout<<endl;
	
}

Measured memory_bytes: 256
N, M = map(int, input().split())
shops = [None] * N
for i in range(N):
  shops[i] = list(map(int, input().split()))
shops.sort()
cnt = 0
ans = 0
while cnt < M:
  shop = shops.pop(0)
  if cnt + shop[1] >= M:
    ans += (M - cnt) * shop[0]
    cnt = M
  else:
    ans += shop[0] * shop[1]
    cnt += shop[1]
print(ans)

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

class Main
{
    public static void main (String[] args) throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int n=Integer.parseInt(bu.readLine()),i,j,k;
        int c[]=new int[10001];
        for(i=1;i<=100;i++)
        for(j=1;j<=100;j++)
        for(k=1;k<=100;k++)
        {
            int v=i*i+j*j+k*k+i*j+i*k+j*k;
            if(v<=10000) c[v]++;
        }
        for(i=1;i<=n;i++)
        sb.append(c[i]+"\n");
        System.out.print(sb);
    }
}

Measured memory_bytes: 36936
#include <iostream>
#include <queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

void bfs(int s) {
    queue<int> q;
    q.push(s);
    for(int i=0; i<n; i++) d[i] = INFTY;
    d[s] = 0;
    int u;
    while(!q.empty()) {
        u = q.front(); q.pop();
        for(int v=0; v<n; v++) {
            if(M[u][v] == 0) continue;
            if(d[v] != INFTY) continue;
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    for(int i=0; i<n; i++) {
        cout << i+1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
    }
}

int main() {
    int u, k, v;
    
    cin >> n;
    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) M[i][j] = 0;
    }
    
    for(int i=0; i<n; i++) {
        cin >> u >> k;
        u--;
        for(int j=0; j<k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    
    bfs(0);
    
    return 0;
}


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

#define ll long long
#define mx  205
#define mod 1000000009
#define lim 10000000
#define inf 1e9
#define N 18
using namespace std;


int main(){
	ios_base::sync_with_stdio(false);
     string s;cin>>s;
     ll k;cin>>k;
     int one=0,num=0;

     for(int i=0;i<s.size();i++)
	{
		if(s[i]=='1')
			one=1,k--;
		else
		{
			num=s[i]-'0';
			break;
		}

		if(!k)break;
	}

	if(k==0 && one)cout<<one<<"\n";
	else if(num)cout<<num<<"\n";
     return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <string>
#include <climits>
#include <algorithm>

using namespace std;

int main(void)
{

    int n;
    cin >>n;

    int ae = 0, bs = 0, ct = 0, both = 0;

    for(int i = 0; i < n; i++){
        string tmp;
        cin >>tmp;
        if(tmp[0] == 'B'){
            bs++;
        }
        if(tmp[tmp.size()-1] == 'A'){
            ae++;
        }
        if(tmp[tmp.size()-1] == 'A' && tmp[0] == 'B'){
            both++;
        }
        for(int j = 0; j < tmp.size()-1; j++){
            if(tmp[j] == 'A' && tmp[j+1] =='B'){
                ct++;
            }
        }
    }
    if(ae == bs && ae == both && both != 0){
        printf("%d\n", ct+min(ae, bs) - 1);
    }else{
        printf("%d\n", ct+min(ae, bs));
    }
    return 0;
}

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

int main(){
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  if(s[k-1]=='A') s[k-1]='a';
  else if(s[k-1]=='B') s[k-1]='b';
  else if(s[k-1]=='C') s[k-1]='c';
  cout<<s<<endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize,
        mut a: [usize; n],
    }
    a.sort();

    let mut memo = vec![0; a[n-1] + 1];
    for &v in &a {
        memo[v as usize] += 1;
    }
    
    let mut ans = n;
    for i in 0..n {
        let v = a[i];
        if memo[v] == 0 {
            continue;
        } else if memo[v] > 1 {
            ans -= memo[v];
            memo[v] = 0;
        }
        for j in (v+v..=a[n-1]).step_by(v) {
            ans -= memo[j];
            memo[j] = 0;
        }
    }

    println!("{}", ans);

}



Measured memory_bytes: 12584
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Extentions;

class IO
{
    int idx;
    string[] input = In.ReadToEnd().Split(new[] { " ", "\n", "\r" },
        StringSplitOptions.RemoveEmptyEntries);

    T Get<T>(Func<string, T> parser) => parser(input[idx++]);

    public string S => Get(s => s);
    public char C => Get(char.Parse);
    public int I => Get(int.Parse);
    public long L => Get(long.Parse);
    public double F => Get(double.Parse);
    public decimal D => Get(decimal.Parse);
    public BigInteger B => Get(BigInteger.Parse);

    T[] Gets<T>(int n, Func<string, T> parser)
        => input.Skip((idx += n) - n).Take(n).Select(parser).ToArray();

    public string[] Ss(int n) => Gets(n, s => s);
    public char[] Cs(int n) => Gets(n, char.Parse);
    public int[] Is(int n) => Gets(n, int.Parse);
    public long[] Ls(int n) => Gets(n, long.Parse);
    public double[] Fs(int n) => Gets(n, double.Parse);
    public decimal[] Ds(int n) => Gets(n, decimal.Parse);
    public BigInteger[] Bs(int n) => Gets(n, BigInteger.Parse);

    public void Write<T>(params T[] xs) => WriteLine(string.Join(" ", xs));
    public void Write(params object[] xs) => WriteLine(string.Join(" ", xs));
}

#region Library

static class Extentions
{
}

#endregion

static class Program
{
    public static void Main()
    {
        var sw = new StreamWriter(OpenStandardOutput()) { NewLine = "\n" };
#if DEBUG
        sw.AutoFlush = true;
#else
        sw.AutoFlush = false;
#endif
        SetOut(sw);
        Solve(new IO());
        Out.Flush();
    }

    static void Solve(IO io)
    {
        var a = io.L;
        var b = io.L;
        var c = io.L;
        var d = io.L;
        var e = io.L;
        var f = io.L;

        var ans0 = 0.0;
        var ans1 = 0L;
        var ans2 = 0L;

        for (var i = 0; i * a * 100 <= f; i++)
        {
            for (var j = 0; ; j++)
            {
                var w = i * a + j * b;
                if (w == 0) break;

                for (var k = 0; w * 100 + k * c <= f; k++)
                {
                    for (var l = 0; ; l++)
                    {
                        var s = k * c + l * d;
                        if (w * 100 + s > f || s > e * w) break;

                        var t = (double)s / (w * 100 + s);

                        if (t >= ans0)
                        {
                            ans0 = t;
                            ans1 = w * 100 + s;
                            ans2 = s;
                        }
                    }
                }

                if (w * 100 > f) break;
            }
        }

        io.Write(ans1, ans2);
    }
}

Measured memory_bytes: 13268
<?php
$N = fgets(STDIN);
$Xs = fgets(STDIN);
$X = array();
$format = "%d";
$formated="";
for($i=0;$i<$N;$i++){
    $formated = $formated.' '.$format;
}
$X = sscanf($Xs,$formated);
$min = 50000000000;
$sum = 0;
for($p=0;$p<=100;$p++){
    for($i=0;$i<$N;$i++){
        $sum += (((int)$X[$i] - $p)**2);
    }
    if(($min > $sum)&&($sum >= 0)){
        $min = $sum;
    }
    $sum = 0;
}
echo $min;

Measured memory_bytes: 3828
#include <stdio.h>
#include <string.h>

#define max 5

int main()
{
    char S[max];
    gets(S);

    if(strcmp(S,"ABC")==0)
    {
        printf("ARC");
    }
    else if(strcmp(S,"ARC")==0)
    {
        printf("ABC");
    }

    return  0;
}


Measured memory_bytes: 1640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const ll mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int K,Q;cin>>K>>Q;
    vector<int> D(K);
    
    for(int i=0;i<K;i++) cin>>D[i];
    
    while(Q--){
        int N,X,M;cin>>N>>X>>M;
        vector<int> mo(K);
        for(int i=0;i<K;i++) mo[i]=D[i]%M;
        
        if(N<K){
            ll now=X%M;
            ll cnt=0;
            for(int i=0;i<N-1;i++){
                now+=mo[i];
                if(mo[i]==0) cnt++;
            }
            cout<<N-1-cnt-now/M<<endl;
        }else{
            ll now=X%M;
            ll cnt=0;
            for(int i=0;(N-1-i)%K!=0;i++){
                now+=mo[i];
                if(mo[i]==0) cnt++;
            }
            cnt+=now/M;
            now%=M;
            
            ll sum=0;
            for(int i=0;i<K;i++) sum+=mo[i];
            
            cnt+=sum/M*((N-1)/K);
            sum%=M;
            
            now+=sum*((N-1)/K);
            cnt+=now/M;
            
            for(int i=0;i<K;i++){
                if(mo[i]==0){
                    cnt+=(N-1)/K;
                }
            }
            
            cout<<N-1-cnt<<endl;
        }
    }
    
}



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

int n;
std::map<int, int> data;
int main()
{
	std::cin >> n;
	for (int i = 0; i < n; ++i) {
		int a;
		std::cin >> a;
		++data[a];
	}

	int ans = 0;
	for (auto& d : data) {
		ans += d.second - 1;
	}

	std::cout << n - 2 * (ans / 2 + ans % 2) << std::endl;
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  bool A = false, B = false, C = false;
  for (char c: S) {
    if (c == 'a') A = true;
    else if (c == 'b') B = true;
    else C = true;
  }
  if (A && B && C) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
interval=[[0,0] for i in range(M)]
for i in range(M):
  interval[i][0],interval[i][1]=map(int,input().split())
L=[interval[i][0] for i in range(M)]
R=[interval[i][1] for i in range(M)]
L_max=max(L)
R_min=min(R)
print(max(0,R_min-L_max+1))

Measured memory_bytes: 25484
#ITP1_11-A Dice 1
rep={
    "N":[4,0,2,3,5,1],
    "S":[1,5,2,3,0,4],
    "E":[2,1,5,0,4,3],
    "W":[3,1,0,5,4,2]
}

d = input().split(" ")
NSEW = input()
c=[d]
for i in range(len(NSEW)):
    c.append([0,0,0,0,0,0])

for i in range(len(NSEW)):
    r=rep[NSEW[i]]
    for j in range(6):
        c[i+1][r[j]]=c[i][j]
print(c[len(NSEW)][0])

Measured memory_bytes: 7476