akhauriyash/Code-Regression huggingface dataset:
// --------------
// Tejas Pandey  |
// 11 - 04 - 20  |
// Atcoder BC 162|
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

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

int main (void)
{
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  //cin >> t;
  while(t--){
  	//cout << "Case :" << c - t << ": ";
  	int k;
  	cin >> k;
  	ll ans = 0;
  	for(int i = 1;i <= k;i++)
  		for(int j = 1;j <= k;j++)
  			for(int l = 1;l <= k;l++){
  				ll f = gcd(i,j);
  				f = gcd(f,l);
  				ans += f;
  			}
  		cout << ans;
  }
  return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,i,j,a[2][101],p=0,m=0,max,sum;
    scanf("%d",&n);
    for(i=0;i<2;i++)
    for(j=0;j<n;j++)
    {
        scanf("%d",&a[i][j]);
    }
    max=0;
    for(j=0;j<n;j++)
    {
        max=max+a[1][j];
    }
    max=max+a[0][0];
    while(p<n)
    {
        sum=0;
        for(j=0;j<=m;j++)
        {
            sum=sum+a[0][j];
        }
    for(j=m;j<n;j++)
    {
        sum=sum+a[1][j];
    }
    if(max<sum)
    {
        max=sum;
    }
        m++;
        p++;

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


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,y;cin>>n>>y;
  for(int i=0;i<y/10000+1;i++){
    int q=y-10000*i;
    for(int j=0;j<q/5000+1;j++){
      if(i*10000+j*5000+(n-i-j)*1000==y){
        cout<<i<<" "<<j<<" "<<n-i-j<<endl;
        return 0;
      }
    }
  }
  cout<<-1<<" "<<-1<<" "<<-1<<endl;
}
    

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <stack>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <sstream>
#include <iomanip>
using namespace std;


#define int int64_t
#define vi vector<int>
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define all(x) (x).begin(), (x).end()
#define vii vector< vector<int> >
#define rip(dp, n, m) vector< vector<int> > dp(n, vector<int>(m,0))
#define ff first
#define ss second
#define pii pair<int64_t, int64_t>
#define miv map<int, vector<int> >
#define mp make_pair
#define pb push_back
#define prr(x) cout << (#x) <<'	' << (x) << endl
#define pr(x) cout  << (x) << endl
#define f(i,n) for(i=0;i<n;i++)
#define pqb priority_queue<int>
#define pqs priority_queue<int,vi,greater<int> >
#define setbits(x)  __builtin_popcountll(x)
#define zrobits(x)  __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x) int x; cin>>x; while(x--)
#define FIO  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int32_t main()
{
    FIO;
    int i, j, m, k, l, t;
   cin >> t >> l;
   l = l*l;
   k=0;
   while(t--)
   {
       int x , y; cin >> x >> y;
       x = (x*x)+(y*y);
       if(l>=x)k++;
       
   }
//    if(n>=30) cout << "Yes";
//    else cout << "No";
cout << k;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main(void){
    int w; //今月の使用水量
    
    while(true){
        cin >> w;
        if(w == -1) break;

        int waterbill; //今月の水道料金
        int base = 1150; //基本料金
        if(w <= 10)
            waterbill = base;
        if(w > 10){
            if(w < 20)
                waterbill = base + (w % 10) * 125;
            else if(w == 20)
                waterbill = base + 1250;
            else if(20 < w && w < 30)
                waterbill = base + 1250 + (w % 10) * 140;
            else if(w == 30)
                waterbill = base + 1250 + 1400;
            else
                waterbill = base + 1250 + 1400 + (w - 30) * 160; 
        }

        int save = 4280 - waterbill;  //節約できた金額
        cout << save << endl;
    }
}



Measured memory_bytes: 2988
n=int(input())
if(n>=400 and n<=599):
    print(8)
elif(n>=600 and n<=799):
    print(7)
elif(n>=800 and n<=999):
    print(6)
elif(n>=1000 and n<=1199):
    print(5)
elif(n>=1200 and n<=1399):
    print(4)
elif(n>=1400 and n<=1599):
    print(3)
elif(n>=1600 and n<=1799):
    print(2)
else:
    print(1)
    

Measured memory_bytes: 61912
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	N := getStdinInt()
	p := getStdinIntArr()
	pcopy := make([]int, N)
	for i := 0; i < N; i++ {
		pcopy[i] = p[i]
	}
	sort.Ints(p)

	dif := 0
	for i := 0; i < N; i++ {
		if pcopy[i] != p[i] {
			dif++
		}
	}
	if dif == 0 || dif == 2 {
		fmt.Printf("YES\n")
	} else {
		fmt.Printf("NO\n")
	}
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt4() (int, int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2], list[3]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2192
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	// マップのキー
	// 0はじまり
	private final static String ANSWER1 = "answer1";
	// 1はじまり
	private final static String ANSWER2 = "answer2";

	public static void main(String[] args) {
		// 1. 入力データの処理
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		sc.close();
		int sLength = input.length();

		// 2. 正解となりうる2通りの文字列を作成
		// 決定因子:文字列の長さ
		Map<String, String> answerMap = new HashMap<>();
		answerMap = generateAnswer(sLength);

		// 3. キョリを計算し、少ない方とのキョリを出力
		printAnswer(input, answerMap);

	}

	/**
	 * キョリが小さい方を出力
	 * @param answerMap
	 */
	private static void printAnswer(String input, Map<String, String> answerMap) {
		// ANSWER1とのキョリ
		String result1 = answerMap.get(ANSWER1);
		int dis1 = calcDistance(input, result1);
		String result2 = answerMap.get(ANSWER2);
		int dis2 = calcDistance(input, result2);
		// 比較し、出力
		if(dis1 >= dis2) {
			System.out.println(dis2);
			return;
		} else {
			System.out.println(dis1);
			return;
		}
	}

	/**
	 * キョリの計算
	 * 想定:inputとanswerChoiceは同じ長さ
	 * @param answerChoice
	 * @return
	 */
	private static int calcDistance(String input, String answerChoice) {
		int distance = 0;
		for(int i = 0; i < input.length(); i++) {
			if(input.charAt(i) != answerChoice.charAt(i)) {
				distance += 1;
			}
		}
		return distance;
	}

	/**
	 * 正解となる文字列を格納するマップ作成
	 * @param length
	 * @return
	 */
	private static Map<String, String> generateAnswer(int length) {
		Map<String, String> result = new HashMap<>();
		StringBuilder answer1 = new StringBuilder();
		StringBuilder answer2 = new StringBuilder();
		for(int i = 0; i < length; i++) {
			if(i % 2 == 0) {
				answer1.append("0");
				answer2.append("1");
			} else {
				answer1.append("1");
				answer2.append("0");
			}
		}

		result.put(ANSWER1, answer1.toString());
		result.put(ANSWER2, answer2.toString());
		return result;
	}

}


Measured memory_bytes: 26640
import collections 
N,X,Y = map(int,input().split())
d = [[0]*(N+1) for _ in range(N+1)]
for i in range(1,N):#i => j
    for j in range(i+1,N+1):
        if(i>=Y or j<=X):
            d[i][j] = j-i
        elif(i<=X and j>=Y):
            d[i][j] = (X-i)+1+(j-Y)
        else:
            a_path = j-i
            b_path = abs(X-i)+1+abs(Y-j)
            d[i][j] = min(a_path,b_path)

ans = [0]
for i in range(N+1):
    ans += d[i]
c = collections.Counter(ans)
for k in range(1,N): 
    print(c[k])

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

const int N = 200005;
const long long inf = 1e9;

vector <int> G[N];
int n, m, d[N], a[N], b[N];
long long f[N][2];
int cnt;

int mex(int mask) {
	int r = 0; for (int i = 0; i < 3; ++i) if (mask & (1<<i)) ++r; return r >= 2;
}

void dfs(int u) {
	if (G[u].size() == 0) {
		if (b[u] == -1) f[u][0] = 0, f[u][1] = 1;
		else {
			if (b[u]) f[u][1] = 1, f[u][0] = inf;
			else f[u][0] = 0, f[u][1] = inf;
		}
		return;
	}
	f[u][0] = f[u][1] = inf;
	for (int v: G[u]) dfs(v);
	for (int mask = 0; mask < 8; ++mask) {
		f[u][mex(mask)] = min(f[u][mex(mask)], f[G[u][0]][mask >> 0 & 1] + f[G[u][1]][mask >> 1 & 1] + f[G[u][2]][mask >> 2 & 1]);
	}
}

bool check(int x) {
	memset(b, -1, sizeof b); int cnt1 = 0;
	for (int i = 1; i <= n; ++i) if (a[i]) { b[i] = a[i] >= x; if (a[i] >= x) ++cnt1; }
	for (int i = 1; i <= n - m; ++i) if (d[i] >= x) ++cnt1; 
	dfs(cnt);
	return f[cnt][1] <= cnt1;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= m; ++i) { int p; cin >> d[i] >> p; a[p] = d[i]; }
	for (int i = 1; i <= n - m; ++i) cin >> d[i];

	int cur = n; cnt = n;
	vector<int> nw, nxt;
	for (int i = 1; i <= n; ++i) nw.push_back(i);
	while(cur > 1) {
		for (int i = 0; i < (int)nw.size(); i += 3) {
			if (i > (int)nw.size() - 3) continue;
			++cnt; G[cnt].push_back(nw[i]); G[cnt].push_back(nw[i + 1]); G[cnt].push_back(nw[i + 2]);
			nxt.push_back(cnt);
		}
		reverse(nxt.begin(), nxt.end());
		for (int i = (int)nw.size()-1; i >= 0; --i) {
			if (i % 3 == 2) break;
 			nxt.push_back(nw[i]);
		}
		reverse(nxt.begin(), nxt.end());
		nw = nxt;
		nxt.clear();
		cur = (int)nw.size();
	}
	
	int l = 0, r = 1e9;
	while(l < r) {
		int mid = ((l + r + 1) >> 1);
		if (check(mid)) l = mid; else r = mid - 1;
	}
	cout << l << endl;
}

