akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define pb push_back
#define fo for(int i=0;i<n;i++)
#define clear cin.clear();cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define loopSolve int t; cin>>t; while(t--){solve();}
//INT_MAX         2,147,483,647                       <10^10
//U_INT_MAX       4,294,967,295                       <10^10
//LONG_LONG_MAX   9,223,372,036,854,775,807           <10^18
//U_LONG_LONG_MAX 18,446,744,073,709,551,615          <10^18

/*ll power(int a, int b){
    return (ll)(pow(a,b)+0.5);
}*/

vector<int> gV(int n){
    vector<int> v;
    int input;
    fo { cin>>input; v.pb(input); }
    return v;
}

int* gA(int n){
    int* arr = new int[n];
    fo cin>>arr[i];
    return arr;
}

void secondThreadApproach(){
    int H,W,K;
    cin>>H>>W>>K;
    char** arr= new char*[H];
    for(int i=0;i<H;i++){
        arr[i]=new char[W];
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>arr[i][j];
        }
    }

    int range = (1<<(H+W))- 1;                //2^(H+W)-1
    int ans=0;                              //int as ans can be at max 2^(H+W) and H,W<=6

    for(int mask=0;mask<=range;mask++){
        int count=0;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(arr[i][j]!='#') continue;
                if ((mask&(1<<(H-i-1+W)|(1<<(W-j-1))))!=0) continue;              //For mask 10010 => R0,R1,C0,C1,C2. 1=>Painted, 0=>Not Painted
                //if((mask&((1<<W+i)|(1<<j)))!=0) continue;                      //For mask 10010 => R1,R0,C2,C1,C2. 1=>Painted, 0=>Not Painted
                count++;
            }
        }
        if(count==K)
            ans++;
    }

    cout<<ans<<endl;
}

//https://atcoder.jp/contests/abc173/tasks/abc173_c
void solve(){
    int H,W,K;
    cin>>H>>W>>K;
    char** arr= new char*[H];
    for(int i=0;i<H;i++){
        arr[i]=new char[W];
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>arr[i][j];
        }
    }

    int range = (1<<H+W)- 1;                //2^(H+W)-1
    ll ans=0;
    for(int i=0;i<=range;i++){
        int t=i,count=0;
        map<int,bool> row;
        map<int,bool>col;
        while(t>0){
            if(t&1==1){
                if(count<W) col[count]=true;
                else row[count-W]=true;
            }
            t=t>>1;
            count++;
        }

        ll temp=0;
        for(int p=0;p<H;p++){
            if(row[p]) continue;
            for(int q=0;q<W;q++){
                if(col[q]) continue;
                if(arr[p][q]=='#') temp++;
            }
        }
        if(temp==K) ans++;

    }

    cout<<ans<<endl;




}




