akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string s; cin >> s;
    REP(i,pow(2,3)) {
        int x = s[0]-'0';
        FOR(j,1,4) {
            if ((i & (1 << (j-1))) == 0) {
                x += s[j] - '0';
            } else {
                x -= s[j] - '0';
            }
        }
        if (x == 7) {
            cerr << i;
            REP(j,4) {
                char pm = ((i & (1 << j)) == 0) ? '+' : '-';
                if (j != 3) {
                    cout << s[j] << pm;
                } else {
                    cout << s[j] << "=7" << endl;
                }
            }
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        while(sc.hasNext()) {
            int n = sc.nextInt();
            int x = sc.nextInt();
            int ret = 0;
            if (n==0&&x==0) break;
            for (int i=1; i<=n; i++) {
                for (int j=i+1; j<=n; j++) {
                    for (int k=j+1; k<=n; k++) {
                        if (i+j+k==x) ret++;
                    }
                }
            }
            
            System.out.println(ret);
        }
    }
}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;
int a[maxn];
void run_case()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        ans ^= a[i];
    }
    //cout << ans << "\n";
    for (int i = 1; i <= n; i++)
    {
        int res = ans ^ a[i];
        cout << res << " ";
    }
    cout << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 4396
# https://atcoder.jp/contests/abc095/tasks/arc096_a
"""
別解(定数時間)
https://atcoder.jp/contests/abc095/submissions/10226556
"""

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

ans = float("inf")

# ABピザを2枚1組で考える -> ABセット
# i: ABセットの個数
for i in range(10**5 + 1):
    ans = min(ans, i*(2*C) + max(0, X-i)*A + max(0, Y-i)*B)

print(ans)