Measured memory_bytes: 13552
def rot_n(c, n):
    if 'a' <= c and c <= 'z':
        return chr((ord(c) - ord('a') + int(n)) % 26 + ord('a'))

    if 'A' <= c and c <= 'Z':
        return chr((ord(c) - ord('A') + int(n)) % 26 + ord('A'))

    return c

def rot(s, n):
    g = (rot_n(c, n) for c in s)
    return ''.join(g)


N = int(input())
s = input()
print(rot(s, N))

Measured memory_bytes: 38896
#include <stdio.h>

int main(void){
  int m,f,r;

  while (1) {
    scanf("%d %d %d", &m, &f, &r);
    if (m == -1 && f == -1 && r == -1) break;
    if      (m == -1 || f == -1) printf("F\n");
    else if (m + f >= 80)        printf("A\n");
    else if (m + f >= 65)        printf("B\n");
    else if (m + f >= 50)        printf("C\n");
    else if (m + f >= 30) (r >= 50) ?
                                 printf("C\n"):
                                 printf("D\n");
    else                         printf("F\n");
  }

  return (0);
}



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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

class BIT {
    static constexpr auto C = 1L << 18;
    static constexpr auto I = -1L;

   public:
    BIT() : values_(C + 1, I) {}

    void set(int64_t idx, int64_t value) {
        while (idx <= C) {
            values_[idx] = max(values_[idx], value);
            idx += (idx & -idx);
        }
    }