int main() {
	ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    secondThreadApproach();
    //solve();
    //loopSolve;

	return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include<algorithm>
using namespace std;
int a[810];
int main()
{
    int n,iwa=1;
    cin>>n;
    for(int i=0;i<n;i++){
        cin >>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
        if(a[i]<a[i+1]){
            iwa++;
        }
    }
    cout<<iwa<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0; i < S.size()-1; i++)
	{
		if (S[i] != S[i+1])
			ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main() {
    int n;
    scanf("%d", &n);
    bool a[n];
    rep(i, n) {
        int x, y;
        scanf("%d%d", &x, &y);
        a[i] = (x == y);
    }
    rep(i, n - 2) if (a[i] && a[i + 1] && a[i + 2]) {
        puts("Yes");
        return 0;
    }
    puts("No");
}

Measured memory_bytes: 3756
use std::io::{BufRead, Read};

pub struct Scanner<R>
where
    R: BufRead,
{
    reader: R,
}

impl<R> Scanner<R>
where
    R: BufRead,
{
    pub fn new(reader: R) -> Self {
        Scanner { reader: reader }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: ::std::str::FromStr,
        <T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
    {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .unwrap()
    }
}

use std::cmp::max;

fn main() {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let mut sc = Scanner::new(stdin);

    let a: i32 = sc.next();
    let b: i32 = sc.next();

    println!("{}", max(max(a+b, a-b), a*b));
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
  int N, count = 0;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++)cin >> A.at(i);
  for(int i = 0; i < N; i++){
    int minj = i;
    for(int j = i; j < N; j++){
      if(A.at(j) < A.at(minj))
        minj = j;
    }
    if(i != minj){
      swap(A.at(i), A.at(minj));
      count++;
    }
  }
  for(int i = 0; i < N; i++){
    cout << A.at(i);
    if(i != N-1) cout << " ";
  }
  cout << endl;
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <vector>
#include <cmath>
#include <cstdint>
#include <string>

using namespace std;

vector<vector<int>> readMatrix(int n, int m) {
  vector<vector<int>> a;
  for (int i = 0; i < n; ++i) {
    vector<int> row;
    for (int j = 0; j < m; ++j) {
      int x;
      cin >> x;
      row.push_back(x);
    }
    a.push_back(row);
  }
  return a;
}

int main() {
  int n, m, l;

  cin >> n >> m >> l;
  auto a = readMatrix(n, m);
  auto b = readMatrix(m, l);

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < l; ++j) {
      int64_t sum = 0;
      for (int k = 0; k < m; ++k) {
        sum += a[i][k] * b[k][j];
      }
      if (j != 0) {
        cout << " ";
      }
      cout << sum;
    }
    cout << endl;
  }
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int main(void){
  char b,a;
  cin >> b;
  if (b=='A') a='T';
  else if (b=='T') a='A';
  else if (b=='C') a='G';
  else a='C';
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
# coding: utf-8
from itertools import *
import sys
import time


#################### library ####################


#################### naive ####################


#################### process ####################

def read_input():
	[N, K] = map(int, raw_input().split())
	S = raw_input().rstrip()
	return K, S


#################### main ####################

#t0 = time.clock()
K, S = read_input()
v = [ sum(1 for _ in w) for k, w in groupby(S) ]
n = v[0] - 1
for k in range(K):
	if len(v)/2 == k:
		break
	n += v[k*2+1]
	if k*2+2 < len(v):
		n += v[k*2+2]
n += sum(m-1 for m in v[K*2+1:])
print(n)


Measured memory_bytes: 37016
#include <cstdio>
#define sqr(x) ((x)*(x))
const int N = 105; 
int a[N];
int n;
int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i ++){
		scanf("%d", &a[i]);
	}
	int mn = 0x7fffffff;
	for(int i = -100; i <= 100; i ++){
		int sum = 0;
		for(int j = 0; j < n; j ++){
			sum += sqr(a[j]-i);
		}
		mn = mn < sum ? mn : sum;
	}
	printf("%d\n", mn);
}

Measured memory_bytes: 128
#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define ld  long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int n ;
vector<int> v1, v2;
int main()
{
    IO
    cin>>n;
    while(n--)
    {
        int x, y ;
        cin>>x>>y;
        v1.push_back(x-y);
        v2.push_back(x+y);
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    cout<< max(abs(v1[0]-v1.back()), abs(v2[0]-v2.back()));
}


Measured memory_bytes: 5132
/*==============================================*\
ID:          shahidul_brur
 
Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh
 
 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int logn = 20;
int a[maxn];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, m;
    cin>>n>>m;
    multiset<ii> s;
    f1(i,n)
    {
        cin>>a[i];
        int d = a[i] - (a[i]>>1);
        s.insert(mp(d,a[i]));
    }
    while(m--){
        if(s.size()==0) break;
        ii b = *s.rbegin();
        s.erase(s.lower_bound(b));
        b.ss>>=1;
        if(b.ss==0) continue;
        int d = b.ss - (b.ss>>1);
        s.insert(mp(d,b.ss));
    }
    ll t=0;
    for(ii x:s) t+=x.ss;
    cout << t;
    return 0;
}



Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n,k;
    cin >> n >> k;
    ll sum=0;
    Vi a(n);
    rp(i,n) {
        cin >> a.at(i);
        sum += a.at(i);
    }
    Vi div;
    for(ll i=1; i*i<=sum; i++){
        if(sum%i==0) div.pb(i);
    }
    for(auto d:div){
        ll st=sum/d;
        ll divsum=0;
        ll ki=k;
        Vi mods(n);
        rp(i,n) {
            divsum += a.at(i)/st;
            mods.at(i)=a.at(i)%st;
        }
        sort(all(mods));
        rp(i,n-(d-divsum)){
            ki -= mods.at(i);
        }
        if(ki>=0){
            print(st);
            return;
        }
    }
    reverse(all(div));
    for(auto d:div){
        ll divsum=0;
        ll ki=k;
        Vi mods(n);
        rp(i,n){
            divsum += a.at(i)/d;
            mods.at(i)=a.at(i)%d;
        }
        sort(all(mods));
        rp(i,n-(sum/d-divsum)){
            ki -= mods.at(i);
        }
        if(ki>=0){
            print(d);
            return;
        }
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

int A[200010];

int main(void) {
  int N, K;
  cin >> N >> K;

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

  sort(A, A + N);

  int ans = 0;
  for (int i = 0; i < N - K; i++) {
    ans += A[i];
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

typedef long long LL;

const int nmax = 1000005; const LL inf = 2e18;

char a[10][10];
int N,M,st[10][10],nr,ok;

inline bool Valid(int i,int j){
 if(i < 1 || i > N || j > M || j < 1)return false;
 return true;
}

void Back(int i,int j,int cnt){
   if(!Valid(i,j))return;
   if(cnt == nr)ok = 1;
   if(a[i+1][j] == '#'){
   st[i+1][j] = true;
   Back(i+1,j,cnt+1);
   st[i+1][j] = false;
   }
   if(a[i][j+1] == '#'){
   st[i][j+1] = true;
   Back(i,j+1,cnt+1);
   st[i][j+1] = false;
   }
}

int main(){
//   #ifndef GLOBAL_JUDGE
//      freopen("txt.in","r",stdin);
//      freopen("txt.out","w",stdout);
//   #endif // GLOBAL_JUDGE
   int i,j;
   cin >> N >> M;
   for(i = 1; i <= N; ++i)
      for(j = 1; j <= M; ++j){
         cin >> a[i][j];
         if(a[i][j] == '#')++nr;
      }
      if(a[1][1] == '.'){
         cout << "Impossible\n";
         return 0;
      }
   Back(1,1,1);
   if(ok){
      cout << "Possible\n";
      return 0;
   }
   cout << "Impossible\n";
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <string>
#include <math.h>
#include <stdint.h>
#include <bitset>
#include <iomanip>
#include <set>

using namespace std;

int main() {
  int N;
  cin >> N;
  set<int> d;
  int d_tmp;
  for (int i=0; i < N; i++) {
    cin >> d_tmp;
    d.insert(d_tmp);
  }

  cout << d.size() << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int i, x;
   
   cin>> x;
   
   for(i = 1; x != 0; i++){
       
       cout<< "Case " << i << ": " << x << endl;
       
       cin>> x;
       
   }
   
   return 0;
}


Measured memory_bytes: 3056
N = int(input())
A = list(map(int,input().split()))

cur = A[0]
ans = 0
rp = 1
for lp in range(N):
    while rp < N and cur & A[rp] == 0:
        cur += A[rp]
        rp += 1
    ans += rp - lp
    cur -= A[lp]
    
print(ans)


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

int main() {
	long long N, K;
	cin >> N >> K;
	vector<double> V(N);
	for (int i = 0; i < N; i++) cin >> V[i], V[i]++;
	double ANS = 0, COUNT = 0;
	for (int i = 0; i < K; i++) COUNT += V[i];
	ANS = COUNT;
	for (int i = 0; i + K < N; i++) {
		COUNT -= V[i];
		COUNT += V[i + K];
		ANS = max(ANS, COUNT);
	}
	printf("%.12lf\n", ANS / 2);
}


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

namespace Program {
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] list = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int a = list[0], b = list[1];
            if ((a * b) % 2 == 0) Console.WriteLine("Even");
            else Console.WriteLine("Odd");
        }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std ; 
int main(){
  int H ,  W ; 
  cin >> H >> W ; 
  
  vector<vector<char>> A(H , vector<char>(W)) ; 
  
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++ ){
      cin >> A.at(i).at(j) ;
    }
  }
  
  for(int i = 0 ; i < W+2 ; i++){
    cout << "#"  ; 
  }
  cout << endl ; 
  
  for(int i = 0 ; i < H ; i ++ ){
    cout << "#" ; 
    
    for(int j = 0 ; j < W ; j++){

      cout << A.at(i).at(j) ; 

    }
    cout << "#" << endl ; 
  }
  
  
  for(int i = 0 ; i < W+2 ; i++){
    cout << "#"  ; 
  }
  cout << endl ; 
    
  
  
}

Measured memory_bytes: 3564
import java.util.Scanner;
class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n=sc.nextInt();
		double ans=0;
		for(int i=0;i<n;i++) {
			double x= sc.nextDouble();
			String s=sc.next();
			if(s.equals("BTC"))x*=380000;
			ans+=x;
		}
		System.out.println(ans);
		}
}






Measured memory_bytes: 23252
/**
        	C++14 (GCC 5.4.1)
**/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;

int main(){
    int A, B;
    cin >> A >> B;

    if (A >= 13){
        cout << B << endl;
    }
    else if( 6 <= A && A <= 12 ){
        cout << B /2 << endl;
    }
    else {
        cout << 0 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 211111
using namespace std;
int num[MAXN], N, tmp[MAXN];
int main(){
    cin>>N;
    int i, l = 1, r = 2 * N;
    for(i = 1;i <= 2 * N - 1; i++){
        scanf("%d", &num[i]);
    }
    int ans = 0;
    while(l <= r){
        int mid = (l + r) >> 1;
//		printf("mid=%d\n", mid); 
        for(i = 1;i <= 2 * N - 1; i++){
            tmp[i] = (num[i] >= mid?1 : 0);
   //         printf("%d ", tmp[i]);
        }                                  
//        puts("");
        bool flag = false, ok = false;
        for(i = 1;i < N; i++){
            if(tmp[N-i] == tmp[N-i+1]){
                if(tmp[N-i] == 1){
                    flag = ok = true;
                    break;
                }
                else {
                    ok = true;
                    break;
                }
            }
            if(tmp[N+i] == tmp[N+i-1]){
                if(tmp[N+i] == 1){
                    ok = flag = true;
                    break;
                }
                else {
                    ok = true;
                    break;
                }
            }
        }
//        printf("ok=%d flag=%d\n", ok, flag);
        if(ok == false){
        	if((tmp[N] == 0 && !(N & 1)) || (tmp[N] == 1 && N & 1 == 1))flag = true;	
        }
//    	printf("flag'=%d\n", flag);
        if(flag){
            ans = max(ans, mid);
            l = mid + 1;
        }
        else r = mid - 1;
    }
    printf("%d\n", ans);
    return 0;
}
/*
写题目习惯不太好
不把该注意的条件写下来
4
4 1 5 2 6 3 7
*/ 

Measured memory_bytes: 1792
n, k = map(int, input().split())
a = [i+1 for i in range(n)]
for _ in range(k):
  d = int(input())
  s = list(map(int, input().split()))
  for i in range(len(s)):
    if(s[i] in a):
      a.pop(a.index(s[i]))
print(len(a))

Measured memory_bytes: 9140
#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 n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  sort(d.begin(), d.end());
  if(n % 2) {
    cout << 0 << endl;
    return 0;
  }
  int diff = d[n / 2] - d[n / 2 - 1];
  cout << diff << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a,b,c;
  cin>>a>>b>>c;
  if(a.at(a.size()-1)==b.at(0)&&b.at(b.size()-1)==c.at(0)){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int num = s.nextInt();
		int guess = 1;
		while(num-guess*guess>=0){
			guess++;
		}
		System.out.println((guess-1)*(guess-1));
	}

}


Measured memory_bytes: 21716
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;

public class Main {
    private static final InputStream IN = new BufferedInputStream(System.in);

    public static void main(String[] args) throws IOException {
	int n;
	while ((n = nextInt()) != 0) {
	    int[][] map = new int[21][21];
	    for (int i = 0; i < n; i++) {
		map[nextInt()][nextInt()] = 1;

	    }
	    int m = nextInt();
	    int x = 10;
	    int y = 10;
	    int count = 0;
	    for (int i = 0; i < m; i++) {
		char c = getChar();
		int l = nextInt();
		if (count != n) {
		    int dx = 0;
		    int dy = 0;
		    if (c == 'N') {
			dy = 1;
		    } else if (c == 'E') {
			dx = 1;
		    } else if (c == 'S') {
			dy = -1;
		    } else if (c == 'W') {
			dx = -1;
		    }
		    for (int j = 0; j < l; j++) {
			count += map[x][y];
			map[x][y] = 0;
			x += dx;
			y += dy;
		    }
		    count += map[x][y];
		    map[x][y] = 0;
		}
	    }
	    if (count == n) {
		System.out.println("Yes");
	    } else {
		System.out.println("No");
	    }
	}
    }

    private static char getChar() throws IOException {
	int c = ' ';
	while (c < 'E' || 'W' < c) {
	    c = IN.read();
	}
	return (char) c;
    }

    private static int nextInt() throws IOException {
	int c = IN.read();
	while ((c < '0' || '9' < c) && c != '-') {
	    c = IN.read();
	}
	if (c == '-') {
	    return -nextInt();
	}
	int result = 0;
	while ('0' <= c && c <= '9') {
	    result = result * 10 + (c - '0');
	    c = IN.read();
	}
	return result;
    }
}

Measured memory_bytes: 25792
types = ["S", "H", "C", "D"]
cards = []
for type in types:
    for i in range(13):
        cards.append({type: str(i+1)})
n = int(input())
for _ in range(n):
    type, num = input().split()
    cards.remove({type: num})
for card in cards:
    for k, v in card.items():
        print(k, v)

Measured memory_bytes: 7696
n = int(input())
num = [ int(v) for v in input().split() ]
beauty = [ int(v) for v in input().split() ]
ln = len(bin(n-1))-1
ln2 = 2**(ln-1)
segtree = [ 0 for i in range(2**ln-1) ]


def update(p, q=1):
    p += 2**(ln-1)-2
    r = 0
    while p >= 0:
        if r == 0:
            segtree[p] = q
            r = 1
        else:
            segtree[p] = max(segtree[p], q)
        p = (p-1)//2

def getmax(a,b,k=0,l=0,r=ln2):
    if r <= a or b <= l:
        return 0
    elif l == r:
        return 0
    elif a == l and b == r:
        return segtree[k]
    elif l + 1 == r:
        return segtree[k]
    else:
        return max( getmax(a,min(b,(l+r)//2),2*k+1,l,(l+r)//2), getmax(max(a,(l+r)//2),b,2*k+2,(l+r)//2,r) )

for i in range(n):
    a, b = num[i], beauty[i]
    c = getmax(0,a-1)
    update(a,b+c)
print(getmax(0,n))

Measured memory_bytes: 119504
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define INF 800000000
#define MAX 1000

int main(){
  string s;
  cin>>s;
  int n=s.size();

  bool flag=true;
  int count=0;
  int left=0;
  int right=n-1;
  while(left<=right){
    if(s.at(left)==s.at(right)){
      left++;
      right--;
    }else if(s.at(left)=='x'){
      count++;
      left++;
    }else if(s.at(right)=='x'){
      count++;
      right--;
    }else{
      flag=false;
      break;
    }
  }
  if(flag){
    cout<<count<<endl;
  }else{
    cout<<-1<<endl;
  }
}


Measured memory_bytes: 512
#include<stdio.h>

int main(){
    int i, j, k;
    int N, A[210000];
    int maxl[210000], maxr[210000];

    scanf("%d", &N);
    for(i=0; i<N; i++){
        scanf("%d", &A[i]);
    }
    maxl[0]=A[0];
    maxr[N-1]=A[N-1];
    for(i=1; i<N; i++){
        if(maxl[i-1]>A[i]){
            maxl[i]=maxl[i-1];
        }else{
            maxl[i]=A[i];
        }
    }
    for(i=N-2; i>=0; i--){
        if(maxr[i+1]>A[i]){
            maxr[i]=maxr[i+1];
        }else{
            maxr[i]=A[i];
        }
    }

    for(i=0;i<N;i++){
        if(i==0){
            printf("%d\n", maxr[i+1]);
        }else if(i==N-1){
            printf("%d\n", maxl[N-2]);
        }else{
            if(maxl[i-1]>maxr[i+1]){
                printf("%d\n",maxl[i-1]);
            }else{
                printf("%d\n", maxr[i+1]);
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

	if (n < 1000) cout << "ABC" << endl;
	else cout << "ABD" << endl;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define DISP1(as)		for(auto it : as) cout<<it.f<<" "<<it.s<<") ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	2e+5 + 99;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, k, l, q, x;
string s;

// <---------------------- > //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>s;
	n = s.length();
	s = '#' + s;

	if(n == 2) {
		if(s[1] == s[2]) {
			cout<<"1 2\n";
		}
		else {
			cout<<"-1 -1\n";
		}
		return;
	}

	ll i= 1,j = 3;
	while(j <= n)  {
		if(s[i]==s[i+1] || s[i] == s[i+2] || s[i+1] == s[i+2]) {
			cout<<i<<" "<<i+2;newl;
			return;
		}
		
		i++;
		j++;
	}

	cout<<"-1 -1\n";
}


int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {

		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3776
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;
double EPS = 1e-10;

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

void pres(double A, ll x = 30){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}



void solve(){
  ll a, b;
  cin >> a >> b;
  string S, T;
  rep(i, a) S += (char)(b + '0');
  rep(i, b) T += (char)(a + '0');
  cout << min(S, T) << endl;
}

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


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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 1e6;
    FOR(st, '0', '1') {
        int cnt = 0;
        REP(i, s.size()) {
            if((s[i] == st) xor (i % 2 == 0)) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << ln;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> T;

const ll mod = 1000000007;
const ll INF = 100000010000;

ll N;
double x[55], y[55];
double ans;

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

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return x * pow_mod(x, y - 1) % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x)
{
	return pow_mod(x, mod - 2);
}

void init()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> x[i] >> y[i];
	}
}

void output()
{
	printf("%.7f\n", ans);
}



void solve()
{
	if (N == 2)
	{
		ans = sqrt((x[0] - x[1]) * (x[0] - x[1]) + (y[0] - y[1]) * (y[0] - y[1]));
		ans /= 2;
		return;
	}
	
	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			for (int k = j + 1; k < N; k++)
			{
				double a, b, c, d, e, f, px, py;
				a = x[i], b = y[i], c = x[j], d = y[j], e = x[k], f = y[k];

				ll u, v, w, q, g, h;
				u = x[i] - x[j], v = y[i] - y[j];
				w = x[k] - x[j], q = y[k] - y[j];
				g = x[k] - x[i], h = y[k] - y[i];
				if (u * q == v * w || u * w + v * q <= 0 || g * (-u) + h * (-v) <= 0 || w * g + q * h <= 0)
				{
					ans = max(ans, sqrt(u * u + v * v) / 2);
					ans = max(ans, sqrt(w * w + q * q) / 2);
					ans = max(ans, sqrt((x[i] - x[k]) * (x[i] - x[k]) + (y[i] - y[k]) * (y[i] - y[k])) / 2);
					continue;
				}


				py = (e - a)*(a*a + b*b - c*c - d*d) -(c - a)*(a*a + b*b - e*e - f*f);
				py /= 2 * (e-a)*(b-d)-2*(c-a)*(b-f);
				if (c - a != 0)
				{
					px = 2 * (b - d)*py - a * a - b * b + c * c + d * d;
					px /= 2 * (c - a);
				}
				else
				{
					px = 2 * (b - f)*py - a * a - b * b + e * e + f * f;
					px /= 2 * (e - a);
				}
				ans = max(sqrt((px - a)*(px - a) + (py - b)*(py - b)), ans);
				
				
			}
		}
	}
}

int main()
{
	init();

	solve();



	output();
	ll N;
	cin >> N;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


int main(void) {
    ll N;
    cin >> N;
    ll l[111];
    ll i;
    ll s=0;
    for(i=0; i<N; i++) {
        cin >> l[i];
        s+=l[i];
    }
    
    for(i=0; i<N; i++) {
        if(s-l[i]<=l[i]) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    
}



Measured memory_bytes: 256
class UnionFind():
	def __init__(self, size):
		self.table = [-1 for _ in range(size)]

	def find(self, x):
		if self.table[x] < 0:
			return x
		else:
			self.table[x] = self.find(self.table[x]) #xをxの根に直接つなぐ
			return self.table[x]

	def union(self, x, y):
		s1 = self.find(x)
		s2 = self.find(y)
		if s1 == s2:
			return
		else:
			st1 = self.table[s1]
			st2 = self.table[s2]
			if st1 > st2:
				self.table[s2] = s1
			elif st1 < st2:
				self.table[s1] = s2
			else:
				self.table[s1] = s2
				self.table[s2] -= 1


n, m = map(int, input().split())
p = list(map(int, input().split()))

uf = UnionFind(n)

for i in range(m):
	x, y = map(int, input().split())
	uf.union(x - 1, y - 1)

ans = 0
for i, pp in enumerate(p):
	if pp - 1 == i:
		ans += 1
	elif uf.find(pp - 1) == uf.find(i):
		ans += 1

print(ans)


Measured memory_bytes: 13812
def main():
    S = list(map(int,input()))
    n = len(S)

    ans = 0
    for i in range(2**(n-1)):
        b = 0
        t = 0
        for j in range(n):
            if (j < (n-1) and i >> j &1) or j == n-1:
                for k,s in enumerate(S[b:j+1]):
                    t += s * 10**(j-b-k)

                b = j+1
        ans += t

    print(ans)
    
main()

Measured memory_bytes: 9136
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
static const ll Max=(1e9+7);

void  divide(ll &x){
    x%=Max;
    return;
}

int main(){
    int n;cin>>n;
    ll inx10=1,inx9=-1,inx8=1;
    rep(i,n){
        inx10*=10;
        inx9*=9;
        inx8*=8;
        inx9+=9*Max;
        divide(inx8);
        divide(inx10);
        divide(inx9);
    }
    ll ans=inx10+inx9*2+inx8;
    ans%=Max;
    cout<<ans<<endl;
    return 0;
}

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

int main(){
	int n,a,b,c,d;
	
	cin >> n;

	a = n / 1000;
	b = (n % 1000) / 100;
	c = (n % 100) / 10;
	d = (n % 10);

	if((a == b && b == c) || (c == d && b == c)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


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

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

  int ans = 0;

  for (int i = 0; i < 1000; i++) {
    string I = to_string(i);
    while (I.size() < 3) I = '0' + I;
    string T = S;

    int j = (int)T.find(I.at(0));
    if (j == -1 || j == N - 1) continue;
    T = T.substr(j + 1);

    j = (int)T.find(I.at(1));
    if (j == -1 || j == N - 1) continue;
    T = T.substr(j + 1);

    j = (int)T.find(I.at(2));
    if (j == -1) continue;
    ans ++;
  }

  cout << ans << "\n";
}

Measured memory_bytes: 384
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s, t, co;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> s >> t;
  rep(i, n) {
    co += s[i];
    co += t[i];
  }
  Cout(co);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll k, n;
    cin >> k >> n;
    vl a(n);
    REP(i, n) cin >> a[i];
    ll mx = k - a[n - 1] + a[0];
    REP(i, n - 1) chmax(mx, a[i + 1] - a[i]);
    cout << k - mx << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"


void solve()
{
    string s;cin>>s;
    if(s=="MON")
    cout<<6<<endl;
    else if(s=="TUE")
    cout<<5<<endl;
    else if(s=="WED")
    cout<<4<<endl;
    else if(s=="THU")
    cout<<3<<endl;
    else if(s=="FRI")
    cout<<2<<endl;
    else if(s=="SAT")
    cout<<1<<endl;
    else
    cout<<7<<endl;
    
}
int32_t main()
{
    rapido;
    int t;
    //cin>>t;
      t=1;
    while(t--)
    solve();
}

Measured memory_bytes: 3596
/////////////////////////   _LeMur_
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <chrono>
#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 100005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n;
int a , b , c;

int main() {
    mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
    cin >> n;
    int answ = 0;
    for(int i=1;i<=n;i++){
        string s;
        cin >> s;
        for(int j=1;j<(int)s.size();j++){
            if(s[j - 1] == 'A' && s[j] == 'B'){
                ++answ;
            }
        }
        if(s[0] == 'B' && s[(int)s.size() - 1] == 'A'){
            ++a;
            continue;
        }
        if(s[0] == 'B'){
            ++b;
        }
        if(s[(int)s.size() - 1] == 'A'){
            ++c;
        }
    }
    if(a){
        answ += a - 1;
        if(c){
            --c;
            ++answ;
        }
        if(b){
            --b;
            ++answ;
        }
    }
    answ += min(b , c);
    cout << answ << endl;
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        w: [i64; n],
    }
    let sum = w.iter().sum();
    let mut min = sum;
    for i in 0..n {
        let diff = (w[..i + 1].iter().fold(0, |s, x| s + x)
            - w[i + 1..].iter().fold(0, |s, x| s + x))
        .abs() as i64;
        if diff < min {
            min = diff;
        }
    }
    println!("{}", min);
}


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

#define MAX 100005
int main(){
  int N; scanf("%d", &N);
  int a[3][MAX];
  int hp[3][MAX];

  for(int i=0;i<N;i++){
    for(int l=0;l<3;l++){
      scanf("%d", &a[l][i]);
      if(i==0) hp[l][i] = a[l][i];
    }
  }

  for(int i=1;i<N;i++){
    for(int l=0;l<3;l++){
      hp[l][i] = max(hp[(l+1)%3][i-1]+a[l][i], hp[(l+2)%3][i-1]+a[l][i]);
    }
  }

  cout << max(hp[0][N-1],max(hp[1][N-1],hp[2][N-1]));
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int> card(5);
  for(;;){
    if(scanf("%d,%d,%d,%d,%d",&card[0],&card[1],&card[2],&card[3],&card[4]) == EOF) break;
    sort(card.begin(),card.end());
    int ans=0,x=card[0],y=1;
    for(int i=1; i<5; i++){
      if(x == card[i]) y++;
      else{
	if(y == 2) ans+=2;
	if(y == 3) ans+=3;
	if(y == 4) ans+=7;
	x = card[i];
	y = 1;
      }
    }
    if(y == 2) ans+=2;
    if(y == 3) ans+=3;
    if(y == 4) ans+=7;
    if(card[0] == card[1]-1 && card[1] == card[2]-1 && card[2] == card[3]-1 && card[3] == card[4]-1) ans+=10;
    if(card[0] == 1 && card[1] == 10 && card[2] == 11 && card[3] == 12 && card[4] == 13) ans+=10;
    if(ans == 0) cout <<"null"<<endl;
    if(ans == 2) cout <<"one pair"<<endl;
    if(ans == 4) cout <<"two pair"<<endl;
    if(ans == 3) cout <<"three card"<<endl;
    if(ans == 5) cout <<"full house"<<endl;
    if(ans == 7) cout <<"four card"<<endl;
    if(ans == 10) cout <<"straight"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<atcoder/dsu>

int main(){
  int n,m;
  std::cin>>n>>m;
  atcoder::dsu uf(n);
  for(int i=0;i<m;++i){
    int a,b;
    std::cin>>a>>b;
    a--;b--;
    uf.merge(a,b);
  }
  int ans = std::size(uf.groups())-1;
  std::cout<<ans<<std::endl;
}


Measured memory_bytes: 8904
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    X=I()
    ans = X//11*2
    if X%11==0:
        pass
    elif (X-X//11*11)<=6:
        ans += 1
    else:
        ans += 2
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;
int INF = numeric_limits<int>::max() / 2;
using ll = long long;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	if (n == 1) {
		if (m == 1)cout << 1 << endl;
		else cout << m - 2 << endl;
	}
	else if (m == 1){
		cout << n - 2 << endl;
	}
	else {
		cout<<(m - 2)*(n - 2) << endl;
	}
}

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

ll gcd(ll a, ll b)
{
	if (a < b) return gcd(b,a);
	if (b==0) return a;
	if (a%b==0) return b;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b)
{
	return a*b/gcd(a,b);
}

int a1, a2, a3, m1, m2, m3;
int main()
{
	while (cin >> a1 >> m1 >> a2 >> m2 >> a3 >> m3, a1||m1||a2||m2||a3||m3)
	{
		int t=1, c=0, cx, cy, cz;
		do
		{
			t = t*a1 % m1;
			c++;
		} while (t!=1);
		cx = c;
		c = 0;
		do
		{
			t = t*a2 % m2;
			c++;
		} while (t!=1);
		cy = c;
		c = 0;
		do
		{
			t = t*a3 % m3;
			c++;
		} while (t!=1);
		cz = c;

		cout << lcm(lcm(cx, cy), cz) << endl;
	}
	return 0;
}

Measured memory_bytes: 0