akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b; 
		return true;
	}
	return false;
}
template <typename T>
bool chmin(T & a, const T & b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };
int dx2[2] = { 1,0 };
int dy2[2] = { 0,1 };

/******************************************************************************************/


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	int n, m;
	cin >> n >> m;

	cout << n * (n - 1) / 2 + m * (m - 1)/2 << endl;






	return 0;
}



Measured memory_bytes: 256
fn main() {
    let input: Vec<i32> = read_vec();
    let n = input[0];
    let m = input[1];
    println!("{}", if n == m {"Yes"} else {"No"});
    
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

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

using namespace std;

int main() {
    int K, T;
    cin >> K >> T;

    int mx = 0;
    for (int i = 0; i < T; ++i) {
        int a;
        cin >> a;
        mx = max(mx, a);
    }
    cout << max(2 * mx - K - 1, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
implicit none
integer(8) :: n,kk,i,j,k,l,s,num,m
integer(8), allocatable, dimension(:):: x,y

read (5,*) n, kk
s=9223372036854775807_8

allocate(x(n))
allocate(y(n))

do i=1, n
    read (5,*) x(i), y(i)
enddo

do i=1, n
do j=1, n
do k=1, n
do l=1, n

    num=0
    do m=1,n
        if(x(m)>=x(i) .and. x(m)<=x(j) .and. y(m)>=y(k) .and. y(m)<=y(l)) then
            num=num+1
        endif 
    enddo

    if(num>=kk) then
        S=min(S, (x(j)-x(i))*(y(l)-y(k)))
    endif
enddo
enddo
enddo
enddo

write(6,*) s

end


Measured memory_bytes: 1024
from collections import defaultdict
import sys
from scipy.misc import comb

N = int(input())

dd=defaultdict(int)

Sread = sys.stdin.read()


for s in Sread.split('\n'):
    slist = list(s)
    slist.sort()
    s = ''.join(slist)
    #print('-', s)
    dd[s]+=1

#FAC = {}
#FAC[1] = 1
#
#for i in range(2,N+1):
#    FAC[i] = FAC[i-1]*i
    
count = 0

for k in dd:
    s_counts = dd[k]
    if s_counts > 1:
        #count += FAC[s_counts]//2
        count += comb(s_counts, 2, exact=True)

print(count)


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

#define MorsheD ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef long long ll;

int main() {
	// ===================
	MorsheD;
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	// ===================

	int n;
	cin >> n;

	int ara[n];

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

	sort(ara, ara + n);
	int cnt = 0;

	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			for (int k = j + 1; k < n; ++k) {
				if (ara[i] < ara[j] && ara[j] < ara[k] && ara[i] + ara[j] > ara[k]) {
					cnt++;
				}
			}
		}
	}

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

Measured memory_bytes: 3656
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

plus = []
minus = []
for i in a:
    if i >= 0: plus.append(i)
    if i < 0: minus.append(-i)
plus.sort(reverse=True)
minus.sort(reverse=True)

ans = 1
if k == n:
    for x in a:
        ans = (ans * x) % mod
elif n == len(plus):
    for x in plus[:k]:
        ans = (ans * x) % mod
elif n == len(minus):
    if k % 2 == 1:
        ans = -1
        minus.sort()
    for x in minus[:k]:
        ans = (ans * x) % mod
else:
    i, j = 0, 0
    if k % 2 == 1:
        ans = plus[0]
        i += 1
    while i + j != k:
        x_p = plus[i] * plus[i + 1] if i < len(plus) - 1 else 0
        x_m = minus[j] * minus[j + 1] if j < len(minus) - 1 else 0
        if x_p > x_m:
            ans = (ans * x_p) % mod
            i += 2
        else:
            ans = (ans * x_m) % mod
            j += 2
print(ans)

Measured memory_bytes: 31572
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const int INF = INT_MAX / 4;

void catMove(const vector<vector<int> >& edges, int start, vector<bool>& move)
{
    int n = edges.size();
    move.assign(n, false);
    move[start] = true;
    queue<int> q;
    q.push(start);

    while(!q.empty()){
        int s = q.front();
        q.pop();
        for(unsigned i=0; i<edges[s].size(); ++i){
            int t = edges[s][i];
            if(!move[t]){
                move[t] = true;
                q.push(t);
            }
        }
    }
}

void humanMove(const vector<vector<int> >& edges, const vector<bool>& start, vector<int>& cost)
{
    int n = edges.size();
    cost.assign(n, INF);
    queue<int> q;
    for(int i=0; i<n; ++i){
        if(start[i]){
            cost[i] = 0;
            q.push(i);
        }
    }

    while(!q.empty()){
        int s = q.front();
        q.pop();
        for(unsigned i=0; i<edges[s].size(); ++i){
            int t = edges[s][i];
            if(cost[t] == INF){
                cost[t] = cost[s] + 1;
                q.push(t);
            }
        }
    }
}

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

    while(--d >= 0){
        int n, m, sh, sc;
        cin >> n >> m >> sh >> sc;

        vector<vector<int> > edgesH(n+1), edgesC(n+1);
        for(int i=0; i<m; ++i){
            int a, b;
            char c;
            cin >> a >> b >> c;

            if(c == 'N'){
                edgesH[a].push_back(b);
                edgesH[b].push_back(a);
            }else{
                edgesC[a].push_back(b);
                edgesC[b].push_back(a);
            }
        }

        vector<bool> move1, move2;
        catMove(edgesC, 0, move1);
        catMove(edgesC, sc, move2);

        vector<bool> move3(n+1);
        move3[sh] = true;

        if(move1[sc]){
            cout << 0 << endl;
            continue;
        }

        vector<int> cost1, cost2, cost3;
        humanMove(edgesH, move1, cost1);
        humanMove(edgesH, move2, cost2);
        humanMove(edgesH, move3, cost3);

        int ret = INF;
        for(int i=0; i<=n; ++i)
            ret = min(ret, cost1[i] + cost2[i] + cost3[i]);
        cout << ret << endl;
    }

    return 0;
}

Measured memory_bytes: 10244
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

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

    cout << n * 800 - n / 15 * 200 << endl;

    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 112345;
int B[MAX_N];

int main2() {
  int N = nextInt();
  vector<int> A(N);
  REP(i, N) A[i] = nextInt();

  REP(i, MAX_N) B[i] = -1;
  REP(i, N) {
    int lo = -1;
    int hi = N;
    while (hi - lo > 1) {
      int mid = (hi + lo) / 2;
      if (A[i] > B[mid]) hi = mid; else lo = mid;
    }
    B[hi] = A[i];
  }
  int ans = 0;
  REP(i, N) {
    if (B[i] >= 0) ans++; else break;
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 1024
fn main() {
    let n: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    let a: Vec<i32> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        iter.map(|x| x.parse().unwrap()).collect()
    };

    let get_primes = |n: usize| -> Vec<i32> {
        let mut primes = Vec::new();
        let mut is_prime = vec![true; n + 1];
        for i in 2..=n {
            if !is_prime[i] { continue; }
            primes.push(i as i32);
            let mut j = i + i;
            while j <= n {
                is_prime[j] = false;
                j += i;
            }
        }
        primes
    };

    let primes = get_primes(1_000_000);

    let is_pair_wise_coprime = || -> bool {
        let mut b = a.clone();
        let mut check = vec![false; primes.len()];
        for i in 0..n {
            for (j, &p) in primes.iter().enumerate() {
                if p * p > b[i] { break; }
                if b[i] % p == 0 {
                    if check[j] {
                        return false;
                    }
                    check[j] = true;
                }
                while b[i] % p == 0 {
                    b[i] /= p;
                }
            }
            if b[i] > 1 {
                let j = primes.binary_search(&b[i]).unwrap();
                if check[j] {
                    return false;
                }
                check[j] = true;
            }
        }
        true
    };

    let gcd = |mut a: i32, mut b: i32| -> i32 {
        let mut r = a % b;
        while r > 0 {
            a = b;
            b = r;
            r = a % b;
        }
        b
    };

    if is_pair_wise_coprime() {
        println!("pairwise coprime")
    } else if (1..n).fold(a[0], |acc, i| gcd(acc, a[i])) == 1 {
        println!("setwise coprime")
    } else {
        println!("not coprime");
    }
}

Measured memory_bytes: 13872
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

Vl divisor(ll N) {
  Vl div;
  for (ll i = 2; i * i <= N; i++) {
    if (N % i == 0) {
      div.push_back(i);
      if (i * i != N) div.push_back(N / i);
    }
  }
  return div;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  Vl div1 = divisor(N);
  Vl div2 = divisor(N - 1);
  // div1.insert(div1.end(), div2.begin(), div2.end());
  // sort(div1.begin(),div1.end());
  // div1.erase(unique(div1.begin(), div1.end()), div1.end());

  ll ans = 0;
  if (N > 2) ans++;

  for (auto a : div1) {
    ll tmp = N;
    while (tmp % a == 0) {
      tmp = tmp / a;
    }

    if (tmp % a == 1) ans++;
  }
  for (auto b : div2) {
    ans++;
  }
  cout << ans + 1 << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <array>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
using namespace std;
template <typename T> istream & operator >> (istream & is, vector<T> & vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


int main() {
	int n; CI n;
	vector<string> a; vector<string> b; vector<string> ab;
	int ans = 0;
	REP(i, n) {
		string s; CI s;
		if (s[0] == 'B' and s[s.length() - 1] == 'A') { ab.push_back(s); }
		else if (s[0] ==  'B')a.push_back(s);
		else if (s[s.length() - 1] == 'A')b.push_back(s);
		REP(i, s.length()) {
			if (s.substr(i, 2) == "AB")ans++;
		}
	}
	if (ab.size() != 0) {
		if (a.size() + b.size() == 0) {
			ans += ab.size() - 1;
		}
		else {
			ans += ab.size()+min(a.size(), b.size());
		}
	}
	else {
		ans +=  min(a.size(), b.size());
	}
	
	CO ans EN;

}

Measured memory_bytes: 768
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		string str2 = Console.ReadLine();
		long K = long.Parse(str2);
		string ans = "1";
		for(var i=0;i<str.Length;i++){
			if(str.Substring(i,1) != "1"){
				ans = str.Substring(i,1);
				break;
			}
			if(i==K-1){
				ans = str.Substring(i,1);
				break;
			}
		}
		Console.WriteLine(ans);
	}
}

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

using namespace std;

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

/* Fenwick Tree (Binary Index Tree) */
template<class T> struct Fenwick {
    vector<T> bit;
    int size;

    Fenwick(int _size) : size(_size) {
        bit.assign(size + 1, 0);
    }

    void add(int ind, T val) {
        for (int i = ind; i <= size; i += i & -i) {
            bit[i] += val;
        }
    }

    T get(int ind) {
        T ans = 0;
        for (int i = ind; i > 0; i -= i & -i) {
            ans += bit[i];
        }
        return ans;
    }

    // [l, r] (l > 0)
    T range(int l, int r) {
        return get(r) - get(l - 1);
    }
};

const int N = 505;
typedef pair<int, int> P;
vector<int> ts[N];
vector<P> qs[N];

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n, m, q; cin >> n >> m >> q;
	Fenwick<int> fw(n + 5);
	REPU(i, 0, m) {
		int l, r; cin >> l >> r;
		ts[l].push_back(r);
		fw.add(r, 1);
	}
	REPU(i, 0, q) {
		int l, r; cin >> l >> r;
		qs[l].push_back(P(i, r));
	}
	vector<int> ans(q);
	REPU(i, 1, n + 1) {
		for (P p : qs[i]) {
			ans[p.first] = fw.range(i, p.second);
		}
		for (int v : ts[i]) {
			fw.add(v, -1);
		}
	}
	REPU(i, 0, q) printf("%d\n", ans[i]);

	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A.at(i);
    sort(begin(A), end(A));
    ll MOD = (ll)pow(10,9) + 7;
    map<ll,int> MAP;
    ll res = 1;
    ll cur, pos;
    if (N % 2 == 1) {
        if (A[0] != 0 || (N > 1 && A[1] == 0)) {
            cout << 0 << endl;
            return 0;
        }
        cur = 2; pos = 1;
    } else {
        cur = 1; pos = 0;
    }
    for (; pos < N; pos += 2) {
        if (A[pos] == A[pos + 1] && A[pos] == cur) {
            res *= 2;
            res = res % MOD;
        } else {
            cout << 0 << endl;
            return 0;
        }
        cur += 2;
    }
    cout << res << endl;
}


Measured memory_bytes: 1024
import sys

input_str = input()

ODD_STR = ['R','U','D']
EVEN_STR = ['L','U','D']
for index, st in enumerate(input_str):
    index += 1
    if index %2 == 0 and st in EVEN_STR:
        continue
    elif index%2 == 1 and st in ODD_STR:
        continue
    print('No')
    sys.exit()

print('Yes')

Measured memory_bytes: 38384
n,a=gets.split.map &:to_i;
i=0;
d=[0]*6**6
d[n*a]=1
gets.split.map{|x|
	x=x.to_i-a;
	(0..2*a*n).map{|j|
		d[5000-i+j]=d[i+j]+d[j<x ? 0: i+j-x]
	}
	i=5000-i
}
p d[i+n*a]-1

Measured memory_bytes: 4348
#include <stdio.h>

int main(void) {
   
   int A,B,C;
   
   scanf("%d%d%d",&A,&B,&C);
   
   if (A >= B + C) {
      printf("0\n");
   }
   else {
      printf("%d\n", C - (A - B));
   }
   
   return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> c(n);
    vector<int> v(n);

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

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

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += max(0, v[i]-c[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
const double INF = 1e18;
int n;
double x[100000], y[100000];
char d[100000];

double calc(double p) {
    double xmax = -INF, xmin = INF, ymax = -INF, ymin = INF;
    for(int i = 0; i < n; i++) {
        xmax = max(xmax, x[i] + (d[i] == 'R' ? p : d[i] == 'L' ? -p : 0));
        xmin = min(xmin, x[i] + (d[i] == 'R' ? p : d[i] == 'L' ? -p : 0));
        ymax = max(ymax, y[i] + (d[i] == 'U' ? p : d[i] == 'D' ? -p : 0));
        ymin = min(ymin, y[i] + (d[i] == 'U' ? p : d[i] == 'D' ? -p : 0));
    }
    return (xmax - xmin) * (ymax - ymin);
}

int main() {
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> x[i] >> y[i] >> d[i];

    vector<double> point;
    point.push_back(0);

    double m1 = INF, m2 = INF, m3 = INF;
    for(int i = 0; i < n; i++) {
        if(d[i] == 'L')
            m1 = min(m1, x[i]);
        else if(d[i] == 'R')
            m2 = min(m2, x[i]);
        else
            m3 = min(m3, x[i]);
    }
    if(m1 != INF && m2 != INF)
        point.push_back(abs(m1 - m2) / 2);
    if(m1 != INF && m3 != INF)
        point.push_back(abs(m1 - m3));
    if(m2 != INF && m3 != INF)
        point.push_back(abs(m2 - m3));

    m1 = INF, m2 = INF, m3 = INF;
    for(int i = 0; i < n; i++) {
        if(d[i] == 'D')
            m1 = min(m1, y[i]);
        else if(d[i] == 'U')
            m2 = min(m2, y[i]);
        else
            m3 = min(m3, y[i]);
    }
    if(m1 != INF && m2 != INF)
        point.push_back(abs(m1 - m2) / 2);
    if(m1 != INF && m3 != INF)
        point.push_back(abs(m1 - m3));
    if(m2 != INF && m3 != INF)
        point.push_back(abs(m2 - m3));

    m1 = -INF, m2 = -INF, m3 = -INF;
    for(int i = 0; i < n; i++) {
        if(d[i] == 'R')
            m1 = max(m1, x[i]);
        else if(d[i] == 'L')
            m2 = max(m2, x[i]);
        else
            m3 = max(m3, x[i]);
    }
    if(m1 != -INF && m2 != -INF)
        point.push_back(abs(m1 - m2) / 2);
    if(m1 != -INF && m3 != -INF)
        point.push_back(abs(m1 - m3));
    if(m2 != -INF && m3 != -INF)
        point.push_back(abs(m2 - m3));

    m1 = -INF, m2 = -INF, m3 = -INF;
    for(int i = 0; i < n; i++) {
        if(d[i] == 'U')
            m1 = max(m1, y[i]);
        else if(d[i] == 'D')
            m2 = max(m2, y[i]);
        else
            m3 = max(m3, y[i]);
    }
    if(m1 != -INF && m2 != -INF)
        point.push_back(abs(m1 - m2) / 2);
    if(m1 != -INF && m3 != -INF)
        point.push_back(abs(m1 - m3));
    if(m2 != -INF && m3 != -INF)
        point.push_back(abs(m2 - m3));

    sort(point.begin(), point.end());
    point.erase(unique(point.begin(), point.end()), point.end());

    double res = INF;
    for(double p : point) {
        res = min(res, calc(p));
    }

    cout << fixed << setprecision(10) << res << endl;
    return 0;
}


Measured memory_bytes: 1920
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
int A[30000];
int a[] = { 2,3,4,6 };
int main() {
	int N;
	cin >> N;
	if (N == 3) {
		cout << "2 5 63" << endl;
		return 0;
	}
	else if (N == 4) {
		cout << "2 5 20 63" << endl;
		return 0;
	}
	else if (N == 5) {
		cout << "2 5 20 30 63" << endl;
		return 0;
	}
	int p = 0, q = 0;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		A[i] = 6 * p + a[q];
		(sum += A[i]) %= 6;
		if (q == 3) p++, q = 0;
		else q++;
	}
	if (sum == 2) {
		A[4] = 6 * (p + 1);
	}
	else if (sum == 3) {
		A[5] = 6 * (p + 1);
	}
	else if (sum == 5) {
		A[5] = 6 * p + 4;
	}
	cout << A[0];
	for (int i = 1; i < N; i++) cout << " " << A[i];
	cout << endl;
}

Measured memory_bytes: 384
h,w = map(int,input().split())
s = ["."*(w+2) for _ in range(h+2)]
for i in range(1, h+1):
  s[i] = "."+input()+"."
#準備完了 マス目は周りに1つ .が追加されている
kekka = [["#" for i in range(w)] for _ in range(h)]
#結果を収納するところ
for i in range(1, h+1):
  for j in range(1, w+1):
    if s[i][j]=="#":
      pass
    else:
      cnt = 0
      cnt += [0,1][s[i-1][j-1]=="#"]
      cnt += [0,1][s[i-1][j]=="#"]
      cnt += [0,1][s[i-1][j+1]=="#"]
      cnt += [0,1][s[i][j-1]=="#"]
      cnt += [0,1][s[i][j+1]=="#"]
      cnt += [0,1][s[i+1][j-1]=="#"]
      cnt += [0,1][s[i+1][j]=="#"]
      cnt += [0,1][s[i+1][j+1]=="#"]
      kekka[i-1][j-1] = str(cnt)
for i in range(h):
  print("".join(kekka[i]))

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

int main() {
    int64_t X, K, D;
    cin >> X >> K >> D;
    if(X < 0) X = -X;
    int64_t N = (X + D - 1) / D;
    int64_t ans = 0;
    if(N > K) {
        ans = X - D * K;
    } else {
        int64_t l = N * D - X;
        int64_t r = X - (N - 1) * D;
        cerr << l << " " << r << '\n';
        if(K % 2 == N % 2) ans = l;
        else ans = r;
    }
    cout << ans << '\n';
    return 0;
}


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

int main(){
	int n, ans[26];
	fill(ans, ans + 26, 1e9);
	cin >> n;
	while(n--){
		int a[26]{};
		string s;
		cin >> s;
		for(auto&& c:s) a[c - 'a']++;
		for(int i = 0; i < 26; i++) ans[i] = min(ans[i], a[i]);
	}
	for(int i = 0; i < 26; i++) cout << string(ans[i], char('a' + i));
	cout << endl;
}

Measured memory_bytes: 256
local mmi, mma = math.min, math.max
local n, k = io.read("*n", "*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
local imos = {}

local function work()
  for i = 1, n + 1 do
    imos[i] = 0
  end
  for i = 1, n do
    local v = a[i]
    local left = mma(1, i - v)
    local right = 1 + mmi(n, i + v)
    imos[left] = imos[left] + 1
    imos[right] = imos[right] - 1
  end
  local z = 0
  local isinf = true
  for i = 1, n do
    z = z + imos[i]
    a[i] = z
    if a[i] < n then isinf = false end
  end
  return isinf
end
for i = 1, k do
  local ret = work()
  if ret then break end
end
print(table.concat(a, " "))


Measured memory_bytes: 16256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,LL>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL vector<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v[3];
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>o;
        v[0].PSB(o);
    }
     for(i=0;i<n;i++)
    {
        cin>>o;
        v[1].PSB(o);
    }
    k=0;
    for(i=n-1;i>=0;i--)
    {
        j=0;
        for(l=0;l<=i;l++)
        {
            j+=v[0][l];
        }
          for(l=i;l<n;l++)
        {
            j+=v[1][l];
        }
        k=max(k,j);
    }
    cout<<k<<endl;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int k=0;
  
  int A1;
  cin >> A1;

    
    while (A1%2 == 0){
      A1 /= 2;
      k += 1;
    }  
  
  for ( int i=0; i<N-1; i++){
    int A;
    cin >> A;
    int j =0;
    
    while (A%2 == 0){
      A /= 2;
      j += 1;
    }
    if (j<k)
      k =j; 
  }
      
   cout << k << endl;
  }


Measured memory_bytes: 3552
#include<cstdio>
using namespace std;
const int N=100100;
int i,j,k,n,ch,ff,sum,Fg;
int a[N];
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
int gcd(int a,int b) {
	if (!b) return a;
	return gcd(b,a%b);
}
int main() {
	R(n);
	for (i=1;i<=n;i++) R(a[i]),sum^=a[i]&1;
	if (!(n&1)) {
		if (sum&1) puts("First");
		else puts("Second");
		return 0;
	}
	if (!(sum&1)) return puts("First"),0;
	for (i=0;;i^=1) {
		k=-1;
		for (j=1;j<=n;j++) if (a[j]&1) {
			if (k!=-1 || a[j]==1) { k=-1;break;}
			k=j;
		}
		if (k==-1) {
			if (i&1) puts("First");
			else puts("Second");
			return 0;
		}
		a[k]--;
		int g=a[1];
		for (j=2;j<=n;j++) g=gcd(g,a[j]);
		for (j=1;j<=n;j++) a[j]/=g;
		k=0;
		for (j=1;j<=n;j++) k^=a[j]&1;
		if (!k) {
			if (i&1) puts("First");
			else puts("Second");
			return 0;
		}
	}
}

Measured memory_bytes: 512
w = input()
lis = {}

for i in w:
    if i in lis:
        lis[i] = not(lis[i])
    else:
        lis[i] = False

flag = True
for b in lis.values():
    if not(b):
        print("No")
        flag = False
        break

if(flag):
    print("Yes")


Measured memory_bytes: 2940
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
l = []
for i in range(n):
    l.append(ii())

l.sort()
sA = sum(l)
if sA%10 != 0:
    print(sA)
else:
    lis = [i for i in l if i%10 != 0]
    if len(lis) == 0:
        print(0)
    else:
        print(sA - min(lis))

Measured memory_bytes: 3064
s=input()
t=1
for i in range(len(s)):
    if ((i+1)%2==0 and s[i] in ['U','D','L']) or ((i+1)%2==1 and s[i] in ['U','D','R']):
        continue
    else:
        print('No')
        t=0
        break
if t:
    print('Yes')


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

int main(){
    
    string s,t;
    cin >> s >> t;
    
    vector<char> S(s.size()),T(t.size());
    rp(i,s.size()){
        S.at(i) = s.at(i);
    }
    rp(i,t.size()){
        T.at(i) = t.at(i);
    }
    sort(S.begin(),S.end());
    sort(T.begin(),T.end());
    reverse(T.begin(),T.end());
    int cnt=0;
    rp(i,(S.size()>T.size()?T.size():S.size())){
        if(S.at(i)>T.at(i)){
            cout << "No" << endl;
            break;
        }else if(S.at(i)<T.at(i)){
            cout << "Yes" << endl;
            break;
        }else{
            cnt++;
        }
    }
    
    if(cnt==(S.size()>T.size()?T.size():S.size())){
        if(S.size()<T.size()){
            cout << "Yes" << endl;
        }else if(S.size()>=T.size()){
            cout << "No" << endl;
        }
    }
    
        
    return 0;
    
}


Measured memory_bytes: 256
A, B = map(int, input().split())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

LA = set(prime_factorize(A))
LB = set(prime_factorize(B))
ans = list(LA & LB)
print(len(ans)+1)

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

int main() {
    int n, a, s[100005]={0}, ans=0;
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> a;
        if(a<=100000) s[a]++;
        else ans++;
    }
    for(int i=1; i<=100000; i++) {
        if(s[i]>=i) ans += s[i]-i;
        else ans += s[i];
    }
    cout << ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
typedef pair<int,int> P;
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
	int a,b,n;
	cin>>a>>b>>n;
	int c=(n+1)/b;
	c=c*b-1;
	int ans=0;
	ans+=a*c/b;
	ans-=a*(int)(c/b);
	int ans2=0;
	ans2+=a*n/b;
	ans2-=a*(int)(n/b);
	cout<<max(ans,ans2)<<endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<vector<int>> vec(N,vector<int>(M));
  
  for (int i=0; i<N; i++){
    int K;
    cin >> K;
    for (int j=0; j<K; j++){
      cin >> vec.at(i).at(j);
    }
  }
  
  int ans=0;
  for (int l=1; l<31; l++){
    int count = 0;
    for (int i=0; i<N; i++){
      for(int j=0; j<M; j++){
        if(vec.at(i).at(j) == l){
          count++;
        }
      }
    }
    if(count == N){
      ans++;
    }
  }
  
  cout << ans <<endl;
}



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


int main() {
  int N;
  cin >> N;
  bool flg = false;
  for (int i = 1; i <= 9; ++i) {
    int div = N / i;
    if (div * i == N && 1 <= div && div <= 9) {
      flg = true;
      break;
    }
  }
  if (flg) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
n = int(input())
dict = {}
for _ in range(n):
    s = input()
    if s in dict:
        dict[s] += 1
    else:
        dict[s] = 0
max_val = max(dict.values())
max_list = [k for k, v in dict.items() if v == max_val]
max_list.sort()
for i in max_list:
    print(i)

Measured memory_bytes: 32096
import java.util.Scanner;

/**
 * Created by suzuki on 17/06/24.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        if (A >= B) {
            System.out.println("delicious");
        }else if(X+A >= B){
            System.out.println("safe");
        }else {
            System.out.println("dangerous");
        }
    }
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  string s;
  cin>>s;
  int SIZE = 26;
  vector<int> key(SIZE,0);

  FOR(i,0,SIZE){
    key[s[i]-'a']=1;
  }
  int pre=0;
  char q='z';
  if((int)s.size()<SIZE){
    FOR(i,0,SIZE){
      if(key[i]==0){
        cout<<s<<(char)('a'+i)<<endl;
        break;
      }
    }
  }
  else{
    if(s=="zyxwvutsrqponmlkjihgfedcba") cout<<-1<<endl;
    else{
      FORr(i,SIZE-2,-1){
        if(s[i]<s[i+1]){
          pre=i;
          break;
        }
      }
      FOR(i,pre,SIZE){
        if(s[pre]<s[i]&&s[i]<q){
          q=s[i];
        }
      }
      FOR(i,0,pre){
        cout<<s[i];
      }
      cout<<q<<endl;
    }
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
using namespace std;
const int MAX = 200005;
vector<vector<int> > g(MAX);
int maxDist;
int V;
void dfs(int u , int dist = 0  , int p = -1)
{
	if(dist > maxDist)
	{
		maxDist = dist;
		V = u;
	}
	for(auto v : g[u])
	{
		if(v != p)
			dfs(v , dist + 1 , u);
	}
}
int main()
{
	ios_base::sync_with_stdio(0);
	int N;
	cin >> N;
	for(int i = 1; i < N; i++)
	{
		int u , v;
		cin >> u >> v;
		u--;v--;
		g[u].PB(v);
		g[v].PB(u);
	}
	dfs(0);
	maxDist = 0;
	dfs(V);
	maxDist++;	
	if(maxDist <= 2)
		cout << (maxDist == 2 ? "Second" : "First");
	else
		cout << (maxDist % 3 < 2 ? "First" : "Second");
    return 0;
}


Measured memory_bytes: 20608
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

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

	Int ans = 0;
	for (Int i = 1; i <= N; ++i) {
		if (i % 3 == 0 || i % 5 == 0) { continue; }
		ans += i;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
int main() {
  map<string,ll>mp;
  ll n,m;
  string s[110],t;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s[i];
    mp[s[i]]++;
  }
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>t;
    mp[t]--;
  }
  ll ans=0;
  for(int i=0;i<n;i++)ans=max(ans,mp[s[i]]);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_e
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, k, s, t;
  cin >> n >> k >> s >> t;
  vector<int> a;
  rep(i, n) {
    int x;
    cin >> x;
    if ((x&s) != s || (x|t) != t) continue;
    a.push_back(x);
  }
  n = a.size();
  k = min(n, k);
  if (n == 0) {
    cout << "0\n";
    return 0;
  }

  vector<vector<ll>> C(n+1, vector<ll>(n+1));
  rep(i, n+1) {
    C[i][0] = 1;
    for (int j = 1; j < i; ++j) C[i][j] = C[i-1][j] + C[i-1][j-1];
    C[i][i] = 1;
  }
  vector<ll> way(n+1);
  rep(i, n+1) {
    for (int j = 1; j <= min(i, k); ++j) way[i] += C[i][j];
  }
  
  ll ans = 0;
  int xo = s^t;
  vector<int> f(1<<18);

  // permutation
  for (int mask = xo;; mask = (mask-1)&xo) {
    ll sum = 0;
    for (int x : a) f[x&mask]++;

    for (int x : a) {
      sum += way[f[x&mask]];
      f[x&mask] = 0;
    }
    ans += (__builtin_popcount(mask)%2 ? -1 : 1)*sum;
    if (mask == 0) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4240
//PR
#include<iostream>
using namespace std;

int main()
{
	int H, W;
	while(1)
	{
		cin >> H >> W;
		if( H == 0 && W == 0)
		break;
		
		for(int j = 0; j < H; j ++){
		for(int i = 0; i < W; i++)
		cout << '#';
		cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3048
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

ans = 0
for i in range(1, N+1):
    n = N//i
    ans += i*n*(n+1)//2
print(ans)


Measured memory_bytes: 74684
import sys
import numpy as np



def main(N,dp):
    dp[0, 0] = min(N[0], 11 - N[0])
    dp[0, 1] = min(N[0] + 1, 10 - N[0])
    for i in range(1, len(N)):
        dp[i, 0] = min(dp[i - 1, 0] + N[i], dp[i - 1, 1] + 10 - N[i])
        dp[i, 1] = min(dp[i - 1, 0] + N[i] + 1, dp[i - 1, 1] + 9 - N[i])
    print(dp[-1,0])


if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', '(i8[:],i8[:,:])')(main)
    # b1: bool, i4: int32, i8: int64, double: f8, [:], [:, :]
    cc.compile()
else:
    from my_module import main
    N = np.array([int(_) for _ in input()])
    dp=np.zeros((len(N),2),dtype=np.int64)
    main(N,dp)


Measured memory_bytes: 51428
#include<bits/stdc++.h>
using namespace std;
#define lol long long
int main(){
  string s;
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a*b>=c*d) cout<<a*b<<"\n";
  else cout<<c*d<<"\n";
  return(0);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<iomanip>
#define P 3.14159265358979323846
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
#define N 200010
int sx,sy,gx,gy,n;
pair<int,int> c[N];
 
vector<int> lis;
 
int main(){
  cin>>sx>>sy>>gx>>gy;
  bool flipx=false,flipy=false;
  if(sx>gx)flipx=true,sx=-sx,gx=-gx;
  if(sy>gy)flipy=true,sy=-sy,gy=-gy;
  cin>>n;
  lol(i,n){
    int x,y;cin>>x>>y;
    if(flipx)x=-x;
    if(flipy)y=-y;
    c[i]=make_pair(x,y);
  }
  sort(c,c+n);
  
  lol(i,n){
    int x=c[i].first,y=c[i].second;
    if(x<sx||gx<x)continue;
    if(y<sy||gy<y)continue;
    
    //V-LIS-V
    vector<int>::iterator it;
    it=lower_bound(lis.begin(),lis.end(),y);
    if(it==lis.end())lis.push_back(y);
    else *it=y;
    //A-LIS-A
  }
  
  double ans=(gx-sx+gy-sy)*(ll)100;
  ans-=(double)lis.size()*(20-5.0*P);
  if(lis.size()-1==gx-sx||lis.size()-1==gy-sy)ans+=5.0*P;
  
  //cout<<lis.size()<<" "<<cornerx<<" "<<cornery<<endl;
  cout<<fixed<<setprecision(15)<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2936
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,h,w;
    int a,b;
    cin>>n>>h>>w;
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        if(a>=h && b>=w) ans++;
    }
    cout<<ans<<endl;
    return 0;
}



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

bool is_kaibun(string s){
    int n=s.size();
    int a=(n+1)/2;
    for(int i = 0;i < a;++i) {
        if(s[i]!=s[n-1-i])return false;
    }
    return true;
}

int main() {
    string s;
    cin>>s;
    int n=s.size();
    if(is_kaibun(s)){
        if(is_kaibun(s.substr(0,(n-1)/2))){
            if(is_kaibun(s.substr((n+3)/2-1,n-((n+3)/2-1)))){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int r = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		int ans = r * x - d;
		System.out.println(ans);

		for(int i = 1 ; i < 10; i++) {
			ans = r * ans - d;
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		 Scanner scanner = new Scanner(System.in);
		 System.out.print(" ");
		 
		int  a = scanner.nextInt();
		int  b = scanner.nextInt();
		int answer = a * b;
		    
		if(answer% 2 ==0) {
		    System.out.println("Even");
		}
		else {
		    System.out.println("Odd");
		}
	    scanner.close();
	}
}


Measured memory_bytes: 21844
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
from collections import defaultdict
dic = defaultdict(int)
for _ in range(N):
    a = float(input())*(10**9)
    a = int(a+0.1)
    num2, num5 = 0, 0
    while a%2==0:
        a//=2
        num2+=1
        if num2>18: break
    while a%5==0:
        a//=5
        num5+=1
        if num5>18: break
    dic[(num2, num5)] += 1

keys = list(dic.keys())
length = len(keys)
ans = 0
for i in range(length):
    a2, a5 = keys[i]
    a_cnt = dic[(a2, a5)]
    for j in range(i, length):
        b2, b5 = keys[j]
        b_cnt = dic[(b2, b5)]
        if a2+b2>=18 and a5+b5>=18:
            if i==j:
                ans += (a_cnt)*(b_cnt-1)//2
            else:
                ans += a_cnt*b_cnt
print(ans)

Measured memory_bytes: 74904
n, x = map(int, input().split())
l = sorted(list(map(int, input().split())))

ans = 0
for i in range(n-1):
    if l[i] <= x:
        x -= l[i]
        ans += 1
else:
    if l[-1] == x:
        ans += 1
print(ans)

Measured memory_bytes: 9124
#include <iostream>

int main()
{
    while (true) {
        int max, sum_make;
        std::cin >> max >> sum_make;

        if (max == 0 && sum_make == 0) {
            break;
        }

        int cnt = 0;
        for (int small = 1; small <= (sum_make / 3); small++) {
            for (int mid = small + 1; mid <= (sum_make - small) / 2; mid++) {
                for (int big = mid + 1; big <= max; big++) {
                    int sum = small + mid + big;
                    if (sum == sum_make) {
                        cnt++;
                    }
                }
            }
        }
        std::cout << cnt << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1160
def solve():
    MOD = 998244353

    A, B, C, D = map(int, input().split())

    dp = [[0]*(D+1) for _ in range(C+1)]
    dp[A][B] = 1
    for j in range(B+1, D+1):
        dp[A][j] = dp[A][j-1] * A % MOD
    for i in range(A+1, C+1):
        dp[i][B] = dp[i-1][B] * B % MOD

    for i in range(A+1, C+1):
        for j in range(B+1, D+1):
            dp[i][j] = (dp[i-1][j]*j + dp[i][j-1]*i - dp[i-1][j-1]*(i-1)*(j-1)) % MOD

    print(dp[C][D])


solve()


Measured memory_bytes: 136572
from collections import deque
import sys

h, w = map(int, input().split())
grid = [list(list(map(str, input().rstrip()))) for _ in range(h)]

kuro = 0
for g in grid:
    kuro += g.count("#")

q = deque([[0, 0]])
grid[0][0] = 1
moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]

while q:
    cx, cy = q.popleft()
    for m in moves:
        nx, ny = cx + m[0], cy + m[1]
        if nx < 0 or nx > h - 1 or ny < 0 or ny > w - 1:
            continue
        elif grid[nx][ny] == "#":
            continue
        elif grid[nx][ny] == ".":
            grid[nx][ny] = grid[cx][cy] + 1
            q.append([nx, ny])
            if nx == h - 1 and ny == w - 1:
                print(h * w - grid[nx][ny] - kuro)
                sys.exit()
else:
    print(-1)

Measured memory_bytes: 3316
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
  long long x, y;
  cin >> x >> y;

  long long ret = 0;
  if (abs(x) > abs(y) && x > 0) {
    // flip sign
    ++ret;
    x *= -1;
    // increment
    ret += abs(x) - abs(y);
    x -= abs(x) - abs(y);
  } else if (abs(x) > abs(y) && x <= 0) {
    ret += abs(x) - abs(y);
    x += abs(x) - abs(y);
  } else if (abs(x) < abs(y) && x >= 0) {
    ret += abs(y) - abs(x);
    x += abs(y) - abs(x);
  } else if (abs(x) < abs(y) && x < 0) {
    // flip sign
    ++ret;
    x *= -1;
    // increment
    ret += abs(y) - abs(x);
    x += abs(y) - abs(x);
  }

  // flip sign
  if ((x > 0 && y < 0) || (x < 0 && y > 0))
    ++ret;

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define f(i, x, n) for(int i = x; i < n; i++)
#define dbg(x) cout << x << endl
#define dbg2(x, y) cout << x << "  " << y << endl
#define dbg3(x, y, z) cout << x << "  " << y << "  " << z << endl
#define mod 1000000007
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    ll n, happy;
    cin >> n;
    happy = (n / 500) * 1000;
    n %= 500;
    happy += n - (n%5);
    cout << happy << endl;
    
}

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

int main(){
    uint_fast32_t N;
    scanf("%u", &N);

    vector<uint_fast64_t> ans(N, numeric_limits<uint_fast64_t>::max());
    ans[0] = 0;

    {
        array<int_fast32_t, 3> h;
        scanf("%d%d", &h[0], &h[1]);
        ans[1] = abs(h[1] - h[0]);

        for(auto i = 2; i < N; ++i){
            scanf("%d", &h[2]);
            
            ans[i] = min(abs(h[1] - h[2]) + ans[i - 1], abs(h[0] - h[2]) + ans[i - 2]);
            
            h[0] = h[1];
            h[1] = h[2];
        }
    }

    printf("%llu\n", *ans.rbegin());

    return 0;
}

Measured memory_bytes: 1024
n = gets.to_i
array = []
answer = "Yes"

(1..n).each do
  array.push(gets.chomp.split(""))
end

if array.length == array.uniq.length
  (0..n-2).each do |number| 
    if array[number].last != array[number+1].first
      answer = "No"
      break
    end
  end
else
  answer = "No"
end

puts answer

Measured memory_bytes: 1916
pub fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let n = read1::<usize>();
    let mut u = Vec::new();

    for _ in 0..n {
        let d = read1::<usize>();
        match u.binary_search(&d) {
            Ok(_) => continue,
            Err(i) => u.insert(i, d),
        };
    }

    println!("{}", u.len());
}

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

#define endl '\n'
#define int ll
using namespace std;
typedef long long ll;
typedef pair<double, int> Node;
#define len first
#define idx second

struct Circle
{
    double x, y, r;
};

int vn;
vector<Circle> circle;


void init();
void process();

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    double x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    int cn; cin >> cn;
    vn = cn+2; circle.resize(vn);
    for(int i = 0; i < cn; i++) cin >> circle[i].x >> circle[i].y >> circle[i].r;
    circle[cn] = (Circle){x1, y1, 0};
    circle[cn+1] = (Circle){x2, y2, 0};
}

double getDist(int i, int j)
{
    Circle &a = circle[i], &b = circle[j];
    double dx2 = (a.x-b.x)*(a.x-b.x);
    double dy2 = (a.y-b.y)*(a.y-b.y);
    double dist = sqrt(dx2 + dy2);
    double rsum = a.r + b.r;
    if(rsum >= dist) return 0;
    else return dist - rsum;
}

void process()
{
    priority_queue<Node, vector<Node>, greater<Node>> pq;
    int start = vn-2, stop = vn-1;
    pq.emplace(0, start);
    vector<double> sp(vn, 1e18); sp[start] = 0;
    vector<bool> vis(vn, false); 
    while(!pq.empty())
    {
        Node f = pq.top(); pq.pop();
        if(vis[f.idx]) continue;
        sp[f.idx] = f.len;
        vis[f.idx] = true;
        if(f.idx == stop) break;
        for(int i = 0; i < vn; i++)
        {
            if(vis[i]) continue;
            double dist = getDist(f.idx, i);
            if(f.len+dist < sp[i])
            {
                sp[i] = f.len+dist;
                pq.emplace(sp[i], i);
            }
        }
    }
    cout << fixed << setprecision(10) << sp[stop] << endl;
}



Measured memory_bytes: 6260