akhauriyash/Code-Regression huggingface dataset:
/*
ID: Nipun Paul
LANG: C++
PROB: God knows
*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> v;
ll b[200005];

int main()
{
    ll a;
    cin>>a;
    for(int i=0; i<a; i++)
    {
        cin>>b[i];
        v.push_back(b[i]);
    }
    sort(v.begin(),v.end());
    for(int i=0; i<a; i++)
    {
        if(b[i]!=v[a-1])
        {
            cout<<v[a-1]<<endl;
        }
        else
        {
            cout<<v[a-2]<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4848
kigou=list("abcdefghijklmnopqrstuvwxyz")
a=int(input())
keta=0
count=0
for i in range(1,100):
    x=26**i+count
    if 26**i+count>=a:
      keta=i
      break
    else:
        count+=26**i

ans=""

for i in range(keta):
    r=(a-1)%26
    ans=kigou[r]+ans
    a=(a-r)//26

print(ans)

Measured memory_bytes: 9096
n = int(input())
x = [0] * n
y = [0] * n
h = [0] * n
for i in range(n):
  x[i], y[i], h[i] = map(int, input().split())

import sys
ind = h.index(max(h))
for cx in range(0, 101):
  for cy in range(0, 101):
    H_calc = h[ind] + abs(x[ind]-cx) + abs(y[ind]-cy)
    for i in range(n):
      if max((H_calc - abs(x[i]-cx) -abs(y[i]-cy)), 0) != h[i]:
        break
    else:
      print(cx, cy, H_calc)
      sys.exit()

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

typedef long long ll;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}


int main(){
  string S;
  cin >> S;
  ll n = S.size();
  vector<ll> in,di;
  ll cnt1 = 0,cnt2 = 0;
  for(ll i = 0;i < n;i++){
    if(S[i] == '>'){
      cnt1++;
    }else{
      if(cnt1 != 0){
      di.push_back(cnt1);
      cnt1 = 0;
      }
    }
    if(i == n-1 && S[i] == '>'){
      di.push_back(cnt1);
      cnt1 = 0;
    }
  }
  for(ll i = 0;i < n;i++){
    if(S[i] == '<'){
      cnt2++;
    }else{
      if(cnt2 != 0){
      in.push_back(cnt2);
      cnt2 = 0;
      }
    }
    if(i == n-1 && S[i] == '<'){
      in.push_back(cnt2);
      cnt2 = 0;
    }
  }
  ll ans = 0;
  
  di.push_back(0),in.push_back(0);
  ll D = di.size(),I = in.size();

  if(S[0] == '>'){
     ans+= di[0]*(di[0]+1) / 2;
     remove(di,0);
  }

  for(ll i = 0;i < min(I,D);i++){
      if(di[i] >= in[i]){
      ans += (di[i] * (di[i]+1)) / 2;
      ans += in[i]*(in[i]-1) / 2;
      }else{
        ans += in[i] * (in[i]+1) / 2;
        ans += di[i]*(di[i]-1) / 2;
      }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 3e5+5;
const ll mod =   1e9+7;
int ans=0;int h,w,kk;string s[10];
int main()
{  fast
cin>>h>>w>>kk;
for(int i=0;i<h;i++)
cin>>s[i];
int cnt=0;

for(int i=0;i<(1<<h);i++){
	for(int j=0;j<(1<<w);j++){int c=0;
   for(int k=0;k<h;k++){
   	for(int l=0;l<w;l++){
   		if(s[k][l]=='#'){
   			if((1<<k)&i||((1<<l)&j))
   			continue;
   			c++;
		   }
	   }
   }
   if(c==kk)
   ans++;
	}
}
cout<<ans;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

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

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << ' ' << max(0, (a + b) - n) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//In wrong answers we believe//
#define db 				double
#define ll 				long long int
#define ld				long long double
//#define int 			long long int
#define ull 			unsigned long long
#define vii 			vector <int>
#define vll 			vector < ll >
#define pii 			pair <int, int>
#define fi 				first
#define se 				second
#define rep(i,a,n)      for(int i=a;i<n;i++)
#define endl 			'\n'
#define mem(a,b) 		memset(a, b, sizeof a)
#define mkp 			make_pair
#define pb 				push_back
#define max3(a,b,c) 	max(a,max(b,c))
#define min3(a,b,c) 	min(a,min(b,c))
#define w(t)            int t; cin>>t; while(t--)
#define all(a)			a.begin(), a.end()
using namespace std;
db pi		 =			2*acos(0.0);
db eps       =			0.000001;
ll mod       =			(1e9+7);   //998244353
const ll INF =			1000000000000000LL;
void print(vector <int> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}
void printll(vector <ll> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}

ll ncr(ll n, ll r)
{
    r=min(r,n-r);
    ll A[r],i,j,B[r];
    iota(A,A+r,n-r+1);  
    iota(B,B+r,1);     

    ll g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    ll ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
const int SIZE=100001;
bool judgePermutation(int a[], int n){
    static int used[SIZE+1];
    for(int i = 1; i <= n; i++) used[i] = 0;
    for(int i = 0; i < n; i++) used[a[i]] = 1;
    for(int i = 1; i <= n; i++) {
        if(!used[i]) return 0;
    }
    return 1;
}


int main(){	
//CONDITION && cout << "YES" || cout << "NO"; cout << '\n';
//////////////////////////////////////////////////////////////////////
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
//For fast IO
///////////////////////////////////////////////////////////////////// 
//  std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//  std::cout.precision(10);
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	int n,m;
	cin>>n>>m;
	vii ht(n);
	rep(i,0,n) cin>>ht[i];
	vector < vii > adj(n);
	rep(i,0,m){
		int u,v;
		cin>>u>>v;
		u--;
		v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	
	vector < bool > good(n,true);
	
	rep(i,0,n){
		rep(ii,0,adj[i].size()){
			if(ht[adj[i][ii]]>=ht[i] && adj[i][ii]!=i) good[i]=false;
		}
	}
	ll tot=0;
	rep(i,0,n) if(good[i]) tot++;

	cout<<tot<<endl;
    return 0;
    }

Measured memory_bytes: 8744
main = input()
word = input()
temp = main
resultArray = []
final = len(word)
for j in range(len(main) - (len(word) - 1)):
    result = ''
    for i in range(len(word)):
        if main[j + i] == word[i]:
            result += '1'
        else:
            result += '0'
    resultArray.append(result)
for i in resultArray:
    if i.count('0') < final:
        final = i.count('0')
print(final)


Measured memory_bytes: 9084
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    let a:i64 = read();
    let b:i64 = read();
    let x:i64 = read();

    println!("{}", if a <= x && a+b >= x {"YES"} else {"NO"});

}


Measured memory_bytes: 4352
n = int(input())
tbl = [[0 for _ in range(10)] for _ in range(10)]

for i in range(1,n+1):
    i = str(i)
    tbl[int(i[0])][int(i[-1])] += 1

ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += tbl[i][j] * tbl[j][i]
print(ans)

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

using namespace std;

int main() {
	long long a, b, k;
	cin >> a >> b >> k;
	long long hoge = k;
	hoge -= a;
	a -= ((a < k) ? a : k);
	if (hoge > 0) b -= ((b < hoge) ? b : hoge);
	cout << a << " " << b;
}

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

using namespace std;
typedef long long ll;
#define DBG(v) cerr << #v << " = " << (v) << endl;

const int MxN = (int)1e5 +9;
bool broken[MxN + 9];
ll dp[MxN + 9];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    int n, m;
    cin >> n >>m;
    for(int i = 0; i < m; ++i) {
        int x;
        cin >> x;
        broken[x] =1;
    }

    dp[n] = 1;
    for(int i = n - 1; i >= 0; --i) {
        if(!broken[i])
            dp[i] = (dp[i+1] + dp[i+2]) % ((int)1e9 + 7);
    }
    cout << dp[0];

    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define REP(i,n) rep(i,0,n)
#define ll long long
#define ull unsigned long 

void dfs(vector<vector<ll> >& g,ll v,ll p,ll x,vector<ll>& con) //V子、P親
{
  con[v]+=x;
  for(auto next:g[v])
    if(next != p) 
      dfs(g,next,v,con[v],con);

}

int main()
{ 
  ll n,q;
  cin >> n >> q;
 vector<vector<ll> >  Ginf(n);
 REP(i,n-1)
 {
   ll a,b;
   cin >> a >> b;
   a--;
   b--;
   Ginf[a].push_back(b);
   Ginf[b].push_back(a);
 }
  vector<ll> con(n,0);
  
  REP(i,q)
  {
    ll p,x;
    cin >> p >> x;
    p--;
    con[p]+=x;
  }
  dfs(Ginf,0,-1,0,con);
  
 REP(i,n)
   cout << con[i] <<" ";
}

Measured memory_bytes: 30464
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> P(N);
    for (int i = 0; i < N; i++)
    {
        cin >> P[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int pivot = i;
        for (int j = i + 1; j < N; j++)
        {
            if (P[i] > P[j])
            {
                pivot = j;
            }
        }
        if (i != pivot)
        {
            ans++;
            swap(P[i], P[pivot]);
        }
    }
    if (ans >= 2)
    {
        cout << "NO" << endl;
    }
    else
    {
        cout << "YES" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//long long int t;
//cin>>t;
//for(int i=0;i<t;i++)
{
    ll n;
    cin>>n;
    if(n>=400&&n<=599)
    {
        cout<<"8"<<endl;
    }
    else if(n>=600&&n<=799)
    {
        cout<<"7"<<endl;
    }
    else if(n>=800&&n<=999)
    {
        cout<<"6"<<endl;
    }
    else if(n>=1000&&n<=1199)
    {
        cout<<"5"<<endl;
    }
    else if(n>=1200&&n<=1399)
    {
        cout<<"4"<<endl;
    }
    else if(n>=1400&&n<=1599)
    {
        cout<<"3"<<endl;
    }
    else if(n>=1600&&n<=1799)
    {
        cout<<"2"<<endl;
    }
    else if(n>=1800&&n<=1999)
    {
        cout<<"1"<<endl;
    }
}
return 0;
}


Measured memory_bytes: 3640
//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber

#include <bits/stdc++.h>

using namespace std;

// typedefs...
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// constants...
const double PI = acos(-1);

// defines...
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll lcm(ll a, ll b)
{
    return (a/gcd(a, b)*b);
}
ll comb(ll a, ll b)
{
    ll x = max(a-b, b), ans=1;

    for(ll K=a, L=1; K>=x+1; K--, L++){
        ans *= K;
        ans /= L;
    }

    return ans;
}


void task()
{
    //code here...
    
    int k, n;
    string s;
    
    cin >> k >> s;
    
    n = s.length();
    
    if(n<=k) cout << s << "\n";
    else {
		s = s.substr(0, k);
		s = s + "...";
		
		cout << s << "\n";
	}
}
 
int main()
{
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    task();

    return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    vec<ll> A(N),S(N+1);
    for(int i=0;i<N;i++){
        cin >> A[i];
        A[i]--;
        S[i+1] = (S[i]+A[i])%K;
    }
    map<ll,ll> mp;
    mp[0] = 1;
    ll ans = 0;
    for(int i=0;i<N;i++){
        if(i-K+1>=0) mp[S[i-K+1]]--;
        if(mp.count(S[i+1])) ans += mp[S[i+1]];
        mp[S[i+1]]++;
    }
    cout << ans << "\n";
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rrepn(i, n) for (int i = ((int)(n)); i > 0; --i)
#define SZ(x) ((int)(x).size())
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long X, long long N, std::vector<long long> p) {
    map<ll, ll> m;
    rep(i, N) { m[p[i]]++; }
    ll res = -1, minv = INF;
    rep(i, 102) {
        if (abs(X - i) < minv && m[i] == 0) {
            res = i;
            minv = abs(X - i);
        }
    }
    cout << res << endl;
}

int main() {
    long long X;
    scanf("%lld", &X);
    long long N;
    scanf("%lld", &N);
    std::vector<long long> p(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &p[i]);
    }
    solve(X, N, std::move(p));
    return 0;
}


Measured memory_bytes: 3696
//19
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  string s;
  cin>>s;
  int a=1<<30;
  for(int i=0;i<4;i++){
    a=min(a,(int)count(s.begin(),s.end(),"KUPC"[i]));
  }
  cout<<a<<endl;
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < (int)(n);++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

ll n;

void fastik() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

//ifstream &cin
void solve(){

}
bool cmp (pll a, pll b){
    return a.fi < b.fi;
}

int main() {
    fastik();
    ll n,m;cin>>n>>m;
    vpll a(n);
    forn(i,n){
        cin >> a[i].fi >> a[i].se;
    }
    sort(all(a),cmp);
    ll ans = 0;
    for(auto i: a){
        ll t = min(i.se,m);
        m -= t;
        ans += t*i.fi;
        if(m == 0){
            break;
        }
    }
    cout << ans;

}

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

#define fn "test"
#define fn1 ""

using namespace std;

const int mn = 1 * (int)(1e5) + 10;
const int mod = 1 * (int)(1e9) + 7;
const int mm = 1 * (int)(1e3) + 10;
const int base = 1 * (int)(1e9);
const bool aNs = 0;

int tt, ntest = 1;

void docfile()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    if (ifstream(fn".inp"))
    {
        freopen(fn".inp", "r", stdin);
        if (!aNs) freopen(fn".out", "w", stdout);
		else freopen (fn".ans", "w", stdout);
    }else if (ifstream(fn1".inp"))
    {
        freopen(fn1".inp", "r", stdin);
        freopen(fn1".out", "w", stdout);
    }
}

template <typename T>
void read(T& x)
{
    x = 0; T f = 1;
    char ch = getchar();
    while (!isdigit(ch)) f = ch == '-' ? - f : f, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
    x *= f;
}

template <typename T>
void write (T a)
{
    if (a < 0)
    {
        putchar ('-');
        write (-a);
        return;
    }
    if (a < 10)
    {
        putchar ('0' + a);
        return;
    }
    write (a / 10);
    putchar ((char)('0' + (a % 10)));
}

char s[510][510];

void enter()
{
    int a, b;
    cin >> a >> b;
    int m = 100, n = 100;
    for (int i = 1; i <= m; ++ i)
    for (int j = 1; j <= n; ++ j)
    s[i][j] = '.';
    int k = m;
    -- b;
    for (int j = n; (j >= 1 && b); j -= 2)
    for (int i = 1; (i <= m && b); i += 2)
    {
        -- b;
        s[i][j] = '#';
        k = j;
    }   
    for (int i = 1; i <= m; ++ i)
    for (int j = 1; j <= k - 2; ++ j)
    s[i][j] = '#';
    -- a;
    for (int j = 1; (j <= k - 2 && a); j += 2)
    for (int i = 1; (i <= m && a); i += 2)
    {
        -- a;
        s[i][j] = '.';
    }
    cout << 100 << " " << 100 << "\n";
    for (int i = 1; i <= m; ++ i)
    {
        for (int j = 1; j <= n; ++ j)
        cout << s[i][j];
        cout << "\n";
    }
}

void solve()
{

}

void print_result()
{

}

int main()
{
    docfile();
    //cin>>ntest;
    for (tt = 1; tt <= ntest; ++ tt)
    {
        enter();
        solve();
        print_result();
    }
}

Measured memory_bytes: 384
import Data.Functor
import Control.Applicative
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU

main :: IO ()
main = do
  n <- read <$> getLine
  ls <- VU.unfoldrN n (BS.readInt . BS.dropWhile (<'!')) <$> BS.getLine
  let s = VU.sum ls
  putStrLn $ if VU.all (\l -> 2 * l < s) ls then "Yes" else "No"


Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <ctype.h>
#include <iomanip>
#include <utility>
#include <bitset>
#include <set>
#include <map>
#include <ios>
#include <cstdlib>
using namespace std;
int main() {
    int N; cin >> N;
    int X; cin >> X;
    vector<int> L(N);
    for (int i=0;i<N;i++) cin >> L[i];
    vector<int> D(N+1);
    D[0] = 0;
    for (int i=1;i<N+1;i++) D[i] = D[i-1] + L[i-1];
    int cnt = 0;
    for (int i=0;i<N+1;i++) {
        if (D[i]<=X) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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


#define ll          long long
#define uint        unsigned int 
#define ld          long double
#define SAM         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#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 mod         1000000007
#define mxn         200005
#define pb          push_back
#define pii         pair<int,int>
#define f           first
#define s           second
#define sz(x)       (int)x.size()
#define all(x)      x.begin(),x.end()

using namespace std;

/*mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int power(int a,int n)
{
    a %= mod;
    if(n == 1) return a;
    if(n == 0) return 1;
    if(n%2) return (a*(power((a*a)%mod,n/2)%mod))%mod;           //n is odd
    return power((a*a)%mod,n/2)%mod;                             //n is even
}

const int inf = (int) 1e18;

int inverse(int x)
{
    return power(x,mod-2)%mod;     //Fermat's little theorem
}*/


