akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  998244353
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
vector<pii>adj[N];
int col[N];
int vis[N]={false};
int bfs(int x)
{
    vis[x]=1;
    col[x]=0;
    queue<int>q;
    q.push(x);
    while(!q.empty())
    {
        int p=q.front();
        q.pop();
        for(auto y:adj[p])
        {
            if(!vis[y.F])
            {
                vis[y.F]=true;
                if(y.S % 2 ==0)col[y.F]=col[p];
                else
                    col[y.F]=!col[p];
                q.push(y.F);
            }
        }
    }
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   rep(i,0,n-1)
   {
       int u,v,w;
       cin>>u>>v>>w;
       adj[u].pb({v,w});
       adj[v].pb({u,w});
   }
   bfs(1);
   for(int i=1;i<=n;i++)
   {
       cout<<col[i]<<endl;
   }

}


Measured memory_bytes: 12544
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
  int n;
  cin >> n;
  for(int i=0;i<=100;i++){
    if( i*2 >= n ){
      cout << i << endl;
      return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

const lint mod=1e9+7;

string L;
lint dp[100010][2];

lint rec(int d,int tight)
{
	if(dp[d][tight]!=-1)
		return dp[d][tight];
	
	if(d==L.size())
		return 1;
	
	lint ret=0;
	if(tight==0)
	{
		//tight 0->0
		ret+=3*rec(d+1,0)%mod;
		ret%=mod;
	}
	if(tight==1)
	{
		//tight 1->0
		if(L[d]=='1')
		{
			ret+=rec(d+1,0);
			ret%=mod;
		}
		//tight 1->1
		if(L[d]=='1')
			ret+=2*rec(d+1,1);
		else
			ret+=rec(d+1,1);
		ret%=mod;
	}

	dp[d][tight]=ret;
	return ret;
}

int main()
{
	for(int i=0;i<100010;i++)
		for(int j=0;j<2;j++)
			dp[i][j]=-1;

	cin >> L;
	cout << rec(0,1) << endl;
	return 0;
}



Measured memory_bytes: 6656
package main

import "os"
import "fmt"
import "strconv"
import "bufio"
import "strings"

func min(a ...int64) int64 {
    v := int64(-1)
    for i := 0; i < len(a); i++ {
        if a[i] == 0 {
            continue
        }
        if v == -1 || v > a[i] {
            v = a[i]
        }
    }
    return v
}

func do(i int64, j int64, arr []int64, total [405][405]int64, dp [405][405]int64) int64 {
    fmt.Println(i,j)
    if i == j {
        return 0
    }
    if i == j-1 {
        dp[i][j] = arr[i] + arr[j]
        return dp[i][j]
    }
    if dp[i][j] > 0 {
        return dp[i][j]
    }
    for k := i; k < j; k++ {
        x := do(i,k,arr,total,dp)
        xx := total[i][k]
        y := do(k+1,j,arr,total,dp)
        yy := total[k+1][j]
        // fmt.Println(i,k,j,x+y+xx+yy)
        dp[i][j] = min(dp[i][j], x+y+xx+yy)
    }
    // fmt.Println(i,j,dp[i][j])
    return dp[i][j]
}
func solve(n int64, arr []int64) int64 {
    dp := [405][405]int64{}
    total := [405][405]int64{}
    for i := int64(0); i < n; i++ {
        for j := i; j < n; j++ {
            if j-1 >= i {
                total[i][j] = total[i][j-1] + arr[j]
            } else {
                total[i][j] = arr[j]
            }
        }
    }
    for j := int64(0); j < n; j++ {
        for i := int64(0); i < n; i++ {
            if i+j >= n {
                break
            }
            if j == 0 {
                dp[i][i+j] = 0
            } else if j == 1 {
                dp[i][i+j] = arr[i] + arr[i+j]
            } else {
                for k := i; k < i+j; k++ {
                    dp[i][i+j] = min(dp[i][i+j], dp[i][k]+dp[k+1][i+j]+total[i][k]+total[k+1][i+j])
                }
            } 
        }
    }
    return dp[0][n-1]
}

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    var n int64 = 0
    var arr = []int64{}
    var i int64 = 0
    for scanner.Scan() {
        if i > 1 {
            break
        }
        if i == 0 {
            n, _ = strconv.ParseInt(scanner.Text(), 10, 64)
        } else {
            strs := strings.Split(scanner.Text(), " ")
            for j := int64(0); j < n; j++ {
                x, _ := strconv.ParseInt(strs[j], 10, 64)
                arr = append(arr, x)
            }  
        }
        i++
    }

    fmt.Println(solve(n, arr))
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main() {
    string a,b;
    cin>>a>>b;

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());

    if(a<b){
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n; cin>>n;
	int a[n]; rep(i,n) cin>>a[i];
	if(n==1) cout<<a[0]<<endl;
	else if(n%2==0){
		for(int i=n-1;i>0;i-=2) cout<<a[i]<<" ";
		for(int i=0;i<n-2;i+=2) cout<<a[i]<<" ";
		cout<<a[n-2]<<endl;
	}else{
      	for(int i=n-1;i>=0;i-=2) cout<<a[i]<<" ";
		for(int i=1;i<n-2;i+=2) cout<<a[i]<<" ";
		cout<<a[n-2]<<endl;
    }
	return 0;
}


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

using namespace std;

const long long aa=(long long) 1e9+7;


void LCM_calc(long long x, vector <long long> &p){   

    vector <long long> pp(p);
    vector <long long> q;

    long long n=2;
    while( x >= n*n ){
        if( x%n==0 ){
            q.push_back(n);
            x /= n;
            continue;
        }
        n++;
    }
    q.push_back(x);

    p.clear();
    long long j=0;
    set_union(begin(q), end(q),
                begin(pp), end(pp),
                inserter(p, end(p)));
/*
    cout << "current p= ";
    for(long long i=0; i<(long long) p.size(); i++){
        cout << p[i] << " ";
    }
    cout << endl; */
}

long long pow_mod(long long a, long long b) {
  long long res=1;
  for(;b;b>>=1, a=a*a%aa) {
    if(b&1) res=res*a%aa;
  }
  return res;
}

int main(){
    vector <long long> p;
    long long N;
    cin >> N;
    long long A[N],lcm;
    long long B[N];
    for(long long i=0; i<N; i++){
        cin >> A[i];
    }

    for(long long i=0; i<N; i++){
        //cout << "lcm loop i " << i << endl;
        LCM_calc(A[i],p);
    }

    lcm = 1;
    for(long long j=0; j<(long long)p.size(); j++){
        lcm *= p[j];
        lcm %= aa;
    }

    long long sum=0;

    for(long long i=0; i<N; i++){

        long long tmp;
        tmp = pow_mod(A[i],aa-2);
        sum += lcm * tmp;
        sum %= aa;
    }

    cout << sum << endl;

    return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  // ll a, b;
  ll n;
  cin >> n;
  ll result = 0;
  bool judge = true;
  vector<ll> a(n), b(n, n);
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  ll t[n][30];
  ll buf;
  for(i=0;i<n;i++){
    buf = a[i];
    for(j=0;j<30;j++){
      t[i][j] =  buf % 2;
      buf /= 2;
    }
  }
  for(i=0;i<30;i++){
    for(j=0,buf=-1;j<n;j++){
      if(t[j][i]==1 && buf!=-1){
        chmin(b[buf], j);
        buf = j;
      }
      else if(t[j][i]==1){
        buf = j;
      }
    }
  }
  
  buf=b[n-1];
  for(i=n-1;i>=0;i--){
    if(b[i]<=buf){
      buf=b[i];
    }
    else{
      b[i]=buf;
    }
  } 

  for(i=0;i<n;i++){
    //cout << a[i] spa a[b[i] - 1] spa b[i] - i << endl;
    result += b[i] - i;
  }


  cout << result << endl;


  return 0;
}

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

using namespace std;



int main(){


	int n; cin >> n;

	vector <int> h(n);


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


	vector < vector <int> > a;

	int current = 1, record = 1;

	for(int i = n - 2; i >= 0; i--){
		if(h[i + 1] <= h[i]){
			current++;
		}else{
			current = 1;
		}

		record = max(record, current);
	}


	cout << record - 1 << endl;




	return 0;
}

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


public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String	strIn = null;

		while ((strIn = parseStdin()) != null) {
			conv(strIn);
		}
	}

	private static void conv(String strIn) {
		int	nA = -1;
		int	nP = -1;

		while (true) {
			nA = strIn.indexOf("apple");
			nP = strIn.indexOf("peach");

			if (nA == -1 && nP == -1) {
				System.out.println(strIn);
				break;
			}
			else if (nA != -1 && (nA < nP || nP == -1)) {
				System.out.print(strIn.substring(0, nA) + "peach");
				strIn = strIn.substring(nA + 5);
			}
			else {
				System.out.print(strIn.substring(0, nP) + "apple");
				strIn = strIn.substring(nP + 5);
			}
		}
	}

	private static String parseStdin() {
		String	strNum = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					strNum = line;
				}
			}
		}
		catch (IOException e) {}

		return strNum;
	}
}

