akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

h,n=map(int,input().split())
AB=[tuple(map(int,input().split())) for i in range(n)]
# AB.sort(key=lambda tup: tup[0]/tup[1])
dp=[inf]*(h+10**4+2)
dp[0]=0
for i in range(1,h+10**4+2):
    for a,b in AB:
        # print(i,a,b)
        if not (0<=i-a<h+10**4+2): continue
        dp[i]=min(dp[i],dp[i-a]+b)
for i in range(h,h+10**4+2):
    mans=min(mans,dp[i])
print(mans)

Measured memory_bytes: 43376
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;




int main(){
    int x,y,z;
    cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<endl;
    return 0;

    return 0;
}


Measured memory_bytes: 256
using namespace std;
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define debug(x) cout << #x <<" = " << x << endl
void solve()
{
int n;
cin>>n;
string ans;
for(int i=0;i<n;i++)
ans+="ACL";
cout<<ans<<endl;
}
int main()
{
     
FASTIO
 long long int t=1;
 //cin>>t;
 while(t--)
  solve();
  return 0;
}


Measured memory_bytes: 3620
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		
		final class Num {
			public int no;
			public int comeOrder;
			
			public Num(int no, int comeOrder) {
				this.no = no;
				this.comeOrder = comeOrder;
			}
			
			public int getNo() { return no; }
			public int getOrder() { return comeOrder; }
		}
		
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		List<Num> student = new ArrayList<>();
		
		for (int i = 0; i < N; ++i) {
			student.add(new Num(i + 1, Integer.parseInt(sc.next())));
		}
		
		// sort
		student.sort(Comparator.comparingInt(Num::getOrder));
		
		// out
		for (int i = 0; i < N; ++i) {
			System.out.print(student.get(i).no + " ");
		}
		
	}

}


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, m, a[100010], b[100010], ans;
priority_queue <P, vector<P>, greater<P> > q2;

int main(){
	cin >> n >> m;
	for(int i=0;i<m;i++){
		cin >> a[i] >> b[i];
		q2.push({b[i], i});
	}
	P fl = q2.top();
	while(!q2.empty()){
		if(fl.first < q2.top().first&&a[q2.top().second]>=fl.first){
			ans++;
			fl = q2.top();
		}
		q2.pop();
	}
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 2040
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    println!("{}",read::<i32>()-read::<i32>()+1)
}

Measured memory_bytes: 4352
/*
Hokudai Practice Contest 2014
A - King's Inspection

ティツァツ」テヲツウツ陛ッツシツ堙」ツつキテ」ツδ淌」ツδ・テ」ツδャテ」ツδシテ」ツつキテ」ツδァテ」ツδウ
テヲツ崢クテ」ツ?凝」ツつ古」ツ?ヲテ」ツ??」ツつ凝」ツδォテ」ツδシテ」ツδォテ」ツ?ォテ・ツセツ禿」ツ?」テ」ツ?ヲテ・ツセツゥテ・ツ?ε」ツ?凖」ツつ凝」ツ??」ツ?妥」ツ??
テ」ツδォテ」ツδシテ」ツδォテ」ツつ津・ツ?催ァツ渉セテ」ツ?凖」ツつ凝」ツ?淌」ツつ?」ツ?ォテ」ツ?ッテ」ツδェテ」ツつケテ」ツδ暗」ツ?ョテ・ツセツェテァツ陳ーテ」ツつ?ヲツ鳴?・ツュツ療」ツ?ョテ・ツセツェテァツ陳ーテ」ツつ津・ツ?催ァツ渉セテ」ツ?凖」ツつ凝・ツソツ?ィツヲツ?」ツ?古」ツ?づ」ツつ凝」ツ??
(M-1)+1 -> 0, 0-1 -> (M-1)テ」ツ??」ツ?ィテ」ツ?ェテ」ツつ凝」ツつ暗」ツ??」ツ?ォテ」ツ?凖」ツつ凝」ツ?ォテ」ツ?ッテ」ツ??・ツ可ーテ、ツスツ?%)テ」ツつ津ァツ板ィテ」ツ??」ツつ古」ツ?ーテ」ツつ暗」ツ??」ツ??

テヲツ卍づゥツ鳴禿ィツィツ暗ァツョツ療ゥツ?湘ッツシツ唹(|s|)
テァツゥツコテゥツ鳴禿ィツィツ暗ァツョツ療ゥツ?湘ッツシツ唹(n + |s|)
*/

#include<iostream>
#include<cctype>
using namespace std;

//a-zA-z -> テゥツ??ァツ閉ェ
int toInt(char a){
  if(islower(a))return a-'a';
  return a-'A'+26;
}

//テゥツ??ァツ閉ェ -> a-zA-Z
char toChar(int a){
  if(a<26)return 'a'+a;
  return 'A'+a-26;
}

//テゥツァツ?ヲツ閉ー
const int M = 52;

