akhauriyash/Code-Regression huggingface dataset:
using AtCoderBeginnerContest129.Questions;
using AtCoderBeginnerContest129.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest129.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var pqr = inputStream.ReadIntArray();
            var p = pqr[0];
            var q = pqr[1];
            var r = pqr[2];

            yield return Math.Min(Math.Min(p + q, q + r), r + p);
        }
    }
}


namespace AtCoderBeginnerContest129
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest129.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest129.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,h[100001],min_cost[100001],k;
int mincost(int i)
{
    if(i==0) return 0;
    int zero=0;
    int minn=INT_MAX;
    for(int j=1;j<=k;j++)
    {
        if(min_cost[max((i-j),zero)]==-1) min_cost[max((i-j),zero)]=mincost(max((i-j),zero));
        minn=min(minn,abs(h[i]-h[max((i-j),zero)])+min_cost[max((i-j),zero)]);
    }
    return minn;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>h[i];
    for(int i=0;i<n;i++) min_cost[i]=-1;
    cout<<mincost(n-1);
    return 0;
}

Measured memory_bytes: 8064
#include <stdio.h>

int main()
{
    int i, j, flag=1, count=0, str, N, X;
    int m[1000];
    
    scanf("%d%d", &N, &X);
    for(i=0; i < N; i++){
        scanf("%d", &m[i]);
    }
    for(j=0; j < i; j++){
        if(X >= m[j]){
            X -= m[j];
            count++;
        }
        else {
            printf("%d\n", count);
            break;
        }
    }
    while(flag){
        flag = 0;
        for(j=i-1; j > 0; j--){
            if(m[j] < m[j-1]){
                str = m[j];
                m[j] = m[j-1];
                m[j-1] = str;
                flag = 1;
            }
        }
    }
    j=0;
    while(X >= m[j]){
        X -= m[j];
        count++;
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) { cout << ", "; first = false; }
    cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n);
  for (lli i=0; i<n; ++i) cin >> v[i];
}

int main() {
  lli n;
  vector<lli> vs[2];
  vector<pair<lli, lli>> hs[2];
  cin >> n;
  for (int i=0; i<n; ++i) {
    lli x; cin >> x;
    vs[i%2].push_back(x);
  }
  for (int i=0; i<2; ++i) {
    auto& v = vs[i];
    auto& h = hs[i];
    sort(begin(v), end(v));
    lli c=0, p=-1;
    for (auto x : v) {
      if (x == p) ++c;
      else {
	h.push_back({p, c});
	p = x;
	c = 1;
      }
    }
    h.push_back({p, c});
    using P = decltype(h[0]);
    sort(begin(h), end(h), [](P& p1, P& p2) {
      return p1.second > p2.second;	
    });
  }
  lli sub = hs[0][0].first == hs[1][0].first ?
    max(hs[0][0].second + hs[1][1].second, hs[0][1].second + hs[1][0].second)
    : hs[0][0].second + hs[1][0].second;
  cout << n - sub << endl;
  return 0;
}


Measured memory_bytes: 3312
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner io = new Scanner(System.in);
		int n = io.nextInt();
		int[][] chars = new int[26][n];
		
		for(int i=0;i<n;i++){
			String S = io.next();
			for(int j=0;j<S.length();j++){
				chars[S.charAt(j)-97][i] ++;
			}
		}
		StringBuffer buffer = new StringBuffer();
		for(int i=0;i<26;i++){
			int min = Integer.MAX_VALUE;
			for(int j=0;j<n;j++){
				min = Math.min(min,chars[i][j]);
			}
			for(int k=0;k<min;k++){
				buffer.append((char)(i+97));
			}
		}
		System.out.println(buffer.toString());
	}
}

Measured memory_bytes: 21972
#include<iostream>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define chmin(a,b) (a>(b)?a=(b),1:0)
#define abs(n) max((n),-(n))
#define dist(a,b) max((a)-(b),(b)-(a))
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000000
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  // ここでストリームに obj を書き込みます。
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}


int main(){
  int x,a,b; cin >>x >>a >>b;
  if(a>=b) print("delicious");
  else if(a+x>=b) print("safe");
  else print("dangerous");
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;
int M[100][100],d[100],p[100];
bool vist[100]={0};
void prim(int n){
	for(int i=0;i<n;i++) d[i] = INF;
	d[0] = 0;
	p[0] = -1;
	int mincost, u;
	while(1){
		mincost = INF;
		for(int i=0;i<n;i++)
			if(!vist[i] && d[i]<mincost)
				mincost = d[i], u = i;
		if(mincost == INF) break;
		vist[u] = 1;
		for(int i=0; i<n; i++)
			if(!vist[i] && M[u][i]!=-1 && d[u]+M[u][i]<d[i])
				d[i] = M[u][i] + d[u],
				p[i] = u;
	}
}
int main()
{	
	memset(M,-1,sizeof(M));
	int n,du,v,u; cin>>n;
	for(int i = 0;i < n;i++){
		scanf("%d%d",&v,&du);
		while(du--)
			scanf("%d",&u),
			scanf("%d",&M[v][u]);
	}
	prim(n);
	for(int i=0; i<n; i++)
		printf("%d %d\n",i,d[i]);
	return 0;
}


Measured memory_bytes: 3228
import java.util.Scanner;

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

	int N = sc.nextInt();
	double x;
	if (N % 2 == 0)
	    x = 1.0 / 2.0;
	else
	    x = (double)(N / 2 + 1) / (double)N;

	System.out.println(x);
    }
}

