akhauriyash/Code-Regression huggingface dataset:
import Control.Monad
import Data.Array
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt

readIntList = map readInt . BS.words

readString = map BS.unpack . BS.words

getIntList = readIntList <$> BS.getLine

getNString n = map readString <$> replicateM n BS.getLine

powerset :: [a] -> [[a]]
powerset xs = filterM (\x -> [True, False]) xs

paintH2 :: Int -> Int -> Int -> Array (Int, Int) Char -> Array (Int, Int) Char
paintH2 h i w sss
  | i == w = sss'
  | otherwise = paintH2 h (i + 1) w sss'
  where
    sss' = sss // [((h, i), 'v')]

paintH :: [Int] -> Int -> Array (Int, Int) Char -> Array (Int, Int) Char
paintH [] w sss = sss
paintH (h : hs) w sss = paintH hs w sss'
  where
    sss' = paintH2 h 1 w sss

paintW2 :: Int -> Int -> Int -> Array (Int, Int) Char -> Array (Int, Int) Char
paintW2 w i h sss
  | i == h = sss'
  | otherwise = paintW2 w (i + 1) h sss'
  where
    sss' = sss // [((i, w), 'v')]

paintW :: Int -> [Int] -> Array (Int, Int) Char -> Array (Int, Int) Char
paintW h [] sss = sss
paintW h (w : ws) sss = paintW h ws sss'
  where
    sss' = paintW2 w 1 h sss

simulate2 :: [Int] -> [Int] -> Int -> Int -> Int -> Array (Int, Int) Char -> Int
simulate2 hs ws k h w sss = if tf then 1 else 0
  where
    sss' = paintH hs w sss
    sss'' = paintW h ws sss'
    tf = length (filter (\x -> x == '#') (elems sss'')) == k

simulate1 :: [[Int]] -> [Int] -> Int -> Int -> Int -> Array (Int, Int) Char -> Int -> Int
simulate1 [] ws k h w sss n = n
simulate1 (hs : hss) ws k h w sss n = simulate1 hss ws k h w sss (n + n')
  where
    n' = simulate2 hs ws k h w sss

simulate :: [[Int]] -> [[Int]] -> Int -> Int -> Int -> Array (Int, Int) Char -> Int -> Int
simulate hss [] k h w sss n = n
simulate hss (ws : wss) k h w sss n = simulate hss wss k h w sss (n + n')
  where
    n' = simulate1 hss ws k h w sss 0

main = do
  [h, w, k] <- getIntList
  sss <- getNString h
  let sss' = concat (map head sss)
  let sss'' = listArray ((1, 1), (h, w)) sss'
  let hss = powerset [1 .. h]
  let wss = powerset [1 .. w]
  let n = simulate hss wss k h w sss'' 0
  print n


Measured memory_bytes: 4728
#include <iostream>
#include <cmath>
#include <stdint.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
using namespace std;
 
#define int long long
 
 
int gcd(int a, int b){
	
	if(b==0){
		return a;
	}
	
	return gcd(b,a%b);
	
}
 
 int lcm(int a, int b)  
 {  
    return (a*b)/gcd(a, b);  
 }  
 
 
int f(int x){
	
	
	int res = 0;
	
	while( x%2 == 0){
		
		x/=2;
		res++;
	}
	
	return res;
	
}
 int a[200001];
 
int32_t main() {
 
 	int n;
  
  	cin >> n;
  	
  	for(int i=0; i<n; i++){
  		
  		cin >> a[i];
  		
	}
  
  	int cnt =1;
  	int b=0;
  	vector<int> v;
  	for(int i=0; i<n; i++){
  		
  		if(a[i] != cnt){
  		b++;	
		}
		else{
			v.push_back(cnt);
			cnt++;
			
		}
  		
	}	
	 
	bool flag = false;
	for(int i=0; i<v.size(); i++){
		if( v[i] == 1)
			flag= true;
	}
 
   if(!flag)
   	b = -1;
  cout << b << endl;
}
 
 
 

Measured memory_bytes: 6496
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	int len=s.length();
	for(int i=0;i<len;i++)
	{
		if(s[i]!=t[i])
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
 } 

Measured memory_bytes: 3588
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
#include <numeric>
#include<iostream>
#include<deque>
#include<queue>
#include<string>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(void){
    int n;
    cin>>n;
    vector <double> v(n);
    rep(i, n){
        cin>>v[i];
    }

    sort(v.begin(), v.end());
    
    double ans=v[0];
    
    for(int i=1;i<n;i++){
        ans+=v[i]*(pow(2, (i-1)));
        
    }
    ans/=pow(2, (n-1));
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
  int n,m;
  scanf("%d%d",&n,&m);
  static bool B[100000]={0};
  static int C[100000];
  B[0]=1;
  for(int i=0;i<n;i++){
    C[i]=1;
  }
  for(int i=0;i<m;i++){
    int x,y;
    scanf("%d%d",&x,&y);
    x--;
    y--;
    if(B[x]){
      B[y]=1;
    }
    if(C[x]==1){
      B[x]=0;
    }
    C[x]--;
    C[y]++;
  }
  int a=0;
  for(int i=0;i<n;i++){
    if(B[i]){
      a++;
    }
  }
  printf("%d\n",a);
  return 0;
}


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

char getGrade(int m,int f, int r){

  int sum = m + f;
  char grade;

  if(sum < 30 || m == -1 || f == -1) grade = 'F';
  else if(sum >= 80) grade = 'A';
  else if(65 <= sum && sum < 80) grade = 'B';
  else if(50 <= sum && sum < 65) grade = 'C';
  else if(30 <= sum && sum < 50){
    if(50 <= r) grade = 'C';
    else grade = 'D';
  }

  return grade;
}

int main() {

  int m, f, r;
  
  while(1){
    cin >> m >> f >> r;
    if(m == -1 && f == -1 && r == -1) break;
    cout << getGrade(m, f, r) << endl;
  }

  return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char turn = 'a';
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        int aCur = 0;
        int bCur = 0;
        int cCur = 0;
        for (int i = 0 ; i < 300 ; i++) {

            if (turn == 'a') {
                if (aCur == a.length()) {
                    System.out.println("A");
                    return;
                }
                turn = a.charAt(aCur);
                aCur++;
            } else if (turn == 'b') {
                if (bCur == b.length()) {
                    System.out.println("B");
                    return;
                }
                turn = b.charAt(bCur);
                bCur++;
            } else {
                if (cCur == c.length()){
                    System.out.println("C");
                    return;
                }
                turn = c.charAt(cCur);
                cCur++;
            }
        }


    }

}