    // [1, idx]
    int64_t query(int64_t idx) {
        int64_t value = I;
        while (idx > 0) {
            value = max(values_[idx], value);
            idx -= (idx & -idx);
        }
        return value;
    }

   private:
    vector<int64_t> values_;
};

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

    vector<int64_t> a(n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    vector<int64_t> l(n);
    BIT bit;
    for (auto i : irange(0L, n)) {
        l[i] = bit.query(a[i]);
        bit.set(a[i], i);
    }

    vector<int64_t> r(n);
    bit = BIT();
    for (auto i : irange(0L, n) | reversed) {
        r[i] = n - 1 - bit.query(a[i]);
        bit.set(a[i], n - 1 - i);
    }

    int64_t ans = 0;
    for (auto i : irange(0L, n)) {
        // cerr << l[i] << " " << r[i] << endl;
        ans += a[i] * (r[i] - i) * (i - l[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 9088
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

int main(){
  int n, a, b;
  while(scanf("%d%d%d", &n, &a, &b) && n+a+b){
    bool f[2000000] = {};
    f[0] = 1;
    rep(i, n+1){
      if(!f[i]) continue;
      f[i+a] = 1;
      f[i+b] = 1;
    }

    //    puts("error\n");
    int res = 0;
    rep(i, n+1) if(!f[i]) res++;

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

Measured memory_bytes: 3148
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

int N, K;
vector<int> A;

void simulate() {
  int RUI[N + 1];
  memset(RUI, 0, sizeof(RUI));

  for (int i = 0; i < N; ++i) {
    int a = A[i];

    int left = max(0, i - a);
    int right = min(N - 1, i + a);

    RUI[left]++;
    RUI[right + 1]--;
  }

  int sum = 0;
  for (int i = 0; i < N; ++i) {
    sum += RUI[i];
    A[i] = sum;
  }
}

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

  int a;
  for (int i = 0; i < N; ++i) {
    cin >> a;
    A.push_back(a);
  }

  for (int i = 0; i < min(100, K); ++i) {
    simulate();
  }

  for (int i = 0; i < N; ++i) {
    cout << A[i];

    if (i != N - 1) {
      cout << " ";
    }
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 4820
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define MOD 998244353
//#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int*makeSA(char*s,int len){
	len++;
	int*SAidx=calloc(len,sizeof(int));
	int*ord=calloc(len,sizeof(int));
	//1文字目
	int cnt1[256]={},cnt2[256]={};
	for(int i=0;i<len;i++)cnt1[s[i]+1]++,cnt2[s[i]+1]|=1;
	for(int i=1;i<256;i++)cnt1[i]+=cnt1[i-1],cnt2[i]+=cnt2[i-1];
	for(int i=0;i<len;i++)SAidx[cnt1[s[i]]++]=i,ord[i]=cnt2[s[i]];
	
	int*cnt=calloc(len+1,sizeof(int));
	int*idx2=calloc(len,sizeof(int));
	int*temp=calloc(len,sizeof(int));
	for(int k=1;k<len;k*=2){
		//2*k文字まで見る
		for(int i=0;i<len;i++)cnt[i]=0;
		for(int i=0;i<len;i++)cnt[ord[i]+1]++;
		for(int i=1;i<len;i++)cnt[i]+=cnt[i-1];
		for(int i=0;i<len;i++)idx2[cnt[ord[(SAidx[i]-k+len)%len]]++]=(SAidx[i]-k+len)%len;
		temp[idx2[0]]=0;
		for(int i=1;i<len;i++)temp[idx2[i]]=temp[idx2[i-1]]+(ord[idx2[i-1]]!=ord[idx2[i]]||ord[(idx2[i-1]+k)%len]!=ord[(idx2[i]+k)%len]);
		for(int i=0;i<len;i++)ord[i]=temp[i],SAidx[i]=idx2[i];
	}
	free(temp);
	free(idx2);
	free(cnt);
	free(ord);
	return SAidx+1;
}

char t[10010];
char s[10010];
int main(){
	int n,k;
	scanf("%d%d%s",&n,&k,t);
	if(k>15)k=15;
	rep(i,0,n)s[i]=t[n-1-i];

	while(k--){
		rep(i,0,n)t[i]=s[n-1-i];
		rep(i,0,n)t[n+i]=s[i];
		int*p=makeSA(t,2*n);
		int mi=0;
		while(p[mi]>=n)mi++;
//		rep(i,0,2*n)printf("%d ",p[i]);puts("");
		rep(i,0,n)s[i]=t[p[mi]+i];
	}
	puts(s);
}

Measured memory_bytes: 944
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a[4];
	cin >> a[0] >> a[1] >> a[2] >> a[3];
	sort(a, a + 4);
	if (a[0] == a[1] & a[2] == a[3]) cout << "yes" << endl;
	else cout << "no" << endl;
}

Measured memory_bytes: 3120
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n, m, sn = 0;
		n = sc.nextLong();
		m = n;
		while(m > 0) {
			sn += m % 10;
			m /= 10;
		}
		System.out.println(n % sn == 0 ? "Yes" : "No");
	}
}

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

int main()
{
    string S;
    string T = "CODEFESTIVAL2016";
    int ans = 0;
    cin >> S;
    for(int i = 0; i < 16; i++) {
        if(S[i] != T[i]) ans++;
    }

    cout << ans << endl;

    return (0);
}


Measured memory_bytes: 256
s = input()
if s[0] == "R" and s[1] == "R" and s[2] == "R":
    print(3)
elif s[1] == "R":
    if s[0] == "R" or s[2] == "R":
        print(2)
    else:
        print(1)
elif s[0] == "R" or s[2] == "R":
    print(1)
else:
    print(0)

Measured memory_bytes: 9056
x1,y1,x2,y2 = map(int,input().split())


c = x2 - x1
d = y2 - y1
x3 = x2 - d
y3 = y2 + c
x4 = x3 - c
y4 = y3 - d
print(x3,y3,x4,y4)

Measured memory_bytes: 9060
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    vector<int> deg(n, 0);
    vector<int> dist(n, 0);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        deg[b]++;
    }
    queue<int> q;
    rep(i, n){
        if(deg[i] ==0 and g[i].size()!=0) q.push(i);
    }
    int ans = 0;
    while (not q.empty()){
        int v = q.front();q.pop();
        for (int nv : g[v]){
            deg[nv]--;
            if (deg[nv] == 0) {
                dist[nv] = dist[v]+1;
                q.push(nv);
            }
        }
    }
    rep(i, n) ans = max(ans, dist[i]);
    cout << ans << endl;
}

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

using namespace std;

int main() {
  string N;
  cin >> N;
  if(N[0] == N[1] && N[1] == N[2]) {
    cout << "Yes" << endl;
  } else if(N[1] == N[2] && N[2] == N[3]) {
    cout << "Yes" << endl;
  } else if(N[0] == N[1] && N[1] == N[2] && N[2] == N[3]) {
    cout << "Yes" << endl;
  } else {
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

string s, t;

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

	int r; cin >> r;
	cout << r * r << endl;



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K; cin >> N >> K;
  string S; cin >> S;
  int cnt = 0;
  vector<char> v;
  v.push_back(S[0]);
  for (int i = 1; i < N; i++) {
    if (v.back() != S[i]) v.push_back(S[i]);
  }
  
  int ans = N - max(1, (int)v.size() - 2 * K);
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int find_all(string str, string subStr) {
    vector<int> result;
    int subStrSize = subStr.size();
    int pos = str.find(subStr);
    
    int cnt=0;
    while (pos != -1) {
        result.push_back(pos);
        pos = str.find(subStr, pos + subStrSize);
        cnt++;
    }
 
    return cnt;
}
int main(){
    string n,s;
    cin >> n;
    cin >> s;
    string subStr = "ABC";
    cout << find_all(s,subStr) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

//nC3だとO(N^3)になって間に合わない
//そういう時には3つのうち2つを固定して考える


int main(){
    int n;
    cin >> n;
    vector<ll> l(n);
    rep(i,n) cin >> l.at(i);
    sort(all(l));

    //aを固定してb,cを尺取法
    //長さ昇順の数直線で ・・・a・・・b・・・c・・・となる
    //初期設定としてbをaの場所から、cをbの場所から始める
    ll res=0;
    rep(a,n){
        int c=a;
        for(int b=a+1; b<n; b++){
            while(c<n && l[c] < l[a] + l[b]) ++c;
            res += c-(b+1);
        }
    }
    cout << res << endl;



}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int64 cnt[10][10];

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int y = i % 10, x;
    for (x = i; x >= 10; x /= 10);
    cnt[x][y]++;
  }
  int64 ret = 0;
  for (int i = 1; i < 10; ++i) {
    for (int j = 1; j < 10; ++j) {
      ret += cnt[i][j] * cnt[j][i];
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import collections

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)

    a = collections.Counter(a)
    return a

def main():
    N = int(input())
    
    fct = prime_factorize(N)
    ans = 0
    for i_fct in fct:
        m = fct[i_fct]
        if m == 1:
            ans += 1
            continue

        sum = 0
        add = 1
        while True:
            sum += add
            if sum > m:
                break
            add += 1
            ans += 1

    print(ans)
    return


if __name__ == "__main__":
    main()
    sys.exit(0)

Measured memory_bytes: 65984
var w,h,i:Longint;s:String;
begin
	readln(h,w);
	for i:=1 to w+2 do write('#');
	writeln('');
	for i:=1 to h do begin
		write('#');
		readln(s);
		write(s);
		writeln('#');
	end;
	for i:=1 to w+2 do write('#');
end.


Measured memory_bytes: 128
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using Graph = std::vector<std::vector<int> >;
const int INF = 1e17;
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	int sum=0;
	for(int x=1;x<=n;x++) {
		if(x%3==0 || x%5==0) continue;
		sum+=x;
	}
	print(sum);
	return 0;
}


Measured memory_bytes: 3636
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char in[1100000];
int dp[1100000][2];
int main(){
	scanf("%s",in);
	int n=strlen(in);
	for(int i=0;i<=n;i++)for(int j=0;j<2;j++)dp[i][j]=mod;
	dp[0][0]=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<2;j++){
			int cur=in[n-1-i]-'0'+j;
			dp[i+1][0]=min(dp[i+1][0],dp[i][j]+cur);
			dp[i+1][1]=min(dp[i+1][1],dp[i][j]+10-cur);
		}
	}
	int ret=min(dp[n][0],dp[n][1]+1);
	printf("%d\n",ret);
}

Measured memory_bytes: 9344
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int[] x=new int[100001];
		int n=sc.nextInt();
		for(int i=0;i<n;i++){
			int m=sc.nextInt();
			if(m+1<100002&&m-1>-1){
			x[m-1]++;
			x[m+1]++;
			}
			x[m]++;
		}
		int s = 0;
		for(int i=0;i<100001;i++){
			if(x[i]>s){
				s = x[i];
			}
		}
		System.out.print(s);
	}
}

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