Measured memory_bytes: 22996
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

x,y=mii()

if (x+y) %3!=0:
    print(0)
    exit()
if max(x,y)/min(x,y)>2:
    print(0)
    exit()

def nCk(n, k, mod=10 ** 9 + 7):
    if n < k:
        return 0
    k = min(k, n - k)
    numer = 1
    for x in range(n - k + 1, n + 1):
        numer = (numer * x) % mod
    denom = 1
    for x in range(1, k + 1):
        denom = (denom * x) % mod
    return numer * pow(denom, mod - 2, mod) % mod

n=(2*y-x)//3
m=(2*x-y)//3

print(nCk(n+m,n,mod))

Measured memory_bytes: 65644
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


int main(){
  
  int n;
  cin>>n;
  
  if(n<6){
    cout<<2<<' '<<5<<' '<<63<<' ';
    if(n>3){
      cout<<20<<' ';
    }
    if(n>4){
      cout<<30<<' ';
    }
    cout<<endl;
    return 0;
  }
  
  bool used[30'010]={};
  int cnt=0;
  int mod_sum=0;
  int last_;
  REPP(i,30'000){
    if(cnt==n)break;
    if(i%6==0 || i%6==2 || i%6==3 || i%6==4){
      used[i] = true;
      last_ = i;
      cnt++;
      mod_sum += i;
      mod_sum %= 6;
    }
  }
  
  int next_;
  //nが6以上の時は良さそうな調整
  if(mod_sum==2){
    used[8] = false;
    next_ = 1+last_;
    while(next_%6){
      next_++;
    }
    used[next_]=true;
  }else if(mod_sum==3){
    used[9] = false;
    next_ = 1+last_;
    while(next_%6){
      next_++;
    }
    used[next_]=true;
  }else if(mod_sum==5){
    used[9] = false;
    next_ = 1+last_;
    while(next_%6 != 4){
      next_++;
    }
    used[next_]=true;
  }
  
  REPP(i,30'000){
    if(cnt==0)break;
    if(used[i]){
      cout<<i<<' ';
      cnt--;
    }
  }
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 384
N,C = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]

t = 0
for i in range(len(p)):
    t += p[i]
    
if t % (N+1) == 0:
    ans = t // (N+1)
else:
    ans = t // (N+1) + 1
    
print(ans)



Measured memory_bytes: 5604
from collections import Counter
n=int(input())
a = [int(i) for i in input().split()]
b=[0]
s=0
for i in a:
  s+=i
  b.append(s)
c= Counter(b)
ans=0
for i in c:
  ans+=int(c[i]*(c[i]-1)/2)
print(ans)
#copy code

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

amari = n % 1000

oturi = (1000 - amari) % 1000

# maisuu = n / 1000
# amari = n - maisuu*1000
# oturi = 1000 - amari

# if amari > 0:
#     maisuu += 1

print(oturi)

Measured memory_bytes: 9032
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  int c=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    if(a[i]!=i+1) c+=1;
  }
 if(c==0||c==2) cout<<"YES";
  else cout<<"NO";
}
  

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

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

    string str = "";

    while(n != 0){
        int r = n % 2;
        if(r < 0){
            r += 2;
        }

        n = (n - r) / (-2);
        str += ('0' + r);
    }
    reverse(str.begin(), str.end());
    if(str == ""){
        str = "0";
    }

    cout << str << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

unsigned char memo[1<<20];
int mask[5][5][6][6];

void printS(int s){
  int tmp[5][5];
  fill(tmp[0], tmp[5], 0);
  for(int i=0;i<5;i++){
    for(int j=0;j<5;j++){
      tmp[i][j] = s >> (i*5+j) & 1;
    }
  }
  for(int i=0;i<5;i++){
    for(int j=0;j<5;j++){
      cout << tmp[i][j];
    }
    cout << endl;
  }
  cout << endl;
}

void init(){
  fill(memo, memo + (1<<20), -1);
  fill(mask[0][0][0], mask[5][0][0], 0);
  for(int i=0;i<5;i++){
    for(int j=0;j<5;j++){
      for(int h=1;i+h<=5;h++){
        for(int w=1;j+w<=5;w++){
          int tmp = (1 << w) - 1 << j;
          for(int k=0;k<h;k++){
            mask[i][j][h][w] |= tmp << (i+k) * 5;
          }
        }
      }
    }
  }
  queue<int> q;
  memo[0] = 0;
  q.push(0);
  while(!q.empty()){
    int u = q.front();
    q.pop();
    for(int i=0;i<4;i++){
      for(int j=0;j<5;j++){
        for(int h=1;i+h<=4;h++){
          for(int w=1;j+w<=5;w++){
            int v = u ^ mask[i][j][h][w];
            if(memo[v] > memo[u] + 1){
              memo[v] = memo[u] + 1;
              /*if((int)memo[v] == 2 && 0){
                cout << "cost = " << (int)memo[v] << endl;
                printS(v);
                }*/
              q.push(v);
            }
          }
        }
      }
    }
  }
}

