akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

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

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

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(n: i32);
    let ranges = [(1, 10), (100, 1000), (10000, 100000)];
    let mut ans = 0;
    for &(x, y) in &ranges {
        let hi = min(n + 1, y);
        if hi >= x {
            ans += hi - x;
        }
    }
    puts!("{}\n", ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define L(i,u) for (int i=head[u]; i!=0; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
typedef long long ll;
using namespace std;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 555;
int a[555];
int main() {
	rep(i,1,3)read(a[i]); sort(a+1,a+3+1);
	if ((a[3]*3-a[1]-a[2]-a[3])%2) {printf("%d",(3*(a[3]+1)-a[1]-a[2]-a[3])/2);}
	else printf("%d",(3*(a[3])-a[1]-a[2]-a[3])/2);
	return 0;
}


Measured memory_bytes: 764
#include<stdio.h>
int main(){
int a,b,c,d,sum,m,s;
scanf("%d\n%d\n%d\n%d\n",&a,&b,&c,&d);
sum = a+b+c+d;
m = sum/60;
s = sum%60;
printf("%d\n%d\n",m,s);
return 0;
}

Measured memory_bytes: 600
import java.util.Arrays;
import java.util.Scanner;

class Main{

	static char[][] map;
	static int H;
	static int W;
	static	int D ;
	static	int G ;
	static	int[] p;
	static	int[] c;
	static int ans = 100000000;

	public static void main(String[] args) {



		Scanner sc = new Scanner(System.in);			//文字の入力
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int[] data = {A,B,C};
		Arrays.sort(data);
		int ans = 10*data[2]+data[1]+data[0];
		System.out.println(ans);


		

	}



}





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

ans = 0
C = [ [0 for i in range(10)] for i in range(10)]

for i in range(1,N+1):
  first_num = int(str(i)[0])
  last_num = int(str(i)[-1])
  C[first_num][last_num] += 1

for first_num in range(1,10):
  for last_num in range(1,10):
    ans += C[first_num][last_num] * C[last_num][first_num]

print(ans)


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

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

int main() {
    int a,b,h,m;
    cin >> a >> b >> h >> m;

    double hh = (60.0 * h + m) / 720 * 360;
    double mm = 6 * m;


    cerr << fixed;
/*
    cerr << "h +++ " << hh << endl;
    cerr << "m --- " << mm << endl;
*/
    double c = (max(mm, hh) - min(mm, hh));
    c = min(c, 360 - c);
//     cerr << "c === " << c << endl;

    double myPI = 4 * atan(1.0);
    double ans = a*a + b*b - 2*a*b * cos(2 * myPI * c / 360);

//    cerr << 2 * myPI * c / 360 << endl;
//    cerr << ans << endl;
    ans = sqrt(ans);
//    cerr << ans << endl;

    cout << fixed << setprecision(20);
    cout << ans << endl;

    return 0;    
}


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

int main()
{
  int n;
  cin>>n;
  long long int arr[n][3];
  long long int dp[n][3];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
  }
  int i=0;
  dp[i][0]=arr[i][0];
  dp[i][1]=arr[i][1];
  dp[i][2]=arr[i][2];
  for(int i=1;i<n;i++)
  {
    for(int j=0;j<3;j++)
    dp[i][j]=arr[i][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
  }
  long long int ans=INT_MIN;
  for(int j=0;j<3;j++)
  {
    ans=max(ans,dp[n-1][j]);
  }
  cout<<ans<<"\n";
  return 0;
}

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

#define MAXSIZE 50

struct Node { int parent, left, right; };

Node T[MAXSIZE];
int n, Depth[MAXSIZE], Height[MAXSIZE];

void setDepth(int u, int depth) {
    if (u == -1) return;
    Depth[u] = depth;
    setDepth(T[u].right, depth + 1);
    setDepth(T[u].left, depth + 1);
    return;
}

int setHeight(int u) {
    int h1 = 0, h2 = 0;
    if (T[u].left != -1) h1 = setHeight(T[u].left) + 1;
    if (T[u].right != -1) h2 = setHeight(T[u].right) + 1;
    return Height[u] = max(h1, h2);
}

int getSibling(int u) {
    int parent = T[u].parent;
    if (parent == -1) return -1;
    if (T[parent].left != -1 && T[parent].left != u) return T[parent].left;
    if (T[parent].right != -1 && T[parent].right != u) return T[parent].right;
    return -1;
}

void print() {
    for (int i = 0; i < n; i++) {
        int u = i;
        cout << "node " << u << ": parent = " << T[u].parent;
        cout << ", sibling = " << getSibling(u);

        int degree = 0;
        if (T[u].left != -1) degree++;
        if (T[u].right != -1) degree++;

        cout << ", degree = " << degree;
        cout << ", depth = " << Depth[u];
        cout << ", height = " << Height[u];
        cout << ", ";

        string type;
        if (T[u].parent == -1) type = "root";
        else if (T[u].left == -1 && T[u].right == -1) type = "leaf";
        else type = "internal node";
        cout << type << endl;
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        T[i].parent = T[i].left = T[i].right = -1;
    }

    int id, left, right;
    for (int i = 0; i < n; i++) {
        cin >> id >> left >> right;
        T[id].left = left;
        T[id].right = right;
        if (left != -1) T[left].parent = id;
        if (right != -1) T[right].parent = id;
    }

    int root;
    for (int i = 0; i < n; i++) {
        if (T[i].parent == -1) root = i;
    }

    setDepth(root, 0);
    setHeight(root);

    print();
    return 0;
}


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

ll N,K,h[100000],m=100000000000;;

int main(void)
{
    cin >> N >> K;
    rep(i,N)cin >> h[i];

    sort(h,h+N);
    rep(i,N-K+1)
    {
        m = min(m,h[i+K-1]-h[i]);
    }
    cout << m << endl;

}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
typedef long long ll;
typedef unsigned un;
//typedef std::string str;
typedef std::pair<ll,ll> pll;
typedef std::pair<int,int> pii;
typedef std::pair<double,double> pd;
ll read(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return f*x;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
void umax(ll& a,ll t){if(t>a)a=t;}
bool umin(ll& a,ll t){if(t<a)return a=t,1;return 0;}
#define MAXN 1000011
const ll mod=998244353;
ll Qpow(ll a,ll p)
{
    ll res=1;
    while(p)
    {
        if(p&1)res=res*a%mod;
        a=a*a%mod,p>>=1;
    }
    return res;
}
ll a[MAXN],c[MAXN],f[MAXN];
int mu[MAXN],pri[MAXN];
bool vis[MAXN];
void sieve()
{
    int cnt=0;
    mu[1]=1;
    for(int i=2;i<MAXN;++i)
    {
        if(!vis[i])pri[++cnt]=i,mu[i]=-1;
        for(int j=1;j<=cnt&&i*pri[j]<MAXN;++j)
        {
            vis[i*pri[j]]=1;
            if(i%pri[j]==0)break;
            mu[i*pri[j]]=-mu[i];
        }
    }
}
int main()
{
    sieve();
    ll n=read(),x,ans=0;
    for(int i=1;i<=n;++i)x=read(),c[x]+=x,ans-=x;
    for(int i=1;i<MAXN;++i)
        for(int j=i;j<MAXN;j+=i)f[i]+=c[j];
    for(int i=1;i<MAXN;++i)f[i]%=mod,f[i]=f[i]*f[i]%mod;
    for(int x=1;x<MAXN;++x)
    {
        ll inv=Qpow(x,mod-2);
        for(int y=1;y*x<MAXN;++y)
        {
            ans=(ans+mu[y]*f[x*y]%mod*inv)%mod;
        }
    }
    printf("%lld\n",ans*Qpow(2,mod-2)%mod);
    return 0;
}

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

int keisan(int r,int d,int x){
    int y;
    y=r*x-d;
    return y;
}
int main(void){
    int r,d,x;
    cin>>r>>d>>x;
    int y[10];
  	y[0]=keisan(r,d,x);
  	for(int i=0;i<10;i++)y[i+1]=keisan(r,d,y[i]);
    for(int t=0;t<10;t++)cout<<y[t]<<endl; 
    return 0;
}

Measured memory_bytes: 256
using System;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            var N = NK[0]; var K = NK[1];
            long MOD = 1000000007;

            long result = 0;
            for (long i = K; i <= N + 1; i++)
            {
                var min = i * (i - 1) / 2;
                var max = i * (2 * N - i + 1) / 2;
                result += max - min + 1;
                result %= MOD;
            }
            Console.WriteLine(result);
        }
    }
}


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