int main(){
	int n, q;
	scanf("%d%d", &n, &q);
	vector<priority_queue<int> > pque(n);
	for(int i = 0; i < q; i++) {
		int id, t;
		scanf("%d%d", &id, &t);
		if(id == 0) {
			int x;
			scanf("%d", &x);
			pque[t].push(x);
		}
		if(id == 1) {
			if(!pque[t].empty())
				printf("%d\n", pque[t].top());
		}
		if(id == 2) {
			if(!pque[t].empty()) {
				pque[t].top();
				pque[t].pop();
			}
		}
	}
}



Measured memory_bytes: 4212
def gcd(x, y):
    if y == 0:
        return x
    while y != 0:
        x, y = y, x % y
    return x
class segment_gcd():
    def __init__(self,A,n,num):
        #####単位元######
        self.ide_ele = 0
        self.seg = [self.ide_ele] * 2 * num
        self.num = num
        # set_val
        for i in range(n):
            self.seg[i +num -1] = A[i]
            # built
        for i in range(num - 2, -1, -1):
            self.seg[i] = gcd(self.seg[2*i +1], self.seg[2*i +2])

    def update(self,k, x):
        k += num - 1
        self.seg[k] = x
        while k:
            k = (k - 1)//2
            self.seg[k] = gcd(self.seg[k*2 +1], self.seg[k*2 +2])

    def query(self,p, q):
        num = self.num; ide_ele = self.ide_ele
        if q <= p:
            return self.ide_ele
        p += num - 1
        q += num - 2
        res = ide_ele
        while q - p > 1:
            if p & 1 == 0:
                res = gcd(res, self.seg[p])
            if q & 1 == 1:
                res = gcd(res, self.seg[q])
                q -= 1
            p = p // 2
            q = (q - 1) // 2
        if p == q:
            res = gcd(res, self.seg[p])
        else:
            res = gcd(gcd(res, self.seg[p]), self.seg[q])
        return res