const int INF = 1 << 28;

void rec(int t, int x, int cnt, int &res){
  if((t >> 20) == 0){
    //printS(t);
    //cout << (int)memo[t&(1<<20)-1] << endl;
    res = min(res, memo[t] + cnt);
  }
  if(x >= 5) return;
  for(int i=0;i<5;i++){
    for(int j=x;j<5;j++){
      int nt = t ^ mask[i][x][5-i][j-x+1];
      if(!(nt&1<<20+x)) rec(nt, x+1, cnt+1, res);
    }
  }
  if(!(t&1<<20+x)) rec(t, x+1, cnt, res);
}

int solve(int s){
  int cnt = 0;
  for(int i=0;i<5;i++){
    if(s >> (20 + i) & 1) cnt++;
  }
  int res = memo[s&(1<<20)-1] + min(cnt, 6-cnt);
  //cout << res << ' ';
  rec(s, 0, 0, res);
  //cout << res << endl;
  return res;
}

main(){
  init();
  int n;
  while(cin >> n && n){
    int m = 0;
    for(int i=0;i<n;i++){
      int t = 0, c;
      for(int j=0;j<n;j++){
        cin >> c;
        t |= c << j;
      }
      m |= t << i * 5;
    }
    int ans = n < 5 ? memo[m] : solve(m);
    for(int i=0;i<ans;i++){
      cout << "myon";
    }
    cout << endl;
  }
}

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

int main(){
  int d,n;
  cin >> n >> d;
  vector<vector<double>>ten(n,vector<double>(d));
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++)
      cin >> ten.at(i).at(j);
  }
  double a;
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      a=0;
      for(int k=0;k<d;k++){
        a+=pow(ten.at(i).at(k)-ten.at(j).at(k),2);
      }
      a=sqrt(a);
      if(a!=0&&ceil(a)==a)
        ans++;
    }
  }
  cout << ans/2 << endl;
  return 0;
}

Measured memory_bytes: 3640
n = int(input())
x = []
for i in range(n):
    x.append(int(input()))

imin=0
imax=1
maxVal=x[imax]-x[imin]
for i in range(1,n):
    if x[imin] > x[i]:
        imin=i
        imax=i+1
        if imax > n-1:
            break
        dx = x[imax]-x[imin]
        if maxVal < dx:
            maxVal = dx
    elif x[imax] < x[i]:
        imax = i
        dx = x[imax]-x[imin]
        if maxVal < dx:
            maxVal = dx
print(maxVal)



Measured memory_bytes: 13588
package main

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

func solve() {
	a := nextInt()
	b := nextInt()
	c := nextInt()
	x := nextInt()

	ans := 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				// fmt.Fprintf(out, "a: %d, b: %d, c:%d\n", 500*i, 100*j, 50*k)
				// fmt.Fprintf(out, "sum:%d\n", 500*i+100*j+50*k)
				if x == 500*i+100*j+50*k {
					// fmt.Fprintln(out, "increment!!!")
					ans++
				}
			}
		}
	}

	fmt.Fprintln(out, ans)
	return

}

func main() {
	in.Split(bufio.ScanWords)

	defer out.Flush()
	solve()
}

// --- template ---

var (
	in  = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func next() string {
	in.Scan()
	return in.Text()
}

func nextInt() int {
	s := next()
	i, e := strconv.Atoi(s)
	if e != nil {
		fmt.Println(e)
	}
	return i
}

func nextInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = nextInt()
	}
	return res
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include <cmath>
#include<cstring>
#include<bits/stdc++.h> 
#define ll long long
#define fo(a,b,c) for(a=b;a<c;a++)
using namespace std;

int main(){
	ll n,i,temp;
	cin >> n;
	vector<int> x;
	while(n>0){
		temp = n%26;
		if(temp==0){
			x.push_back(26);
			n-=26;
		}
		else{
			x.push_back(temp);
			n-=temp;
		}
		n/=26;
	}
	for(i=x.size()-1;i>=0;i--){
		cout << char(x[i]+'a' - 1) ;
	}
	return 0;
}

Measured memory_bytes: 3552
import java.math.BigDecimal;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int i;
		for (i = 0; i < n; i++) {

			BigDecimal bigDecimal1 = scanner.nextBigDecimal();
			BigDecimal bigDecimal2 = scanner.nextBigDecimal();
			BigDecimal add = bigDecimal1.add(bigDecimal2);
			if (add.precision() > 80) {
				System.out.println("overflow");
			} else {
				System.out.println(add);
			}
		}
		scanner.close();
	}

}



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

typedef long long ll;

ll n[4];