Measured memory_bytes: 22868
Plan = Struct.new(:t, :x, :y)

plans = Array.new(gets.chomp.to_i) do
          t, x, y = gets.chomp.split.map(&:to_i)
          Plan.new(t, x, y)
        end

able = true
x, y, t = 0, 0, 0
until plans.empty?
  plan = plans.shift
  d = (x - plan.x).abs + (y - plan.y).abs
  
  if plan.t - t < d
    able = false
    break
  end
  
  unless (plan.t - t) % 2 == d % 2
    able = false
    break
  end
  
  x, y, t = plan.x, plan.y, plan.t
end
puts able ? "Yes" : "No"

Measured memory_bytes: 9596
import java.util.Scanner

fun main(args: Array<String>) {
    val (k, s) = Scanner(System.`in`).use<Scanner, Pair<Int, Int>> {
        it.nextInt() to it.nextInt()
        // 0≦X,Y,Z≦K
        // 2≦K≦2500
        // 0≦S≦3K
    }

    // zを定めると、x + y = s - z, z in range 0 .. minOf(s, k)
    val result: Int = (0..Math.min(s, k)).map (fun(z: Int): Int {
        val max = s - z
        // x + y = maxを満たすx,yの組み合わせの数は、
        return when {
            max > 2 * k -> 0
            max > k -> 2 * k - max + 1
            else -> max + 1
        }
    }).toIntArray().sum()
    // resultの最大値は、2500^3より少ないが、Intの上限を超えるおそれがあるかにみえるが、
    // 一辺2500の立方体を平面で切った時の格子点の数なので、2500^2の2〜数倍程度おのはず。

    /*
    var count = 0
    for (z in 0..Math.min(s, k)) {
        val max = s -z
        count += when {
            max > 2 * k -> 0
            max > k -> 2 * k - max + 1
            else -> max + 1
        }
    }*/

    print(result)
}

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