def examC():
    N = I()
    A = LI()
    # num:n以上の最小の2のべき乗
    num = 2 ** (N - 1).bit_length()
    Seggcd = segment_gcd(A,N,num)
    ans = -1
    for i in range(N):
        ans = max(ans, gcd(Seggcd.query(0, i), Seggcd.query(i + 1, N)))
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()


Measured memory_bytes: 65240
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define int long long int
using namespace std;

void desperate_optimization(bool submitting=true,int precision=10)
{
  if(!submitting) return;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(precision);
}
int memo[3005][3005][2];
int arr[3005];
int dpfunction(int i,int j,int player)
{
  if(memo[i][j][player]!=-1) return memo[i][j][player];
  if(i==j) return memo[i][j][player]=((player==1)*2-1)*arr[i];
  if(player)
    return memo[i][j][player]=max(arr[i]+dpfunction(i+1,j,1-player),arr[j]+dpfunction(i,j-1,1-player));
  else
    return memo[i][j][player]=min(-arr[i]+dpfunction(i+1,j,1-player),-arr[j]+dpfunction(i,j-1,1-player));
}
int32_t main()
{
  //freopen("input.txt","r",stdin);
  desperate_optimization(true);
  memset(memo,-1,sizeof(memo));
  int n;
  cin>>n;
  for(int i=0;i<n;i++) cin>>arr[i];
  cout<<dpfunction(0,n-1,1);


  return 0;
}