int main(){
	
	int n,i; cin >> n;
	string s; cin >> s;
	bool b=1;
	
	if (n%2 == 1) b = 0;
	else{
		for (i=0 ; i<n/2 ; i++)
			if (s[i] != s[i+n/2]){
				b = 0; break;
			}
	}
	
	if (b) cout << "Yes\n";
	else cout << "No\n";
	
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
signed main(void){
    string s; cin>>s;
    int n = s.size();
    deque<char> deq;
    rep(i,n) deq.push_back(s[i]);
    
    int ans = 0;
    while(deq.size()>1){
        char x = deq.front(),y = deq.back();
        if(x == y) deq.pop_front(), deq.pop_back();
        else if(x=='x') deq.push_back('x'), ans++;
        else if(y=='x') deq.push_front('x'), ans++;
        else {cout<<-1<<endl; return 0;}
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 512
# N = gets.chomp.to_i
# A, B, C = gets.chomp.split.map(&:to_i)
S = gets.chomp.chars

ans = 0
cnt = 0
0.upto(S.size-1).each do |i|
  if ['A', 'C', 'G', 'T'].include?(S[i])
    cnt += 1
  else
    ans = [ans, cnt].max
    cnt = 0
  end
end
ans = [ans, cnt].max

p ans

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

int main(){
	ll ans=0,a;
	ll maxl=0;
	for(int i=0;i<5;i++){
		cin >> a;
		maxl = max(maxl,(10-a%10)%10);
		ans += a+(10-a%10)%10;
	}
	cout << ans-maxl << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }

    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }

    #[allow(dead_code)]
    pub fn get3<S: FromStr, T: FromStr, U: FromStr>() -> (S, T, U)
    where
        <S as FromStr>::Err: Debug,
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}

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

fn main() {
    let (n, m): (usize, usize) = util::get2();

    if max(n, m) - min(n, m) <= 1 {
        println!("Brown");
    } else {
        println!("Alice");
    }
}


Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readlines

import math

def main():

    lines = input()
    a, b, c, d = list(map(int, lines[0].split()))

    def gcd(a, b):

        r = a % b

        if r == 0:
            return int(b)
        
        return gcd(b, r)

    g = gcd(c, d)
    gcm = int(c * d / g)

    c_in = int(b // c - (a-1)//c)
    d_in = int(b // d - (a-1)//d)
    cd_in = int(b // gcm - (a-1)//gcm)

    ans = int((b-a+1) - (c_in + d_in - cd_in))
    print(ans)

main()




Measured memory_bytes: 9212
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

#ifdef __GNUC__
#define popcount __builtin_popcount
#elif _MSC_VER >= 1400
#include <intrin.h>
#define popcount __popcnt
#else
static inline int popcount(unsigned int b) {
	b = (b & 0x55555555) + (b >> 1 & 0x55555555);
	b = (b & 0x33333333) + (b >> 2 & 0x33333333);
	b = (b & 0x0F0F0F0F) + (b >> 4 & 0x0F0F0F0F);
	b += b >> 8;
	return (b + (b >> 16)) & 0x3F;
}
#endif

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		int h = -1, w, k;
		cin >> h >> w >> k;
		if (h < 0) return 0;
		vector<string> s(h);
		int bd[10][1000];
		for (int i = 0; i < h; ++i) {
			cin >> s[i];
			for (int j = 0; j < w; ++j) {
				bd[i][j] = s[i][j] != '0';
			}
		}
		int ans = 1 << 30;
		int bm = 1 << (h - 1);
		for (int b = 0; b < bm; ++b) {
			vector<int> cnt(10);
			int ai[10] = {};
			int gi = 0;
			for (int i = 0; i < h - 1; ++i) {
				if (b & (1 << i)) {
					++gi;
				}
				ai[i + 1] = gi;
			}
			int div = popcount(b);
			int ac = 0;
			for (int i = 0; i < w; ++i) {
				bool ok = true;
				for (int j = 0; j < h; ++j) {
					cnt[ai[j]] += bd[j][i];
				}
				for (int j = 0; j <= gi; ++j) {
					if (cnt[j] > k) {
						ok = false;
					}
				}
				if (!ac && !ok) {
					goto next;
				}
				if (!ok) {
					++div;
					--i;
					ac = 0;
					cnt = vector<int>(10);
					continue;
				}
				++ac;
			}
			ans = min(ans, div);

		next: {}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        try {
            line = br.readLine();
            int n = Integer.parseInt(line.trim());
            for(int i=0; i<n; i++){
                line = br.readLine();
                String[] numbers = line.trim().split(" ");
                int[] sides = {Integer.parseInt(numbers[0]), Integer.parseInt(numbers[1]), Integer.parseInt(numbers[2])};
                int maxSide = sides[0]>sides[1] && sides[0]>sides[2]? 0: sides[1]>sides[2]? 1: 2;
                int sum = 0;
                for(int j=0; j<3; j++){
                    if(j != maxSide){
                        sum += sides[j] * sides[j];
                    }
                }
                System.out.println(sides[maxSide] * sides[maxSide] == sum ? "YES": "NO");
            }
        } catch (IOException e) {
        }
    }
}

Measured memory_bytes: 20196
using System;
public class Simple {
    public static void Main() { new Simple().Solve(); }
    char[] s;
    int K;
    void Solve() {
        //input
        s = Console.ReadLine().ToCharArray();
        K = int.Parse(Console.ReadLine());

        for(int i = 0; i < s.Length; ++i) {
            if (s[i] != 'a' && ('z' - s[i] + 1) <= K) {
                K -= 'z' - s[i] + 1;
                s[i] = 'a';
            }
        }
        int last = s[s.Length - 1] + K % 26;
        if (last > 'z') last -= 26;
        s[s.Length - 1] = (char)last;
        //res
        Console.WriteLine(s);
    }
}

Measured memory_bytes: 13224
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vs = vector<string>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vll A(n), B(n);
    forn(i, n) cin >> A[i] >> B[i];
    ll cost = 0;
    for (int i=n-1; i>=0; i--) {
        cost += (B[i]-(A[i]+cost)%B[i])%B[i];
    }
    cout << cost << '\n';
}


Measured memory_bytes: 1792
#include<stdio.h>
int main (void)
{
    int i;
    int N,K;
    int X,Y;
    int sum = 0;
    scanf("%d",&N);
    scanf("%d",&K);
    scanf("%d",&X);
    scanf("%d",&Y);
if(N<K){
for(i=0;i<N;i++)
sum+= X;
}else{
for(i=0;i<K;i++)
sum+=X;
for(i=0;i<N-K;i++)
sum+=Y;
}

printf("%d\n",sum);
return 0;
}

Measured memory_bytes: 128
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Sat Jun  2 14:36:05 2018
//
package main

import "fmt"

var N, A, B int
var S string

func main() {
	fmt.Scan(&N, &A, &B)
	fmt.Scan(&S)

	b := 1
	count := 0
	for _, s := range S {
		switch s {
		case 'a':
			if count < A+B {
				fmt.Println("Yes")
				count++
			} else {
				fmt.Println("No")
			}
		case 'b':
			if count < A+B && b <= B {
				fmt.Println("Yes")
				count++
				b++
			} else {
				fmt.Println("No")
			}
		case 'c':
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 3200
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = LIST()

cnt = [0]*10**5

for n in a:
	cnt[n] += 1

ans = 0
for i in range(2, 10**5):
	ans = max(ans, cnt[i-2]+cnt[i-1]+cnt[i])

print(ans)


Measured memory_bytes: 15364
#include <bits/stdc++.h>
using namespace std;
int a,b,n;
map<int,bool>m;
int main()
{
    a=0;
    cin>>n;
    while(n--)
    {
        cin>>b;
        if(m[b]==true)a=1;
        m[b]=true;
    }
    if(a==1)cout<<"NO\n";else cout<<"YES\n";
    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int happy[N][3];
    int sum[N][3];
    for(int i=0; i<N; i++){
        for(int j=0; j<3; j++){
            cin >> happy[i][j];
        }
    }
    for(int i=0; i<3; i++){
        sum[0][i] = happy[0][i];
    }
    for(int i=1; i<N; i++){
        sum[i][0] = max(sum[i-1][1],sum[i-1][2])+happy[i][0];
        sum[i][1] = max(sum[i-1][0],sum[i-1][2])+happy[i][1];
        sum[i][2] = max(sum[i-1][0],sum[i-1][1])+happy[i][2];
    }
    cout << max(max(sum[N-1][0],sum[N-1][1]),sum[N-1][2]);
    return 0;
}

Measured memory_bytes: 2560
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

int N,M;

int main()
{
	ll ans;
	cin>>N>>M;
	if(N==1){
		if(M==1){
			ans=1;
		}
		else{
			ans=M-2;
		}
	}
	else if(M==1){
		ans=N-2;
	}
	else{
		ans=((ll)(N-2))*((ll)(M-2));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <vector>
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-9;
const double PI = acos(-1);
const int MOD = 998244353;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 100005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
struct Apple {
    int c, w;
    bool operator<(const Apple& a) const { return w > a.w; }
};
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<Apple> A, B, C;
    int t;
    for (int i = 1; i <= a; i++) {
        cin >> t;
        A.push_back({0, t});
    }
    for (int i = 1; i <= b; i++) {
        cin >> t;
        B.push_back({1, t});
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    for (int i = 1; i <= c; i++) {
        cin >> t;
        C.push_back({3, t});
    }
    for (int i = 0; i < x; i++) C.push_back(A[i]);
    for (int i = 0; i < y; i++) C.push_back(B[i]);
    sort(C.begin(), C.end());
    ll ans = 0;
    for (int i = 0; i < x + y; i++) ans += C[i].w;
    cout << ans;
    return 0;
}

Measured memory_bytes: 7920
N,Y = map(int,input().split())
def check_otoshidama(N,Y):
    for i in range(N+1):
        for q in range(N+1):
            if i + q > N:
                break
            c_1,c_2,c_3 = i,q,N-(i+q)
            
            money_sum = c_1 * 10000 + c_2 * 5000 + c_3 * 1000
            if money_sum == Y:
                return [c_1,c_2,c_3]
            elif money_sum > Y:
                break
    return [-1,-1,-1]
     
res = check_otoshidama(N,Y)
print("{} {} {}".format(res[0],res[1],res[2]))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>
 
#define DBG cout << '!' << endl;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;
 
int main()
{
	ll q,h,s,d;
	ll n;
	ll ans = 0;
	cin >> q >> h >> s >> d >> n;
	
	h = min(h,q*2);
	s = min(s,h*2);
	d = min(d,s*2);
	
	ans += n / 2 * d;
	n = n % 2;
	if(n) ans += s;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
s = list(input())
flag = True
# ord(文字) == 文字を表す整数(ASCIIコード)
# chr(整数) == 整数に対応する文字
for i in range(ord('a'), ord('z') + 1):
    if s.count(chr(i)) == 0:
        flag = False
        ans = chr(i)
        break
print('None' if flag else ans)

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
long long getSum(long long n)
{ 
   long long sum = 0;
   while (n != 0)
   {
       sum = sum + n % 10;
       n = n/10;
   }
   return sum;
}
int main()
{
    long long n;
cin>>n;
    long long cnt = getSum(n);;
   
if(n%cnt==0) cout<<"Yes";
else cout<<"No";

return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		long a = long.Parse(input[0]);
		long b = long.Parse(input[1]);
    long c = long.Parse(input[2]);

    if(a == b && a == c) Console.WriteLine("Yes");
    else Console.WriteLine("No");
	}
}

Measured memory_bytes: 11092
#include <iostream>
using namespace std;
 
int rise(int *num){
  if(*num % 10){
    return (*num / 10 + 1) * 10;
  }else{
    return *num;
  }
}

int main(){
  int a[5],b[5],times = 0;
  for(int i = 0;i < 5;i++)cin >> a[i];
  for(int i = 0;i < 5;i++){
    times += rise(&a[i]);
    b[i] = (a[i] % 10) ? (a[i] % 10) : 10;
  }
  for(int i = 0;i < 5;i++){
    for(int j = i + 1;j < 5;j++){
      if(b[i] < b[j]){
        b[i] ^= b[j];
        b[j] ^= b[i];
        b[i] ^= b[j];
      }
    }
  }
  cout << times + b[4] - 10 << endl;
  return 0;
}

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

int main(){
    int n,a,b;  cin>>n>>a>>b;
    int ans=0;

    for(int i=1;i<=n;i++){
        int x=i;
        int sum=0;
        while(x){
            sum+=x%10;
            x/=10;
        }
        if(a<=sum && sum<=b)ans+=i;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int c=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='7'){
      cout<<"Yes"<<"\n";
      c=1;
      break;
    }
  }
  if(!c){
    cout<<"No"<<"\n";
  }
  return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

int main(){
  int N,W;
  cin >> N >> W;
  //vectorにpair入れる場合は注意
  vector<pair <int,int> > vw(N,make_pair(0,0));
  vector<int> dp(W+1,0);//価値0~Wまでのdpのvector
  vector<int> dp_sub(W+1,0);//勝手に更新しちゃまずいので仮の配列も用意する
  for(int i=0;i<N;i++){cin >> vw[i].first >> vw[i].second;}
  //v調べてdpを評価
  for(int i=0;i<N;i++){
    for(int j=0;j<W+1;j++){
      if((j==0 or dp[j]!=0) and j+vw[i].second<W+1){
        dp_sub[j+vw[i].second]=max(dp_sub[j+vw[i].second],dp[j]+vw[i].first);
      }
    }
    for(int j=0;j<W+1;j++){
      dp[j]=max(dp_sub[j],dp[j]);
      dp_sub[j]=0;
    }
  }
  //no matching function for call to 'max'は引数の型などのミス
  //functionの使い方の単純なミス
  //for(int i=0;i<W+1;i++){cout << dp_sub[i] << endl;}
  //for(int i=0;i<W+1;i++){cout << dp[i] << endl;}
  cout << *(max_element(dp.begin(),dp.end())) << endl;
}



Measured memory_bytes: 3188
let () =
  let n, a, b = Scanf.scanf "%d %d %d\n" (fun n a b -> n, a, b) in
  let xs = Array.init n (fun _ -> Scanf.scanf "%d " (fun x -> x)) in
  Array.init (n - 1) (fun i -> min b (a * (xs.(i + 1) - xs.(i))))
  |> Array.fold_left ( + ) 0
  |> Printf.printf "%d\n"

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define ull unsigned ll
#define pb push_back
#define popb pop_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define piiii pair <pii,pii>
#define pll pair <ll,ll>
#define plll pair <pair <ll, ll>, ll>
#define rep0(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<=(ll)n;i++)
#define rep(i,x,y) for(ll i=(ll)x;i<=(ll)y;i++)
#define reprev(i,n) for(ll i=(ll)n;i>=0;i--)
#define all(c) c.begin(),c.end()
#define print(a) rep0(i,a.size()) cout << a[i] << " "
#define hi() cout << "\nHello, I am error. Can you find me? :):):)\n"
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_eppoch().count())
 
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;

// FOR DEBUGGING
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", ";
	else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

const int mod = 1e9+7;
const long double pi = acos(-1);
const ll INF = 1e15;

ll power(ll x, ll y){
	x %= mod;
	ll ans = 1;
	while(y){
		if(y&1) ans = (ans*x)%mod;
		y /= 2;
		x = (x*x)%mod;
	}
	return ans;
}


void solve(){

	ll n,m,k;
	cin >> n >> m >> k;
	vector <ll> a(n), b(m);
	rep0(i,n){
		cin >> a[i];
		if(i) a[i] += a[i-1];
	}
	rep0(i,m){
		cin >> b[i];
		if(i) b[i] += b[i-1];
	}

	ll ans = 0, j = m-1;
	rep0(i,m){
		if(b[i]<=k) ans = max(ans,i+1);
	}
	rep0(i,n){
		if(a[i]>k) break;
		while(j>-1 && a[i]+b[j]>k) j--;
		ans = max(ans,i+j+2);
	}
	cout << ans;

	return;
}

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		// cout << "Case #" << t << ": ";
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

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

int main() {
  int N = 0, A = 0;
  cin >> N >> A;
  
  int yesno = N%500;
  yesno = A - yesno;
  if (yesno >= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>

using namespace std;

int n,m,q,from,to;
int rank[100000],parent[100000];

int find(int x){
	if(x == parent[x])return x;
	else{
		return parent[x] = find(parent[x]);
	}
}

bool isSame(int x,int y){
	return find(x) == find(y);
}

void unite(int x,int y){
	x = find(x);
	y = find(y);

	if(x == y)return;

	if(rank[x] < rank[y]){
		parent[x] = y;
	}else{
		parent[y] = x;
		if(rank[x] == rank[y])rank[x]++;
	}
}

int main(){

	scanf("%d %d",&n,&m);

	for(int i = 0; i < n; i++){
		rank[i] = 0;
		parent[i] = i;
	}

	for(int i = 0; i < m; i++){
		scanf("%d %d",&from,&to);

		if(isSame(from,to))continue;
		unite(from,to);
	}

	scanf("%d",&q);

	int left,right;

	for(int i = 0; i < q; i++){
		scanf("%d %d",&left,&right);

		if(isSame(left,right))printf("yes\n");
		else{
			printf("no\n");
		}
	}
	return 0;
}

Measured memory_bytes: 3392
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef pair<int, int> mypair;
int main(void)
{
	int n;
	while (1)
	{
		cin >> n;
		if (n == 0)
			break;
		vector<string> w(n);
		vector<mypair> p;
		for (int i = 0; i < n; i++)
			cin >> w[i];
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < w[i].size() - 1; j++)
			{
				if (w[i][j] == '.' && w[i][j + 1] != '.')
				{
					w[i][j] = '+';
					mypair temp;
					temp.first = j;
					temp.second = i;
					p.push_back(temp);
				}
			}
		}
	
		sort(p.begin(), p.end());
		for (int i = 0; i < p.size() - 1; i++)
		{
			if (p[i].first == p[i + 1].first)
			{
				int l=0;
				for (int j = p[i].second + 1; j < p[i + 1].second; j++){
				if(w[j][p[i].first]=='.')
				l++;
				}
				if(l==p[i+1].second-p[i].second-1){
				for (int j = p[i].second + 1; j < p[i + 1].second; j++)
				{
					if(w[j][p[i].first]=='.'){
					w[j][p[i].first] = '|';
				}
				}
			}
			}
		}
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < w[i].size(); j++)
			{
				if (w[i][j] == '.')
				{
					w[i][j] = ' ';
				}
			}
		}
		for (int i = 0; i < n; i++)
		{
			cout << w[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <algorithm>
#include<vector>
#include <queue>
#include "math.h"
#include <string>
using namespace std;
int main()
{
	long n, m;
	cin >> n >> m;
	cout << pow(2,m)*(1900 * m + 100 * (n - m)) << endl;
}

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

namespace ABC072_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var maxCount = 0;
            var maxNum = 100000;
            var b = new int[maxNum];
            for (int i = 0; i < N; i++)
            {
                b[a[i]]++;
            }

            for (int i = 1; i < maxNum - 1; i++)
            {
                var sum = b[i] + b[i - 1] + b[i + 1];
                if (maxCount < sum)
                {
                    maxCount = sum;
                }
            }

            Console.WriteLine(maxCount);
        }


    }
}


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

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

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

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

int prime2(int n)
{
  int result = 0;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      if (i == 2) result++;
      n /= i;
    }
  }
  if (n == 2) result++;
  return result;
}

int N;
int A[200];

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

  cin >> N;
  REP(i, N) cin >> A[i];

  int ans = INT_MAX;
  REP(i, N) { ans = min(ans, prime2(A[i])); }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		for (int i = 0; i < N; ++i) {
			char[] mut = sc.next().toCharArray();
			char[] mes = sc.next().toCharArray();
			int L = mes.length;
			for (int j = mut.length - 1; j >= 0; --j) {
				char tmp;
				switch (mut[j]) {
				case 'J':
					tmp = mes[L - 1];
					for (int k = L - 1; k > 0; --k) {
						mes[k] = mes[k - 1];
					}
					mes[0] = tmp;
					break;
				case 'C':
					tmp = mes[0];
					for (int k = 0; k < L - 1; ++k) {
						mes[k] = mes[k + 1];
					}
					mes[L - 1] = tmp;
					break;
				case 'E':
					for (int k = 0; k < L / 2; ++k) {
						tmp = mes[k];
						mes[k] = mes[(L + 1) / 2 + k];
						mes[(L + 1) / 2 + k] = tmp;
					}
					break;
				case 'A':
					for (int k = 0; k < L / 2; ++k) {
						tmp = mes[k];
						mes[k] = mes[L - 1 - k];
						mes[L - 1 - k] = tmp;
					}
					break;
				case 'P':
					for (int k = 0; k < L; ++k) {
						if (Character.isDigit(mes[k])) {
							if (mes[k] == '0') {
								mes[k] = '9';
							} else {
								mes[k]--;
							}
						}
					}
					break;
				case 'M':
					for (int k = 0; k < L; ++k) {
						if (Character.isDigit(mes[k])) {
							if (mes[k] == '9') {
								mes[k] = '0';
							} else {
								mes[k]++;
							}
						}
					}
					break;
				}
			}
			System.out.println(String.valueOf(mes));
		}
	}

}

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

namespace AtCoder
{
    class Program
    {
        static int n;

        static void Main(string[] args)
        {
            //[summary]B - Trained?
            var lines = ReadLines<int>(1).ToList();
            n = lines[0][0];

            //マス目上のアメをListに入れる
            var candies = ReadLines<int>(2).ToList();

            //獲得可能なアメの最大数を計算
            int count = GetMaxCountOfCandies(candies);

            Console.WriteLine(count);
        }

        static int GetMaxCountOfCandies(List<List<int>> candies)
        {
            var upperCandies = candies[0];
            var lowerCandies = candies[1];
            int max = 0;

            for(int i = 1; i <= n; i++)
            {
                int upper = upperCandies.Take(i).Sum();
                int lower = lowerCandies.Skip(i - 1).Sum();
                int sum = upper + lower;

                if (sum > max)
                {
                    max = sum;
                }
            }

            return max;
        }
                               
        static IEnumerable<List<T>> ReadLines<T>(int count = 0, char separator = ' ')
        {
            //[summary]コンソールの値を読み込んで、List<T>のコレクションを返却

            //読み込む行数が未指定のときは、1行目の値を"count"とみなす
            if (count == 0)
            {
                string line = Console.ReadLine().TrimEnd();
                count = int.Parse(line);
            }

            for (int i = 0; i < count; i++)
            {
                //コンソールを1行読み込み
                string line = Console.ReadLine().TrimEnd();

                //char型のときは1文字ずつに分割
                if (typeof(T) == typeof(char))
                {
                    var list = line.ToCharArray().ToList();
                    yield return (List<T>)(object)list;
                }
                else
                {
                    //読み込んだ値を"separator"で区切る
                    var list = line.Split(separator).ToList();

                    //int型のときは数値に変換
                    if (typeof(T) == typeof(int))
                    {
                        var numbers = list.ConvertAll(int.Parse);
                        yield return (List<T>)(object)numbers;
                    }
                    else if (typeof(T) == typeof(long))
                    {
                        var numbers = list.ConvertAll(long.Parse);
                        yield return (List<T>)(object)numbers;
                    }
                    else
                    {
                        yield return (List<T>)(object)list;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
//max=({});


int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d)puts("Yes");
	else if (abs(a - b) <= d && abs(b - c) <= d)puts("Yes");
	else puts("No");
	return 0;
}


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

rank = 1
b_rank = 0
for n in range(N):
    if S[n] == 'a':
        if rank <= (A+B):
            rank += 1
            print('Yes')
        else:
            print('No')

    if S[n] == 'b':
        b_rank += 1
        if (rank <= (A+B)) and (b_rank <= B):
            rank += 1
            print('Yes')
        else:
            print('No')

    if S[n] == 'c':
        print('No')

Measured memory_bytes: 4016
k,t = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)

while a != [0] * (t-1) + [a[-1]]:
    a[-2], a[-1] = 0, a[-1] - a[-2]
    a = sorted(a)

print(a[-1]-1 if a[-1]>0 else 0)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e5 + 10;
LL N, K;
int main()
{
    scanf("%lld %lld", &N, &K);
    if(N > K)
    {
        LL k = (N - K) / K + 1;
        N -= k * K;
    }
    printf("%lld", min(K - N, N));
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
	string s;
	cin >>s;
	int count=0,Max=0;
	rep(i,3){
		if(s[i]=='R')count++;
		if(s[i]=='S')count=0;
		Max=max(Max,count);
	}
	cout << Max;
	return 0;
}

Measured memory_bytes: 3592
from collections import deque

INF = -1

sizeI, sizeJ = map(int, input().split())
a = [input().rstrip() for _ in range(sizeI)]

def bfs(startI, startJ):
    dist = [[INF for _ in range(sizeJ)] for _ in range(sizeI)]
    dist[startI][startJ] = 0
    q = deque([(startI, startJ)])
    while q:
        i, j = q.pop()
        curDist = dist[i][j]
        for di, dj in ((1, 0), (-1, 0), (0, 1), (0, -1)):
            ni, nj = i + di, j + dj
            if 0 <= ni < sizeI and 0 <= nj < sizeJ and dist[ni][nj] == INF and a[ni][nj] == '.':
                dist[ni][nj] = 1 + curDist
                q.appendleft((ni, nj))
    return max([max(row) for row in dist])

ret = -float('inf')
for i in range(sizeI):
    for j in range(sizeJ):
        if a[i][j] == '.':
            ret = max(ret, bfs(i, j))
print(ret)

Measured memory_bytes: 45148
M = 10**9 + 7
def f(n):
    x = 1
    for i in range(1, n + 1):
        x = x * i % M
    return x

n, m = map(int, input().split())
if n == m:
    x = f(n)
    print(2 * x * x % M)
elif abs(m - n) == 1:
    a = min(m, n)
    x = f(a)
    print(x * x * (a + 1) % M)
else: print(0)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);++i)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;--i)
#define FOR(i,s,n) for(int i = s;i < (int)n;++i)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;--i)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr int INF = 1e18;



signed main(){
	int N;
	cin >> N;
	vector<int>a(N);
	REP(i,N){
		cin >> a[i];
	}
	sort(ALL(a));
	int ans = INF;
	FOR(i,1,100){
		int t = 0;
		REP(j,N){
			t += (a[j] - i) * (a[j] - i);
		}
		CHMIN(ans,t);
	}
	out(ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int x;
    int y;
    while(1){
    cin>>x>>y;
    if(x==0 && y==0)break;
    if(x<=y){
        cout<<x<<" "<<y<<endl;
    }else{
        cout<<y<<" "<<x<<endl;
    }
    }
    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main() {
	vector<int> A(6);
	for (int i = 0; i < 5; i++) {
		cin >> A[i];
	}
	int ans = 0;
	int rec = 0;
	int min = A[0]%10;
	for (int i = 0; i < 5; i++) {
		if (A[i] % 10 != 0 && A[i] % 10 < min) {
			min = A[i] % 10;
			rec = i;
		}
	}
	for(int i=0;i<5;i++){
		if (A[i] % 10 != 0) {
			ans += 10 * ((A[i] + 10) / 10);
		}
		else {
			ans += A[i];
		}
	}
	if (A[rec] % 10 != 0) {
		ans += A[rec] - 10 * ((A[rec] + 10) / 10);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <cstdlib>

using namespace std;

int main(int argc, const char * argv[]) {
	int N, K;
	int count = 0;

	cin >> N >> K;
	int h[N];

	for(int i=0; i<N; i++){
		cin >> h[i];
		if(h[i] >= K){count++;}
	}
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 640
H,W = map(int,input().split())
S = [list(input()) for i in range(H)]

C = [[0 for i in range(W)] for j in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            C[i][j] ="#"
        else:
            bottomi = i - 1 if i > 0 else 0
            bottomj = j - 1 if j > 0 else 0
            topi = i + 1 if i < H-1 else H-1
            topj = j + 1 if j < W-1 else W-1
            cnt = 0
            for k in range(bottomi,topi+1):
                for l in range(bottomj,topj+1):
                    if S[k][l] == "#":
                        C[i][j] += 1

for i in range(H):
    ST = ""
    for j in range(W):
        ST +=str(C[i][j])
    else:
        print(ST)


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

using namespace std;

int main()
{
    int N, p = 0;
    cin >> N;
    
    bool poss = 1;
    for (int i = 0; i < N; i++) {
        char c; int n;
        cin >> c >> n;
        if (c == '(') {
            p += n;
        } else {
            p -= n;
        }
        if (p < 0) {
            poss = 0;
        }
    }
    if (poss && p == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
using namespace std;
typedef long long ll;
template <class T> inline bool dpmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool dpmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

// 6[h-1, w-1] 7[h-1, w] 8[h-1, w+1]
// 5[h,   w-1] 0[h,   w] 1[h,   w+1]
// 4[h+1, w-1] 3[h+1, w] 2[h+1, w+1]
void solve(long long H, long long W, vector<string> S) {
    int dh[8] = { 0, +1, +1, +1,  0, -1, -1, -1};
    int dw[8] = {+1, +1,  0, -1, -1, -1,  0, +1};
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            if (S[h][w] == '#') continue;

            int bomb = 0;
            for (int d = 0; d < 8; d++) {
                int h_tmp = h + dh[d];
                int w_tmp = w + dw[d];
                if (h_tmp < 0 || H <= h_tmp) continue;
                if (w_tmp < 0 || W <= w_tmp) continue;
                if (S[h_tmp][w_tmp] == '#') bomb++;
            }

            S[h][w] = char('0' + bomb);
        }
    }

    rep (h, H) {
        cout << S[h] << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  long long H;
  cin >> H;
  long long W;
  cin >> W;
  vector<string> S(H);
  for (int i = 0; i < H; i++) {
    cin >> S[i];
  }
  solve(H, W, move(S));
  return 0;
}


Measured memory_bytes: 3588