int main()
{
    SAM;
    string s;
    cin>>s;
    
    if(s[0]=='R' && s[1]=='R' && s[2]=='R')
    {
        cout<<"3";
        return 0;
    }
    
    if((s[0]=='R' && s[1]=='R') || (s[1]=='R' && s[2]=='R'))
    {
        cout<<"2";
        return 0;
    }
    
    if(s[0]=='R' || s[1]=='R' || s[2]=='R')
    {
        cout<<"1";
        return 0;
    }
    
    cout<<"0";
    
    
    
    
    
    
    
    
    return 0;
}




Measured memory_bytes: 3644
R=range
l=[[[0 for i in R(10)]for j in R(3)]for s in R(4)]
n=int(input())
for a in range(n):
    b,f,r,v=map(int,input().split())
    l[b-1][f-1][r-1]+=v
for b in range(4):
    for k in l[b]:
        print('',*k)
    if b<3:
        print('#'*20)

Measured memory_bytes: 7704
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, sum int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	for _, v := range a {
		sum += v
	}
	fmt.Printf("%d %d %d\n", a[0], a[n-1], sum)
}


Measured memory_bytes: 1800
n, y = map(int, input().split())
for i in range(n+1):
    for j in range(n-i+1):
        k = n-i-j
        if y - 10000*i - 5000*j == 1000*k and 0 <= k <= n:
            a=str(i)
            b=str(j)
            c=str(n-i-j)
            print(a+" "+b+" "+c)
            exit()