Measured memory_bytes: 141568
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <numeric>
#include <ctype.h>
using namespace std;
void print(vector<int> v);
int main(void){
    int N, num;
    vector<int> v;
    cin >> N;
    for(int i = 0; i < N; i++){
	cin >> num;
	v.push_back(num);
    }
    for(int i = 1; i < N; i++){
	print(v);
	int x = v[i];
	int j = i - 1;
	while(j >= 0 && v[j] > x){
	    v[j + 1] = v[j];
	    j--;
	    v[j + 1] = x;
	}
    }
    print(v);
}

void print(vector<int> v){
    for(int i = 0; i < v.size(); i++){
	cout << v[i];
	if(i != v.size() - 1) cout << ' ';
    }
    cout << endl;
}



Measured memory_bytes: 3124
use std::io::stdin;

fn main(){
    let (n, k) = {
        let nk: Vec<usize> = getvec();
        (nk[0], nk[1])
    };
    let xys = {
        let mut result: Vec<(usize, usize)> = Vec::new();
        for _ in 0..n { result.push(getpair()) }
        result
    };
    let mut ans = highest_for(k, &xys);

    for i in 1..31 {
        if (k & (1<<i)) == 0 { continue; }
        let l = ((k>>(i+1))<<(i+1)) + ((1i64<<i) - 1) as usize;
        ans = std::cmp::max(ans, highest_for(l, &xys));
    }
    println!("{}", ans);
}

fn highest_for(k: usize, xys: &Vec<(usize, usize)>) -> usize {
    let mut result = 0;
    for &(x, y) in xys {
        if (x & !k) == 0 {
            result += y;
        }
    }
    result
}