int main(){
  int n,k[100];
  string s;

  while(cin >> n,n){
    for(int i=0;i<n;i++)cin >> k[i];
    cin >> s;

    for(int i=0;i<(int)s.size();i++){
      //テ・ツセツェテァツ陳ーテ」ツつ津」ツつキテ」ツδ淌」ツδ・テ」ツδャテ」ツδシテ」ツつキテ」ツδァテ」ツδウテ」ツ?凖」ツつ凝」ツ?ォテ」ツ?ッmodテ」ツつ津、ツスツソテ」ツ?暗」ツ?ーティツ可ッテ」ツ??
      int tmp = toInt(s[i]) - k[i%n];
      //ティツイツ?ヲツ閉ーテ」ツつづ」ツ?づ」ツつ甘・ツセツ療」ツつ凝・ツ?エテ・ツ青暗」ツ?ョテ・ツョツ嘉・ツ?ィテ」ツ?ェmodテ」ツ?ョテ・ツ渉姪」ツつ甘ヲツ鳴ケテ」ツ?ッ((x%mod) + mod)%mod
      tmp = ((tmp%M) + M) % M;
      cout << toChar(tmp);
    }
    cout << endl;
  }
}

Measured memory_bytes: 1200
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int min = Integer.MAX_VALUE;
    for(int a=1;a<=n;a++){
      int b=n-a;
      if(b>=1){
        int sum=0,num;
        for(int i=0;i<2;i++){
          if(i==0) num=a;
          else num=b;
          while(num>0){
            sum+=num%10;
            num/=10;
          }
        }
        if(sum<min) min=sum;
      }
    }
    System.out.println(min);
  }
}

Measured memory_bytes: 21844
n = int(input())
p = [int(x) for x in input().split()]
a = 0
for i in range(1,n-1):
    if p[i-1] < p[i] <p[i+1] or p[i+1] < p[i] <p[i-1]:
        a += 1
        
print(a)

Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
INF = float("inf")


def GCD(a, b):
    if a == 0:
        return b
    else:
        return GCD(b % a, a)


def LCM(a, b):
    return a*b//GCD(a, b)


def solve(A: int, B: int):
    print(LCM(A, B))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n){
        cin >> a.at(i);
    }

    ll cache = 1000, stock = 0;
    REP(i, n){
        if(i + 1 < n){
            if(a.at(i) > a.at(i + 1)){
                cache += a.at(i) * stock;
                stock = 0;
            }else if(a.at(i) < a.at(i + 1)){
                stock += cache / a.at(i);
                cache = cache % a.at(i);
            }
        }else{
            cache += stock * a.at(i);
            stock = 0;
        }
    }
    cout << cache << endl;
    return 0;
}


Measured memory_bytes: 3628
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main(){
    input!{
        n:usize,
        k:usize,
        s:chars
    }
    for j in 0..s.len() {
        if j == k-1 {
            if s[j] == 'A'{
                print!("a")
            } else if s[j] == 'B' {
                print!("b")
            } else if s[j] == 'C'{
                print!("c")
            }

        } else {
            print!("{}",s[j]);
        }
        
    }
}

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

ll N, K;
ll num[200005];
ll maximum = 2e18;

ll neg, pos, zero;
ll a, b, c;

ll numLessNeg(ll key){
    ll r = N-1;
    ll tot = 0;
    for (ll i=a-1; i>=0; i--){
        while (num[i]*num[r] <= key && r >= a+b) r--;
        tot += N-1-r;
    }
    return tot;
}

ll numLessPos(ll key){
    ll r = a-1;
    ll tot = 0;
    for (ll i=0; i<a; i++){
        while (num[i]*num[r] <= key && r >= 0) r--;
        tot += a-1-r;
        if (r < i) tot--;
    }

    r = a+b;
    for (ll i=N-1; i>=a+b; i--){
        while (num[i]*num[r] <= key && r < N) r++;
        tot += r-(a+b);
        if (r > i) tot--;
    }
    return tot/2;
}