Measured memory_bytes: 16864
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    int n;
    vector<int> cnt;
    Problem(LL n):n(n),cnt(13){};
    int mindist(vector<int> &s){
        int ret=30,prev=0;
        for(auto && x: s){
            ret=min(ret,x-prev);
            prev=x;
        }
        ret = min(ret,24-prev);
        return ret;
    }

    void solve(){
        if(n>=24){
            cout << 0 <<"\n";
            return;
        }
        for(int i=0; i<n; ++i){
            int d;
            cin >> d;
            cnt[d]++;
        }
        int ans=0;
        vector<int> bin;
        if(cnt[0]>=1){
            cout << 0 <<"\n";
            return;
        }
        for(int i=1; i<=11; ++i){
            if(cnt[i]==1)bin.push_back(i);
            if(cnt[i]>=3){
                cout << 0 <<"\n";
                return;
            }
        }
        DBG(cnt)
        if(cnt[12]>=2){
            cout << 0 <<"\n";
            return ;
        }
        for(int i=0; i<(1<<(int)bin.size()); ++i){
            vector<int> used;
            for(int j=1; j<=11; ++j){
                if(cnt[j]==2){
                    used.push_back(j);
                    used.push_back(24-j);
                }
            }
            if(cnt[12]==1)used.push_back(12);
            for(int j=0; j<(int)bin.size(); ++j){
                if((i>>j)&1){
                    used.push_back(bin[j]);
                }else{
                    used.push_back(24-bin[j]);
                }
            }
            sort(used.begin(),used.end());
            DBG(used)
            DBG(mindist(used))
            ans=max(ans,mindist(used));
        }
        cout << ans <<"\n";
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0;
    cin  >> n;
    Problem p(n);
    p.solve();
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main()
{
    set<string> a;
    string s, t = "";
    int n;
    cin >> s >> n;
    for(int i = 0; i < s.length(); ++i)
    {
        t += s[i];
        a.insert(t);
        for(int j = 1; j <= n && i + j < s.length(); ++j)
        {
            t += s[i + j];
            a.insert(t);
        }
        t = "";
    }
    auto ite = a.begin();
    for(int i = 1; i < n; ++i)
    {
        ++ite;
    }
    cout << *ite << "\n";
}

Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	if(a>b) printf("a > b\n");
	else if(a==b) printf("a == b\n");
	else printf("a < b\n");
	return 0;
}