#[allow(dead_code)]
fn getline() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn getvec<T: std::str::FromStr>() -> Vec<T>{
    let line = getline();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn getpair() -> (usize, usize){
    let nm = getvec();
    (nm[0], nm[1])
}

Measured memory_bytes: 6396
#include<stdio.h>

int main(void){

    int X;

    scanf("%d",&X);
    if(X<=599){
        printf("8\n");
    }else if(X<=799){
        printf("7\n");
    }else if(X<=999){
        printf("6\n");
    }else if(X<=1199){
        printf("5\n");
    }else if(X<=1399){
        printf("4\n");
    }else if(X<=1599){
        printf("3\n");
    }else if(X<=1799){
        printf("2\n");
    }else{
        printf("1\n");
    }

    return 0;
}

Measured memory_bytes: 1648
#include <stdio.h>

int main(void)
{
    int i;
    int spades[13] = {0};
    int hearts[13] = {0};
    int clubs[13] = {0};
    int diamonds[13] = {0};

    int n;
    int rank;
    char mark;
    scanf("%d", &n);

    for (i = 0; i < n; i++)
    {

        scanf(" %c %d", &mark, &rank);
        if ('S' == mark)
        {
            spades[rank - 1] = 1;
        }
        else if ('H' == mark)
        {
            hearts[rank - 1] = 1;
        }
        else if ('C' == mark)
        {
            clubs[rank - 1] = 1;
        }
        else if ('D' == mark)
            diamonds[rank - 1] = 1;
    }


    for (i = 0; i < 13; i++)
    {

        if (spades[i] == 0)
        {
            printf("S %d\n", i + 1);
        }
    }
    for (i = 0; i < 13; i++)
    {

        if (hearts[i] == 0)
        {
            printf("H %d\n", i + 1);
        }
    }
    for (i = 0; i < 13; i++)
    {

        if (clubs[i] == 0)
        {
            printf("C %d\n", i + 1);
        }
    }
    for (i = 0; i < 13; i++)
    {

        if (diamonds[i] == 0)
        {
            printf("D %d\n", i + 1);
        }
    }
    return 0;
}



Measured memory_bytes: 2716
m = int(input())
while m:
    m -= 1
    ax, ay, bx, by = map(int, input().split())
    n = int(input())
    dx, dy = bx - ax, by - ay
    intersections = set()
    while n:
        n -= 1
        sx, sy, tx, ty, o, l = map(int, input().split())
        tdx, tdy = tx - sx, ty - sy
        asx, asy = sx - ax, sy - ay
        denom = dx * tdy - dy * tdx
        if not denom:
            continue
        r = (tdy * asx - tdx * asy) / denom
        s = (dy * asx - dx * asy) / denom
        if not 0 < r < 1 or not 0 < s < 1:
            continue
        px = ax + r * dx
        intersections.add((px, o == l))

    pl, counter = -1, -1
    for px, l in sorted(intersections):
        counter += pl != l
        pl = l
    print(max(counter, 0))

Measured memory_bytes: 7648
#include<iostream>
#include<stdio.h>
#include<string.h>
//#define MOD 1000000007
using namespace std;
int main()
{
	long long a;
	long long  A[100] = { 0 };
	cin >> a;
	A[0] = 2, A[1] = 1;
	for (int i = 2; i <= a; i++)
	{
		A[i] = A[i - 2] + A[i - 1];
	}
	printf("%lld\n", A[a]);
}

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

template <typename T>
struct graph {

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

	vector<edge> edges;
	vector<vector<int>> g;
	int n;

	graph(int n) : n(n) {
		g.resize(n);
	}

	virtual void add(int from, int to, T cost) = 0;
};

template <typename T>
struct undirected_graph : graph<T> {
	using graph<T>::edges;
	using graph<T>::g;
	using graph<T>::n;

	undirected_graph(int n) : graph<T>(n) {
	}

	void add(int from, int to, T cost = 1) {
		assert(0 <= from && from < n && 0 <= to && to < n);
		g[from].emplace_back(edges.size());
		g[to].emplace_back(edges.size());
		edges.push_back({from, to, cost});
	}
};

//O(E + V * logV)
template <typename T>
vector<T> dijkstra(const graph<T> &g, int start) {
	assert(0 <= start && start < g.n);
	vector<T> dist(g.n, numeric_limits<T>::max());
	priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> s;
	dist[start] = 0;
	s.emplace(dist[start], start);
	while (!s.empty()) {
		T expected = s.top().first;
		int i = s.top().second;
		s.pop();
		if (dist[i] != expected) {
			continue;
		}
		for (int id : g.g[i]) {
			auto &e = g.edges[id];
			int to = e.from ^ e.to ^ i;
			if (dist[i] + e.cost < dist[to]) {
				dist[to] = dist[i] + e.cost;
				s.emplace(dist[to], to);
			}
		}
	}
	return dist;
}


int main() {
	int n, m;
	cin >> n >> m;
	int a[m], b[m];
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}
	int ans = 0;
	for (int i = 0; i < m; i++) {
		undirected_graph<int> g(n);
		for (int j = 0; j < m; j++) {
			if (i == j) continue;
			g.add(a[j], b[j]);
		}
		auto d = dijkstra(g, 0);
		bool f = true;
		for (auto i : d) {
			if (i == numeric_limits<int>::max()) {
				f = false;
				break;
			}
		}
		if (!f) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub, or_

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())

def read_int_n():
    return list(map(int, input().split()))

def read_float():
    return float(input())

def read_float_n():
    return list(map(float, input().split()))

def read_str():
    return input().strip()

def read_str_n():
    return list(map(str, input().split()))

def error_print(*args):
    print(*args, file=sys.stderr)



def main():
    n = read_int()
    a = read_int_n()
    a.sort()

    ans = 1
    for i in a:
        ans = ans * i
        if ans > 1000000000000000000:
            ans = -1
            break
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 23436
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

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

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

int main()
{

    int N,M;
    cin >> N >> M;

    int a[100010];
    int br[100010]={0};
    REP(i,M){
    	cin >> a[i];
    	br[a[i]-1]=1;
    }

    lint num[100010]; //i段目まで行く数

    if(br[0]==1){
    	num[0]=0;
    }else{
    	num[0]=1;
    }

    if(br[1]==1){
    	num[1]=0;
    }else{
    	num[1]=1+num[0];
    }

    FOR(i,2,N){
    	if(br[i]==1){
    		num[i]=0;
    	}else{
    		num[i] = num[i-1] + num[i-2];
    	}
    	num[i]=num[i]%1000000007;
    }



    cout << num[N-1] << endl;

}


Measured memory_bytes: 1792
//
// Created by sanyinchen on 17/4/17.
//

#include <iostream>
#include <limits>
#include <string.h>
#include <vector>
#include <cstdio>

using namespace std;

vector<int> findMaxWithMidPoint(int *array, int low, int high) {

    int mid = (low + high) / 2;
    int leftSum = 0, leftLow = mid;
    int rightSum = 0, rightHigh = mid + 1;
    int maxLeft = array[leftLow], maxRight = array[rightHigh];

    vector<int> res;
    for (int i = mid; i >= low; i--) {
        leftSum += array[i];
        if (leftSum > maxLeft) {
            maxLeft = leftSum;
            leftLow = i;
        }
    }
    res.push_back(leftLow);

    for (int i = mid + 1; i <= high; i++) {
        rightSum += array[i];
        if (rightSum > maxRight) {
            maxRight = rightSum;
            rightHigh = i;
        }
    }
    res.push_back(rightHigh);
//    cout << low << " " << high << endl;
//    cout << "sum:" << maxLeft + maxRight << " left:" << leftLow << " " << "high:" << rightHigh << endl;
    res.push_back(maxLeft + maxRight);

    return res;
}


vector<int> findMax(int *array, int low, int high) {


    if (low == high) {

        vector<int> res;
        res.push_back(low);
        res.push_back(high);
        res.push_back(array[low]);
        return res;
    } else {
        int mid = (low + high) / 2;

        vector<int> left = findMax(array, low, mid);
        vector<int> right = findMax(array, mid + 1, high);
        vector<int> midRes = findMaxWithMidPoint(array, low, high);
//        cout << "left:" << left[0] << " " << left[1] << " " << left[2] << endl;
//        cout << "right:" << right[0] << " " << right[1] << " " << right[2] << endl;
//        cout << "midRes:" << midRes[0] << " " << midRes[1] << " " << midRes[2] << endl;

        if (left[2] >= right[2] && left[2] >= midRes[2]) {
            return left;
        }
        if (right[2] >= left[2] && right[2] >= midRes[2]) {

            return right;
        }

        return midRes;

    }

}


int main() {
    //freopen("../files/in.txt", "r", stdin);
    int input[200001] = {0};
    int data[200001] = {0};
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> input[i];
        if (i == 0) {
            data[i] = 0 - input[i];
        } else {
            data[i] = input[i] - input[i - 1];
        }
    }
//    for (int i = 0; i < n; i++) {
//        cout << data[i] << " ";
//    }
    //cout << endl;
    vector<int> res = findMax(data, 0, n - 1);
    //cout << res[0] << " " << res[1] << " " << res[2] << endl;
    cout << res[2] << endl;

    return 0;
}