signed main() {
  int a,b,c,x,y; cin >>a>>b>>c>>x>>y;
  int ans = 1e9;
  int xy = max(x,y);
  for(int ab=0; ab<=xy * 2; ab+=2) {
    int xx = max(0, x - ab/2);
    int yy = max(0, y - ab/2);
    ans = min(ans, ab * c + xx * a + yy * b); 
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import heapq

l = input().split()
V = int(l[0])
E = int(l[1])
r = int(l[2])

graph = [[] for _ in range(V)]
for i in range(E):
    l = input().split()
    graph[int(l[0])].append((int(l[2]),int(l[1])))

heap = [(0,r)]
dist = [float("inf") for _ in range(V)]
while heap:
    pop = heapq.heappop(heap)
    if dist[pop[1]] < pop[0]:
        continue
    dist[pop[1]] = pop[0]
    for (w,i) in graph[pop[1]]:
        if i!= pop[1] and w >= 0 and dist[i] == float("inf"):
            heapq.heappush(heap, (pop[0]+w, i))

for d in dist:
    if d == float("inf"):
        print("INF")
    else:
        print(d)

Measured memory_bytes: 101972
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

const int mod = 1000000007;
struct mint {
    ll x; // using 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, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n; cin>>n;
    vl as(n); cin>>as;

    mint acc = 0;
    mint accp = 0;
    rep(i, n) {
        acc += as[i];
        accp += as[i] * as[i];
    }
    mint ans = (acc * acc - accp) / 2;
    cout<<ans<<endl;
}

Measured memory_bytes: 4744
N,Y = map(int, input().split())
cnt=0
for i in range(N+1):
    for j in range(N+1):
        if 0<= N- (i +j) <=2000 and Y == 10000*i+5000*j+1000*(N-i-j):
            cnt+=1
            l =[i, j]
if cnt>=1:
    print(l[0],l[1],(N-(l[0]+l[1])))
else:
    print(-1,-1,-1)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long s = sc.nextLong();
		long point[][] = new long[3][2];
		point[0][0] = 0;
		point[0][1] = 0;
		long rt = (long)Math.ceil(Math.sqrt(s));
		if(rt * rt == s) {
			System.out.println("0 0 0 "+rt+" "+rt+" 0"); return;
		}
		point[1][1] = rt;
		point[2][0] = rt;
		long rest = rt * rt - s;
		long max = (long)Math.pow(10, 9);
		for(long i = 1; i * i <= rest; i ++) {
			if(rest % i == 0 && rest / i <= max) {
				point[1][0] = i;
				point[2][1] = rest / i;
			}
		}
		
		for(int i = 0; i < 3; i ++) {
			for(int j = 0; j < 2; j ++) {
				System.out.print(point[i][j]+" ");
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());


int n,m;
int niz[100005];
vector<int> graf[100005];
int poj[100005];

int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,k;
    cin >> n >> k;
    ff(i,1,k){
        int d;
        cin >> d;
        ff(j,1,d){
            int x;
            cin >> x;
            poj[x]++;
        }
    }
    int res = 0;
    ff(i,1,n){
        if(poj[i] == 0)res++;
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int64_t> A(n), B(n);
    for (int i = 0; i < n; i++)
        cin >> A[i] >> B[i];

    auto C = A;
    sort(C.begin(), C.end());

    auto mid = [](const auto &A){
        int n = A.size();
        if (n % 2 == 0)
            return (A[n / 2] + A[n / 2 - 1]);
        else
            return A[n / 2];
    };
    int64_t lower = mid(C);
    C = B;
    sort(C.begin(), C.end());
    int64_t upper = mid(C);

    cout << upper - lower + 1 << endl;
}

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

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

using namespace std;

int digitsum(int a){
	int res=0;
	for(;a>0;a/=10) res+=a%10;
	return res;
}

int main(){
	int n; scanf("%d",&n);

	int ans=n;
	for(int a=1;a<n;a++) ans=min(ans,digitsum(a)+digitsum(n-a));
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main (void){
  int s,b;
  scanf("%d%d",&s,&b);
  int sum=s+b;
  if(s+s-1>sum){
    sum=s+s-1;
  }
  if(b+b-1>sum){
    sum=b+b-1;
  }
  printf("%d",sum);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int


int main(){
	string ss[]={"AC", "WA", "TLE", "RE"};
        map<string,ll>m;
        ll n;
        cin>>n;
        string s;
        for(ll i=0; i<n; i++){
        	cin>>s;
        	m[s]++;
        }
        for(ll i=0; i<4; i++)
        	cout<<ss[i]<<" x "<<m[ss[i]]<<endl;


   } 







Measured memory_bytes: 3608
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int a, b;
	cin >> a >> b;
	cout << (a + b) % 24 << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep_3(i, initial, n) for (int i = (int)(initial); i < (int)(n); ++i)
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int i = (int)(n); i > 0; i--)
#define rep_r_3(i, initial, n) for (int i = (int)(initial); i > (int)(n); i--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
// namespace mp = boost::multiprecision;
typedef long long ll;
typedef pair<int, int> P;
// typedef mp::cpp_int mpint;
const double EPS = numeric_limits<double>::epsilon();
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

	ll result = 0, n = N/2;
	unsigned long long count = 5;

	if ((N % 2) == 0) {

		while (count <= n) {
			result += n / count;
			count *= 5;
		}

	}
	cout << fixed << setprecision(20) << result << endl;
	return 0;
}


Measured memory_bytes: 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int k;
    int x;
    cin >> k;
    cin >> x;
    if(k*500>=x){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 888
import java.util.Scanner

object Main extends App {
  val scanner = new java.util.Scanner(System.in)
    val words = scanner.nextLine.map(_.toString).map { x =>
      if(x == "?"){
        "D"
      } else{
        x
      }
    }.mkString("")

    //val cntMap = wordsList.groupBy(identity).mapValues(_.size)

    println(words)
}

Measured memory_bytes: 69548
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
#include <iomanip>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)

ll INF = 1000000000;
ll stay_x_max=-INF,stay_x_min=INF,stay_y_max=-INF,stay_y_min=INF;
ll up_x_max=-INF,up_x_min=INF,up_y_max=-INF,up_y_min=INF;
ll down_x_max=-INF,down_x_min=INF,down_y_max=-INF,down_y_min=INF;

double solve(double t){
    double x_max=(double)stay_x_max,x_min=(double)stay_x_min,y_max=(double)stay_y_max,y_min=(double)stay_y_min;
    x_max = max(x_max,(double)up_x_max+t);
    x_max = max(x_max,(double)down_x_max-t);
    x_min = min(x_min,(double)up_x_min+t);
    x_min = min(x_min,(double)down_x_min-t);
    y_max = max(y_max,(double)up_y_max+t);
    y_max = max(y_max,(double)down_y_max-t);
    y_min = min(y_min,(double)up_y_min+t);
    y_min = min(y_min,(double)down_y_min-t);

    return (x_max-x_min)*(y_max-y_min);
}

int main(){
    int N;
    cin>>N;
    ll *x = new ll[N];
    ll *y = new ll[N];
    char *d = new char[N];
    rep(i,N) cin>>x[i]>>y[i]>>d[i];

    rep(i,N){
        if(d[i]=='R'){
            up_x_max = max(up_x_max,x[i]);
            up_x_min = min(up_x_min,x[i]);
            stay_y_max = max(stay_y_max,y[i]);
            stay_y_min = min(stay_y_min,y[i]);
        }else if(d[i]=='L'){
            down_x_max = max(down_x_max,x[i]);
            down_x_min = min(down_x_min,x[i]);
            stay_y_max = max(stay_y_max,y[i]);
            stay_y_min = min(stay_y_min,y[i]);
        }else if(d[i]=='U'){
            stay_x_max = max(stay_x_max,x[i]);
            stay_x_min = min(stay_x_min,x[i]);
            up_y_max = max(up_y_max,y[i]);
            up_y_min = min(up_y_min,y[i]);
        }else{
            stay_x_max = max(stay_x_max,x[i]);
            stay_x_min = min(stay_x_min,x[i]);
            down_y_max = max(down_y_max,y[i]);
            down_y_min = min(down_y_min,y[i]);
        }
    }
    vector<double>times;
    times.push_back((double)0);
    times.push_back((stay_x_max-up_x_max)/1.0);
    times.push_back((down_x_max-stay_x_max)/1.0);
    times.push_back((down_x_max-up_x_max)/2.0);
    times.push_back((stay_y_max-up_y_max)/1.0);
    times.push_back((down_y_max-stay_y_max)/1.0);
    times.push_back((down_y_max-up_y_max)/2.0);
    
    times.push_back((stay_x_min-up_x_min)/1.0);
    times.push_back((down_x_min-stay_x_min)/1.0);
    times.push_back((down_x_min-up_x_min)/2.0);
    times.push_back((stay_y_min-up_y_min)/1.0);
    times.push_back((down_y_min-stay_y_min)/1.0);
    times.push_back((down_y_min-up_y_min)/2.0);


    double ans=(double)INF*(double)INF*(double)4;
    rep(i,13){
        double t = times[i];
        // cout<<t<<endl;
        if(t<-0.05) continue;
        ans = min(ans,solve(t));
        // cout<<t<<" "<<solve(t)<<endl;
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;

    delete[] x,y,d;
    return 0;
}

Measured memory_bytes: 1920
///HR_Bappy
//
///*******

#include<bits/stdc++.h>
#define pb push_back
#define mkp make_pair
#define maxx 1000000005
#define MOD 1000003
#define sf(n) scanf("%lld", &n);
#define sff(n,m) scanf("%lld %lld", &n, &m)
#define pf(n) printf("%lld\n", n)
#define pff(n,m) printf("%lld %lld\n", n, m)
#define mem(a) memset(a, 0, sizeof(a))
#define fr(i,n) for(ll i=0; i<n; i++)
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type))
#define pi 2*acos(0.0)
#define F first
#define S second
#define EPS 1e-9

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n;
    cin >> n;
    string a;
    cin >> a;
    int c = 0;
    for(int i = 0; i < a.size();){
        int x = 0;
        while(a[x+i] == a[x+i+1]) x++;

        c++;
        i += x+1;
        //cout <<c << " "<< x << endl;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define chmax(x,y) x = max(x,y)
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll h, w, a, b;
set<pair<ll, ll>> s;
multiset<ll> vals;

int main() {
	cin >> h >> w;
	rep(i, w) {
		s.insert(mp(i, i));
		vals.insert(0);
	}
	rep(i, h) {
		cin >> a >> b;
		a--;
		auto it = s.lower_bound(mp(a, 0));
		ll mr = -1;
		while (it != s.end() && it->first <= b) {
			mr = it->second;
			vals.erase(vals.find(it->first - it->second));
			it = s.erase(it);
		}
		if (b == w)mr = -1;
		if (mr != -1) {
			s.insert(mp(b, mr));
			vals.insert(b - mr);
		}
		if (vals.size()) {
			cout << *vals.begin() + i + 1 << endl;
		}
		else {
			cout << -1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 25504
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const double pi=3.1415926535;

int main(){
  ll n;
  cin>>n;
  co(2*pi*n);
  return 0;
}

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

int main()
{
	int N;
	int A[100];
	double sum = 0;
	
	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	for (int i = 0; i < N; i++) {
		sum += 1 / (double)A[i];
	}

	cout << (double)(1 / sum);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;

using namespace std;

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll N;cin >> N;
	ll ans = 0;
	ll max = 1e9 + 7;
	ll x;
	for (int i = 0;i < N;i++) {
		cin >> x;
		if (x <= max) {
			max = x;
			ans++;
		}
	}
		cout << ans << endl;
}


Measured memory_bytes: 256
import bisect
n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
res = 0
for bi in b:
    aUpper = bisect.bisect_left(a, bi)
    cLower = len(c) - bisect.bisect_right(c, bi)
    res += (aUpper * cLower)
print(res)


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

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool connect(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool isSame(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

bool used[100005];

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
  int n,m;cin>>n>>m;
  UnionFind uf = UnionFind(n);

  for(int i=0;i<m;i++){
    int x,y,z;cin>>x>>y>>z;x--,y--;
    uf.connect(x, y);
  }
  int ans=0;
  for(int i=0;i<n;i++){
    auto r = uf.root(i);
    if (used[r])continue;
    used[r]=1;
    ans++;
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define all(v) (v).begin(),(v).end()
 
#define PII pair<int,int>
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream &os, vector<T> V){
  os<<"[";for(auto vv:V)os<<vv<<",";return os<<"]";
} 

template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}


#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
 
#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue
 
#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb fflush(stdout)

const int max_n = 1e5+5;

lint a[max_n];
lint b[max_n];

int main () {
	make2(n, m);
	makev(v, n);
	for (auto& x: v) {
		x--;
	}
	lint ans = 0;
	for (int i = 0; i < n-1; i++) {
		if (v[i] < v[i+1]) {
			int c = v[i+1]-v[i];
			a[v[i]+1]++;
			b[v[i]+1] -= (v[i]+1);
			if (v[i+1] != m-1) {
				a[v[i+1]+1]--;
				b[v[i+1]+1]+= (v[i]+1);
			}
			ans += v[i+1]-v[i];
		} else {
			if (v[i] != m-1) {
				a[v[i]+1]++;
				b[v[i]+1]-= (v[i]+1);
			}
			a[0]++;
			b[0] += (m-v[i]-1);
			a[v[i+1]+1]--;
			b[v[i+1]+1]-=(m-v[i]-1);
			ans += (v[i+1]-v[i]+m);
		}
		/*cerr << "A = ";
		FOR(j, 0, m) {
			cerr <<a[j] << ", ";
		}
		cerr << endl << "B = ";
		FOR(j,0,m) {
			cerr << b[j] << ",";
		}
		cerr << endl;*/
	}
	//debug(ans);
	lint best = 0;
	lint acta = 0;
	lint actb = 0;
	for (int j = 0; j < m; j++) {
		acta += a[j];
		actb += b[j];
		best = max(best, acta*1LL*j + actb);
		//debug(acta*1LL*j + actb);
	}
	printf("%lld\n", ans - best);
}


Measured memory_bytes: 2296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[70] = {};
int main() {
    ll n;
    cin >> n;
    vector<int> v;
    a[1] = 1;
    for (int i = 2; i < 70; i++) {
        a[i] = a[i-1] + i;
    }
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            int cnt = 0;
            while (n % i == 0) {
                n /= i;
                cnt++;
            }
            v.push_back(cnt);
        }
    }
    if (n > 1) v.push_back(1);
    sort(v.begin(), v.end());
    int ans = 0;
    int p = 1;
    for (int i = 0; i < (int)v.size(); i++) {
        while (a[p] <= v[i]) p++;
        ans += p - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 1e9+7;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }


main(){
  ll n,k,d,ks=0,kkind=0;
  //cin>>n;
  string s;
  cin>>s;
  if(s[5]=='1')cout<<"TBD";
  else{
    ll x=(ll)(s[6]-'0');
    if(x>4)cout<<"TBD";
    else cout<<"Heisei";
  }
}


Measured memory_bytes: 256
s = input()
S = list(set(s))
list.sort(S)
strings = "abcdefghijklmnopqrstuvwxyz"
switch = 0
for i in S:
    if i != strings[S.index(i)]:
        print(strings[S.index(i)])
        switch = 1
        break
    else:
        continue
if switch == 0:
    if len(strings) == len(S):
        print("None")
    else:
        print("z")

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <math.h>
using namespace std;

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	int n;
	while(1){
		cin >> n;
		if( n == 0 ) break;
		vector< int > v;
		double a = 0.0, m = 0.0;
		for(int i = 0; i < n; i++) {
			int tmp;
			cin >> tmp;
			v.push_back( tmp );
			m += ( double )tmp;
		}
		m /= (double) n;
		for(int i = 0; i < n; i++)
			a += ( v[i] - m ) * ( v[i] - m );
		a /= (double) n;
		a = sqrt( a );
		printf("%.5lf\n",a);
	}
	//while(1){}
	return 0;
}

Measured memory_bytes: 1248
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int N;
    cin >> N;
    string S;
    cin >> S;

    vector<int> stones(N, 0);
    int nR = 0;
    int nW = 0;
    for (int i = 0; i < N; ++i) {
        if (S[i] == 'R') {
            stones[i] = 0;
            ++nR;
        }
        else {
            stones[i] = 1;
            ++nW;
        }
    }

    if (nR == 0 || nW == 0) {
        cout << 0 << endl;
        return;
    }

    int numWAfter = 0;
    for (int i = 0; i < nW; ++i) {
        if (stones[N - 1 - i] == 1) {
            ++numWAfter;
        }
    }
    cout << (nW - numWAfter) << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

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

int main(){
    int h,w; cin>>h>>w;
    char m[55][55];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++) cin>>m[i][j];
    }
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int cnt=0;
            if(m[i][j]=='.'){
                for(int k=0;k<8;k++){
                    int nx=j+dx[k];
                    int ny=i+dy[k];
                    if(nx>=0&&nx<w&&ny>=0&&ny<h&&m[ny][nx]=='#') cnt++;
                }
                cout<<cnt;
            }else cout<<m[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    struct dice{int u,e,w,n,s,d;
    void rotate(char c){
        int temp=u;
        if(c=='E'){u=w;w=d;d=e;e=temp;}
        else if(c=='W'){u=e;e=d;d=w;w=temp;}
        else if(c=='N'){u=s;s=d;d=n;n=temp;}
        else if(c=='S'){u=n;n=d;d=s;s=temp;}
    }
    bool hikaku(dice q){
        int counter=0;
        if(u==q.u)counter++;
        if(s==q.s)counter++;
        if(e==q.e)counter++;
        if(w==q.w)counter++;
        if(n==q.n)counter++;
        if(d==q.d)counter++;
        if(counter==6)return true;else return false;
    }
    };
    int n;
    in(n);
    vector<dice> vec(n);
    rep(i,n){
        in(vec[i].u,vec[i].s,vec[i].e,vec[i].w,vec[i].n,vec[i].d);
    }
    string s="NNNNENNNN";
    for(int j=0;j<n-1;j++){
        for(int k=j+1;k<n;k++){
            dice a=vec[j];
            dice b=vec[k];
        rep(i,9){
            if(a.s==b.s)break;
            b.rotate(s[i]);
        }
        int counter=0;
        while(!a.hikaku(b)){
            b.rotate('E');
            counter++;
            if(counter>=5){
                goto skip;
            }
        }
        out("No");
        return 0;
        skip: ;
        }
    }
    out("Yes");
}


Measured memory_bytes: 3188
import sys

input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]
    XYZ = [[int(x) for x in input().split()] for _ in range(N)]

    ans = 0
    for i in range(2 ** 3):
        tmp = []
        for v in XYZ:
            total = 0
            for j, v2 in enumerate(v):
                if i >> j & 1:
                    total += v2
                else:
                    total -= v2
            tmp.append(total)

        tmp.sort(reverse=True)
        ans = max(ans, sum(tmp[:M]))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3292
#define _USE_MATH_DEFINES


#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <numeric>

#include <cmath>

using namespace std;

typedef long long LL;

int main() {
	vector<pair<int, int>> vec;
	int H, W;

	while (true)
	{
		cin >> H >> W;
		if (H == 0 && W == 0) break;

		auto p = make_pair(H, W);
		vec.emplace_back(p);
	}

	for (auto&& v : vec) {
		for (int j = 0; j < v.first; ++j) {
			for (int i = 0; i < v.second; ++i) {
				if ((i + j) % 2 == 0) cout << "#";
				else cout << ".";
			}
			cout << "\n";
		}
		cout << "\n";
	}

	return 0;
}



Measured memory_bytes: 3032
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

mod = 10**9+7

n,a,b = map(int, input().split())

# def comb(n, k):
#     c = 1
#     for i in range(n - k + 1, n + 1):
#         c *= i
#         c %= mod
#
#     for i in range(1, k + 1):
#         c *= pow(i, mod - 2, mod)
#         c %= mod
#
#     return c

def comb(n, k):
    c = 1
    for i in range(k):
        c *= n - i
        c %= mod

    d = 1
    for i in range(1, k + 1):
        d *= i
        d %= mod

    return (c * pow(d, mod - 2, mod)) % mod

ans = pow(2, n, mod) - 1 - comb(n, a) - comb(n, b)
print(ans % mod)


Measured memory_bytes: 9140
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll d;
	cin>>d;
	rep(b0, 3500) rep(c0, 3500){
		ll b = b0+1, c = c0+1;
		ll x = b*c*d, y = 4*b*c-b*d-c*d;
		if(y==0 || x/y<0) continue;
		if(x%y==0){
			cout<<x/y<<" "<<b<<" "<<c<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int n , k;
	cin >> n >> k;
	auto a = vector<int>(n,0);
	for(int i=0;i<n;i++){
	    cin >> a[i];
	}
	
	n--;
	k--;
	cout << n/k+(n%k==0?0:1);
}

Measured memory_bytes: 640
Even, Odd = map(int, input().split())

if Odd > 1:
    ans1 = Even * (Even-1) / 2
    ans2 = Odd * (Odd-1) / 2
else:
    ans1 = Even * (Even-1) / 2
    ans2 = 0
print(int(ans1+ans2))

Measured memory_bytes: 3060
#include <stdio.h>

void ins_sort(int *A); //insertion sort

int num;

int main () {
	int a[101],i;
	
	scanf ("%d",&num);
	for (i = 0;i < num;i ++) {
		scanf ("%d",&a[i]);
	}
	ins_sort(a);
	
	return 0;
}

void ins_sort(int *A) {
	int  i,j,k,v;
	
	for (k = 0;k < num;k ++) { //なんか最初に出力しないといけないから
		printf ("%d",A[k]);
    	if (k != num - 1) {
    		putchar (' ');
    	}
	}
	putchar('\n');
	
    for (i = 1;i < num;i ++){
    	v = A[i]; /*i番目の数が手前の数たちの中のどこに入るか
    	            vは、A[i]の値の保存*/
    	j = i - 1; //手前の数たち
    	while (j >= 0 && A[j] > v) { //vのとこA[i]だと下の代入で違うの入ってる
    		//手前の数がデカかったら
    		A[j + 1] = A[j]; //iじゃなくてj+1なのはj--がきくから
    		j --;
    	}
    	A[j + 1] = v; //やっとv落ち着きました
    	
    	for (k = 0;k < num;k ++) {
    		printf ("%d",A[k]);
    		if (k != num - 1) {
    			putchar (' ');
    		}
    	}
    	putchar ('\n');
    }
	
}


Measured memory_bytes: 2120
import copy

def BubbleSort(card):
    card_b = []
    card_b = copy.deepcopy(card)
    for i in range(len(card_b)-1):
        j = len(card_b)-1
        while i+1 <= j:
            if list(card_b[j])[1] < list(card_b[j-1])[1]:
                w = card_b[j]
                card_b[j] = card_b[j-1]
                card_b[j-1] = w
            j -= 1
    return card_b

def SelectionSort(card):
    card_s = []
    card_s = copy.deepcopy(card)
    for i in range(len(card_s)-1):
        mini = i
        j = i
        while len(card_s)-1 >= j:
            if list(card_s[j])[1] < list(card_s[mini])[1]:
                mini = j
            j += 1
        w = card_s[i]
        card_s[i] = card_s[mini]
        card_s[mini] = w
    return card_s

def CardPrint(card):
    i = 0
    for c in card:
        if i != n-1:
            print("{} ".format(c), end="")
        elif i == n-1:
            print(c)
        i += 1


n = int(input())
card = input().split()

r1 = []
r1 = BubbleSort(card)
CardPrint(r1)
print("Stable")

r2 = []
r2 = SelectionSort(card)
CardPrint(r2)
if r1 == r2:
    print("Stable")
else:
    print("Not stable")



Measured memory_bytes: 6344
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n, k = map(int,input().split())
    mod = 998244353
    LR = [tuple(map(int,input().split())) for i in range(k)]
    LR.sort()
    DP = [0] * (n + 1)#i(0-)番目まで行く方法f_iについて、f_i-f_(i-1)
    DP[1] = 1
    DP[2] = -1
    f = 0
    for i in range(1, n + 1):
        f = (f + DP[i])%mod
        for l, r in LR:
            if i + l > n:
                break
            DP[i + l] = (DP[i + l] + f)%mod
            if i + r + 1 > n:
                break
            DP[i + r + 1] = (DP[i + r + 1] - f)%mod
    print(f%mod)

        





if __name__=='__main__':
    main()

Measured memory_bytes: 75080
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

char X, Y;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> X >> Y;

  if (X > Y) {
    cout << ">" << endl;
  }
  else if (X == Y) {
    cout << "=" << endl;
  }
  else {
    cout << "<" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
    	Scanner sc = new Scanner(System.in);
    	int count = sc.nextInt();

    	int ans = 0;
    	boolean af = false;
    	for (int i = 1; i <= count; i++) {
    		int element = sc.nextInt();
    		if (af && i == element) {
    			ans++;
    			af = false;
    		} else if (i == element) {
    			af = true;
    		} else if (af && i != element) {
    			ans++;
    			af = false;
    		}
    	}
    	int last = af ? 1 : 0;
    	System.out.println(ans + last);
    }

}

Measured memory_bytes: 50264
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  ll N, M;
  cin >> N >> M;
  cout << (1900*M + 100*(N-M)) * pow(2, M) << endl;;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int sz, k;
    cin>>sz>>k;
    int arr[sz];
    for(int i = 0;i<sz;i++){
        cin>>arr[i];
    }
    int sum = 0;
    sort(arr,arr+sz);
    for(int i = 0;i<k;i++){
        sum+=arr[i];
    }
    cout<<sum<<endl;
    return 0;




}



Measured memory_bytes: 3644
#include<stdio.h>
int main(){
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c),a+b+c){
        c=100-c;
        int win=0;
        int mon=0;
        for(int i=0;i<a;i++){
            int d;
            scanf("%d",&d);
            if(b==i+1)win=d;
            mon+=c*d;
        }
        printf("%d\n",win?mon/win:0);
    }
}


Measured memory_bytes: 2048
#include<cstdio>

const int NMAX = 10005;
int a[NMAX];

int has2(int n){
        int res = 0;
        while(true){
                if(n%2!=0) break;
                n = n/2;
                res++;
        }
        return res;
}

int main(){
        int N, i;
        int n = 0;
        scanf("%d", &N);
        for(i=0; i<N; i++){
                scanf("%d", &a[i]);
        }
        for(i=0; i<N; i++){
                n += has2(a[i]);
        }
        printf("%d", n);
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  std::cin>>a>>b;
  std::cout<<"a ";
  if(a==b) std::cout<<"==";
  if(a>b) std::cout<<">";
  if(a<b) std::cout<<"<";
  cout<<" b"<<endl;
  return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 998244353;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;

  set<string> mySet;
  for (ll i = 1; i <= n; i++) {
    string s;
    cin >> s;
    mySet.insert(s);
  }
  cout << mySet.size() << endl;

  return 0;
}


Measured memory_bytes: 19288
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N=int(input())
    xy = [list(map(int, input().split())) for _ in range(N)]
    res=0
    for i in range(N):
        for j in range(N):
            res += ((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)**0.5
    print(res/N)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#define rep(i, m, n) for(int i = m; i < n; i++)
#define repM(i, m, n) for(int i = n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll; using namespace std;
//typedef pair<int,int> pii; using namespace std;

// d = distance(lower_bound(all(x)), upper_bound(all(x)));

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

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

Measured memory_bytes: 256
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(13);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI = 3.141592653589793;

const int INF = 1e18;

void solve()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int ans[4];
	ans[0] = a*c;
	ans[1] = a*d;
	ans[2] = b*c;
	ans[3] = b*d;
	sort(ans,ans+4);
	cout << ans[3];
}

int32_t main()
{
	FastIO;
	Fast_D;
	int T;
	T=1;
	while(T--) solve();
	return 0;
}



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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	int c[3][3];

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c[i][j];
		}
	}

	// a[0] = 0
	int b[3];
	for (int i = 0; i < 3; i++) {
		b[i] = c[0][i];
	}

	int a2 = c[1][0] - b[0];
	int a3 = c[2][0] - b[0];

	for (int i = 0; i < 3; i++) {
		if (c[1][i]-b[i] != a2) {
			cout << "No" << "\n";
			return 0;
		}
		if (c[2][i]-b[i] != a3) {
			cout << "No" << "\n";
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256