Measured memory_bytes: 3152
//raja1999
 
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
 
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
 
using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define int ll
 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
 
 
//std::ios::sync_with_stdio(false);
 
int main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	ll a,b,v,w,t,den;
	cin>>a>>v>>b>>w>>t;
	den=v-w;
	if(den<=0){
		cout<<"NO"<<endl;
	}
	else{
		if(abs(a-b)<=den*t)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	return 0;
} 

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,y,i,n,m,c,ans=0;cin>>n>>m>>c;
    int b[m];
    for(i=0;i<m;i++){
        cin>>b[i];
    }
    for(i=0;i<n;i++){
        int sum=0;
        for(y=0;y<m;y++){
            cin>>a;
            sum+=a*b[y];
        }
        if(sum+c>0){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;


class Program
{
    static void Main(string[] args)
    {
        string s = crS();
        string t = crS();
        int sLen = s.Length;
        int tLen = t.Length;
        int min = 10000;
        for(int i = 0; i < sLen - tLen + 1; i++)
        {
            string bubun = s.Substring(i, tLen);
            int count = 0;
            for(int j = 0; j < tLen; j++)
            {
                if (bubun[j] != t[j]) count++;
            }
            min = Math.Min(min, count);
        }
        Console.WriteLine(min) ;
    }




    //入力受け取り用
    static string crS() { return Console.ReadLine(); }
    static int crI() { return int.Parse(Console.ReadLine()); }
    static int[] arrInt() { return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray(); }
    static long[] arrLong() { return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray(); }
    static string[] arrStr() { return Console.ReadLine().Split(' ').ToArray(); }
    static List<int[]> mapInt(int h)
    {
        List<int[]> mapInt = new List<int[]>();
        for (int i = 0; i < h; i++)
        {
            mapInt.Add(arrInt());
        }
        return mapInt;
    }

    static List<string[]> mapStr(int h)
    {
        List<string[]> mapStr = new List<string[]>();
        for (int i = 0; i < h; i++)
        {
            mapStr.Add(arrStr());
        }
        return mapStr;
    }

    static List<char[]> mapChar(int h)
    {
        List<char[]> mapChar = new List<char[]>();
        for (int i = 0; i < h; i++)
        {
            string s = crS();
            mapChar.Add(s.ToCharArray());
        }
        return mapChar;
    }

    static List<char[]> mapCharCopy(List<char[]> map)
    {
        List<char[]> copyMap = new List<char[]>();
        foreach (var arr in map)
        {
            List<char> list = new List<char>();
            foreach (var ele in arr)
            {
                list.Add(ele);
            }
            copyMap.Add(list.ToArray());
        }
        return copyMap;
    }
}

Measured memory_bytes: 26172
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long int ll;

ll a,b,x;

ll f(ll n){
    if(n >= 0)	return n/x+1;
    else	return 0;
}

int main(){
    cin >> a >> b >> x;
    cout << f(b) - f(a-1) << endl;
}


Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
l=sorted(l,reverse=True)
if n==2:
    print(l[0])
elif n%2==1:
    k=n//2
    num=l[0]
    for i in range(1,k):
        num+=l[i]*2
    num+=l[k]
    print(num)
else:
    k=n//2
    num=l[0]
    for i in range(1,k):
        num+=l[i]*2
    print(num)

Measured memory_bytes: 94056
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N, K;
  cin>>N>>K;
  vector<Int> cnt(N);
  for(Int i=0;i<K;i++){
    Int d;
    cin>>d;
    for(Int j=0;j<d;j++){
      Int a;
      cin>>a;
      cnt[a - 1]++;
    }
  }

  Int ans = 0;
  for(Int i=0;i<N;i++) if(cnt[i] == 0) ans++;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3664
N = int(input())
ans = 10e10
for i in range(1,int(N/2)+1):
  a = str(i)
  a_sub = 0
  for j in range(len(a)):
    a_sub += int(a[j])
  b = str(N - i)
  b_sub = 0
  for j in range(len(b)):
    b_sub += int(b[j])
  if ans >= b_sub + a_sub:
    ans = a_sub + b_sub
print(ans)

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

int n, xi, mn = 1e9;
vector<int> x, dif, divs;

int main() {
	cin >> n >> xi;
	x = vector<int> (n);
	for(int i = 0; i < n; i++){
		cin >> x[i];
		dif.push_back(max(xi, x[i]) - min(xi, x[i]));
		if((max(xi, x[i]) - min(xi, x[i])) < mn) mn = (max(xi, x[i]) - min(xi, x[i]));

	}
	for(int i = 1; i * i <= mn; i++){
		if(mn % i != 0) continue;
//		cerr << i << " " << mn/i <<"\n";
		divs.push_back(i);
		if(i != mn/i)
		divs.push_back(mn / i);
	}
	sort(divs.begin(), divs.end());
	vector<int> a;
	for(int i = divs.size() - 1; i > -1; i--) a.push_back(divs[i]);
	for(int i : a){
		bool t = true;
		for(int j : dif){
			if(j % i) t = false;
		}
		if(t){
			cout << i << "\n";
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 1276
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data;
using System.Linq;
using System.Numerics;
using System.Text.RegularExpressions;

class Program
{
    static long[] ReadLongs()
        => Console.ReadLine()
            .Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)
            .Select(s => long.Parse(s))
            .ToArray();

    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        if (s.Contains("RRR"))
        {
            Console.WriteLine(3);
        }
        else if (s.Contains("RR"))
        {
            Console.WriteLine(2);
        }
        else if (s.Contains("R"))
        {
            Console.WriteLine(1);
        }
        else
        {
            Console.WriteLine(0);
        }
    }
}


// TODO: cpp: GCD切り出し、非mod GCD作成、segtree作成


Measured memory_bytes: 25952
from collections import defaultdict
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    alst = list(map(int, input().split()))
    alst.sort(reverse = True)
    max_a = alst[0]
    dd = defaultdict(int)
    for a in alst:
        dd[a] += 1
    i = 1
    while i <= max_a:
        i *= 2
    ans = 0
    for a in alst:
        if dd[a] <= 0:
            continue
        while i > a * 2:
            i /= 2
        dd[a] -= 1
        num = i - a
        if dd[num]:
            ans += 1
            dd[num] -= 1
    print(ans)
    
main()

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    string st;
    cin >> st;
    int a = 0, b = 0;
    rep(i, st.size()) {
        if (st[i] == 'R') {
            a++;
        } else {
            b++;
        }
    }

    if (a > b) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
  string S; cin>>S;
  int A=S[0]-'0',B=S[1]-'0',C=S[2]-'0',D=S[3]-'0';
  
  if(A+B+C+D==7) cout<<A<<"+"<<B<<"+"<<C<<"+"<<D<<"=7"<<endl; 
  else if(A-B+C+D==7) cout<<A<<"-"<<B<<"+"<<C<<"+"<<D<<"=7"<<endl; 
  else if(A+B-C+D==7) cout<<A<<"+"<<B<<"-"<<C<<"+"<<D<<"=7"<<endl; 
  else if(A+B+C-D==7) cout<<A<<"+"<<B<<"+"<<C<<"-"<<D<<"=7"<<endl; 
  else if(A-B-C+D==7) cout<<A<<"-"<<B<<"-"<<C<<"+"<<D<<"=7"<<endl; 
  else if(A-B+C-D==7) cout<<A<<"-"<<B<<"+"<<C<<"-"<<D<<"=7"<<endl; 
  else if(A+B-C-D==7) cout<<A<<"+"<<B<<"-"<<C<<"-"<<D<<"=7"<<endl; 
  else if(A-B-C-D==7) cout<<A<<"-"<<B<<"-"<<C<<"-"<<D<<"=7"<<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++)
ll mod = 1000000000+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  
  ll x = 1;
  rep(i,n){
    x=x*10;
  x%=mod;
  }
  ll y=2;
  rep(i,n){
    y*=9;
    y%=mod;
  }
  ll z=1;
  rep(i,n) {
    z*=8;
    z%=mod;
  }
  ll ans = (x-y)%mod;
  if(ans<0) ans+=mod;
  ans = (ans+z)%mod;
  cout<<ans<<endl;
}

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

int main(){
    int x;
    int y;
    cin >> x >> y;
    int ans=0;

    if(x==1){
        ans=ans+300000;
    }else if(x==2){
       ans=ans+200000; 
    }else if(x==3){
        ans=ans+100000;
    }else{
    }

    if(y==1){
        if(ans==300000){
            ans=ans+700000;
        }else{
            ans=ans+300000;
        }
    }else if(y==2){
        ans=ans+200000;
    }else if(y==3){
        ans=ans+100000;
    }else{
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = sorted(list(map(int, input().split())))
memo = [0]*(10**6+1)

for a in A:
    memo[a] += 1
    if memo[a] < 2:
        for i in range(2*a, 10**6+1, a):
            memo[i] += 1

ans = 0
for a in A:
    if memo[a] == 1:
        ans += 1

print(ans)


Measured memory_bytes: 32204
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    long long total=0,x;
    map<long long,long long> mp;
    cin>>n;
    int ar[n+2];
    for(i=0;i<n;i++){
        cin>>ar[i];
        mp[ar[i]]++;
    }
    for(auto it=mp.begin();it!=mp.end();it++){
        x=(*it).second;
        total+=x*(x-1)/2;
    }
    for(i=0;i<n;i++){
        x=mp[ar[i]];
        total-=x*(x-1)/2;
        x--;
        total+=x*(x-1)/2;
        cout<<total<<"\n";
        total-=x*(x-1)/2;
        x++;
        total+=x*(x-1)/2;
    }
}


Measured memory_bytes: 10240
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
using ll = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;};

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

  Int m,n;
  cin>>m>>n;
  vector<Int> ws(m),ts(m);
  for(Int i=0;i<m;i++) cin>>ws[i]>>ts[i];

  vector<Int> cs(n),bs(n);
  for(Int i=0;i<n;i++) cin>>cs[i]>>bs[i];

  vector<Int> sw(m+1,0),st(m+1,0);
  for(Int i=0;i<m;i++){
    sw[i+1]=sw[i]+ws[i];
    st[i+1]=st[i]+ts[i];
  }
  
  Int s=1<<n;
  const Int INF = 1e9;
  vector<Int> dp(s,-INF);
  dp[0]=0;
  for(Int b=0;b<s;b++){
    for(Int i=0;i<n;i++){
      if((b>>i)&1) continue;
      Int nb=b|(1<<i);
      Int x=upper_bound(sw.begin(),sw.end(),sw[dp[b]]+cs[i])-sw.begin();
      Int y=upper_bound(st.begin(),st.end(),st[dp[b]]+bs[i])-st.begin();
      chmax(dp[nb],min(x,y)-1);
    }
  }  
  cout<<dp[s-1]<<endl;
  return 0;
}