print("-1 -1 -1")

        


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int maxn = 1e6 + 5;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    n = n * 2 - 1;
    if (k == 1 || k == n) {
        cout << "No\n";
        exit(0);
    }
    cout << "Yes\n";
    if (n == 3) {
        cout << "1\n2\n3\n";
        exit(0);
    }
    int ans[n + 5] = {};
    int u[n + 5] = {};
    ans[n/2] = k;
    ans[n/2-1] = k - 1;
    ans[n/2+1] = k + 1;
    u[k] = 1;
    u[k + 1] = 1;
    u[k - 1] = 1;
    if (k == 2) {
        ans[n/2-2] = k + 2;
        u[k+2] = 1;
    }
    else {
        ans[n/2+2] = k - 2;
        u[k-2] = 1;
    }
    int ptr = 1;
    f(n) {
        if (ans[i])continue;
        while(u[ptr]) {
            ptr++;
        }
        u[ptr] = 1;
        ans[i] = ptr;
    }
    f(n) {
        cout << ans[i] << '\n';
    }
}

Measured memory_bytes: 3072
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;
 
int n;
int v[2][100010];
int la[2][100010],ne[2][100010];
 
int main(){
	scanf("%d",&n);
	for(int i=0;i<=1;i++)
		for(int j=1;j<=100000;j++) v[i][j]=n/2;
	la[0][0]=la[1][0]=ne[0][100001]=ne[1][100001]=1e9;
	int x;
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		v[i%2][x]--;
	}
	for(int i=1;i<=100000;i++) la[0][i]=min(la[0][i-1],v[0][i]),la[1][i]=min(la[1][i-1],v[1][i]);
	for(int i=100000;i>=1;i--) ne[0][i]=min(ne[0][i+1],v[0][i]),ne[1][i]=min(ne[1][i+1],v[1][i]);
	int mmin=1e9;
	for(int i=1;i<=100000;i++){
		mmin=min(mmin,v[0][i]+min(la[1][i-1],ne[1][i+1]));
		mmin=min(mmin,v[1][i]+min(la[0][i-1],ne[0][i+1]));
	}
	printf("%d\n",mmin);
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector<int>
#define VII vector<PII>
#define VLL vector<PLL>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second