int main(){
    cin >> N >> K;
    a = b = c = 0;
    for (int i=0; i<N; i++){
        scanf("%lld", &num[i]);
        if (num[i] < 0) a++;
        else if (num[i] == 0) b++;
        else c++;
    }
    sort(num, num+N);
    neg = a*c;
    pos = a*(a-1)/2+c*(c-1)/2;
    zero = b*(b-1)/2+b*(a+c);

    if (K <= neg){
        ll l = -maximum, r = 0, m;
        while (l < r){
            m = l+(r-l)/2;
            if (numLessNeg(m) < K) l = m+1;
            else r = m;
        }
        cout << l << endl;
    }
    else if (K > neg && K <= neg+zero){
        cout << 0 << endl;
    }
    else {
        ll l = 1, r = maximum, m;
        while (l < r){
            m = l+(r-l)/2;
            if (numLessPos(m) < K-neg-zero) l = m+1;
            else r = m;
        }
        cout << l << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k = map(int,input().split())
H = [int(input()) for i in range(n)]
H.sort()
for i in range(n-k+1):
  mans = min(mans,H[i+k-1]-H[i])
print(mans)

Measured memory_bytes: 43868
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll a,b,c;
cin >> a>> b >> c;
for(ll i = 1; i <= b; i++){
    if((a * i) % b == c)
    {
        cout << "YES" << endl;
        return 0;
    }
}
cout << "NO" << endl;
}

Measured memory_bytes: 3632
#ifndef UTIL_INCLUDED
#define UTIL_INCLUDED

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
// #define DEBUGGING

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(0);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifndef DEBUG_FILE
#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#endif
#endif

#endif
int main() {
    ll N;
    cin >> N;
    string S;
    cin >> S;
    V<ll> cnt(N + 1);
    for(ll i = 0; i < N; i++) cnt[i + 1] += (S[i] == '#');
    for(ll i = 0; i < N; i++) cnt[i + 1] += cnt[i];
    ll ans = N + 1;
    DEBUG(cnt);
    for(ll i = 0; i <= N; i++) {
        ll br = cnt[N] - cnt[i];
        ll bl = cnt[i];
        ll tmp = bl + ((N - i) - br);
        chmin(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost::adaptors;

int main(void) {
    string s;
    int q;
    cin >> s >> q;
    deque<char> ans;
    bool r = false;
    for (char c : s) ans.push_back(c);
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if (t == 1) {
            r = !r;
        } else {
            int f;
            char c;
            cin >> f >> c;
            if ((f == 1 && !r) || f == 2 && r) {
                ans.push_front(c);
            } else {
                ans.push_back(c);
            }
        }
    }

    if (r) {
        for (char c : ans | reversed) cout << c;
    } else {
        for (char c : ans) cout << c;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <set>

using namespace std;

vector<int> a;

set<int> f(int n) {
	set<int> ret;
	for (auto i : a) {
		if (i >= n)break;
		if (n % i == 0) {
			int t = n / i;
			if (t % 7 != 1 && t % 7 != 6)continue;
			ret.insert(i);
		}
	}
	ret.insert(n);
	return ret;
}

int main() {
	for (int i = 2; i <= 300000; i++) {
		if (i % 7 == 1 || i % 7 == 6) {
			a.push_back(i);
		}
	}
	int n;
	while (cin >> n && n != 1) {
		int m = a.size();
		set<int> ans = f(n);

		cout << n << ":";
		for (auto i : ans) {
			if (f(i).size() == 1) {
				cout << " " << i;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3296
#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>;

/* double	get_distance(auto&& XY, int n) */
double	get_distance(vector<vector<double>> XY, int n)
{
	double	sum;
	double	x;
	double	y;

	sum = 0.0;
	x = 0.0;
	y = 0.0;
	rep(i, n - 1)
	{
		x = XY.at(i).at(0) - XY.at(i + 1).at(0);
		y = XY.at(i).at(1) - XY.at(i + 1).at(1);
		sum += sqrt(x * x + y * y);
	}
	return (sum);
}

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

	int					n;
	double				sum;
	double				factorial;
	cin >> n;
	vector<vector<double>> XY(n, vector<double>(2));

	rep(i, n)
		cin >> XY.at(i).at(0) >> XY.at(i).at(1);
	sum = 0.0;
	sort(XY.begin(), XY.end());
	do
		sum += get_distance(XY, n);
	while (next_permutation(XY.begin(), XY.end()));
	factorial = 1;
	rep(i, n - 1)
		factorial *= (i + 2);
	cout << fixed << setprecision(8) << sum / factorial << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

map<int, int > M;

int main() {
  int n,m;
  S2(n,m);
  M[0]++;
  int sm = 0;
  LL ans = 0;
  rep(i,0,n) {
    int x;
    S(x);
    sm += x;
    sm %= m;
    ans += M[sm];
    M[sm]++;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n) {
        string tmp;
        cin >> tmp;
        mp[tmp]++;
    }

    cout <<"AC x " << mp["AC"] << endl;
    cout <<"WA x " << mp["WA"] << endl;
    cout <<"TLE x " << mp["TLE"] << endl;
    cout <<"RE x " << mp["RE"] << endl;

    return 0;
}

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

using namespace std;

int main(void) {
    int N, C;
    cin >> N >> C;
    vector<vector<int>> D(C+1, vector<int>(C+1));
    for (int i = 1; i <= C; i++) {
        for (int j = 1; j <= C; j++) {
            cin >> D[i][j];
        }
    }
    vector<vector<int>> c(N+1, vector<int>(N+1));
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            cin >> c[i][j];
        }
    }

    // for (vector<int> x : D) {
    //     for (int xx : x) {
    //         cout << xx << " ";
    //     }
    //     cout << endl;
    // }

    // cout << endl;
    // for (vector<int> x : c) {
    //     for (int xx : x) {
    //         cout << xx << " ";
    //     }
    //     cout << endl;
    // }

    vector<vector<int>> color_count(3, vector<int>(C+1, 0));
    for (int i = 1; i < c.size(); i++) {
        for (int j = 1; j < c[i].size(); j++) {
            color_count[(i + j) % 3][c[i][j]]++;
        }
    }
    vector<vector<int>> count(3, vector<int>(C+1, 0));
    for (int g = 0; g < 3; g++) {
        for (int cl = 1; cl <= C; cl++) {
            for (int i = 1; i < color_count[g].size(); i++) {
                count[g][cl] += D[i][cl] * color_count[g][i];
            }
        }
    }

    // cout << endl;
    // for (vector<int> x : color_count) {
    //     for (int xx : x) {
    //         cout << xx << " ";
    //     }
    //     cout << endl;
    // }

    // cout << endl;
    // for (vector<int> x : count) {
    //     for (int xx : x) {
    //         cout << xx << " ";
    //     }
    //     cout << endl;
    // }

    int ans = 500*500*1000;
    for (int i = 1; i <= C; i++) {
        for (int j = 1; j <= C; j++) {
            if (i == j) {
                continue;
            }
            for (int k = 1; k <= C; k++) {
                if (i == k || j == k) {
                    continue;
                }
                ans = min(ans, count[0][i] + count[1][j] + count[2][k]);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

void solver() {
  int a, b;

  cin >> a >> b;

  if (a <= b) {
    cout << "unsafe" << "\n";
  } else {
    cout << "safe" << "\n";
  }
}

int main() {
  solver();
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return sorted 約数list 1 <= x <= n
vector<ll> divv(ll n) {
  vector<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.push_back(i);
      if(i*i != n) v.push_back(n/i);
    }
  }
  sort(ALL(v));
  return v;
}

auto isprime = [](auto n){
  bool isPrime = true;
  for(decltype(n) i = 2; i <= sqrt(n); ++i)
  {
      if(n % i == 0)
      {
          isPrime = false;
          break;
      }
  }
  return isPrime;
};

int main() {
    ll n,k;
    cin>>n>>k;


    unordered_set<ll> divn,divk;
    {
        ll lim = sqrt(n);
        fr(i, 1, lim+1){
            if(n%i ==0){
                divn.insert(i);
                divn.insert(n/i);
            }
        }
    }
    {
        ll lim = sqrt(k);
        fr(i, 1, lim+1){
            if(k%i ==0){
                divk.insert(i);
                divk.insert(k/i);
            }
        }
    }
    ll sum=0;
    for(auto it:divk) if(divn.count(it)) if(isprime(it)) sum++;
    pr(sum);
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B;
	cin >> A >> B;
	cout << A + (B - A) * 2 << endl;
}

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

static class Extensions
{
    public static int ToInt(this string s) => int.Parse(s);
    public static long ToLong(this string s) => long.Parse(s);
    public static char ToChar(this string s) => char.Parse(s);
    public static double ToDouble(this string s) => double.Parse(s);
    public static int[] ToIntArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToInt()).ToArray();
    public static long[] ToLongArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToLong()).ToArray();
    public static double[] ToDoubleArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToDouble()).ToArray();
    public static Queue<T> ToQueue<T>(this IEnumerable<T> seq) => new Queue<T>(seq);
    public static Stack<T> ToStack<T>(this IEnumerable<T> seq) => new Stack<T>(seq);
    public static HashSet<T> ToHashSet<T>(this IEnumerable<T> seq) => new HashSet<T>(seq);
}
static class MyMath
{
    static public long GCD(long a, long b) => (a < b) ? GCD(b, a) : ((b == 0) ? a : GCD(b, a % b));
    static public long LCM(long a, long b) => (a > b) ? (a / GCD(a, b) * b) : (b / GCD(a, b) * a);
    static private readonly long _m = 1000000000 + 7;
    static public long Mod(long val) => (val % _m + _m) % _m;
    static private long extGCD(long a, long b, ref long x, ref long y) => (b == 0) ? (a + (x = 1) * 0 + (y = 0) * 0) : (extGCD(b, a % b, ref y, ref x) + (y -= a / b * x) * 0);
    static public long ModInverse(long a, long dummy1 = 0, long dummy2 = 0) => extGCD(a, _m, ref dummy1, ref dummy2) * 0 + Mod(dummy1);    
}

class Program
{
    static string[] ReadLines(int n) => Enumerable.Range(0, n).Select(s => Console.ReadLine()).ToArray();

    static void Main()
    {
        int N = Console.ReadLine().ToInt();
        int[] array = Console.ReadLine().ToIntArray();
        int numMax = array.Length;
        int[] box = new int[array.Length];

        for(int i = array.Length - 1; i >= 0; i--)
        {
            //箱に書かれている数
            int num = i + 1;

            var xx = getBisuu(num).TakeWhile(n => n <= numMax).Sum(n => box[n - 1]);

            if (array[i] == 1 && xx % 2 == 0)
            {
                box[i] = 1;
            }
            else if (array[i] == 0 && xx % 2 == 1)
            {
                box[i] = 1;
            }
        }

        var list = new List<int>();
        for(int i = 0; i < array.Length; i++)
        {
            if (box[i] == 1)
            {
                list.Add(i + 1);
            }
        }

        Console.WriteLine(list.Count);

        Console.WriteLine(string.Join(" ", list.Select(n => n.ToString())));

        
    }

    static IEnumerable<int> getBisuu(int n)
    {
        var ret = n;

        while (true)
        {
            ret += n;
            yield return ret;            
        }
    }
}

Measured memory_bytes: 32284
// Author: Tyler Wang

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

using namespace std;

template <class Fun>
class y_combinator_result {
 public:
  template <class T>
  explicit y_combinator_result(T&& fun) : fun_(std::forward<T>(fun)) {}

  template <class... Args>
  decltype(auto) operator()(Args&&... args) {
    return fun_(std::ref(*this), std::forward<Args>(args)...);
  }

 private:
  Fun fun_;
};

template <class Fun>
decltype(auto) y_combinator(Fun&& fun) {
  return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.precision(12);
  std::cerr.precision(12);
  std::mt19937 rng((std::uint_fast32_t)std::chrono::high_resolution_clock::now()
                       .time_since_epoch()
                       .count());
  int n;
  cin >> n;
  vector<int> cnt(4);
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    ++cnt[a];
  }
  vector<vector<vector<double>>> dp(
      n + 1, vector<vector<double>>(n + 1, vector<double>(n + 1, -1)));
  dp[0][0][0] = 0;
  // dp[i][j][k] = 1 + (n - i - j - k) / n * dp[i][j][k] +
  // i / n * dp[i - 1][j][k] + j / n * dp[i][j - 1][k] + k / n * dp[i][j][k - 1]
  auto solve = y_combinator([&](auto self, int i, int j, int k) -> double {
    if (i < 0 || j < 0 || k < 0) {
      return 0;
    }
    if (dp[i][j][k] >= 0) {
      return dp[i][j][k];
    }
    double res = i * self(i - 1, j, k) + j * self(i + 1, j - 1, k) +
                 k * self(i, j + 1, k - 1);
    res = (n + res) / (i + j + k);
    return dp[i][j][k] = res;
  });
  cout << solve(cnt[1], cnt[2], cnt[3]) << '\n';
  return 0;
}

Measured memory_bytes: 216960
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=0;cin>>n;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    if(i>0) a.at(i)+=a.at(i-1);
  }
  for(int i=0;i<n;i++) cin>>b.at(i);
  for(int i=n-2;i>-1;i--) b.at(i)+=b.at(i+1);
  for(int i=0;i<n;i++) ans=max(ans,a.at(i)+b.at(i));
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

  int i,j,k,l,m;
  int n,e,s,w,un,up;
  int a[7];
int t;


void input() {
 for(i=0;i<6;i++){
  
    scanf("%d",&a[i+1]);
  
  }
}

 void N() {
   t = a[1];
   a[1] = a[2];
   a[2] = a[6];
   a[6] = a[5];
   a[5] = t;
 }

 void S() {
   t = a[1];
   a[1] = a[5];
   a[5] = a[6];
   a[6] = a[2];
   a[2] = t;
}

 void E() {
   t = a[1];
   a[1] = a[4];
   a[4] = a[6];
   a[6] = a[3];
   a[3] = t;
 }

 void W() {
   t = a[1];
   a[1] = a[3];
   a[3] = a[6];
   a[6] = a[4];
   a[4] = t;
 }

int main() {

  input();
  //  strlen(?) 文字の長さ(数)を表示
 char str[110];  
 scanf("%s",str);

 for(i=0;i<strlen(str);i++) {

   if(str[i] == 'N') {
     N();
   } else if(str[i] == 'S') {
     S();
   } else if(str[i] == 'W') {
     W();
   } else if(str[i] == 'E') {
     E();
   }
 }

 printf("%d\n",a[1]);

 return 0;
}


Measured memory_bytes: 2764
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
using namespace std;

ll a,b,k;
bool ok;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> k >> a >> b;

    for(ll i=a; i<=b; i++){
        if( i%k==0 ) ok = true;
    }

    if( ok ){
        cout << "OK";
    }else{
        cout << "NG\n";
    }

    return 0;
}


Measured memory_bytes: 3652
import scala.io.StdIn._

object Main extends App {
  private def rec(): Unit = {
    val Array(h, w) = readLine().split(" ").map(_.toInt)
    if (h != 0 && w != 0) {
      printBoard(h, w)
      println()
      rec()
    }
  }

  private def printBoard(h: Int, w: Int): Unit =
    (1 to h).foreach { i =>
      (1 to w).foreach { j =>
        if ((i + j) % 2 == 0) print("#") else print(".")
      }
      println()
    }

  rec()
}


Measured memory_bytes: 56540
#include <bits/stdc++.h>
using namespace std;
 
int n, m, d[1001][1001], a[1001][1001], xs, ys, xf, yf;
bool inque[1001][1001];
deque<pair<int, int>> coada;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
 
bool in(int x, int y) {
    return x >= 1 && x <= n && y >= 1 && y <= m;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    cin >> xs >> ys;
    cin >> xf >> yf;
    for(int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        for(int j = 1; j <= m; j++) {
            d[i][j] = n * m;
            if(s[j - 1] == '.') {
                a[i][j] = 1;
            } else {
                a[i][j] = 0;
            }
        }
    }
    d[xs][ys] = 0;
    inque[xs][ys] = 1;
    coada.push_back(make_pair(xs, ys));
    while(!coada.empty()) {
        int x = coada.front().first;
        int y = coada.front().second;
        inque[x][y] = 0;
        coada.pop_front();
        for(int i = 0; i < 4; i++) {
            int newx = x + dx[i];
            int newy = y + dy[i];
            if(in(newx, newy) && a[newx][newy] && d[newx][newy] > d[x][y]) {
                d[newx][newy] = d[x][y];
                if(!inque[newx][newy]) {
                    inque[newx][newy] = 1;
                    coada.push_front(make_pair(newx, newy));
                }
            }
        }
        for(int i = max(x - 2, 1); i <= min(x + 2, n); i++) {
            for(int j = max(y - 2, 1); j <= min(y + 2, m); j++) {
                if(abs(i - x) + abs(j - y) > 1 && a[i][j] && d[i][j] > d[x][y] + 1) {
                    d[i][j] = d[x][y] + 1;
                    if(!inque[i][j]) {
                        inque[i][j] = 1;
                        coada.push_back(make_pair(i, j));
                    }
                }
            }
        }
    }
    if(d[xf][yf] == n * m) {
        cout << -1;
    } else {
        cout << d[xf][yf];
    }
    return 0;
}

Measured memory_bytes: 12352
n = int(input())

temp_dict = {}
for _ in range(n):
    s_list = list(input())
    s_list.sort()
    s = "".join(s_list)

    if s not in temp_dict:
        temp_dict[s] = 0
    temp_dict[s] += 1

ans = 0
for v in temp_dict.values():
    ans += v * (v - 1) // 2
print(ans)

Measured memory_bytes: 17808
#include <bits/stdc++.h>
using namespace std;
int main(){
  long n; cin >>n;
  int m; cin >>m;
  int k=1;
  vector<int> num(m);
  vector<int> match(m);
  vector<int> matches = {2,5,5,4,5,6,3,7,6};
  for( int i = 0; i < m; i++ ){
    cin >> num[i];
  }
  sort(num.begin(),num.end());
  reverse(num.begin(),num.end());
  for(int i=0;i<m;i++){
    match[i] = matches[num[i]-1];
  }
  
  
  vector<int> dp(n+1,-100);
  dp[0] = 0; dp[1] = -100;
  
  for(int i = 2; i <= n; i++){
    int dp1=-100,dp2=-100,dp3=-100,dp4=-100,dp5=-100;
    for(int j=0; j<m; j++){
      if(dp[i-match[j]]==-100)continue;
      
      if(i>=match[j]){
        if(dp[i-match[j]] !=-100 ){
          if(dp5<dp[i-match[j]]+1)dp5=dp[i-match[j]]+1;
        }
       
      }
       
    }
   dp[i] = dp5;
  }
  
  int a,b=0;
  string ans="";
  for(int i=0;i<dp[n];i++){
    a=0;
    for(int j = 0 ; j < m ; j++){
      if( dp[ n - match[j] - b ] == dp[n]-i-1 &&n-match[j]-b>=0){
        a = j;
        break;
      }
    }
    ans += to_string(num[a]);
    b += match[a]; 
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
// Undone
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
  public static void Main() {
    int N = cin(); string S = ReadStr();
    // int W = 0, B = 0;
    List<int> count = new List<int>(); // first and last means white count
    if (S[0] == '#') count.Add(0);
    char last = ' ';
    for (int i = 0; i < N; i++) {
      if (S[i] == last) {
        count[count.Count()-1] = count.Last() + 1;
      } else {
        count.Add(1);
        last = S[i];
      }
    }
    if (S[N-1] == '#') count.Add(0);

    // 本番で累積和使ったの初めて、嬉しい。
    int[] sumW = new int[count.Count()+1], sumB = new int[count.Count()+1];
    for (int i = 0; i < count.Count(); i++) {
      if (i % 2 == 0) {
        sumW[i+1] = sumW[i] + count[i];
        sumB[i+1] = sumB[i];
      } else {
        sumB[i+1] = sumB[i] + count[i];
        sumW[i+1] = sumW[i];
      }
    }

    // どこまで W にするかを検討すればよい
    int ans = int.MaxValue;
    for (int i = 1; i < count.Count()+1; i+=2) {
      ans = Math.Min(ans, sumB[i]-sumB[0] + sumW[count.Count()]-sumW[i]);
    }
    ans = (ans == N) ? 0 : ans;
    Console.WriteLine(ans);
  }

  private static List<int> _var;
  public static int cin() { if (_var == null || _var.Count() == 0) { _var = Console.ReadLine().Split(' ').Select(int.Parse).ToList<int>(); } int ans = _var[0]; _var.RemoveAt(0); return ans; }
  public static void Swap<T>(ref T a, ref T b) {T temp = a;a = b;b = temp;}
  public static string ReadStr() { return Console.ReadLine(); }
  public static int ReadInt() { return int.Parse(Console.ReadLine()); }
  public static double ReadDouble() { return double.Parse(Console.ReadLine()); }
  public static long ReadLong() { return long.Parse(Console.ReadLine()); }
  public static char ReadChar() { return Console.ReadLine()[0]; }
  public static string[] ReadStringArray() { return Console.ReadLine().Split(' '); }
  public static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
  public static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
  public static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
  public static char[] ReadCharArray() { return Console.ReadLine().ToArray(); }
  public static string[] ReadCharStringArray() { return Console.ReadLine().ToCharArray().Select(c => c.ToString()).ToArray(); }
}


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

map<char,int> dat;
int main(){
    string str;
    cin >> str;
    for(int i = 0; i < str.length(); i++){
        dat[str[i]]++;
    }
    for(auto e : dat){
        if(e.second % 2 != 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_d

N = int(input())
S = input()
#
# ans = 0
# pattern = []
# for x in range(N):
#     for y in range(x + 1, N):
#         if (S[x] + S[y]) not in pattern:
#             ans += len(set(S[y + 1:]))
#             pattern.append(S[x] + S[y])
#
# print(ans)
ans = 0
for i in range(1000):
    key = str(i).zfill(3)
    first = S.find(key[0])
    if first == -1 or first == N:
        continue
    second = S[first + 1:].find(key[1])
    if second == -1 or (first + second + 2) == N:
        continue
    third = S[first + second + 2:].find(key[2])
    if not third == -1:
        # print(first, first + second + 1, first + second + third + 2, key)
        ans += 1
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 takahashi = A;
  long long aoki = B;
  if(A > K) takahashi  = A - K;
   else if(A + B > K) {
     takahashi = 0;
     aoki = A + B - K ;
   }
    else {
      takahashi = 0;
      aoki = 0; 
    }
    cout << takahashi << " "<< aoki << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		char[] n = sc.next().toCharArray();
		String ans = "No";

		if (n[0] == n[1] && n[1] == n[2])
			ans = "Yes";
		if (n[1] == n[2] && n[2] == n[3])
			ans = "Yes";

		System.out.println(ans);
	}

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)
using Graph = vector<vector<int>>;
using pint = pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main(){
    ll a,b,n;cin>>a>>b>>n;
    ll ans;
    if(b==1) ans=0;
    else{
        ll z;
        if(n>=b) z=b-1;
        else{
            z=n;
        }
        ans=a*z/b;
    }

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

Measured memory_bytes: 3652
from itertools import permutations


N, M, R = map(int, input().split())
r = list(map(int, input().split()))
INF = float('inf')

graph = [[INF for _ in range(N)] for _ in range(N)]

for _ in range(M):
    a, b, c = map(int, input().split())
    graph[a-1][b-1] = c
    graph[b-1][a-1] = c

distance = [[float('inf') for _ in range(N)] for _ in range(N)]

for k in range(N):
    for i in range(N):
        for j in range(N):
            graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])

total_min = INF
for i in permutations(r, len(r)):
    total = 0
    for j in range(len(r)-1):
        total += graph[i[j]-1][i[j-1]-1]
    if total < total_min:
        total_min = total

print(total_min)



Measured memory_bytes: 73560
import itertools
n, m, q = map(int, input().split())
a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q
for i in range(q):
  a[i], b[i], c[i], d[i] = map(int, input().split())
ans = 0
for A in itertools.combinations_with_replacement(range(m), n):
  tmp = 0
  for i in range(q):
    if A[b[i]-1] - A[a[i]-1] == c[i]:
      tmp += d[i]
  ans = max(ans, tmp)
print(ans)

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

constexpr size_t print_limit = 10;

template <typename It>
void print(ostream& os, It begin, It end, size_t len) {
    size_t count = 0;
    os << "{";
    while (begin != end && count < print_limit) {
        os << "(" << *begin << ")";
        count++;
        begin++;
    }
    if (print != end)
        os << "... " << len << " total";
    os << "}";
}

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& t) {
    print(os, t.begin(), t.end(), t.size());
    return os;
}


int main () {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    size_t n;
    cin >> n;
    vector<size_t> v;
    for (size_t i = 0; i < n; i++) {
        size_t a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    size_t res = 0;
    for (size_t i = 0; i < n; i++) {
        if (i == 0 || v[i - 1] != v[i]) {
            size_t j = i;
            while (j < n && v[j] <= v[i] + 2) j++;
            res = max(res, j - i);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 1400
# -*- coding: utf-8 -*-
import sys


def get_num():
    return int(input())


def get_nums(n):
    res = [0 for _ in range(n)]
    for i in range(n):
        res[i] = int(input())
    return res


def get_numbers():
    return map(int, input().split())

n, q = get_numbers()
s = input()

dp = [0 for _ in range(n + 1)]
for i in range(1, n):
    dp[i + 1] = dp[i]
    if s[i - 1:i + 1] == 'AC':
        dp[i + 1] += 1

ans = list()
for i in range(q):
    l, r = get_numbers()
    ans.append(dp[r] - dp[l])

for a in ans:
    print(a)

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

using Int = long long int;
using UInt = unsigned long long int;

int main(void) {
    Int a, b, c;
    cin >> a >> b >> c;
    if (b - a == c - b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


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

int main(){
  int c,sum = 0;
  int coin[6] = {1, 5, 10, 50, 100, 500};
  for (int i = 0; i < 6; i++){
    cin>>c;
    sum += coin[i] * c;
  }
  if (sum >= 1000) {
    cout << 1 << endl; 
  }else{
    cout << 0 << endl; 

  }
  return 0;
}

Measured memory_bytes: 1160
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations

input = sys.stdin.readline

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

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

ans = 1

for num in sorted(list(set(prime_factorize(a)))):
    if num in set(prime_factorize(b)):
        ans += 1

print(ans)



Measured memory_bytes: 3700
from itertools import product, combinations

INF = float('inf')
def floyd_warshall(E):
    N = len(E)
    dist = [[INF for _ in range(N)] for _ in range(N)]
    for v in range(N):
        dist[v][v] = 0
        for u, c in E[v]: dist[v][u] = c
    for k in range(N):        
        for i, j in product(range(N), repeat=2):
            if dist[i][j] > dist[i][k] + dist[k][j]:
                dist[i][j] = dist[i][k] + dist[k][j]
    return dist

N, M, L = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    E[a-1].append((b-1, c))
    E[b-1].append((a-1, c))
dist = floyd_warshall(E)

E_charge = [[] for _ in range(N)]
for u, v in combinations(range(N), 2):
    if dist[u][v] <= L:
        E_charge[u].append((v, 1))
        E_charge[v].append((u, 1))
charge = floyd_warshall(E_charge)

Q = int(input())
for _ in range(Q):
    s, t = map(int, input().split())
    n = charge[s-1][t-1]
    print(n - 1 if n != INF else -1)

Measured memory_bytes: 76760
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
	double a,b,c,d,e,f,x,y;
	while(cin >> a >> b >> c >> d >> e >> f){
	y = ((c*d)-(a*f))/((b*d)-(a*e));
	x = (c - (b * y)) / a;
	printf("%.3f %.3f\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 0
n, k = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp.split("").map(&:to_i)
nums = []
now = 1
cnt = 0
n.times do |i|
  if s[i] == now
    cnt += 1
  else
    nums << cnt
    now = 1 - now
    cnt = 1
  end
end
if cnt != 0
  nums << cnt
end
if nums.size.even?
  nums << 0
end

sums = Array.new(nums.size + 1, 0)
nums.size.times do |i|
  sums[i+1] = sums[i] + nums[i]
end

add = 2 * k + 1

ans = 0

(0..(nums.size)).step(2) do |i|
  left = i
  right = [i + add, nums.size].min
  tmp = sums[right] - sums[left]
  if tmp > ans
    ans = tmp
  end
end
puts ans

Measured memory_bytes: 11900
using System;

namespace _160abc
{
    class Program
    {
        static void Main(string[] args)
        {     
            long[] read = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            long K = read[0];
            long N = read[1];

            long[] A = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            long sum = 0;
            long max_A = 0;
            long[] sa_hairetu = new long[N];
            for(int i= 0;i<N;i++){
                if(i != N-1){
                    sa_hairetu[i] = A[i+1] - A[i];
                }else{
                    sa_hairetu[i] = K - A[i] + A[0];
                }
                sum += sa_hairetu[i];
                if(sa_hairetu[i] > max_A){
                    max_A = sa_hairetu[i];
                }
            }
            Console.WriteLine(sum-max_A);
            

            // long X = long.Parse(Console.ReadLine());
            // long resfff = 0;
            // long resf = 0;
            // resfff = X/500;
            // resf = (X-X/500*500)/5;
            // Console.WriteLine(resfff*1000+resf*5);

            // string S = Console.ReadLine();
            // bool flag = true;
            // if(S[2]==S[3] && S[4]==S[5]){
            //     flag = true;
            // }else{
            //     flag = false;
            // }
            // Console.WriteLine(flag? "Yes":"No");
        }
    }
}


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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))

int main(){
    FAST
    int arr[3];
    for(int i = 0; i < 3; i++){
        cin >> arr[i];
    }
    sort(arr, arr + 3);
    cout << arr[0] + arr[1];
    return 0;
}


Measured memory_bytes: 3648
a[10];main(i,j,x){
for(;scanf("%d",&j),j;){
memset(a,0,40);
for(i=0;i<j;i++)scanf("%d",&x),a[x]++;
for(j=0;j<10;puts(""),j++)if(!a[j])putchar('-');else for(i=0;i<a[j];i++)putchar('*');
}}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long int ll;

template<typename T>
struct BellmanFord{
	struct Edge{
		int  from,to; ll cost;
		Edge(){}
		Edge(int from,int to,ll cost):from(from),to(to),cost(cost){}
	};

	int n;
	vector<vector<int> >G;
	vector<int> used,reach;
	BellmanFord(int n):n(n),G(n),used(n,0),reach(n,0){}

	vector<Edge> es;
	void add_edge(int from,int to,ll cost){
		es.push_back(Edge(from,to,cost));
		G[from].push_back(to);
	}

	void dfs(int v){
		if(used[v])return ;
		used[v]=1;
		for(int u:G[v]){
			dfs(u);
		}
	}
	ll build(int from,int to,int &neg_loop){
		for(int i=0;i<n;i++){
			fill(used.begin(),used.end(),0);
			dfs(i);
			reach[i]=used[to];
		}
		vector<ll> ds(n,1e18);
		ds[from]=0;
		for(int i=0;i<n;i++){
			bool update=0;
			for(auto e:es){
				if(!reach[e.from]||!reach[e.to]||ds[e.from]==1e18) continue;
				if(ds[e.to]>ds[e.from]+e.cost){
					ds[e.to]=ds[e.from]+e.cost;
					update=1;
				}
			}
			if(!update)break;
			if(i==n-1){
				neg_loop=1;
				return 1e18;
			}
		}
		neg_loop=0;
		return ds[to];
	}
};

int main(){
	int n,m,p; cin >> n >> m >> p;
	BellmanFord<int> G(n);
	for(int i=0;i<m;i++){
		int a,b,c; cin >> a >> b >> c;
		a--; b--;
		G.add_edge(a,b,p-c);
	}
	int neg_loop;
	int res=G.build(0,n-1,neg_loop);
	if(neg_loop){
		cout << -1 << endl;
		return 0;
	}
	else{
		cout << max((ll)0,(ll)-res) << endl;
		return 0;
	}
}

Measured memory_bytes: 640