Measured memory_bytes: 9276
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <utility>

#define reps(i,f,n) for(ll i=f; i<ll(n); ++i)
#define rep(i,n) reps(i,0,n)

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;

signed main()
{
    string s;
    cin >> s;
    
    bool ok = false;
    rep(i1, 2) rep(i2, 2) rep(i3, 2) rep(i4, 2){
        string a = (i1 ? "A" : "") + string("KIH") + (i2 ? "A" : "") + "B" + (i3 ? "A" : "") + "R" + (i4 ? "A" : "");
        if(a == s) ok = true;
    }
    cout << (ok ? "YES" : "NO") << endl;
}


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


int main(){
    string s; cin >> s;
    ll k; cin >> k;
    ll n = s.size();

    s += s;
    ll a=0,b=0;
    bool all_same = true;
    rep(i,n-1){
        if(s[i]!=s[i+1]){
            all_same = false;
            break;
        }
    }
    rep(i,n-1){
        if(s[i]==s[i+1]){
            a++;
            s[i+1] = '0';
        }
    }

    for(int i=n-1;i<2*n-1;i++){
        if(s[i]==s[i+1]){
            b++;
            s[i+1] = '0';
        }
    }
    if(!all_same) cout << a+b*(k-1) << endl;
    else cout << n*k/2 << endl;
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;



public class Test
{
	public static void Main()
	{
//		while(true){
		  string[] str1 = Console.ReadLine().Split(' ');
		  int n = int.Parse(str1[0]); 
		  int m = int.Parse(str1[1]); 

//		  if(n == 0) break;
		
//		  int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
//		  string ss = Console.ReadLine();
//		  int[] b = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
//		  int[] c = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
		  //Console.WriteLine("改行あり N = {0} P = {1} Ai = {2}", n, p, a);
		  Console.WriteLine(((double)n/(double)m).ToString());
//	    }


	}

  public static int calc(int n,int m,int[] a,int[] b,int[] c) {



	  return 0;
  }
  
  


}


Measured memory_bytes: 13140
import java.io.*;
import java.util.*;

public class Main{

	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public String next(){
			try{
				while(st==null||!st.hasMoreElements()){
					st = new StringTokenizer(br.readLine());
				}
			}catch(Exception e){
				e.printStackTrace();
			}
			return st.nextToken();

		}
		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
		public String nextLine(){
			String s = "";
			try{
				s = br.readLine();
			}catch(Exception e){
				e.printStackTrace();
			}	
			return s;		
		}
	} 

	public static void main(String[] args){
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		String s1 = in.next();
		String s2 = in.next();
		if(s1.length()>s2.length())out.println("GREATER");
		else if (s1.length()<s2.length())out.println("LESS");
		else{
			int cmp = s1.compareTo(s2);
			if(cmp==0){
				out.println("EQUAL");
			}
			else if(cmp>0)out.println("GREATER");
			else out.println("LESS");	


		}
		out.flush();
		out.close(); 
	}

}