Measured memory_bytes: 4720
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define ITR(v, i) for(auto ite = v.begin(); ite != v.end(); ite++)
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    vl A, B;
    rep(i, n) {
        cin >> x;
        A.push_back(x);
        B.push_back(x);
    }

    rep(i, n) { a = a ^ A[i]; }

    vl used(n, 0);
    p = 0;

    rep(i, 61) {
        if(a & (1LL << (60 - i)))
            continue;
        rep(j, n) {
            if((A[j] & (1LL << (60 - i)) && !used[j])) {
                used[j] = 1;
                rep(k, n) {
                    if((A[k] & (1LL << (60 - i))) && j != k) {
                        A[k] = A[j] ^ A[k];
                    }
                }
                goto next;
            }
        }
    next:
        // cout << i << " " << ans << endl;
        q = 1;
        // cout << A[0] << " " << A[1] << " " << A[2] << " " << A[3] << endl;
    }

    /*sort(all(A));
    reverse(all(A));*/

    rep(i, n) p ^= A[i];
    // cout << a << " " << p << endl;

    cout << p + (a ^ p) << endl;
}

Measured memory_bytes: 2796
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 1000005
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define P pair<int,int> 
#define INF 1000000000
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
	int n,m;
    cin>>n>>m;
    if(n==m) OUT("Yes");
    else OUT("No");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 105
#define WHITE 0
#define GLAY 1
#define BLACK 2
int n,color[MAX],d[MAX],f[MAX],time,A[MAX][MAX];
void visit(int u){
  int v,i;
  color[u]=1;
  d[u]=++time;
  for(v=0;v<n;v++){
    if(A[u][v]==0)continue;
    if(color[v]==0)visit(v);
  }
    color[u]=2;
    f[u]=++time;

  



}
void dfs(void){
  int i;
  for(i=0;i<n;i++){
    color[i]=0;
    time=0;
  }
    for(i=0;i<n;i++){

      if(color[i]==0) visit(i);
}
    for(i=0;i<n;i++){
      printf("%d %d %d\n",i+1,d[i],f[i]);
    }
}


int main(){

  int i,j,u,k,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=0;

    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      A[u-1][v-1]=1;
    }
  }

  dfs();

  return 0;
}



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

//素因数分解
vector<pair<ll, int>> factorize(ll n) {
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; i++) {
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

int main()
{
    int n;
    cin >> n;
    vi a(n);
    int x = 0;
    rep(i, n) {
        cin >> a[i];
        x ^= a[i];
    }
    rep(i, n) {
        int ans = x ^ a[i];
        cout << ans << " ";
    }

    return 0;
}


Measured memory_bytes: 3964