template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}

struct TT{
	string s;
}ff[111];
LL t,n,m,ans;

bool cmp(TT a,TT b){
	return a.s+b.s<b.s+a.s;
}

int main()
{
	LL i,j,k,l,res;
	cin>>n>>m;
	for(i=0;i<n;i++)cin>>ff[i].s;
	sort(ff,ff+n,cmp);
	for(i=0;i<n;i++)cout<<ff[i].s;
	puts("");
	return 0;
}

Measured memory_bytes: 764
mod = 1000000007
n, m = map(int, input().split())
b = [0] * (n + 1)
for _ in range(m):
    b[int(input())] = 1
dp = [1] + [0] * n
for i in range(1, n + 1):
    if b[i] == 1:
        dp[i] = 0
    elif i == 1:
        dp[i] = dp[i - 1]
    else:
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod
print(dp[n])

Measured memory_bytes: 7780
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

// aのp乗を求める関数
ll mpow(ll a, ll b){
	if(b==0){
		return 1;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1)*a%MOD;
	}
}


signed main(){
	ll a,b,m; cin>>a>>b>>m;
	VL A(a),B(b);
	rep(i,a) cin>>A[i]; rep(i,b) cin>>B[i];
	VL x(m),y(m),c(m); rep(i,m) cin>>x[i]>>y[i]>>c[i];
	ll ans = LINF;
	rep(i,m){
		chmin(ans,max(A[x[i]-1]+B[y[i]-1]-c[i],0LL));
	}
	sort(ALL(A)); sort(ALL(B));
	chmin(ans,A[0]+B[0]);
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4224
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define _for(i,a,b) for(int i = (a);i<(b);i++)
#define endl  '\n'
#define inf 0x3f3f3f3f
using namespace std;
const int mod=1e9+7;
const int MAX=1e6+7;
//ll a[MAX];
int main()
{
 	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 	ll x,n=100;
 	ll ans=0;
 	cin>>x;
 	while(1)
 	{
 		if(n>=x){
 			break;
		 }	
 		n*=1.01;
 		ans++;
	}
 	cout<<ans;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a < b){
        cout << "a < b" << endl;
    }
    else if(a > b){
        cout << "a > b" << endl;
    }
    else{
        cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
//AUTHOR ANUPAM PRAKASH MMMUT
#include<bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#define MOD 1000000007
#define ll long long int
#define ld long double
#define vll vector<long long>
#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define TEST ll t; cin>>t; while(t--)
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep3(i,a,b) for(ll i=a;i>b;i--)
#define rep4(i,a,b) for(ll i=a;i>=b;i--)
using namespace std;


// Driver code
int main()
{   //your code goes here
    FAST
   
	//rainy season - ATCODER
	
	string s;
	cin >> s;
	
	ll count=0;
	
	rep(i, 0, s.size())
	{
		if( s[i] == 'R')
		  count++;
	}        
	
	if( count == 0)
	  cout<<"0\n";
	else if ( count == 1)
	  cout<<"1\n";  
	else if( count == 3)
	  cout<<"3\n";  
	else 
	{
		if( s[0] == 'R' && s[1] == 'R')
		  cout<<"2\n";
		else if( s[1] == 'R' && s[2] == 'R')
		  cout<<"2\n";  
		else
		  cout<<"1\n";  
	}  
       
    return 0;

}

Measured memory_bytes: 3628
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


int main()
{
	set<int> s;

	rep(i, 3)
	{
		int a;
		cin >> a;
		s.insert(a);
	}

	if (s.size() == 2)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    v a(n+1), b(n);
    
    for(int i=0; i<n+1; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        cin >> b[i];
    }
    
    //前寄せ
    v na,nb;
    na = a;
    nb = b;
    
    ll count = 0;
    
    for(int i=0; i<n+1; i++){
        if(i){
            count += min(nb[i-1], na[i]);
            na[i] = max(na[i]-nb[i-1],0);
        }
        if(i!=n){
            count += min(nb[i], na[i]);
            nb[i] = max(nb[i]-na[i],0);
        }
    }
    
    ll ans = count;
    
    na = a;
    nb = b;
    reverse(na.begin(), na.end());
    reverse(nb.begin(), nb.end());
    count = 0;
    
    for(int i=0; i<n+1; i++){
        if(i){
            count += min(nb[i-1], na[i]);
            na[i] = max(na[i]-nb[i-1],0);
        }
        if(i!=n){
            count += min(nb[i], na[i]);
            nb[i] = max(nb[i]-na[i],0);
        }
    }
    
    ans = max(ans, count);
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1792
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip, std.regex;

void main() {
    int[] dr = [1, -1, 0, 0];
    int[] dc = [0, 0, 1, -1];

    auto s = readln.split.map!(to!int);
    auto H = s[0];
    auto W = s[1];
    auto A = H.iota.map!(_ => readln.chomp).array;

    foreach (i; 0..H) {
        foreach (j; 0..W) {
            if (A[i][j] != '#') continue;
            bool ok = false;
            foreach (k; 0..4) {
                int di = i + dr[k];
                int dj = j + dc[k];
                if (di < 0 || di >= H || dj < 0 || dj >= W) continue;
                if (A[di][dj] == '#') ok = true;
            }
            if (!ok) {
                writeln("No");
                return;
            }
        }
    }

    writeln("Yes");
}


Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
D = defaultdict(int)
A.sort(reverse=True)

for i in A:
  D[i] += 1

L = []

for i, x in D.items():
  if x >= 4:
    L.append(i)
    L.append(i)
    break
  elif x >= 2:
    L.append(i)

if len(L) <= 1:
  print(0)
else:
  print(L[0]*L[1])

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

using namespace std;

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

	vector<int> V;
	V.push_back(a);
	V.push_back(b);
	V.push_back(c);

	sort(V.begin(), V.end());

	cout << V[0] <<" "<< V[1] <<" "<< V[2] << endl;

	return 0;
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+5;
int n,m,k,x[N],y[N],vis[N];
vector<int>v[N];
priority_queue<int>q,d;
void add(int i)
{
    d.push(vis[y[i]]);
    vis[y[i]]++;
    q.push(vis[y[i]]);
}
void del(int i)
{
    d.push(vis[y[i]]);
    vis[y[i]]--;
    q.push(vis[y[i]]);
}
int get()
{
    while(d.size()&&q.top()==d.top()) q.pop(),d.pop();
    return q.top();
}
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<=m;i++) q.push(0);
    for(int i=1;i<=k;i++)
    {
        scanf("%d%d",&x[i],&y[i]);
        v[x[i]].push_back(i);
        add(i);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int x:v[i]) del(x);
        ans=max(ans,int(v[i].size())+get());
        for(int x:v[i]) add(x);
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 36292
n = int(input())
inf = float("inf")

dp = [[inf]*(3) for i in range(n)]
dp[0] = list(map(int, input().split()))

for i in range(n-1):
  a, b, c = map(int, input().split())

  dp[i+1][0] = max(dp[i][1] + a, dp[i][2] + a)
  dp[i+1][1] = max(dp[i][2] + b, dp[i][0] + b)
  dp[i+1][2] = max(dp[i][0] + c, dp[i][1] + c)  


print(max(dp[n-1]))

Measured memory_bytes: 71148
from collections import deque
import sys


deq = deque()

q = int(input())

for _ in range(q):
    s = input()
    if s == 'deleteFirst':
        deq.popleft()
    elif s == 'deleteLast':
        deq.pop()
    else:
        ss, num = s.split()
        if ss == 'insert':
            deq.appendleft(num)
        else:
            try:
                deq.remove(num)
            except:
                pass

print(" ".join(deq))




Measured memory_bytes: 69732
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,m,mod=1000000007;
	long long int sum=0;
	cin>>n>>m;
	long long int min,max;
	if(m==n+1)
	cout<<1<<endl;
	else
	{
		for(long long int i=m;i<=n;i++)
		{
			min=(i*(i-1))/2;
			max=((n*(n+1))/2)-(((n-i+1)*(n-i))/2);
			sum=(sum%mod+((max%mod-min%mod)+mod)%mod+1)%mod;
		}
		sum++;
		cout<<sum%mod<<endl;
	}
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <algorithm>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>
#include <ctime>

using namespace std;

#define ll long long
#define sc(n) static_cast<ll>(n)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {
	IO;
#ifdef _DEBUG
	ifstream cin("In.txt");
#endif	
	string st;
	cin >> st;
	sort(st.begin(), st.end());
	for (int i = 1; i < st.size(); i++) {
		if (st[i] != st[i - 1]) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

int main()
{
	vector<int> a(5+1);

	for (int i=1;i<=5;++i)
	{
		cin >> a[i];
	}

	for (int i=1;i<=5;++i)
	{
		if (a[i]==0)
		{
			cout << i << endl;
		}
	}
}







Measured memory_bytes: 3564
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    ll x;
    scanf("%lld", &x);

    ll tmp = x / 11 * 2;
    if(x % 11>0) {
        tmp += (x % 11 > 6? 2: 1);
    }
    printf("%lld\n", tmp);

    return 0;
}


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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

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

bool isPrime(int a) {
  if(a == 2) return true;
  if(a < 2 || !(a % 2)) return false;

  double sq = sqrt(a);
  for(int i = 3; i <= sq; i += 2) {
    if(a % i == 0) return false;
  }
  return true;
}


int main() {
  int e, y;
  cin >> e >> y;
  if(!e) {
    y -= 1867;
    if(y <= 44) cout << "M" << y << endl;
    else if(y <= 58) cout << "T" << y - 44 << endl;
    else if(y <= 121) cout << "S" << y - 58 << endl;
    else cout << "H" << y - 121 << endl;
  }
  else if(e == 1) cout << 1867 + y << endl;
  else if(e == 2) cout << 1911 + y << endl;
  else if(e == 3) cout << 1925 + y << endl;
  else cout << 1988 + y << endl;
}

Measured memory_bytes: 3224
N = int(input())
S = ""
if N == 0:
  S = "0"
c = 1
while N != 0:
  if N%(2**c) != 0:
    N -= (-2)**(c-1)
    S = "1" + S
  else:
    S = "0" + S
  c += 1  
print(S)     

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

int main() {
	int n;
	cin >> n;
	int a[n], dp[n];
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	dp[0] = 0;
	dp[1] = dp[0] + abs(a[1] - a[0]);
	for (int i = 2; i < n; i++)
		dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
	cout << dp[n - 1];
	return 0;
}

Measured memory_bytes: 4408
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int H = sc.nextInt();
		int W = sc.nextInt();

		int blocks = H*W;
		int blacks = 0;
		char[][] c = new char[H][W];
		boolean[][] visited = new boolean[H][W];
		for(int i=0; i<H; i++) {
			c[i] = sc.next().toCharArray();
			for(int j=0; j<W; j++) {
				visited[i][j] = false;
				if(c[i][j] == '#')
					blacks++;
			}
		}

		//座標
		class Point{
			int x;
			int y;

			public Point(int x, int y) {
				this.x = x;
				this.y = y;
			}

			@Override
			public boolean equals(Object obj) {
				if(obj instanceof Point) {
					Point p = (Point)obj;

					if(this.x == p.x && this.y == p.y)
						return true;
					else
						return false;
				}

				return false;
			}

			@Override
			public int hashCode() {
				return Objects.hash(x, y);
			}

		}

		int min_distance = -1;
		int[][] distance = new int[H][W];

		List<Point> direction = new ArrayList<>();
		Point down = new Point(-1, 0);
		Point left = new Point(0, -1);
		Point up = new Point(1, 0);
		Point right = new Point(0, 1);

		Queue<Point> queue = new ArrayDeque<>();
		queue.add(new Point(0, 0));
		while(!queue.isEmpty()) {
			Point p = queue.poll();
			int h = p.x;
			int w = p.y;

			if(h == H-1 && w == W-1) {
				min_distance = distance[h][w];
				break;
			}

			//訪問済み
			visited[h][w] = true;

			direction.clear();
			if(h-1 >= 0)
				direction.add(down);
			if(w-1 >= 0)
				direction.add(left);
			if(h+1 < H)
				direction.add(up);
			if(w+1 < W)
				direction.add(right);

			for(Point dir : direction) {
				int n_h = h + dir.x;
				int n_w = w + dir.y;

				Point n_p = new Point(n_h, n_w);
				if(!queue.contains(n_p) && !visited[n_h][n_w] && c[n_h][n_w] != '#') {
					queue.add(n_p);
					distance[n_h][n_w] = distance[h][w] + 1;
				}
			}
		}

		if(min_distance == -1)
			System.out.println(-1);
		else {
			int ans = blocks - (min_distance+1) - blacks;
			System.out.println(ans);
		}

	}
}


