akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i ,n) for(int i = 0; i < (int)(n); i++)

int main(){
  string S;
  cin >> S;
  
  string ans = "Good";
  rep(i,3){
    if(S.at(i) ==S.at(i+1)) ans = "Bad";
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <array>
using namespace std;
#define len(_x) (sizeof((_x)) / sizeof(_x)[0])
#define ll long long
#define fastIO  ios_base::sync_with_stdio(false); cin.tie(0); 
#define iT(_t,_x) _t _x;std::cin >> _x;  
#define iInt(_x) int _x;in(_x); 
#define ill(_x) ll _x;in(_x); 
template<typename T> void in(T &x) { x = 0; bool neg = false; register T c = getchar(); if (c == '-')neg = true, c = getchar(); while ((c < 48) || (c > 57))c = getchar(); for (; c < 48 || c > 57; c = getchar()); for (; c > 47 && c < 58; c = getchar())x = (x << 3) + (x << 1) + (c & 15); if (neg) x *= -1; }



int main() {
	iInt(n);
	ll sum = 0;
	while (n--)
	{
		int a, b;
		std::cin >> a >> b;
		sum += b - a + 1;
	}
	std::cout << sum;
}


Measured memory_bytes: 256
from collections import Counter
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

n,m = map(int,input().split())
par = [-1]*n
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    unite(a,b)
ans = 0
for i in range(n):
    ans = max(size(i),ans)
print(ans)

Measured memory_bytes: 14884
<?php
  
$n = trim(fgets(STDIN));
$k = trim(fgets(STDIN));

$num = 1;
for($i=0; $i<$n; $i++){
  if($num > $k) {
    $num += $k;
  } else {
    $num += $num;
  }
}

echo $num;

?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
int H,W,pp,nn;
int P(char x){
    return x-'a';
}
char X[101][101],A[101];
int main()
{
    cin>>H>>W;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin>>X[i][j];
            A[P(X[i][j])]++;
        }
    }
    if(H%2==0 && W%2==0){
        pp=1;               // obe parne,svaki mora biti deljiv sa 4 bar
        for(int i=0;i<27;i++){
            if(A[i]%4 !=0){
                printf("No");
                return 0;
            }
        }
        printf("Yes");
        return 0;
    }

    if(H%2==1 && W%2==1){
        nn=1;               // obe neparne,sme jedan da bude 1 (centralno polje) i najvise H/2+W/2 deljivih sa 2 a, ne sa 4
        int cnt=0,jed=0;
        for(int i=0;i<27;i++){
            if(A[i]%4 !=0){
                if(A[i]%2!=0){
                    if(jed){
                        printf("No");
                        return 0;
                    }
                    jed++;
                }
                else{
                    cnt++;
                    if(cnt>H/2+W/2){
                        printf("No");
                        return 0;
                    }
                }
            }
        }
        printf("Yes");
        return 0;
    }
    int gr=0,aa=0;                    //ostaje jedna parna,druga neparna
    if(H%2!=0)
        gr=W/2;
    else
        gr=H/2;                 // toliko sme parnih
    for(int i=0;i<27;i++){
        if(A[i]%4 !=0){
            if(A[i]%2!=0){
                printf("No");
                return 0;
            }
            else{
                aa++;
                if(aa>gr){
                    printf("No");
                    return 0;
                }
            }
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 256
N,M= list(map(int, input().split())) 
H = list(map(int, input().split())) 
A = [0]*M
B = [0]*M
ans = [1]*N

for i in range(M):
    A[i], B[i]= map(int, input().split())
    

for i in range(M):
    a = A[i]-1
    b = B[i]-1
    if H[a] < H[b]:
        ans[a]=0
    elif H[a] > H[b]:
        ans[b]=0
    else:
        ans[a]=0
        ans[b]=0
        
print(ans.count(1))

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

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	
	int N, K;
	cin >> N >> K;
	int ans = 1, now = K;
	while (now < N) {
		now += K-1;
		ans++;
	}
	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 256
#![allow(unused_mut, non_snake_case,unused_imports)]
use std::iter;
use std::cmp::{max, min, Ordering};
use std::mem::{swap};
use std::collections::{HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap,VecDeque};
use std::iter::FromIterator;

//　高速 EOF要
//macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};}
//macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};}
//macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};}
// 低速 EOF不要
macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
fn main(){
    input!(S:chars);
    let S:Vec<char> = S;
    let mut ans = 0;
    let mut now:char = 'A';
    for i in 0..S.len(){
        if S[i] <= now{
            ans+=1;
        }
        now = S[i];
    }
    println!("{}",ans);
}


Measured memory_bytes: 5032
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

int main(void) {
    string s;
    cin >> s;
    cout << s[0] << (s.length() - 2) << s[s.length()-1] << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine().Split(' ');
            var n = int.Parse(str[0]);
            var m = int.Parse(str[1]);
            var a = new String[n];
            var b = new String[m];
            for (int i = 0; i < n; i++)
            {
                a[i] = Console.ReadLine();
            }
            for (int i = 0; i < m; i++)
            {
                b[i] = Console.ReadLine();
            }

            Boolean isMatch = false;
            for (int i = 0; i < n - m + 1; i++)
            {
                for (int j = 0; j < n - m + 1; j++)
                {
                    isMatch = true;

                    for (int k = 0; k < m; k++)
                    {
                        for (int l = 0; l < m; l++)
                        {
                            if (a[i + k][j + l] != b[k][l])
                            {
                                isMatch = false;
                            }

                            if (!isMatch)
                            {
                                break;
                            }
                        }

                        if (!isMatch)
                        {
                            break;
                        }
                    }

                    if (isMatch)
                    {
                        break;
                    }
                }

                if (isMatch)
                {
                    break;
                }
            }

            if (isMatch)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  int h, w;
  cin >> h >> w;
  int a, b;
  cin >> a >> b;
  int one = 1;
  int zero = 0;
  bool yes = true;
  rep(i, h) {
    if (i >= b && yes) {
      swap(zero, one);
      yes = false;
    }
    rep(j, w) {
      if(j < a) cout << one;
      else cout << zero;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1280
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <set>
#include <functional>

using namespace std;

#define DT long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)
typedef vector<DT> vec;
typedef list<DT> li;

DT n;
vector<vector<DT> >vc(n, vector<DT>(n));


void fw(){
	for (int k=0;k<n;k++)
		for (int i = 0; i<n; i++)
			for (int j = 0; j<n; j++)
				vc[i][j] = min(vc[i][j], vc[i][k] + vc[k][j]);
}

int main() {
	ifstream fin("Text.txt");
	int i, j , q;
	DT m,a,b,c,ans=0;
	cin >> n >> m;
	vc = vector<vector<DT> >(n, vector<DT>(n));
	vector<vector<DT> >vc2(n, vector<DT>(n));

	forn(i, m) {
		cin >> a >> b >> c;
		vc[a - 1][b - 1] = c;
		vc[b - 1][a - 1] = c;
		vc2[a - 1][b - 1] = c;
		vc2[b - 1][a - 1] = c;
	}
	forn(i, n) {
		forn(j, n) {
			if (i != j && !vc[i][j]) {
				vc[i][j] = 1000000000000;
				vc2[i][j] = 1000000000000;
			}
		}
	}
	fw();
	forn(i, n) {
		forn(j, n) {
			if (i != j && vc2[i][j] != 1000000000000) {
				if (vc2[i][j] > vc[i][j])
					ans++;
			}
		}
	}
	cout << ans / 2 << endl;
	return 0;

}

Measured memory_bytes: 384
#include <stdio.h>

#include <iostream>
#include <vector>
#include <string.h>

#pragma warning (push)
#pragma warning (disable : 4996)
#pragma warning (disable : 6031)
#define mod 1000000007;

using namespace std;

int main()
{
    long N, A, B, Remain;

    cin >> N >> A >> B;

    if (A + B == 0) {
        cout << 0 << endl;
        return -1;
    }

    Remain = N % (A + B);

    if (Remain >= A){
        cout << (A * (N / (A + B)) + A);
    }
    else {
        cout << (A * (N / (A + B)) + Remain);
    }
}

#pragma warning (pop)

Measured memory_bytes: 256
#include<stdio.h>
#define mod 1000000007
#define ll long long
ll n,k;
ll ans[100010];
ll quickpow(ll a,ll b){
	ll ans=1;
	while(b!=0){
		if(b%2==1)ans=(ans%mod*a%mod)%mod;
		b=b/2;
		a=(a%mod*a%mod)%mod;
	} 
	return ans;
}
int main(){
	scanf("%lld %lld",&n,&k);
	for(ll i=k;i>=1;i--){
		ans[i]=quickpow(k/i,n);
		for(ll j=(ll)2*i;j<=k;j=j+i){
			ans[i]=(ans[i]-ans[j]+mod)%mod;
		}
	}
	ll res=0;
	for(ll i=1;i<=k;i++){
		res=(res+i*ans[i])%mod;
	}
	printf("%lld\n",res);
}


Measured memory_bytes: 2496
s = input()
t = input()
lg = len(t)
ans, cnt = 1001, 0
for i in range(len(s) - lg + 1):
    st = s[i:i+lg]
    for j in range(lg):
        if t[j] != st[j]:
            cnt += 1
    ans = min(ans, cnt)
    cnt = 0
print(ans)


Measured memory_bytes: 9056
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge
{
    ll to, cost, val;
};
template <class T, class U>
bool chmin(T &a, const U &b)
{
    if (a <= b)
        return false;
    a = b;
    return true;
}
template <class T, class U>
bool chmax(T &a, const U &b)
{
    if (a >= b)
        return false;
    a = b;
    return true;
}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll

signed main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll A,B,K;
    cin>>A>>B>>K;

    if(A>=K) A-=K;
    else{
        B-=(K-A);
        A=0;
        if(B<0) B=0;
    }
    cout<<A<<" "<<B<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;

int main(){
  string s;
  cin>>s;
  stack<int> a;
  a.push(0);
  int b=1;
  for(int i=0;i<s.size();i++){
    if(s[i]=='('){a.push(b);b++;}
    else if(s[i]==')'){b=a.top();a.pop();}
    else {cout<<a.top()<<endl;return 0;}
  }
  return 0;
}



Measured memory_bytes: 3216
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, a, N) for(int i = a; i < N; i++)

int main() {
    string S;
    cin >> S;

    ll cnt = 0, ans = 0;
    rep(i, 0, S.size()) {
        if (S[i] == 'W') {
            ans += i - cnt;
            cnt++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

// ローリングハッシュ
struct RollingHash {
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1000000007, mod2 = 1000000009;
    vector<long long> hash1, hash2, power1, power2;

    // construct
    RollingHash(const string &S) {
        int n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1);
        power2.assign(n+1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i+1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i] * base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }
    
    // get hash of S[left:right]
    inline pair<long long, long long> get(int l, int r) const {
        long long res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if (res1 < 0) res1 += mod1;
        long long res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if (res2 < 0) res2 += mod2;
        return {res1, res2};
    }
};

int main() {
    int N;
    string S;
    cin >> N >> S;

    // ロリハ
    RollingHash rh(S);

    // 二分探索判定
    auto check = [&](int d) -> bool {
        map<pair<long long, long long>, int> ma;
        for (int i = 0; i + d <= N; ++i) {
            auto p = rh.get(i, i+d);
            if (ma.count(p)) {
                if (i - ma[p] >= d) return true;
            }
            else ma[p] = i;
        }
        return false;
    };

    // 二分探索
    int left = 0, right = N/2 + 1;
    while (right - left > 1) {
        int mid = (left + right) >> 1;
        if (check(mid)) left = mid;
        else right = mid;
    }
        
    cout << left << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
#define REP(i, n) for (i64 (i) = 0; (i) < (n); ++(i))
#define FOR(i, a, b) for (i64 (i) = (a); (i) < (b); ++(i))

int N;
vector<vector<int>> graph;

vector<double> dp;
double dfs(int cur, int prv = -1) {
    int child = 0;
    double sum = 0.0;
    for (auto& nxt: graph[cur]) {
        if (nxt == prv) continue;
        sum += dfs(nxt, cur);
        ++child;
    }
    if (child == 0) {
        return dp[cur] = 0.0;
    } else {
        return dp[cur] = sum / child + 1;
    }
}

vector<double> ans;
double reroot(int cur, double d_par, int prv = -1) {
    int child = 0;
    double sum = 0.0;
    for (auto& nxt: graph[cur]) {
        if (nxt == prv) {
            sum += d_par;
        } else {
            sum += dp[nxt];
        }
        ++child;
    }
    ans[cur] = sum / child + 1;

    for (auto& nxt: graph[cur]) {
        if (nxt == prv) continue;
        double nxt_d_par;
        if (child == 1) {
            nxt_d_par = 0;
        } else {
            nxt_d_par = (ans[cur] * child - 1 - dp[nxt]) / (child - 1);
        }
        reroot(nxt, nxt_d_par, cur);
    }
    return ans[cur];
}

signed main() {

    cout << fixed << setprecision(20);

    cin >> N;

    graph.resize(N);
    REP(i, N - 1) {
        int U, V;
        cin >> U >> V;
        --U, --V;
        graph[U].emplace_back(V);
        graph[V].emplace_back(U);
    }

    dp.assign(N, 0);
    dfs(0);

    ans.assign(N, 0);
    reroot(0, 0.0);

    REP(i, N) cout << ans[i] << endl;

}

Measured memory_bytes: 21248
def find_primes(n):
    ps = []
    t = [True] * n
    t[0] = t[1] = False
    for i in range(2, n):
        if not t[i]:
            continue
        ps.append(i)
        for j in range(i, n, i):
            t[j] = False
    return ps


def solve(string):
    n = int(string)
    if n == 1:
        return "0"
    rn = int(n**0.5 + 1)
    ps = find_primes(rn)
    ans = 0
    f = True
    for i in ps:
        k = 1
        while n % (i**k) == 0:
            ans += 1
            n //= i**k
            f = False
            k += 1
    return str(ans + 1 if f else ans + (n >= rn))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 20264
#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;
const static int MAX = 200000;

int n, c1, c2, c3;
char S[MAX];
string s;

int main() {
    scanf("%d", &n);
    scanf("%s", S);
    s = S;
    c1 = 0;
    
    for ( int i = 0; i < n; i++ ) {
        if ( s[i] == '.' ) {
            c1++;
        }
    }
    
    c2 = 0;
    c3 = c1;
    
    for ( int i = 0; i < n; i++ ) {
        if ( s[i] == '.' ) {
            c2++;
        }
        c3 = min(c3, c1-2*c2+i+1);
    }
    
    printf("%d\n", c3);
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	string s; cin >> s;
	int sz = s.l_ength();
	int ans = 0;
	for( int n = 1; n <= sz; ++n ){
		for( int l = 0; l+n <= sz ; ++l ){
			string tmp = s.substr(l, n);
			int len = tmp.l_ength();
			bool flag = true;
			for( int i = 0; i < len; ++i ){
				if( tmp[i] != 'A' && tmp[i] != 'T' && tmp[i] != 'G' && tmp[i] != 'C' ){
					flag = false;
					break;
				}
			}
			if( flag ) ans = max( ans, len );
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
N, *a = map(int, open(0).read().split())

cnt = 0
for v in set(a):
    cnt ^= v

ctr = Counter(a)
flg1 = sum(a) == 0
flg2 = len(ctr) == 2 and ctr[0] == N // 3
flg3 = cnt == 0 and len(ctr) == 3 and all(v == N // 3 for v in ctr.values())
print('Yes' if flg1 or flg2 or flg3 else 'No')



Measured memory_bytes: 67712
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

ll inf=1ll<<60,mod=1e9+7;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n,m,i,s1=0,s2=0,t;
	cin>>n>>m;
	for (i=1;i<=n;i++){
		cin>>t;
		s1=(s1+(i-1)*t-(n-i)*t)%mod;
	}
	for (i=1;i<=m;i++){
		cin>>t;
		s2=(s2+(i-1)*t-(m-i)*t)%mod;
	}
	cout<<(s1*s2)%mod;
	return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  string a, b;
  std::cin >> a >> b;
  reverse(ALL(b));
  if (a == b)
    std::cout << "YES" << std::endl;
  else
    std::cout << "NO" << std::endl;
}


Measured memory_bytes: 256
ss = raw_input()
ss = [s for s in ss]
idx = len(ss) / 2
count = 0
a = ss[:idx]
b = ss[idx * -1:]
for i, (j, k) in enumerate(zip(a, b)):
    if a[i] != b[i * -1 -1]:
        count += 1
print count

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int n;
  cin >> n;

  if (n / 100 == 1) cout << '9';
  else cout << '1';
  
  if (n / 10 % 10 == 1) cout << '9';
  else cout << '1';
  
  if (n % 10 == 1) cout << '9' << endl;
  else cout << '1' << endl;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define w(e) int e ; cin >> e ; while (e--)  
#define ll long long 
#define endl "\n"
#define mod  10000000007
#define pi 3.1415926535897932384626433
#define setbit(x) __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)  
/*
*/
int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    double A,B,H,M,ans;
        cin>>A>>B>>H>>M;
        double angH=H,angM=M;
        ans=sqrt(pow(A,2)-2*A*B*cos(abs(angH/12.0 +(angM/60.0)/12.0-angM/60.0)*2.0*pi) +pow(B,2));
        cout<<fixed<<setprecision(15)<<ans;
	return  0;
}

Measured memory_bytes: 4204
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // A - On the Way

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        boolean onC = (a < c && c < b) ||  (a > c && c > b);

        String ans = onC ? "Yes" : "No";
        
        System.out.println(ans);
    }

}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;

// tourist set
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << '\n'; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set 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; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define p_yes() p("YES")
#define p_no() p("NO")
#define SZ(x) ((int)(x).size())
#define SORT(A) sort(ALL(A))
#define RSORT(A) sort(ALL(A), greater<ll>())

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;
const double PI = acos(-1);

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

    // input
    ll N; 
    cin >> N;

    string s; cin >> s;

    for(char c : s){
      ll v = c - 'A';
      v += N;
      v %= 26;
      char d = v + 'A';
      cout << d;
    }
    cout << endl;
    
    return 0;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 50 + 7;

int n;
li a[N];

bool read () {
	if (scanf("%d", &n) != 1)
		return false;
	forn(i, n)
		scanf("%lld", &a[i]);
	return true;
}

void solve() {
	bool fl = false;
	int pos = max_element(a, a + n) - a;
	if (-(*min_element(a, a + n)) >= *max_element(a, a + n)){
		forn(i, n) a[i] = -a[i];
		reverse(a, a + n);
		pos = max_element(a, a + n) - a;
		fl = true;
	}
	vector<pt> ans;
	forn(i, n){
		while (i && a[i] < a[i - 1]){
			ans.pb(mp(pos, i));
			a[i] += a[pos];
		}
		if (a[i] > a[pos]){
			pos = i;
		}
	}
	printf("%d\n", sz(ans));
	for (auto it : ans){
		if (fl)
			printf("%d %d\n", n - it.x, n - it.y);
		else
			printf("%d %d\n", it.x + 1, it.y + 1);
	}
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
	
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

	while(read()) {	
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

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

int main() {
    int A=0,B=0,C=0,D=0,diff=0;
    cin >> A >> B >> C >> D;
    diff = (A+B) - (C+D);
    if(diff > 0){
        cout << "Left" << endl;
    }else if(diff == 0){
        cout << "Balanced" << endl;
    }else{
        cout << "Right" << endl;
    }
    return 0;
}

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

signed main(){
	lint N; cin >> N;
	vector<lint> a(N), b(500000, 0), c(500000, 0);
	for(lint i = 0; i < N; i++) {
		cin >> a[i];
		if(i + a[i] <= N) b[i + a[i]]++;
		if(i - a[i] >= 0) c[i - a[i]]++;
	}
	lint ans = 0;
	for(lint i = 0; i < b.size(); i++){
		if(b[i]!= 0 && c[i] != 0) ans += b[i] * c[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 12764
a = []; b = []; c = []
n, m = map(int, input().split())

for i in range(n):
	row = map(int, input().split())
	a.append(list(row))

for j in range(m):
	col = int(input())
	b.append(col)

for k in range(n):
	temp = 0
	for l in range(m):
		temp += a[k][l] * b[l] 
	c.append(temp)

for ind in range(n):
	print(c[ind])

Measured memory_bytes: 8020
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<62)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin>>n;
    vl x(n);
    cin>>x;
    vl cost(100,0);
   
    rep(i,100){
        range(j,1,n+1){
            cost[i]+=(x[j-1]-i-1)*(x[j-1]-i-1);
            //puta(cost[i]);
        }
    }
    
    /*rep(i,100){
        cout<<cost[i]<<" ";
    }
    cout<<endl;*/
    sort(all(cost));
    
    puta(cost[0]);

}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n,k=MAP()
h=LIST()
h.sort()
if n-k<=0:
    print(0)
else:
    print(sum(h[:n-k]))



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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  ll n, cnt = 0;
  string s;
  cin >> n >> s;
  rep(i, n) if (s.substr(i, 3) == "ABC") cnt++;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3584
s = input()
ans = [0 for _ in range(len(s))]
temp = 0
start = 0
for i in range(len(s) - 1):
    if s[i] == "R" and s[i + 1] == "L":
        pivot = i
    if s[i] == "L" and s[i + 1] == "R":
        temp += 1
        ans[pivot] = ans[pivot + 1] = temp // 2
        if temp % 2 == 1:
            if (pivot - start) % 2 == 1:
                ans[pivot + 1] += 1
            else:
                ans[pivot] += 1
        temp = -1
        start = i + 1
    temp += 1
temp += 1
ans[pivot] = ans[pivot + 1] = temp // 2
if temp % 2 == 1:
    if (pivot - start) % 2 == 1:
        ans[pivot + 1] += 1
    else:
        ans[pivot] += 1
for a in ans:
    print(str(a) + " ", end = "")


Measured memory_bytes: 50848
S = input()
T = input()

chars = "abcdefghijklmnopqrstuvwxyz"
c2n = {chars[i]: i for i in range(26)}
RS = [-1]*26
RT = [-1]*26
N = len(S)
flag = True
for i in range(N):
    if RS[c2n[S[i]]] >= 0:
        if RS[c2n[S[i]]] != c2n[T[i]]:
            flag = False
            break
    if RT[c2n[T[i]]] >= 0:
        if RT[c2n[T[i]]] != c2n[S[i]]:
            flag = False
            break
    if RS[c2n[S[i]]] < 0:
        RS[c2n[S[i]]] = c2n[T[i]]
    if RT[c2n[T[i]]] < 0:
        RT[c2n[T[i]]] = c2n[S[i]]
    
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 74116
n = int(input())
hs = list(map(int, input().split()))

cnt = 0
while True:
    flag = True
    prev = -1
    # print(hs)
    for i in range(n):
        h = hs[i]
        if h == 0:
            # 0→0
            if prev == -1:
                continue
            # 1→0
            else:
                cnt += 1
                prev = -1
        else:
            # 0→1
            if prev == -1:
                flag = False
                hs[i] -= 1
                prev = 0
            # 1→1
            else:
                hs[i] -= 1
    if prev != -1:
        cnt += 1
    if flag:
        break
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>

using namespace std;
typedef long long int ll;

int N,ans;
void count(ll x,bool a,bool b,bool c){
  if (x>N) return;
  if (a&&b&&c) ans++;
  count(x*10+3,true,b,c);
  count(x*10+5,a,true,c);
  count(x*10+7,a,b,true);
}
int main(void){
  cin >>N;
  ans=0;
  count(0,false,false,false);
  cout << ans<<endl;
  return 0;
}


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

void sortString (string &str) {
  sort(str.begin(), str.end());
}

int main () {
  string s;
  string t;
  cin >> s >> t;
  
  sortString(s);
  sortString(t);
  reverse(t.begin(), t.end());

  if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import bisect

n=int(input())
llist = list(int(i) for i in input().split())
llist=sorted(llist)
kotae=0
#print(llist)
swit=0
etswit=0

for i in range(n-2):
    swit=0
    for j in range(n-2-i):
        a=i
        b=i+j+1
        koho=llist[b+1:]
        nagasa=len(koho)
        if etswit==0:
            if swit==0:
                index = bisect.bisect_left(koho, llist[a]+llist[b])
                if index==nagasa:
                    swit=1
                    if j==0:
                        etswit=1
                #print(a,b,koho,index)
                kotae+=index
            else:
                kotae+=nagasa
        else:
            kotae+=nagasa

print(kotae)

Measured memory_bytes: 59100
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int
#define ld long double

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10
#define PI acos(-1LL)

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

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

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	int n;
	cin>>n;
	string s;
	cin>>s;


	for(i=0;s[i];i++)
	{
		int dist=s[i]-'A';

		dist=(dist+n)%26;
		cout<<(char)('A'+dist);
	}

}

Measured memory_bytes: 3628
//
// Created by ZEN on 2019/10/20.
//

#include <bits/stdc++.h>

using namespace std;

int main() {
    int a;
    string s;
    cin >> a;
    cin >> s;
    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
}


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

double Ans;
int N;
double x;
char k[10];

inline int Rd() {
	
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') f=-1;ch=getchar(); }
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}

int main() {
	
	scanf("%d",&N);
	while(N--) {
		
		scanf("%lf",&x);
		scanf("%s",k);
		if(k[0]=='J') Ans+=x;
		else Ans+=x*380000.0;
	} printf("%.6f\n",Ans);
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		FastScanner fs = new FastScanner();
		int N = fs.nextInt();
		int M = fs.nextInt();
		boolean[] solved = new boolean[N];
		int[] pe = new int[N];
		for(int i = 0; i < N; i++) {
			solved[i] = false;
		}

		for(int i = 0; i < M; i++) {
			int p = fs.nextInt();
			String s = fs.next();
			if(s.equals("AC")) {
				solved[p-1] = true;

			}else {
				if(!solved[p-1]) {
					pe[p-1]++;
				}
			}
		}
		int solv = 0;
		int count = 0;
		for(int i = 0; i < N; i++) {
			if(solved[i]) {
				solv++;
				count += pe[i];
			}
		}
		
		
		System.out.println(solv + " " + count);
	}

}


Measured memory_bytes: 37256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++){
    int ctr=0;
    int cpy=i;
    while(cpy){
      cpy/=10;
      ctr++;
    }
    if(ctr%2==1) ans++;
  }
  cout<<ans<<'\n';
  return 0;
}

Measured memory_bytes: 256
# frozen_string_literal: true

require 'prime'

n = gets.to_i
a = gets.split.map(&:to_i)

@p = {}

@primes = Prime.each(Math.sqrt(a.max)).to_a

def prime_division(n)
  return @p[n] if @p[n]
  return @p[n] = [n] if n.prime?

  divs = []
  @primes.each do |p|
    break if n == 1

    if n.prime?
      divs.push n
      break
    end
    while (n % p).zero?
      divs.push p
      n /= p
    end
  end
  @p[n] = divs
end

b = Array.new(n + 1, false)
flag = true
a.each do |e|
  prime_division(e).uniq.each do |p|
    if b[p]
      flag = false
      break
    end
    b[p] = true
  end
  break unless flag
end

if flag
  puts 'pairwise coprime'
  exit
end

g = a[0]
(1..(n - 1)).each do |i|
  g = g.gcd(a[i])
end

if g == 1
  puts 'setwise coprime'
else
  puts 'not coprime'
end


Measured memory_bytes: 92236
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		sc.close();
		int ans = 0;
		for(int i=1;i<N+1;i++) {
			String I = Integer.toString(i);
			int length = I.length();
			if(length%2==1) {
				ans++;
			}
		}
		System.out.println(ans);


	}
}


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

int main()
{
    string ss;
    cin>>ss;
    int m=ss.size();

    int n= ss.size()/2;



    int cnt=0;
    for(int i=0;i<n;i++)
    {

        if(ss[i]!=ss[m-1-i])
            {
                cnt++;
            }
    }

    cout<<cnt;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        
        var sc = new Scanner(System.in);
    
        int n = Integer.parseInt(sc.next());
        
        int ans = 0;
        for(int i = 1; i <= n; i++){
            int a = Integer.parseInt(sc.next());
            if(i%2 == 1 && a%2 == 1) ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35648
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

bool isPrime(int n){
    if(n < 2) return false;
    if(n == 2) return true;
    if(n%2 == 0) return false;

    for(int i=3; i*i<=n; i++){
        if (n%i == 0) return false;
    }
    return true;
}

int main(){
    int n, cnt = 0, s[1000000]={0};
    REP(i, 1000000){
        if (isPrime(i)) s[i]++;
    }
    while(cin>>n){
        for(int i=0; i <= n; i++){
            if (s[i] == 1) cnt++;
        }
        cout << cnt << endl;
        cnt = 0;
    }
}


Measured memory_bytes: 6968
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
ll N;
ll _case[10] = { 0,0,0,6,36,150,540,1806,5796,18150 };

ll presum = 0;
int num3 = 0;
int num5 = 0;
int num7 = 0;

void cal(int n,ll val) {

	if (n == -1) {
		if (num3 == 0 || num5 == 0 || num7 == 0) {
			return;
		}
		else {
			if (val <= N) presum++;
		}
		return;
	}

	val += 3 * pow(10, n);
	num3++;
	cal(n - 1, val);
	num3--; num5++;
	val += 2 * pow(10, n);
	cal(n - 1, val);
	num5--; num7++;
	val += 2 * pow(10, n);
	cal(n - 1, val);
	num7--;
	return;
}

//解法
void solve() {

	ll ans = 0;

	int num = floor(log10(N) + 1);

	rep(i, num+1) {
		//ans += _case[i];
		cal(i - 1, 0);
	}

	//cal(num-1,0);

	cout << ans+presum;

	return;
}

int main() {
	//入力

	cin >> N;

	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
  
int main(int argc, char *argv[]) {
    int n, k;
    int l[50];

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

    for (int j = 0; j <= n - 2; j++) {
        for (int i = 0; i <= n - j - 2; i++) {
            int tmp;
            if (l[i] < l[i + 1]) {
                tmp = l[i];
                l[i] = l[i + 1];
                l[i + 1] = tmp;
            }
        }
    }

    int sum = 0;
    for (int i = 0; i < k; i++) {
        sum += l[i];
    }

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

    return 0;
}

Measured memory_bytes: 128
import java.util.*

fun main(args: Array<String>) {
    val (H, W) = readLine()!!.split(" ").map{it.toInt()}
    val f = Array<String>(H) { readLine()!! }
    val mp = TreeMap<Char, Int>()

    for (row in f) {
        for (c in row) {
            mp[c] = (mp[c] ?: 0) + 1
        }
    }

    val h: Int
    val w: Int

    if (H % 2 != 0) {
        h = W
        w = H
    } else {
        h = H
        w = W
    }

    var c2: Int
    var c1: Int

    if (h % 2 != 0) {
        c1 = 1
        c2 = h + w - 2
    } else if (w % 2 != 0) {
        c1 = 0
        c2 = h
    } else {
        c1 = 0
        c2 = 0
    }
    var c4 = h * w - (c1 + c2)

    if (c2 % 2 != 0 || c4 % 4 != 0) {
        System.exit(1)
    }

    for (c in mp.keys) {
        val a = Math.min(c4, mp[c]!! / 4 * 4)
        mp[c] = mp[c]!! - a
        c4 -= a
    }
    if (c4 > 0) {
        println("No")
        return
    }

    for (c in mp.keys) {
        val a = Math.min(c2, mp[c]!! / 2 * 2)
        mp[c] = mp[c]!! - a
        c2 -= a
    }
    if (c2 > 0) {
        println("No")
        return
    }

    for (c in mp.keys) {
        val a = Math.min(c1, mp[c]!!)
        mp[c] = mp[c]!! - a
        c1 -= a
    }
    if (c1 > 0) {
        println("No")
        return
    }

    println("Yes")
}


Measured memory_bytes: 38200
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n,x=0, max=0;
    char s;
    cin>>n;
    REP(i,n){
        cin>>s;
        if(s=='I'){
            x++;
        }else{
            x--;
        }
        if(x>max){
            max=x;
        }
    }
    cout<<max<<endl;
    return 0;
}


Measured memory_bytes: 3604