Measured memory_bytes: 20564
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

string s,t,ans="";
int dp[3010][3010];
pair <pii,int> pre[3010][3010];

int main()
{
	cin>>s>>t;
	rep(i,3005) rep(j,3005) dp[i][j]=-1;
	dp[0][0]=0;
	pre[0][0]=mpr(mpr(-1,-1),0);
	rep(i,s.size()+1)
	{
		rep(j,t.size()+1)
		{
			if(dp[i][j]==-1) continue;
			if(i<s.size()&&j<t.size()&&s[i]==t[j]&&dp[i+1][j+1]<dp[i][j]+1)
			{
				dp[i+1][j+1]=dp[i][j]+1;
				pre[i+1][j+1]=mpr(mpr(i,j),1);
			}
			if(i<s.size()&&j<t.size()&&dp[i+1][j+1]<dp[i][j])
			{
				dp[i+1][j+1]=dp[i][j];
				pre[i+1][j+1]=mpr(mpr(i,j),0);
			}
			if(i<s.size()&&dp[i+1][j]<dp[i][j])
			{
				dp[i+1][j]=dp[i][j];
				pre[i+1][j]=mpr(mpr(i,j),0);
			}
			if(j<t.size()&&dp[i][j+1]<dp[i][j])
			{
				dp[i][j+1]=dp[i][j];
				pre[i][j+1]=mpr(mpr(i,j),0);
			}
		}
	}
	int x=s.size(),y=t.size();
	while(x>-1)
	{
		int tmp=pre[x][y].se,tmp2=x;
		x=pre[x][y].fi.fi;
		y=pre[tmp2][y].fi.se;
		if(tmp==1) ans.pb(s[x]);
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 141824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007

bool dbgflag = false;

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

  ll n, k;
  cin >> n >> k;
  vector<int> teleporter(n);
  for (int i = 0; i < n; i++) cin >> teleporter[i];
  vector<int> appear(n, -1), nexts(2*n); //はじめ何番目に現れる？
  
  int now = 1;
  int cnt = 0;
  int rep;
  for (int i = 0; i <= n; i++) {
    if (appear[now-1] != -1) {
      rep = cnt - appear[now-1];
      break;
    }
    nexts[i] = now;
    appear[now-1] = cnt;
    now = teleporter[now-1];
    cnt++;
  }
  cnt -= rep;
  if (dbgflag) cout << rep << " " << cnt << endl;

  if (k < cnt) {
    cout << nexts[k] << endl;
    return 0;
  }
  k -= cnt;
  cout << nexts[cnt + (k%rep)] << endl;
}


Measured memory_bytes: 6368
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;
const int MOD = 1000000007;

int main() {
	int N, M, T;
	cin >> N >> M >> T;

	vi a(N);
	REP(i, N) {
		cin >> a[i];
	}

	int ans = max(a[0] - M, 0);
	FOR(i, 1, N - 1) {
		ans += max(a[i] - a[i - 1] - 2 * M, 0);
	}
	ans += max(T - a[N - 1] - M, 0);

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3080
N,M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
ans=0

for i in range(1,M+1):
  chk=0
  for j in range(N):
    if i in A[j][1:]:
      chk += 1
    if chk == N:
      ans += 1
print(ans)



Measured memory_bytes: 3060
import itertools
li=[]
n,m,q=map(int,input().split())#n:Aの長さ m:A[n]の最大値 q=(a,b,c,d)の組の数
ans=0
ansl=[0]
for cnt in range(q):
    a,b,c,d=map(int,input().split())
    li.append([a,b,c,d])
for A in itertools.combinations_with_replacement(range(1,m+1),n):#重複組み合わせmHn
    for i in range(q):
        if li[i][2]==A[li[i][1]-1]-A[li[i][0]-1]:
            ans+=li[i][3]
    ansl.append(ans)
    ans=0
print(max(ansl))


Measured memory_bytes: 12588
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            a.add(Integer.parseInt(sc.next()));
        }

        // 主処理
        int max = a.stream().mapToInt(t -> t).max().getAsInt() + 1;
        int[] count = new int[max + 1];
        for (int num : a) {
            int minus1 = num - 1;
            int plus1 = num + 1;
            if (0 <= minus1) {
                count[minus1]++;
            }
            count[plus1]++;
            count[num]++;
        }
        int result = Arrays.stream(count).max().getAsInt();

        // 出力
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 47244
/*
* @Author: dnhirapara
* @Date: 2020-04-25 19:37
* @Name: dp_b
*/

#include <bits/stdc++.h>

using namespace std;

/************defination************/

#define endl "\n"
#define log(x) cerr << __LINE__ << ": " << #x << " -> " << (x) << endl;
#define ll long long int
#define ull unsigned long long int

void in_out_file(){
    #ifdef _DEBUG
        freopen("F:/Coding/CompetitiveProg/static/input.txt", "r", stdin);
        freopen("F:/Coding/CompetitiveProg/static/output.txt", "w", stdout);
        freopen("F:/Coding/CompetitiveProg/static/debug.txt", "w", stderr);
    #endif
}

int main(){
    // cin.ignore(); must be there when using getline(cin, s)
    #ifndef AUTO
        in_out_file();
    #endif
    ll n, k;
    cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans = 0;
    ll dp[n] ;
    for(ll i=0;i<n;i++){
        dp[i] = INT_MAX;
    }
    dp[0] = 0;
    for(ll i=0;i<n;i++){
        for(ll j=1;j<=k && j<=i;j++){
            dp[i] = min(dp[i-j]+(abs(a[i]-a[i-j])),dp[i]);
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define MOD 1000000007
#define ALL(a) (a).begin(),(a).end()
#define ms(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10) 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge{ int from, to, cost; };

int main()
{
	int n, m;
	int h[2000]; int w[2000];
	while (cin >> n >> m, n)
	{
		REP(i, n) cin >> h[i];
		REP(i, m) cin >> w[i];
		map<int,int> ari;
		int sh[2000]; int sw[2000];
		sh[0] = sw[0] = 0;
		FOR(i,1, n+1) sh[i] = sh[i - 1] + h[i - 1];
		FOR(i, 1, m + 1) sw[i] = sw[i - 1] + w[i - 1];
		REP(i, n)FOR(j, i + 1, n+1)
		{
			int t = sh[j] - sh[i];
			if (ari.find(t) == ari.end()) ari[t] = 1;
			else ari[t]++;
		}
		int cnt = 0;
		REP(i, m)FOR(j, i + 1, m+1)
		{
			cnt += ari[sw[j] - sw[i]];
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 19068
import java.util.Scanner;

class Main {

    public static int min(int a, int b) {
        if (a < b) {
            return a;
        } else {
            return b;
        }

    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] candles = new int[n];
        for (int i = 0; i < n; i++) {
            candles[i] = scanner.nextInt();
        }

        int ans = Integer.MAX_VALUE;

        for (int i = 0; i < n - k + 1; i++) {
            int a = Math.abs(candles[i] - candles[i + k - 1]) + Math.abs(candles[i]);
            int b = Math.abs(candles[i] - candles[i + k - 1]) + Math.abs(candles[i + k - 1]);
            int min = min(a, b);
            if (min < ans)
                ans = min;
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 50200
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int x,y;
  cin>>x>>y;
  
  cout<<x+y/2<<endl;

  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    ll n; cin >> n;
    vector<ll> num(100001,0);
    rep(i,n){
        ll a; cin >> a;
        num.at(a)++;
    }
    ll notzero_count = 0;
    ll tot = 0;
    for(ll i=0;i<=100000;i++){
        if(num.at(i)!=0) notzero_count++;
        tot += num.at(i);        
    }
    if((tot-notzero_count)%2) notzero_count--;
    cout << notzero_count << endl;
}

Measured memory_bytes: 1024
X, N = map(int, input().split())

if N == 0:
	print(X)
	exit()

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

Sa = []

Ba = list(range(-1, 102))
Cha = list(range(-1, 102))

for i in range (0, N):
	if Ba.count(P[i]) > 0:
		Cha.remove(P[i])

Denbaba = len(Cha)

for i in range (0, Denbaba):
	Sa.append(abs(Cha[i]-X))

Da = min(Sa)

for i in range (0, Denbaba):
	if Sa[i] != Da:
		Cha[i]=1000000


print(min(Cha))

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

int main() {

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

    long long r, d, x;
    cin >> r >> d >> x;

    for(int i=1; i<=10; i++)
    {
        x = r * x - d;
        cout << x << "\n";
    }

    return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

lli gcd(lli x, lli y)
{
       if(x<y)swap(x,y);
        if (y == 0) {
                return x;
        } else {
                return gcd(y, x % y);
        }
}

lli lcm(lli a,lli b)
{
   return a*b/gcd(a,b);
}


signed main(){

	lli n,m;
	cin>>n>>m;

	vector<lli> a(n);
	lli LCM = 1;
	REP(i,0,n){
		cin>>a[i];
		a[i]/=2;
		LCM = lcm(LCM,a[i]);
		if(LCM > m){
			cout<<0<<endl;
			return 0;
		}
	}
	REP(i,0,n){
		if((LCM/a[i])%2==0){
			cout<<0<<endl;
			return 0;
		}
	}
	if((m/LCM)%2){
		cout<<(m/LCM+1)/2<<endl;
	}
	else{
		cout<<(m/LCM)/2<<endl;
	}
}


Measured memory_bytes: 1024
def main():
    n = int(input())
    A = input().split()
    B = [0] * n
    k = n % 2
    l = n // 2
    if k == 0:
        l -= 1
    r = l + 1
    for i in range(n):
        if i % 2 != k:
            B[l] = A[i]
            l -= 1
        else:
            B[r] = A[i]
            r += 1
    print(' '.join(B))


main()


Measured memory_bytes: 25716
MOD = 10**9 + 7
MAX = int(2e5+1)


def div(a, b):
    return a * pow(b, MOD-2, MOD) % MOD


FACT = [1] * (MAX+1)
for i in range(1, MAX+1):
    FACT[i] = (i * FACT[i-1]) % MOD
INV = [1] * (MAX+1)
INV[MAX] = div(1, FACT[MAX])
for i in range(MAX, 0, -1):
    INV[i-1] = (INV[i] * i) % MOD


def main():
    H, W, A, B = map(int, input().split())
    ans = 0
    i = H-A-1
    j = B
    while i >= 0 and j < W:
        a = (FACT[i+j] * INV[i] * INV[j]) % MOD
        b = (FACT[H-i-1 + W-j-1] * INV[H-i-1] * INV[W-j-1]) % MOD
        ans = (ans + a * b) % MOD
        i -= 1
        j += 1
    print(ans)


if __name__ == "__main__":
    main()


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

int main()
{
	int N;
	cin >> N;
	int a, b;
	a = N / 10;
	b = N % 10;
	if (a==9||b==9)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var ans = 0
    for (i in 1..9) {
        for (j in 1..9) {
            var x = 0
            var y = 0

            for (k in 1..n) {
                val (a, b) = k.toString().let { it.first() - '0' to it.last() - '0' }
                if (a == i && b == j) x++
                if (b == i && a == j) y++
            }

            ans += x * y
        }
    }
    println(ans)
}


Measured memory_bytes: 112220
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = scan!(usize);
    let vs = scan!(i64;;);
    let num = vs.iter().filter(|&&x| x < 0).count();

    let plus_total = vs.iter().map(|v| v.abs()).sum::<i64>();
    if num % 2 == 0 {
        println!("{}", plus_total);
    } else {
        let min = vs.iter().map(|v| v.abs()).min().unwrap();
        println!("{}", plus_total - 2 * min)
    }
}


Measured memory_bytes: 8444
n,m = map(int,input().split())
a = set([int(input()) for _ in range(m)])
mod = 10**9+7
fl = [0]*(n+1)
fl[0] = 1

for i in range(1,n+1):
    if i not in a:
        fl[i] = (fl[i-1] + fl[i-2])%mod
    else:
        fl[i] = 0
print(fl[-1])

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

int main()
{
    int n, m, a;

    cin >> n >> m;

    int max = 0;
    for( int i = 0; i < n; i++ )
    {
        int cnt = 0;
        for( int j = 0; j < m; j++ )
        {
            cin >> a;
            if( a == 1 )
                cnt++;
        }
        if( max < cnt )
            max = cnt;
    }

    cout << max << endl;

    return 0;
}


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

long long N,M,B,C,i,j,n,ans;

main(){
    cin>>N>>M;
    vector<long long>A(N);
    vector<pair<long long,int>>c(M);

    for(auto&a:A) cin>>a;
    sort(A.begin(),A.end());

    for(;i<M;++i){
        cin >> B >> C;
        c[i]=make_pair(C,B);
    }
    sort(c.begin(),c.end());

    // ソートしてAの最小値をCの最大値から書き換えていく．
    // 書き換え出来なくなったら総和取って返す．
    for(i=0,j=M-1,n=c[M-1].second; i<N&&A[i]<c[j].first; ++i){
        A[i]=c[j].first;
        // nは回数。nが0になったらjが1減り、nが補充される．
        if(--n==0&&--j>=0) n=c[j].second;
    }

    ans = accumulate(A.begin(),A.end(),0LL);
    cout << ans;
    return 0;
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;
  cin>>n;
  string s;cin>>s;

  int res=n;
  for(int i=0;i<n-1;i++){
    if(s[i]==s[i+1])res--;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 512