Measured memory_bytes: 23764
N = int(input())

A = list(map(int, input().split()))

C = [0] * 9

for i in range(N):
    if 1 <= A[i] <= 399:
        C[0] = 1
    elif 400 <= A[i] <= 799:
        C[1] = 1
    elif 800 <= A[i] <= 1199:
        C[2] = 1
    elif 1200 <= A[i] <= 1599:
        C[3] = 1
    elif 1600 <= A[i] <= 1999:
        C[4] = 1
    elif 2000 <= A[i] <= 2399:
        C[5] = 1
    elif 2400 <= A[i] <= 2799:
        C[6] = 1
    elif 2800 <= A[i] <= 3199:
        C[7] = 1
    else:
        C[8] += 1

num = sum(C[0:8])

ans1 = str(max(num, 1))
ans2 = str( num + C[8])
print(ans1 + " " + ans2)


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

int set(string str,string a,int loc){
	return str.find(a,loc);
}

string rep(string str,string tar,string rp){
	int loc=0;
	while((loc=set(str,tar,loc))!=string::npos) str.replace(loc,tar.length(),rp);
	return str;
}

int main(){
	string str,a="apple",p="peach",tmp=".....";
	unsigned int loc=0;
	getline(cin,str);
	str = rep(str,a,tmp);
	str = rep(str,p,a);
	str = rep(str,tmp,p);
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 1192
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container, std.typecons;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

void main() {
	int n;
	scanf("%d", &n);
	int[] X = new int[n];
	int[] Y = new int[n];
	long INF = 1L<<40;
	int parity = 0;
	foreach (i; 0..n) {
		scanf("%d%d", &X[i], &Y[i]);
		int p = (X[i]+Y[i]+INF+1)%2;
		if (i == 0) parity = p;
		else if (parity != p) {
			writeln(-1);
			return;
		}
	}
	int m = 32;
	writeln(m+parity);
	foreach_reverse (i; 0..m) {
		writeln(1L<<i);
	}
	if (parity) {
		writeln(1);
	}
	foreach (_i; 0..n) {
		long x = X[_i], y = Y[_i];
		if (parity) x++;
		string ans;
		foreach_reverse (i; 0..m) {
			long l = 1L<<i;
			if (abs(x) < abs(y)) {
				if (y < 0) {
					ans ~= 'D';
					y += l;
				} else {
					ans ~= 'U';
					y -= l;
				}
			} else {
				if (x < 0) {
					ans ~= 'L';
					x += l;
				} else {
					ans ~= 'R';
					x -= l;
				}
			}
		}
		if (parity) ans ~= 'L';
		writeln(ans);
	}
}

Measured memory_bytes: 380
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <queue>
using namespace std;
char a[100];
char b[100];
char c[100]= {0};
char d[100]= {0};
int main()
{
    while(~scanf("%s %s",a,b))
    {
        int i;
        for(i=0; i<3; i++)
        {
            c[i]=a[2-i];
            d[i]=b[2-i];
        }
        if(strcmp(c,b)==0&&strcmp(d,a)==0)
        {
            printf("YES\n");
        }
        else
            printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 256
def solve(n, A):

    def gcd(a, b):
        if a > b:
            a, b = b, a
        while a % b != 0:
            a, b = b, a % b
        return b

    l = A.pop()
    for a in A:
        l = gcd(l, a)
    return l

_n = int(input())
_A = list(map(int, input().split()))
print(solve(_n, _A))


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int dp[100005][3];

int main() {
    int n; cin >> n;
    REP(i,n+1) {
        vint data(3);
        rep(i,3) cin >> data[i];
        rep(j,3)rep(k,3) {
            if (j == k) continue;
            chmax(dp[i][j],dp[i-1][k]+data[k]);
        }
    }
    int ans = 0;
    rep(i,3) ans = max(ans,dp[n][i]);
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define int long long
#define mp make_pair
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("C:/Users/Aman/Desktop/kachda/input.txt", "r", stdin); freopen("C:/Users/Aman/Desktop/kachda/output.txt", "w", stdout);

using namespace std;
char c[1001][1001];
int h, w, dp[1001][1001] = {{1}};
signed main()
{
	//FILEIO
 	start_routine
 	cin>>h>>w;
	fr(i,1,h + 1)
	{
		fr(j,1,w + 1) cin>>c[i][j];
	}

	fr(i,1,h + 1)
	{
		fr(j,1,w + 1)
		{
			if(i == 1 && j == 1)
			{
				dp[i][j] = 1;
				continue;
			}
			if(c[i][j] == '#') {dp[i][j] = 0; continue;}
			dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]);
			dp[i][j] %= mod;
		}
	}

	cout<<dp[h][w];
 	end_routine
}

Measured memory_bytes: 9088
i = input()

a, b, c = map(int, i.split())

if a > b:
    num = a
    a = b
    b = num

if b > c:
    num = b
    b = c
    c = num

if a > b:
    num = a
    a = b
    b = num


print(a, b, c)




Measured memory_bytes: 5596
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n, m;

	cin>>n>>m;

	vi like(m, 0);

	rep(i, n){
		int k;
		cin>>k;
		rep(j, k){
			int a;
			cin>>a;
			like[a-1]++;
		}
	}

	int ans=0;
	rep(i, m){
		if(like[i]==n) ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
k1=(t-a)/0.006
ans=1
k2=abs(k1-h[0])
for i in range(n):
    if k2>abs(k1-h[i]):
        k2=abs(k1-h[i])
        ans=i+1
print(ans)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    int D; cin >> D;
    vector<int> C(26 + 1);
    for (int i = 1; i <= 26; i++) scanf("%d", &C[i]);
    vector<vector<int>> S(D + 1, vector<int>(26 + 1));
    for (int i = 1; i <= D; i++) {
        for (int j = 1; j <= 26; j++) scanf("%d", &S[i][j]);
    }

    ll sum = 0;
    vector<int> last(26 + 1);
    for (int d = 1; d <= D; d++) {
        int t; cin >> t;
        sum += S[d][t];
        last[t] = d;
        for (int i = 1; i <= 26; i++) {
            sum -= C[i] * (d - last[i]);
        }
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 3736