int main(){
  for(int i=0; i<4; i++)
    cin >> n[i];
  
  sort(n,n+4);
  
  if(n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

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;
  cin >> n;
  vector<int> a(n+1);
  for (int i = 1; i <= n; ++i) cin >> a[i];

  vector<int> b(n+1, 0);
  for (int i = n; i >= 1; --i) {
    int c = 0;
    for (int j = i; j <= n; j += i) {
      c += b[j];
    }
    if (c % 2 != a[i]) b[i] = 1;
  }

  vector<int> d;
  for (int i = 1; i <= n; ++i) if (b[i]) d.push_back(i);
  int m = d.size();

  printf("%d\n", m);
  rep(i, m-1) printf("%d ", d[i]);
  if (m > 0) printf("%d\n", d[m-1]);
  return 0;
}

Measured memory_bytes: 5252
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int m,int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(m,n / 2);
	x *= x;
	if (n % 2 == 1)x *= m;
	return x;
}
ll max(ll a, ll b) {
	if (a < b)return b;
	else return a;
}

int main() {
	string a[4] = { "dream","dreamer" ,"erase", "eraser" };
	rep(i, 0, 4)reverse(a[i]);
	string s; cin >> s;
	reverse(s);
	while (s.size()){
		bool f = false;
		rep(i, 0, 4) {
			if (s.size() < a[i].size())continue;
			string t = s.substr(0, a[i].size());
			if (t == a[i]) {
				f = true;
				s.erase(0, t.size());
				break;
			}
		}
		if (!f) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 512
def main():
    H = int(input())
    W = int(input())
    N = int(input())

    ans = 0
    h, w = 0, 0
    while True:

        if H >= W and h != H:
            N -= H
            h += 1
        elif w != W:
            N -= W
            w += 1
            
        ans += 1

        if N <= 0:
            print(ans)
            exit()
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import sys
N=int(input())
A=0
B=0
table=[]
for i in range(N):
    a,b=map(int,input().split())
    table.append((a,i))
    table.append((b,i))
    A+=a
    B+=b
ans=min(A,B)
table.sort()
num=0
for i in range(N):
    num+=table[i][0]
L=[0]*N
#print(table)
for i in range(N):
    c,j=table[i]
    if L[j]!=0:
        ans=min(num,ans)
        print(ans)
        #print(L)
        sys.exit()
    L[j]+=1
c,n=table[N-1]
if n!=table[N][1]:
    num=num-table[N-1][0]+table[N][0]
    ans = min(num, ans)
    print(ans)
    sys.exit()
num1=num-table[N-1][0]+table[N+1][0]
num2=num-table[N-2][0]+table[N][0]
print(min(ans,num1,num2))




Measured memory_bytes: 64752
from bisect import bisect
inf=float("inf")
a,b,q=map(int,input().split())
s=[int(input()) for _ in range(a)]
t=[int(input()) for _ in range(b)]
x=[int(input()) for _ in range(q)]
for i in range(q):
    west=inf
    east=inf
    c=inf
    d=inf
    j=bisect(s,x[i])
    k=bisect(t,x[i])
    if j!=a and k!=0:
        c=s[j]-t[k-1]+min(s[j]-x[i],x[i]-t[k-1])
    if k!=b and j!=0:
        d=t[k]-s[j-1]+min(x[i]-s[j-1],t[k]-x[i])
    if j!=0 and k!=0:
        west=max(x[i]-s[j-1],x[i]-t[k-1])
    if j!=a and k!=b:
        east=max(s[j]-x[i],t[k]-x[i])
    print(min(west,east,c,d))

Measured memory_bytes: 16272
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  double n; cin >> n;
  int extax = floor(n/1.08);
  REP(i,3) {
    double d = extax - 1 + i;
    if (floor( d * 1.08 ) == n) {
      COUT(d);
      return 0;
    }
  }
  COUT(":(");

  return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#define INF 500000
#define P  pair <int , pair < int, pair <int , int > > >
#define dis first
#define x second.first
#define y second.second.first
#define sta second.second.second
using namespace std;
string str[60];
int w,h,cnt;
priority_queue < P > Q;
int d[61][31][2];

void dijkstra(int sx,int sy,int rl) {
  bool visited[61][31][2] = {};
  while(!Q.empty()) Q.pop();
  P ttt;
  ttt.dis=0,   ttt.x = sx,   ttt.y=sy, ttt.sta = rl;
  d[sy][sx][rl] = 0;
  Q.push(ttt);

  while(!Q.empty()) {
    cnt++;
    P t = Q.top();
    Q.pop();

    if(visited[t.y][t.x][t.sta] == 1) continue;
    visited[t.y][t.x][t.sta] = 1;

    for(int i=1;i<=3;i++) { //i = x
      for(int j=-3+i;j<=3-i;j++) { // j = y
	int nx,ny = t.y + j;
	if(t.sta == 0) nx = t.x - i;
	if(t.sta == 1) nx = t.x + i;
	if(nx<0 || ny<0 || w<=nx || h<=ny) continue;
	if(str[ny][nx]=='X') continue;
	int cost = str[ny][nx] - '0';
	if(str[ny][nx] == 'T' || str[ny][nx] == 'S') cost = 0;
		if(d[ny][nx][(t.sta+1)%2] < d[t.y][t.x][t.sta]-cost){
	  d[ny][nx][(t.sta+1)%2] =  d[t.y][t.x][t.sta]-cost;
	  P tt;
	  tt.dis =  d[ny][nx][(t.sta+1)%2];
	  tt.x = nx , tt.y = ny , tt.sta = (t.sta+1)%2;
	  Q.push(tt);
	}
      }
    }
  }
}

int main() {

  while(1) {  
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    
    for(int i=0;i<h;i++) {
      str[h-i-1] = "";
      for(int j=0;j<w;j++) {
	string a;
	cin >>a;
	str[h-i-1] += a;
      }
    }

    for(int i=0;i<h;i++)for(int j=0;j<w;j++)for(int k=0;k<2;k++) d[i][j][k] = -INF;

    for(int i=0;i<w;i++) 
      if(str[0][i] == 'S') {
	dijkstra(i,0,0);
	dijkstra(i,0,1);
      }
    
    int ans = -INF;    
    for(int i=0;i<w;i++) {
      if(str[h-1][i] == 'T') ans = max(ans,d[h-1][i][0]),ans = max(ans,d[h-1][i][1]);
    }


    if(ans == -INF) cout << -1 <<endl;
    else cout << -ans <<endl;
    // cout << cnt <<endl;
  }
    
  return 0;
}
  

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


namespace ABC121B
{
    class MainClass
    {
        static int[] s;
        static int[] n;
        public static void Main(string[] args)
        {

            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            n = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            int ans = 0;

            for(int i = 0; i < s[0]; i++)
            {
                int[] a = new int[s[1]];
                a = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
                int tmp = s[2];
                for (int j = 0; j < s[1]; j++)
                {
                    tmp += a[j]*n[j];

                }
                if (tmp > 0) {

                    ans++;
                }

            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>
#include<math.h>

int main()
{
	int n, a, b, c, d, cnt = 0;
	while (scanf("%d", &n) != EOF)
	{
		cnt = 0;
		if (n > 36)
		{
			printf("0\n");
			continue;
		}
		for (a = 0; a < 10; a++)
		{

			if (n - a>27)continue;

			for (b = a; b < 10; b++)
			{
				if (n - a - b > 18)continue;

				for (c = b; c < 10; c++)
				{
					if (n - a - b - c > 9)continue;

					for (d = c; d < 10; d++)
					{

						if (a + b + c + d == n)
						{
							if ((a == b) && (a == c) && (a == d))cnt++;
							else if (((a == b) && (b == c)) | ((b == c) && (c == d)))cnt += 4;
							else if ((a == b) && (c == d))cnt += 6;
							else if ((a == b) | (b == c) | (c == d))cnt += 12;
							else cnt += 24;
						}
					}
				}
			}
		}

		printf("%d\n", cnt);
	}
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            // データセット数を取得
            int dataSetCount = int.Parse(Console.ReadLine());

            // データセット数分の繰り返し
            for(int dsi = 0; dsi < dataSetCount; dsi++)
            {
                int[,] val = new int[3, 9];

                int[] num = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                string[] color = Console.ReadLine().Split(' ');

                for(int i = 0; i < 9; i++)
                {
                    switch(color[i])
                    {
                        case "R": val[0, num[i] - 1]++; break;
                        case "G": val[1, num[i] - 1]++; break;
                        case "B": val[2, num[i] - 1]++; break;
                    }
                }

                for (int row = 0; row < 3; row++)
                {
                    for (int col = 0; col < 9; col++)
                    {
                        if(col < 7)
                        {
                            // 連続する3枚を除外
                            while (val[row, col] > 0 && val[row, col + 1] > 0 && val[row, col + 2] > 0)
                            {
                                val[row, col]--;
                                val[row, col + 1]--;
                                val[row, col + 2]--;
                            }
                        }

                        // 同数3枚を除外
                        if (val[row, col] >= 3) val[row, col] -= 3;
                    }
                }

                bool isOk = true;
                for (int row = 0; row < 3; row++)
                {
                    for (int col = 0; col < 9; col++)
                    {
                        if (val[row, col] > 0) isOk = false;
                    }
                }

                Console.WriteLine(isOk ? "1" : "0");
            }
        }
    }
}


Measured memory_bytes: 13924
// in the name of Allah

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

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

ll mod;

ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

/*

// a bit of NT

const int _N = 1234567;

ll F[_N];
ll IF[_N];

void init() {
	F[0] = 1;
	for(int i=1; i<_N; i++) F[i] = mul(F[i-1], i);
	IF[_N-1] = power(F[_N-1], mod-2);
	for(int i=_N-2; i>=0; i--) IF[i] = mul(IF[i+1], i+1);
}

ll ncr(ll x, ll y) {
	if(y > x || y < 0) return 0;
	return mul(F[x], mul(IF[x-y], IF[y]));
}

ll euler(ll m) {
	ll res = 1;
	for(ll i = 2; i*i <= m; i++) {
		if(m%i == 0) {
			m /= i;
			res *= (i - 1);
			while(m % i == 0) {
				m /= i;
				res *= i;
			}
		}
	}
	if(m > 1) res *= (m-1);
	return res;
}

/**/

int main() {
	// ll start = clock();
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    string s;
    cin >> s;
    int cnt = 0;
    int n = sz(s);
    if(s[0] == '0' || s[n-1] == '1') {
        cout << -1 << endl;
        return 0;
    }
    for(int i=0; i<n-1; i++) {
        if(s[i] != s[n-2-i]) {
            cout << -1 << endl;
            return 0;
        }
        if(s[i] == '1') cnt++;
    }
    for(int i=1; i<=cnt; i++) cout << i << " " << i+1 << endl;
    cnt += 2;
    int past = 1, sz = 1;
    for(int i=0; i<n; i++) {
        if(s[i] == '1') {
            past++;
            for(int j=past; j<=i+1; j++) {
                cout << sz << " " << cnt++ << endl;
                past++;
            }
            sz++;
        }
    }
	// cerr << (clock() - start) / (CLOCKS_PER_SEC*1.0) << endl;
	return 0;
}

Measured memory_bytes: 1616
#include <iostream>
#include <math.h>

using namespace std;

int main() {
    string a, b;
    int num;
    float x;
    cin >> a >> b;
    num = atoi((a + b).c_str());
    x = sqrt(num);

    if (ceil(x) == floor(x)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
x,a,b = LI()
if b<=a:
    print("delicious")
elif b-a <= x:
    print("safe")
else:
    print("dangerous")
"""
#B
n = I()
a = IR(n)
f = [0 for i in range(n)]
x = 0
f[x] = 1
for i in range(n):
    x = a[x]-1
    if x == 1:
        print(i+1)
        quit()
    if f[x]:
        print(-1)
        quit()
    f[x] = 1
#C

#D
"""
def root(x):
    if x == par[x]:
        return x
    par[x] = root(par[x])
    return par[x]

def same(x,y):
    return root(x) == root(y)

def unite(x,y):
    x = root(x)
    y = root(y)
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1
n = I()
v = LIR(n)
l = [None for i in range(2*n-2)]
for i in range(n):
    v[i].append(i)
par = [i for i in range(n)]
rank = [0 for i in range(n)]
v.sort(key = lambda x:x[0])
for i in range(n-1):
    l[i] = [v[i][2],v[i+1][2],v[i+1][0]-v[i][0]]
v.sort(key = lambda x:x[1])
for i in range(n-1):
    l[i+n-1] = [v[i][2],v[i+1][2],v[i+1][1]-v[i][1]]
l.sort(key = lambda x:x[2])
k = 0
ans = 0
for i in range(2*n-2):
    x,y,c = l[i]
    if not same(x,y):
        k += 1
        ans += c
        unite(x,y)
    if k == n-1:break
print(ans)
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 49584
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
B = [list(map(int, input().split())) for _ in range(N)]

A.sort(key=lambda x: x[0], reverse=True)
B.sort(key=lambda x: x[1])


flag1 = [False for _ in range(N)]
flag2 = [False for _ in range(N)]

res = 0
for i in range(N):
    for j in range(N):
        if A[i][0] < B[j][0] and A[i][1] < B[j][1] and flag1[i] == False and flag2[j] == False:
            res += 1
            flag1[i] = True
            flag2[j] = True

print(res)



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
#include <map>
using ll = long long int;
using namespace std;

int main()
{
    int N, ans = 0;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
    }
    for (int i = 1; i < N; i++)
    {
        if (H[i - 1] > H[i])
        {
            ans += (H[i - 1] - H[i]);
        }
    }
    ans += H[N - 1];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	. "fmt"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	var n, sum, v int
	Fscan(in, &n, &sum)
	f := make([]int, sum+1)
	f[0] = 1
	for ; n > 0; n-- {
		Fscan(in, &v)
		for s := sum; s >= 0; s-- {
			f[s] <<= 1
			if s >= v {
				f[s] += f[s-v]
			}
			f[s] %= 998244353
		}
	}
	Print(f[sum])
}


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

int main()
{
    int H1, M1, H2, M2, K, ans = 0;
    cin >> H1>> M1 >> H2 >> M2 >> K;

    ans = (H2-H1)*60 + M2- M1-K;

    cout << ans;


}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) std::begin(x), std::end(x)
using namespace std;

/**
 * @brief a disjoint set structure
 * @note union-by-size + path-compression
 */
struct union_find_tree {
    std::vector<int> data;
    union_find_tree() = default;
    explicit union_find_tree(std::size_t n) : data(n, -1) {}
    bool is_root(int i) { return data[i] < 0; }
    int find_root(int i) { return is_root(i) ? i : (data[i] = find_root(data[i])); }
    int tree_size(int i) { return - data[find_root(i)]; }
    int unite_trees(int i, int j) {
        i = find_root(i); j = find_root(j);
        if (i != j) {
            if (tree_size(i) < tree_size(j)) std::swap(i, j);
            data[i] += data[j];
            data[j] = i;
        }
        return i;
    }
    bool is_same(int i, int j) { return find_root(i) == find_root(j); }
};


int main() {
    int n, m; cin >> n >> m;
    union_find_tree uft(n);
    REP (i, m) {
        int x, y, z; cin >> x >> y >> z;
        -- x;
        -- y;
        uft.unite_trees(x, y);
    }
    int cnt = 0;
    REP (i, n) {
        cnt += uft.is_root(i);
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include<string>
#include<utility>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;


bool cmpf(pair<lli, lli> left, pair<lli, lli> right) {
	return left.first < right.first;
}


int main() {
	string s, t, temp, comp;
	cin >> s;
	t = s;
	int num1 = 1, num2 = 1;
	temp += s[0];
	s.erase(s.begin());
	while (!s.empty()) {//初手1
		comp += s[0];
		s.erase(s.begin());
		if (comp != temp) {
			//cout << num1 << endl;
			//cout << comp << ',' << temp << endl;
			temp = comp;
			num1++;
			comp.erase(all(comp));
			
		}
	}
	if (comp == temp)num1 == 0;

	comp.erase(all(comp)); temp.erase(all(temp));
	temp = temp+t[0] + t[1];
	t.erase(t.begin(), t.begin() + 2);
	while (!t.empty()) {//初手2
		comp += t[0];
		t.erase(t.begin());
		if (comp != temp) {
			//cout << num2 << endl;
			//cout << comp << ',' << temp << endl;
			temp = comp;
			num2++;
			comp.erase(all(comp));
		}
	}
	if (comp == temp)num2 == 0;
	cout << (num1>num2?num1:num2);
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
int main() 
{
    int n,k;
    cin>>n>>k;
    int a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    int cost[n+1];
    cost[1]=0;
    cost[2]=abs(a[2]-a[1]);
    for(int i=3;i<=n;i++)
    {
        int min=INT_MAX;
        for(int j=1;j<=k;j++)
        {
            if((i-j)<=0)
            {
                break;
            }
            int c=cost[i-j]+abs(a[i]-a[i-j]);
            if(c<min)
            {
                min=c;
            }
        }
        cost[i]=min;
        
    }
    cout<<cost[n]<<endl;
    return 0;
}


Measured memory_bytes: 1024
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main(){
	FIO
	
	int n, a;
	cin >> n >> a;
	cout << n * n - a << '\n';
 	return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100003];
int main()
{
    int N;
    cin >> N;
    while (N--){
        int t;
        cin >> t;
        a[t]++;
        a[t + 1]++;
        a[t + 2]++;
    }
    cout << *max_element(a + 2, a + 100000) << endl;
}

Measured memory_bytes: 3980
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...

    int n;
    
    cin >> n;
    
    int a[n];
    
    for(int i=0; i<n; i++)
        cin >> a[i];
    
    int ans=0;
    
    int Alice=0;
    int Bob = 0;
    
    sort(a, a+n);
    reverse(a, a+n);
    
    
    for(int i=0; i<n; i++){
        if(i%2==0)
            Alice += a[i];
        else
            Bob += a[i];
    }

    ans = Alice - Bob;
    
    cout << ans << endl;
   
    return 0;
    
}


Measured memory_bytes: 256
def main():
    A, B, C, D, E, F = list(map(int, input().split()))
    A *= 100
    B *= 100
    dp = [[0] * 3000 for _ in range(3000)]
    dp[0][0] = 1
    m = 0
    mt = (A, 0)
    for i in range(3000):
        for j in range(3000):
            if dp[i][j] == 0:
                continue
            if i + A <= F:
                dp[i+A][j] = 1
            if i + B <= F:
                dp[i+B][j] = 1
            if i + C <= F:
                dp[i+C][j+C] = 1
                if (j+C)/(i+C) > m and (j+C)/(i+C)<= E/(100+E):
                    m = (j+C)/(i+C)
                    mt = ((i+C), (j+C))
            if i + D <= F:
                dp[i+D][j+D] = 1
                if (j+D)/(i+D) > m and (j+D)/(i+D)<= E/(100+E):
                    m = (j+D)/(i+D)
                    mt = ((i+D), (j+D))
    return mt
mt = main()
print(mt[0], mt[1])



Measured memory_bytes: 112604
#include<iostream>
#include<cmath>

using namespace std;

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

    int ans = 1;
    for(int i=2;i<sqrt(x);i++){
        int tmp = i;
        while(tmp*i<=x){
            tmp *= i;
        }
        if(ans<tmp)ans = tmp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
S = input()
f = False
if S[:7] == 'keyence':
    f = True
if S[-7:] == 'keyence':
    f = True

for i in range(len(S)):
    s1 = S[:i]
    s2 = S[i:]
    if 'k' in s1 and 'eyence' in s2:
        if s1[0] == 'k':
            if s2[-6:] == 'eyence':
                f = True
                break
    if 'ke' in s1 and 'yence' in s2:
        if s1[:2] == 'ke':
            if s2[-5:] == 'yence':
                f = True
                break
    if 'key' in s1 and 'ence' in s2:
        if s1[:3] == 'key':
            if s2[-4:] == 'ence':
                f = True
                break
    if 'keye' in s1 and 'nce' in s2:
        if s1[:4] == 'keye':
            if s2[-3:] == 'nce':
                f = True
                break
    if 'keyen' in s1 and 'ce' in s2:
        if s1[:5] == 'keyen':
            if s2[-2:] == 'ce':
                f = True
                break
    if 'keyenc' in s1 and 'e' in s2:
        if s1[:6] == 'keyenc':
            if s2[-1] == 'e':
                f = True
                break
if f:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
struct edge{int u,v,typ;}e[maxn];
int fa[maxn];
int n,q,c; 
long long m;
int find(int u){return fa[u]==u?u:fa[u]=find(fa[u]);}
int main()
{
    scanf("%d%lld%d",&n,&m,&q);
    for(int i=1;i<=n;i++)fa[i]=i;
    for(int i=1;i<=q;i++)
    {
        scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].typ);
		e[i].u++,e[i].v++;
        if(e[i].typ==0)
        {
            int u=find(e[i].u),v=find(e[i].v);
            if(u!=v)fa[u]=v;
        }
    }
    int flag=0;c=0;
    for(int i=1;i<=n;i++)if(i==find(i))c++;
    for(int i=1;i<=q;i++)
    if(e[i].typ==1)
    {
        flag=1;
        int u=find(e[i].u),v=find(e[i].v);
        if(u==v){puts("No");return 0;}
    }
    long long l=flag?max(3,c):c-1,r=c*1LL*(c-1ll)/2ll;
    if(m-(n-c)>=l&&m-(n-c)<=r)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
const long long INF = 1LL << 60;
const int MOD = 1000000007;
#define F first
#define S second
signed main(void){
    int h,w; cin>>w>>h;
    priority_queue <pair <int,int>, vector <pair <int,int> >, greater<pair <int,int> >> pq; //横0 縦1
    int ver = h+1, hor = w+1;
    int ans = 0;
    
    rep(i,w){
        int a; cin>>a;
        pq.push({a,0});
    }
    rep(i,h){
        int a; cin>>a;
        pq.push({a,1});
    }
    while(!pq.empty()){
        auto tmp = pq.top(); pq.pop();
        if(tmp.S){
            //cout<<tmp.F<<' '<<hor<<"tate"<<endl;
            ans += hor*tmp.F; ver--;
        }else{
            //cout<<tmp.F<<' '<<ver<<"横"<<endl;
            ans += ver*tmp.F; hor--;
        }
    }
    cout<<ans<<endl;
}


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

const int INF = 100100100;
const int MAX = 100100;
const int WH = 0;
const int GR = 1;


vector<int> G[MAX];
vector<int> prenum(MAX);
vector<int> lowest(MAX, INF);
vector<int> color(MAX, WH);
vector<int> parent(MAX, -1);
int ttime = 1;

void dfs(int u) {
    prenum[u] = ttime;
    lowest[u] = ttime;
    color[u] = GR;
    for (int i = 0; i < G[u].size(); i++) {
        int v = G[u][i];
        if (color[v] == WH) {
            parent[v] = u;
            ttime++;
            dfs(v);
            lowest[u] = min(lowest[u], lowest[v]);
        }
        else if (parent[u] != v) {
            lowest[u] = min(lowest[u], prenum[v]);
        }
    }
}


int main() {
    int size_v, size_e;
    cin >> size_v >> size_e;

    for (int i = 0; i < size_e; i++) {
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    dfs(0);

    set<int> ap;
    int cnt = 0;
    for (int i = 1; i < size_v; i++) {
        int p = parent[i];
        if (p == 0) {
            cnt++;
        }
        else {
            if (prenum[p] <= lowest[i]) {
                ap.insert(p);
            }
        }
    }
    if (cnt > 1) {
        ap.insert(0);
    }

    for (set<int>::iterator it = ap.begin(); it != ap.end(); it++) {
        cout << *it << endl;
    }

    return 0;
}



Measured memory_bytes: 8076
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,A;
    cin >> N >> A;
    vl X(N);
    rep(i,N){
        cin >> X[i];
    }
    ll dp[N+1][N+1][50*N+1];
    rep(i,N+1){
        rep(j,N+1){
            rep(k,50*N+1){
                dp[i][j][k]=0;
            }
        }
    }
    dp[0][0][0]=1;
    FOR(i,1,N+1){
        rep(j,N+1){
            rep(k,50*N+1){
                dp[i][j][k]+=dp[i-1][j][k];
                if(k>=X[i-1]){
                    dp[i][j][k]+=dp[i-1][j-1][k-X[i-1]];
                }
            }
        }
    }
    ll ans=0;
    FOR(i,1,N+1){
        ans+=dp[N][i][A*i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 54468