Measured memory_bytes: 3060
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-31 15:56:35
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  vector<int> l(n); cin >> l;

  sort(all(l));

  int64 ans = 0;

  for (int i = 1; i < n - 1; ++i) {
    for (int j = 0; j < i; ++j) {
      ans += distance(l.begin(), lower_bound(all(l), (l[i] + l[j])) - 1) - i;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int mod=1e9+7;
int pow_mod(int a,int b)
{
	int ret=1;
	for(;b;b>>=1,a=1LL*a*a%mod)if(b&1)ret=1LL*ret*a%mod;
	return ret;
}
int gcd(int a,int b){return a==0?b:gcd(b%a,a);}
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
int solve(int n,int m)
{
	int d=gcd(n,m),ret=0;
	ad(ret,pow_mod(2,d));
	ad(ret,(pow_mod(2,n)-2+mod)%mod);
	ad(ret,(pow_mod(2,m)-2+mod)%mod);
	ad(ret,1);return ret;
}
int main()
{
	int n=read(),m=read(),T=read();
	int d1=gcd(n,T),d2=gcd(m,T);
	int ans=solve(n/d1,m/d2);
	pr2(pow_mod(ans,1LL*d1*d2%(mod-1)));
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll n,x,cnt=0;
    cin>>n>>x;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    for(int i=1; i<=n; i++)
    {
        if(arr[i-1]+arr[i]>x)
        {
            int cur=arr[i-1]+arr[i];
            int red=cur-x;
            cnt+=red;
            if(arr[i]>=red)
                arr[i]-=red;
            else
            {
                red-=arr[i];
                arr[i]=0;
                arr[i-1]-=red;
            }

        }
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 3960
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<math.h>
#include <string>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;
ll mod=1e9+7;
int N=1e6;
int cnt[1000000];
int odd[1000000];
int main(){
	vector<int> v(180),u(181);
	v[0]=0;
	for(int i=1;i<=180;i++){
		v[i]=(i*(i+1)*(i+2)/6);
	}
	u[0]=0;
	for(int i=1;i<=180;i++){
		u[i]=u[i-1]+i;
	}
	cnt[0]=odd[0]=0;
	for(int i=1;i<N;i++){
		cnt[i]=1e9;
		odd[i]=1e9;
	}
	for(int i=1;i<N;i++){
		for(int j=1;j<=180;j++){
			if(i-v[j]>=0){
				if(cnt[i]>cnt[i-v[j]]+1){
					cnt[i]=cnt[i-v[j]]+1;
				}
				if(v[j]%2==1&&odd[i]>odd[i-v[j]]+1){
					odd[i]=odd[i-v[j]]+1;
				}
			}
		}
	}
	while(1){
		int n; cin >>n;
		if(n==0)break;
		cout << cnt[n] << " " << odd[n] << endl;
	}
}


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

int main(){
  int H , W , K ;
  cin >> H >> W >> K ;
  vector<vector<char>> c(H, vector<char>(W));
  for(int i = 0; i < H; i++)
    for(int j = 0; j < W; j++)
      cin >> c[i][j];
  int ans = 0;
  for(int Hbit = 0; Hbit < (1<<H); Hbit++){
    for(int Wbit = 0; Wbit < (1<<W); Wbit++){
      int black = 0;
      for(int i = 0; i < H; i++) for(int j = 0; j < W; j++){
        if( !(Hbit & (1<<i) || Wbit & (1<<j)) && c[i][j] == '#') black++;
      }
      if(black == K) ans++;
    }
  } 
  cout << ans;
}


Measured memory_bytes: 3632
object Main extends App {
  import scala.io.StdIn._
  val n = readInt()
  val h = readLine().split(" ").map(_.toInt)
  var flag = false
  var big = h(0)
  for(i <- (1 until(n))){
    if(big > h(i) + 1) {
      flag = true
    }
    big = Math.max(big, h(i))
  }
  println(if(flag) "No" else "Yes")
}

Measured memory_bytes: 65600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>


int main()
{
	char a, b;

	std::cin >> a >> b;

	if (a == b) {
		std::cout << "=" << std::endl;
	}
	else if (a < b) {
		std::cout << "<" << std::endl;
	}
	else {
		std::cout << ">" << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
def readinput():
    h,w=list(map(int,input().split()))
    return h,w

def main(h,w):
    if (h==1 or w==1):
        return 1
    if w%2==0:
        yoko1=w//2
        yoko2=yoko1
    else:
        yoko1=w//2+1
        yoko2=yoko1-1
    if h%2==0:
        tate=h//2
        return (yoko1+yoko2)*tate
    else:
        tate=h//2
        return (yoko1+yoko2)*tate+yoko1

if __name__=='__main__':
    h,w=readinput()
    ans=main(h,w)
    print(ans)
    

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a[3][3];
	bool b[3][3];
	memset(b,false,sizeof(b));
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			cin>>a[i][j];
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int k;
		cin>>k;
		for(int q=0;q<3;q++)
			for(int x=0;x<3;x++)
				if(a[q][x]==k) b[q][x]=true;
	}
	if((b[0][0]&&b[1][1]&&b[2][2])||(b[0][2]&&b[1][1]&&b[2][0])||(b[0][0]&&b[0][1]&&b[0][2])||(b[1][0]&&b[1][1]&&b[1][2])||(b[2][0]&&b[2][1]&&b[2][2])||(b[0][0]&&b[1][0]&&b[2][0])||(b[0][1]&&b[1][1]&&b[2][1])||(b[0][2]&&b[1][2]&&b[2][2])) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int N;
  cin >> N;
  cout << N * N * N << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);

	if(n == 1) {
		printf("1\n0\n");
		return 0;
	}
	if(n == 2) {
		printf("2\n0\n11\n");
		return 0;
	}

	std::vector<std::string> ans;
	for(int i = 0; i < n - 1; i++) ans.push_back("1" + std::string(i, '0') + "1");
	
	
	printf("%d\n", ans.size());
	for(auto v: ans) printf("%s\n", v.c_str());
	return 0;
}



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

int main() {
  int N, K;
  cin >> N >> K;
  int result = 0;
  for (int i = 0; i < N; ++i) {
    int h;
    cin >> h;
    if (K <= h) {
      ++result;
    }
  }
  cout << result << endl;
}


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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	cin >> s;
	int cnt[26];
	rep(i, 26) cnt[i] = 0;
	rep(i, s.length()) {
		cnt[s[i] - 'A']++;
	}
	
	bool flag = true;
	rep(i, 26) {
//		cout << cnt[i] << endl;
		if (not(cnt[i] == 0 or cnt[i] == 2)) {
			flag = false;
		}
	}
	
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

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

using namespace std;

long long max_gcd(vector<long long> &v)
{
    int n=v.size();
    long long pre[n+2],suff[n+2];

    pre[0]=0,suff[n-1]=0;

    for(int i=0;i<n-1;i++){
        pre[i+1]=__gcd(pre[i],v[i]);
        suff[n-i-2]=__gcd(suff[n-i-1],v[n-i-1]);
    }
    long long ans=0;
    for(int i=0;i<n;i++){
        ans=max(ans,__gcd(pre[i],suff[i]));
    }
    return ans;
}

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

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

    cout <<max_gcd(v)<<endl;

    return 0;
}


Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main()
{
    int A,B,C,i;
    cin>>A>>B>>C;
    if(A==1)
    {
        cout<<"YES"<<endl;
        return 0;
    }
    for(i=1;i<=100;i++)
    {
        if((A*i)%B==C)
        {
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 1000005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 998244353;
bool isp(string s) {
    string rev = s;
    reverse(all(s));
    return s == rev;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    if (isp(s) && isp(s.substr(0,s.size()/2)) && isp(s.substr(s.size()-s.size()/2))) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
}
    



Measured memory_bytes: 256
count = 0
until (w = gets.to_i) == 0
    count += 1
    items = []
    (n = gets.to_i).times do
        items << gets.split(',').map(&:to_i)
    end

    dp = [[0]*(w+2)]
    n.times do
        dp << Array.new(w+2, 0)
    end

    n.times do |x|
        (w+1).times do |y|
            if items[x][1] > y
                dp[x+1][y+1] = dp[x][y+1]
            else
                dp[x+1][y+1] = [ dp[x][y+1], dp[x][y+1-items[x][1]] + items[x][0] ].max
            end
        end
    end
    puts "Case #{count}:", dp[n][w+1]
    (w+2).times do |i|
        if dp[n][i] == dp[n][w+1]
            puts i-1
            break
        end
    end
end

Measured memory_bytes: 13836
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define infy 2e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
const int N = five;
int dp[N][3];
int a[N][3];
int n,k;
int f(int i,int j)
{
       if(i==n){return 0;}
       if(dp[i][j] != -1){return dp[i][j];}
       if(j==0){
              return dp[i][j] = a[i][j] + max(f(i+1,1),f(i+1,2));
       }
       if(j==1){
              return dp[i][j] = a[i][j] + max(f(i+1,0),f(i+1,2));
       }
       return dp[i][j] = a[i][j] + max(f(i+1,0),f(i+1,1));

}
int main(){
       //int n;
       cin>>n;
       memset(dp,-1,sizeof dp);
       fri(i,0,n){
              cin>>a[i][0]>>a[i][1]>>a[i][2];
       }
       cout<<max({f(0,0),f(0,1),f(0,2)})<<endl;
}


Measured memory_bytes: 7296
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main() {

    int n, p;
    scanf("%d", &n);

    int cnt = 0;
    int arr[n];

    for (int i = 0; i < n; i++) {
        scanf("%d", &p);
        arr[i] = p;
    }

    for (int j = 0; j < n - 2; j++) {
        int p1 = arr[j];
        int p2 = arr[j + 1];
        int p3 = arr[j + 2];

        if ((p1 > p2 && p2 > p3) || (p3 > p2 && p2 > p1)) {
            cnt++;
        }


    }

    printf("%d", cnt);


    return 0;
}


Measured memory_bytes: 128
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Set<Integer> num = new HashSet<>();
        for(int i=0;i<N;i++){
            int di = sc.nextInt();
            num.add(di);
        }
        System.out.println(num.size());
    }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" \
                              << "\n";

int main()
{
  vector<tuple<string, int, int>> res;
  int n;
  cin >> n;
  REP(i, n)
  {
    int score;
    string name;
    cin >> name >> score;
    res.push_back(make_tuple(name, -score, i+1));
  }
  sort(res.begin(), res.end());
  REP(i, n)
  {
    cout << get<2>(res.at(i)) << "\n";
  }
  return 0;
}


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

int main() {
    int N;
    ll r=0, g=0, b=0;
    cin >> N;
    string S;
    cin >> S;
    rep(i, N) {
        if(S[i] == 'R') {
            r++;
        } else if(S[i] == 'G') {
            g++;
        } else if(S[i] == 'B') {
            b++;
        }
    }
    ll all, cnt = 0;
    all = r * g * b;
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            if(S[i] == S[j])
                continue;
            int k = j * 2 - i;
            if(k >= N || S[k] == S[i] || S[k] == S[j])
                continue;
            ++cnt;
        }
    }
    // cout << cnt << endl;
    cout << all - cnt << endl;
}


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

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

	int s, w;
	cin >> s >> w;

	cout << (w >= s ? "unsafe\n" : "safe\n");


	return 0;
}

Measured memory_bytes: 3652
n = int(input())
active = [list(map(int,input().split())) for i in range(n)]

dp = [[0]*3 for i in range(n+1)]
for i in range(1,n+1):
    for j in range(3):
        add = active[i-1][j]
        if(j==0):
            dp[i][j] = max(dp[i-1][2]+add,dp[i-1][1]+add)
        elif(j==1):
            dp[i][j] = max(dp[i-1][0]+add,dp[i-1][2]+add)
        else:
            dp[i][j] = max(dp[i-1][0]+add,dp[i-1][1]+add)

print(max(dp[-1]))

Measured memory_bytes: 47348
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list> 
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string>
#include<fstream>
#include<set>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define ld long double
#define vi vector<int>
#define vll vector<long long>
#define pi pair<int,int>
#define pll pair<long long,long long>
#define mp make_pair
#define B begin()
#define E end()
#define S size()
#define m9 1000000007
#define endl "\n"
using namespace std;
 
 

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

ll powmod(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = powmod(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 

 
ll mul_inv(ll a, ll b) {
    ll b0 = b, t, q;
    ll x0 = 0ll, x1 = 1ll;
    if (b == 1ll) return 1ll;
    while (a > 1ll) {
        q = a / b;
        t = b, b = a % b, a = t;
        t = x0, x0 = x1 - q * x0, x1 = t;
    }
    if (x1 < 0ll) x1 += b0;
    return x1;
}
 
 
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define pin(a) for(auto x:a)cout<<x<<" ";cout<<endl
#define fck(a) cout<<a;exit(0)
#define vvll vector<vector<ll> >
#define A(b) b.begin(),b.end()
#define vpi std::vector<pll>
#include <array>
#include <stack>
#define arr2 array<ll,2>
#define arr3 array<ll,3>
#define varr2 vector<array<ll,2> >
#define varr3 vector<array<ll,3> >
//include<bits/stdc++.h>
 
 
bool fa(vll &x,vll &y){return x[0]<y[0];}
bool fa1(vll &x,vll &y){return x[1]<y[1];}
bool f1(pll &x,pll &y){return x.second>y.second;}
bool f2(pll &x,pll &y){
    return x.first>y.first;
}
 
 
bool f3(ll &x,ll &y){
    return x>y; 
    }


const ll maxn=2e5+2;





int main()
{ fastio;
//freopen("input.txt, "r", stdin); 
//freopen("output.txt", "w", stdout);
ll n,k;cin>>n>>k;
ll m=998244353;
vll dp(n+n+n,0ll);
varr2 b(k);
forl(i,0,k){
    cin>>b[i][0]>>b[i][1];
}
dp[1]=1;
dp[2]=-1;
// vll h(n+n,0ll);
for(int i=1;i<=n;i++){
    // h[i]+=h[i-1];
    dp[i]+=dp[i-1];
    dp[i]%=m;
    while(dp[i]<0){dp[i]+=m;}
    forl(t,0,k){
        dp[i+b[t][0]]+=dp[i];
        dp[i+b[t][1]+1]-=dp[i];
         dp[i+b[t][0]]%=m;
        while(dp[i+b[t][1]+1]<0){
            dp[i+b[t][1]+1]+=m;
        }
    }
//    forl(i,0,n+1){
//     cout<<dp[i]<<" ";
// }cout<<endl; 
}
// forl(i,0,n+1){
//     cout<<dp[i]<<" ";
// }
p1(dp[n]);


return 0;
}





  







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

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

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

    sort(a, a + n);
    int ans;

    while (1) {
        ans = a[0];
        for (int i = 1; i < n; i++) {
            int mod = a[i] % ans;
            if (mod > 0) {
                a[i] = mod;
            }
        }

        sort(a, a + n);
        if (ans == a[0]) {
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
  int N;  cin >> N;
  vector<long long>A(N);
  long long sum = 0;

  for(int i=0;i<N;i++){
    cin >> A.at(i);
    A.at(i) = A.at(i) % 1000000007;
    sum += A.at(i);
    sum = sum % 1000000007;
  }
  long long ans = 0;
  for(int i=0;i<N;i++){
    sum -= A.at(i);
    if(sum < 0) sum += 1000000007;
    ans += A.at(i)*sum;
    ans = ans % 1000000007;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4828
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

vector<string> normalize(string s, bool compress){
  REP(i, s.size()) if(s[i] == '/') s[i] = ' ';
  istringstream in(s);
  vector<string> ss;

  {
    string tmp_s;
    while(in >> tmp_s) ss.push_back(tmp_s);
  }

  if(compress){
    int m = 0;
    REP(i, ss.size()){
      if(ss[i] == "."){
        continue;
      }else if(ss[i] == ".."){
        m--;
        assert(m >= 0);
      }else{
        ss[m++] = ss[i];
      }
    }
    ss.resize(m);
  }
  return ss;
}

int get_idx(const vector<vector<string> > &vvs, string s){

  bool is_file = false;
  
  if(*s.rbegin() == '.') s += '/';
  if(*s.rbegin() == '/'){
    is_file = true;
    s += "index.html";
  }
  
  vector<string> vs = normalize(s, false);
      
  int m = 0;

  REP(i, vs.size()){
    if(vs[i] == ".") continue;
    else if(vs[i] == ".."){
      if(--m < 0) return -1;
    }else{
      vs[m++] = vs[i];
      bool ok = false;
      REP(j, vvs.size()){
        if(i < (int)vs.size() - 1 && m >= (int)vvs[j].size()) continue;
        
        size_t l = min(m, (int)vvs[j].size());
        vector<string> tmp_vs1 = vector<string>(vvs[j].begin(), vvs[j].begin() + l);
        vector<string> tmp_vs2 = vector<string>(vs.begin(), vs.begin() + m);
        if(tmp_vs1 == tmp_vs2) ok = true;
      }
      if(!ok) return -1;
    }
  }

  vs.resize(m);
  REP(i, vvs.size()) if(vvs[i] == vs) return i;
  if(!is_file){
    vs.push_back("index.html");
    REP(i, vvs.size()) if(vvs[i] == vs) return i;
  }
  return -1;
}

int main(){
  int N, M;
  while(cin >> N >> M && N + M > 0){
    string s,t;
    vector<vector<string> > vvs;
    REP(i, N){
      cin >> s;
      vvs.push_back(normalize(s, true));
    }
    REP(i, M){
      cin >> s >> t;
      int si = get_idx(vvs, s);
      int ti = get_idx(vvs, t);

      if(si == -1 || ti == -1) {
        cout << "not found" << endl;
      }else{
        cout << (si == ti ? "yes" : "no") << endl;
      }
    }
  }
  return 0;

}

Measured memory_bytes: 1244
#include<iostream>
#include<algorithm>
using namespace std;
int a,b,c,d;
int main(void){
  cin>>a>>b>>c>>d;
  if((abs(a-c)<=d)||(abs(a-b)<=d&&abs(b-c)<=d))cout<<"Yes";
  else cout<<"No";
  return 0;
}

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

int main()
{
	int N;
	cin >> N;
	while (N--)
	{
		string str;
		cin >> str;

		stringstream ss;
		int Min, Max;
		sort(str.begin(), str.end());
		ss << str;
		ss >> Min;
		ss.clear();
		ss.str("");
		sort(str.rbegin(), str.rend());
		ss << str;
		ss >> Max;

		cout << Max-Min << endl;
	}
}

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

vector<int64_t> memo(100, -1);

int64_t Luca(int N) {
  if (memo.at(N) !=-1) return memo.at(N);
  if (N==1) return 1;

  return memo.at(N) = Luca (N-1) + Luca (N-2);
}

int main(){
  int N;
  cin >> N;
  memo.at(0) = 2;
  memo.at(1) = 1;
  cout << Luca (N) << endl;
}
        
      

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

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007
void printbit(int u){if(u==0)cout<<0;else{int s=0,k=0;for(;0<u;u>>=1,k++)s=(s<<1)|(u&1);for(;0<k--;s>>=1)cout<<(s&1);}}

#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

template<typename T1,typename T2>
ostream& operator <<(ostream &o,const pair<T1,T2> p){o<<"("<<p.first<<":"<<p.second<<")";return o;}

int width,height;
int m,n;

int startx,starty;
int goalx,goaly;
int circle[1010][3];

double dista[1010][1010];

double dp[1010];
bool dflg[1010];

double dist(double x,double y){
    return sqrt(x*x+y*y);
}

double dist(double x1,double y1,double x2,double y2){
    return dist(x2-x1,y2-y1);
}

int main(){
    int i,j,k;
    int x,y,a,b;
    
    cin >> startx>>starty>>goalx>>goaly>>n;
    
    for (i=0;i<n;i++){
        scanf("%d%d%d",&(circle[i][0]),&(circle[i][1]),&(circle[i][2])); // x,y,r
    }
    
    circle[n][0] = startx;
    circle[n][1] = starty;n++;
    circle[n][0] = goalx;
    circle[n][1] = goaly;n++;
    
    for (i=0;i<n-1;i++){
        for (j=i+1;j<n;j++){
            dista[i][j] = max(
                dist(circle[i][0],circle[i][1],circle[j][0],circle[j][1])-circle[i][2]-circle[j][2] ,
                0.0
            );
        }
    }
    
    priority_queue<vector<double>> pq;
    pq.push(vector<double>{0.0,n-2});
    dflg[n-2] = true;
    
    double w,d;
    while (!pq.empty()){
        vector<double> v = pq.top();pq.pop();
        d = -v[0];
        int idx = (int)v[1];
        
        if (dp[idx] < d) continue; // 他のルートの方が近い
        
        if (idx == n-1) break;
        
        for (i=0;i<n;i++){
            if (idx==i) continue;
            w = d + dista[min(i,idx)][max(i,idx)];
            if (!dflg[i]){
                dflg[i] = true;
                dp[i] = w;
                pq.push(vector<double>{-w,(double)i});
            }else if (w < dp[i]){
                dp[i] = w;
                pq.push(vector<double>{-w,(double)i});
            }
        }
    }
    
    printf("%.10f\n",dp[n-1]);
    

    return 0;
}

Measured memory_bytes: 20908
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

vector<bool> seen, finished;

int pos = -1;
stack<int> hist;
vector<int> pp;

void dfs(vector<ll> &g, int v, int p)
{
  pp.push_back(v);
  seen[v] = true;
  hist.push(v);
  int nv = g[v];
  // サイクルを検出
  if (seen[nv] && !finished[nv])
  {
    pos = nv;
    return;
  }

  // 再帰的に探索
  dfs(g, nv, v);

  // サイクル検出したならば真っ直ぐに抜けていく
  if (pos != -1)
    return;
  hist.pop();
  finished[v] = true;
}

int main()
{
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for (auto &e : A)
  {
    cin >> e;
    e--;
  }
  seen.assign(N, false), finished.assign(N, false);
  dfs(A, 0, -1);
  vector<int> cycle;
  while (!hist.empty())
  {
    int t = hist.top();
    cycle.push_back(t);
    hist.pop();
    if (t == pos)
      break;
  }
  reverse(cycle.begin(), cycle.end());
  int index = 0;
  for (int i = 0; i < pp.size(); ++i)
  {
    if (pp[i] == cycle[0])
    {
      index = i;
      break;
    }
  }
  if (index > K)
  {
    cout << pp[K] + 1 << endl;
  }
  else
  {
    K -= index;
    K %= cycle.size();
    cout << cycle[K] + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 19068
import std.stdio,std.string,std.conv;

int main()
{
	string s;
	while((s = readln.chomp) != "-1 -1 -1")
	{
		string[] _s = s.split(" ");
		int hours = _s[0].to!int;
		int minutes = _s[1].to!int;
		int seconds = _s[2].to!int;
		int max_hours = 2;
		int temp = max_hours*60*60 - hours*60*60 - minutes*60 - seconds;
		int ans_seconds = temp % 60;
		int ans_minutes = temp/60;
		int ans_hours = ans_minutes/60;
		ans_minutes -= ans_hours*60;

		writefln("%02d:%02d:%02d",ans_hours,ans_minutes,ans_seconds);

		temp *= 3;
		ans_seconds = temp % 60;
		ans_minutes = temp/60;
		ans_hours = ans_minutes/60;
		ans_minutes -= ans_hours*60;

		writefln("%02d:%02d:%02d",ans_hours,ans_minutes,ans_seconds);

	}
	return 0;
}

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

typedef long long ll;
const int MOD = 1000000007;

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int cnt = 0;
  int flag = 0;
  for(int i = 0; i < S.size(); i++){
    if(S[i] == 'A'){
      flag = 1;
    }else if(S[i] == 'B' && flag == 1){
      flag = 2;
    }else if(S[i] == 'C' && flag == 2){
      cnt++;
      flag = 0;
    }else{
      flag = 0;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
N = int(input())
A = [0] + [int(input()) for _ in range(N)]

x = 1
visited = set([1])
answer = 0

while True:
    x = A[x]
    if x in visited:
        answer = -1
        break
    visited.add(x)
    answer += 1
    if x == 2:
        break

print(answer)

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

N = INT()
st = [LIST() for _ in range(N)]
X = input()
S = []
T = []
for s, t in st:
	S.append(s)
	T.append(int(t))

i = S.index(X)+1
print(sum(T[i:]))


Measured memory_bytes: 5200
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define HOURS   (3600)
#define MINUTES   (60)

int main()
{
    int S;
    cin >> S;
    
    cout << S / HOURS << ":"
         << S % HOURS / MINUTES << ":"
         << S % MINUTES << endl;
    
    return 0;
}


Measured memory_bytes: 3092
#include <cstdio>
#include <vector>
#include <algorithm>
#include <bitset>

struct edge
{
  short from;
  short to;
  int cost;
};

constexpr long long INF = 1e18;
long long dist[1000];
std::bitset<1000> neg;

int main()
{
  int n, m;
  scanf("%d%d", &n, &m);

  std::vector<edge> edges;
  for (int i = 0; i < m; ++i)
  {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    edges.emplace_back(edge{a - 1, b - 1, -c});
  }

  std::fill(dist + 1, dist + n, INF);
  for (int i = 0; i < n - 1; ++i)
  {
    for (edge& e : edges)
    {
      if (dist[e.from] == INF) continue;
      if (dist[e.to] > dist[e.from] + (long long)e.cost) dist[e.to] = dist[e.from] + (long long)e.cost;
    }
  }
  for (int i = 0; i < n; ++i)
  {
    for (edge& e : edges)
    {
      if (dist[e.from] == INF) continue;
      if (neg[e.from] || dist[e.to] > dist[e.from] + (long long)e.cost)
      {
        neg[e.to] = true;
      }
    }
  }
  if (neg[n - 1])
  {
    puts("inf");
  }
  else
  {
    printf("%lld\n", -dist[n - 1]);
  }
  return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, k;
    cin >> n >> k;
    vi cnt;
    cnt.pb(k);
    while (k>1) {
        k = (k + 1) / 2;
        cnt.pb(k);
    }
    double ans = 0;
    int t = 0, r = 1;
    rep1r(i, n) {
        while (i < cnt[t]) {
            ++t;
            r *= 2;
        }
        ans += 1.0 / r;
    }
    printf("%.10f\n", ans/n);
    return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <map>
using namespace std;
int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i = 0; i < N; ++i) cin >> A[i];
  map<int,int> C;
  for(int i = 0; i < N; ++i){
    for(int j = -1; j <= 1; ++j){
      ++C[A[i]+j];
    }
  }
  int count = 0;
  for(map<int,int>::iterator itr = C.begin(); itr != C.end(); ++itr){
    count = max(count,itr->second);
  }
  cout << count << endl;
  return 0;
}


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

int main(){
  vector<long long> sum(1000001,0);
  for(int i=0;i<=1000;i++){
    for(int j=0;j<=1000;j++){
      sum[i+j]++;
    }
  }

  int n;
  while(cin >> n){
    long long ans = 0;
    for(int i=0;i<=n;i++){
      ans += sum[i] * sum[n-i];
    }
    cout << ans << endl;
  }
}
      

Measured memory_bytes: 8792
#include<bits/stdc++.h>
using namespace std;
double w,h,x,y;
int main(){
	cin>>w>>h>>x>>y;
	printf("%7.5f",w*h/2);
	if(w/2==x&&h/2==y) cout<<" "<<1;
	else cout<<" "<<0;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
	ll n,m,l;
	cin>>n>>m>>l;
	vvl mat(n,vl(n)),path(n,vl(n));
	for(ll i=0;i<m;i++){
		ll u,v,c;
		cin>>u>>v>>c;
		u--;v--;
		mat[u][v]=c;
		mat[v][u]=c;
	}
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n;j++){
			if(i!=j && mat[i][j]==0) mat[i][j]=INT_MAX;
		}
	}
	for(ll k=0;k<n;k++){
		for(ll i=0;i<n;i++){
			for(ll j=0;j<n;j++){
				if(mat[i][k]+mat[k][j]<mat[i][j]){
					mat[i][j]=mat[i][k]+mat[k][j];
				}
			}
		}
	}
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n;j++){
			if(mat[i][j]<=l) path[i][j]=(ll)1;
			else path[i][j]=INT_MAX;
		}
	}
	for(ll k=0;k<n;k++){
		for(ll i=0;i<n;i++){
			for(ll j=0;j<n;j++){
				if(path[i][k]+path[k][j]<path[i][j]){
					path[i][j]=path[i][k]+path[k][j];
				}
			}
		}
	}
	ll q;
	cin>>q;
	while(q--){
		ll u,v;
		cin>>u>>v;
		u--;v--;
		if(path[u][v]==INT_MAX) cout<<"-1"<<endl;
		else cout<<path[u][v]-1<<endl;
	}
}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}



Measured memory_bytes: 1920
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

struct edge{
    int from, to;
    lint cost;
};

int n, m;
lint p;
vector<edge> edges;
vector<lint> cost;

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

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

bool bellman_ford(int start, int goal){
    cost.resize(n);
    fill(cost.begin(), cost.end(), -LLINF);
    cost[start] = 0;
    for(int i = 0 ; i < n * 2 ; ++i){
        for(int j = 0 ; j < m ; ++j){
            edge now = edges[j];
            if(cost[now.from] != -LLINF && cost[now.to] < cost[now.from] + now.cost){
                cost[now.to] = cost[now.from] + now.cost;
                if(i >= n - 1 && now.to == goal){
                    return false;
                }
                if(i >= n - 1){
                    cost[now.to] = LLINF;
                }
            }
        }
    }
    return true;
}

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

    cin >> n >> m >> p;

    rep(i, m){
        int a, b;
        lint c;
        cin >> a >> b >> c;
        edges.push_back({--a, --b, c - p});
    }

    if(bellman_ford(0, n - 1)){
        cout << max(cost[n - 1], 0LL) << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define N 100010
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
struct Info{int nu,ne;}a[N*2];
int b[N],num,li[N],v[N],va[N],d[N],n,f[N],x,y,sum;
void jb(int x,int y){a[++num].nu=y;a[num].ne=b[x];b[x]=num;}
void dfs(int x,int fa){
	f[x]=fa;
	for (int y=b[x];y;y=a[y].ne)if (a[y].nu!=fa){dfs(a[y].nu,x);d[x]++;}
}
bool comp(const int &a,const int &b){return a<b;}
int main(){
	cin>>n;
	for (int i=1;i<n;i++){
		read(x);read(y);jb(x,y);jb(y,x);
	}
	dfs(1,0);
	for (int i=1;i<=n;i++)read(v[i]);
	sort(v+1,v+n+1,comp);
	for (int i=1;i<n;i++)sum+=v[i];
	int l=1,r=0;
	for (int i=1;i<=n;i++)if (d[i]==0)li[++r]=i;
	while (l<=r){
		va[li[l]]=v[l];
		d[f[li[l]]]--;if (d[f[li[l]]]==0)li[++r]=f[li[l]];
		l++;
	}
	cout<<sum<<endl;
	for (int i=1;i<=n;i++)cout<<va[i]<<' ';cout<<endl;
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(void) {
    int N, A[15], B, C[15], i, j;
    for (i=0; i<9; i++) scanf("%d", &A[i]);
    scanf("%d", &N);
    for (i=0; i<9; i++) C[i]=0;
    for (i=0; i<N; i++) {
        scanf("%d", &B);
        for (j=0; j<9; j++) {
            if (B==A[j]) C[j]=1;
        }
    }
    if (C[0]*C[1]*C[2]==1 || C[3]*C[4]*C[5]==1 || C[6]*C[7]*C[8]==1 || C[0]*C[4]*C[8]==1 || C[2]*C[4]*C[6]==1 || C[0]*C[3]*C[6]==1 || C[1]*C[4]*C[7]==1 || C[2]*C[5]*C[8]==1) printf("Yes");
    else printf("No");
    /*
    for (i=0; i<9; i++) {
        printf("%d", C[i]);
        if (i%3!=2) printf(" ");
        else printf("\n");
    }
    */
    return 0;
}


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

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

def sol(arr, n):

    arr.sort()

    count = 0

    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            for k in range(j + 1, n):

                if (arr[i] != arr[j]) and (arr[i] != arr[k]) and (arr[k] != arr[j]) and ( arr[i] + arr[j] > arr[k] and arr[i] + arr[k] > arr[j] and arr[k] + arr[j] > arr[i] ):
                    count += 1

    return count


print (sol(arr, n))


Measured memory_bytes: 9204