akhauriyash/Code-Regression huggingface dataset:
package main

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

type Row []string

type Data []Row

func main() {
	nextReader = newScanner()
	N := nextString()
	byteIdx := strings.IndexRune(N, '7')
	if byteIdx != -1 {
		fmt.Printf("Yes")
		return
	}
	fmt.Printf("No")
}

var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	// r.Split(bufio.ScanLines)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func CustomScan(data []byte, atEOF bool) (advance int, token []byte, err error) {
	for i := 0; i < len(data); i++ {
		if data[i] == ' ' {
			return i + 1, data[:i], nil
		}
	}
	fmt.Println(data)
	return 0, data, bufio.ErrFinalToken
}

func nextStrings() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	// r.Split(bufio.ScanWords)
	r.Split(CustomScan)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}


Measured memory_bytes: 1756
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*
int inv[1000001]={0};int invf[1000001]={0};
void findinverse(){
	inv[0]=1;
	inv[1] = 1;
	for(int i = 2; i <=1e6 ; ++i)
		inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;
	invf[0]=1;invf[1]=1;
	for(int i=2;i<=1e6;i++){
		invf[i]=invf[i-1]*inv[i]%mod;
	}
}*/
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> orderedMultiset;
int solve()
{
	int k,x;
	cin>>k>>x;
	for(int i=x-(k-1);i<=x+(k-1);i++)
		cout<<i<<" ";
	cout<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}



Measured memory_bytes: 3536
using System;

namespace ITP1_2_D
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] inputs = Console.ReadLine().Split(' ');
            int W = Convert.ToInt32(inputs[0], 10);
            int H = Convert.ToInt32(inputs[1], 10);
            int x = Convert.ToInt32(inputs[2], 10);
            int y = Convert.ToInt32(inputs[3], 10);
            int r = Convert.ToInt32(inputs[4], 10);

            if(x - r >= 0 && x + r <= W)
            {
                if(y - r >= 0 && y + r <= H)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 5364
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int primax = 250000;
		int[] pri = new int[primax+10000];
		for(int i=2;i<=primax;i++) pri[i] = i;
		for(int i=2;i<=primax+1;i++){
			for(int j=i+i;j<=primax;j+=i){
					pri[j]=0;
			}
		}
		
		while(true){
			int n = sc.nextInt();
			int p = sc.nextInt();
			if(n==-1 && p==-1) break;
			
			int[] a = new int[p+1];
			int count = 0;
			for(int i=n+1;;i++){
				if(pri[i]>0){
					a[count] = pri[i];
					count++;
				}
				if(count==p+1) break;
			}
			
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i=0;i<=p;i++){
				for(int j=i;j<=p;j++){
					list.add(a[i]+a[j]);
				}
			}
			Collections.sort(list);
			System.out.println(list.get(p-1));
		}
	}
}

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

int main(){
  int N;cin>>N;
  int h[N];
  int dp[N];
  rep(i,N) cin>>h[i];
  
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(int i=2;i<N;i++){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[N-1]<<endl;
}

Measured memory_bytes: 4408
#include<stdio.h>
int main(){
	int h, w, i, j;
	while(1){
		scanf("%d %d", &h, &w);
		if(h == 0 && w == 0){
			break;
		}
		for (i = 1; i <= h; i++){
			for (j = 1; j <= w; j++){
				if(i % 2 == 1 && j % 2 == 1){
					printf("#");
				}else if(i % 2 == 0 && j % 2 == 0){
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
} 


Measured memory_bytes: 2104
N=int(input())
A=list(map(int, input().split()))
B=A
M=max(A)
k=0
Fumi=0

for k in range(1,N):
    if A[k-1]>A[k]:
        Fumi=Fumi+A[k-1]-A[k]
        A[k]=A[k-1]
    k=k+1

print(Fumi)

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

const int MAXV = 50005;

int coin[20], dp[MAXV];

int main(){

	int N, M;
	scanf("%d%d",&N,&M);

	for (int i=0; i<N; i++) scanf("%d",&coin[i]);

	memset(dp, -1, sizeof(dp));
	
	dp[0] = 0;
	for (int i=0; i<M; i++) {
    	for (int x = coin[i]; x <= N; x++) {
        	if (dp[x-coin[i]] == -1) continue;

        	if (dp[x] == -1 || dp[x] > dp[x-coin[i]] + 1)
        		dp[x] = dp[x-coin[i]] + 1;
    	}
	}

	if (dp[N] == -1) printf("Impossible\n");
	else printf("%d\n", dp[N]);
}

Measured memory_bytes: 1392
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=100005;
int n,m;
struct node{int a,b;}w[MAXN];
bool cmp(node n1,node n2){return n1.a!=n2.a?n1.a<n2.a:n1.b>n2.b;}
priority_queue<pii,vector<pii>,greater<pii> > hp;
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;i++)w[i].a=m-read()+1,w[i].b=read();
	sort(w+1,w+1+n,cmp);
	for(int i=1;i<=n;i++)
	{
		int c=hp.size();
		if(w[i].a&&w[i].a==c)
		{
			pii temp=hp.top();
			if(w[i].b>temp.first)hp.pop(),hp.push(mp(w[i].b,w[i].a));
		}
		else if(w[i].a>c)hp.push(mp(w[i].b,w[i].a));
	}
	LL ans=0;
	while(!hp.empty())
	{
		pii temp=hp.top();ans+=temp.first;hp.pop();
	}
	pr2(ans);
}


Measured memory_bytes: 2168
n,m,x = map(int, input().split())
a = list(map(int, input().split()))
b = 0
c = 0
for i in range(m):
    if 0 < a[i] < x:
        b += 1
    elif x < a[i] < n:
        c += 1
print(min(b,c)) 

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

using namespace std;

#define ll					long long
#define vi					vector<int>
#define vii					vector<vi>
#define ALL(s)			(s).begin(),(s).end()
#define pii					pair<int, int>
#define pll					pair<ll, ll>
#define si					set<int>
#define mp					make_pair
#define F						first
#define S						second
#define pb					push_back
#define tc(t)				int t; cin >> t; while(t--)
#define _						ios_base::sync_with_stdio(false); cin.tie(NULL); 
const ll MOD = 1e9 + 7;
const ll INF = 1<<29;
const ll MAX_N = 1e6 + 7;

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

	ll ans = 0;
	ans += (n/500)*1000;
	n %= 500;
	ans += (n/5)*5;

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


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<stack>
#include<vector>
using namespace std;
int main()
{
    stack<int> s;
    int n;
    cin >> n;
    if(n == 0){
        cout << 0 << endl;
        return 0;
    }
    while(n != 0){
        s.push(abs(n) % 2);
        n -= s.top();
        n /= -2;
    }
    while(s.empty() == 0){
        cout << (s.top() == 0 ? 0 : 1) << flush;
        s.pop();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool D[10];
bool a(int x) {
    while (x) {
        if (D[x % 10])
            return false;
        x /= 10;
    }
    return true;
}
int main() {
    int N, K, d;
    cin >> N >> K;
    for (; K--;) {
        cin >> d;
        D[d] = true;
    }
    while (!a(N))
        N++;
    cout << N << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma once
#include <algorithm>
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
using namespace std;
//int hito;
//int sa[100000]={};
int A,B,result;
string S;

int main(){
	/*scanf("%d",&hito);

	for(int i=0;i<hito;i++){
		scanf("%d",&sa[i]);
	}*/

	scanf("%d",&A);
	cin>>S;
	scanf("%d",&B);

	if(S[0]=='+'){
		result=A+B;
	}
	else{
		result=A-B;
	}
	printf("%d\n",result);

return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String n =scan.nextLine();
		ArrayList<Integer> list = new ArrayList<Integer>();
		int sss =1000000;
		int ddd =-1000000;
		long sum =0;
		long kazuA = 0;
		long kazuB = 0;
		while(scan.hasNextInt()){
			int x = scan.nextInt();
			list.add(x);
		}
		for(int i=0;i<list.size();i++){
			kazuA = list.get(i);
			if(kazuA < sss){
				sss = list.get(i);
			}
			if(kazuA > ddd){
				ddd = list.get(i);
			}
			sum+= list.get(i);
		} 
		System.out.println(sss+" "+ddd+" "+sum);
	}
}

Measured memory_bytes: 42772
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

using namespace std;

typedef long long int lli;

#define N_MAX 100
#define W_MAX 3
#define MOD 1000000007

pair<int, int> table[N_MAX];
int memo[N_MAX][N_MAX + 1][N_MAX*W_MAX+1];

int func(int index, int cnt, int sum)
{
	if (sum < 0){
		return -1;
	}
	if (cnt < 0){
		return -1;
	}
	if (-2 != memo[index][cnt][sum]){
		return memo[index][cnt][sum];
	}
	if (0 == index){
		if (cnt > 1){
			return -1;
		}
		else if (1 == cnt){
			if (table[index].first <= sum){
				return table[index].second;
			}
			else{
				return -1;
			}
		}
		else{
			return 0;
		}
	}

	int val1 = func(index - 1, cnt - 1, sum - table[index].first);
	if (-1 != val1){
		val1 += table[index].second;
	}
	int val2 = func(index - 1, cnt, sum);

	return memo[index][cnt][sum] = (val1 > val2 ? val1 : val2);
}

void solv()
{
	int N, W; scanf("%d%d", &N, &W);
	for (int i = 0; i < N; i++){
		int w, v; scanf("%d%d", &w, &v);
		table[i] = make_pair(w, v);
	}

	int w0 = table[0].first;
	for (int i = 0; i < N; i++){
		table[i].first -= w0;
	}

	for (int i = 0; i < N; i++){
		for (int j = 0; j <= N; j++){
			fill(memo[i][j], memo[i][j] + N_MAX*W_MAX + 1, -2);
		}
	}

	int ret = 0;
	for (int cnt = 1; cnt <= N; cnt++){
		if (w0*cnt > W){
			break;
		}
		ret = max(ret, func(N - 1, cnt, min(W - w0*cnt, W_MAX*N)));
	}

	printf("%d\n", ret);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 12032
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;
ll mod = 1e9+7;

int main(){

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

	std::vector<ll> dp(N+1);
	std::vector<int> A(N+1,0);

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

	dp[0] = 1;
	if (A[1] == 1) dp[1] = 0;
	else dp[1] = 1;

	//cout << 1 << ":" <<dp[1] << endl;

	for (int i = 2; i <= N; i++)
	{
		if(A[i] == 1)dp[i] = 0;
		else dp[i] = (dp[i-1] + dp[i-2]) % mod;
		//cout << i << ":" <<dp[i] << endl;
	}

	cout << dp[N] << endl;

	return 0;
}

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = 1e16;
const int N = 1e6+5;

int a[N],mx_nlf[N],tot[N];

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n = 100000;
        cin>>n;
        for(int i=0;i<=n;i++)cin>>a[i];
        int ok = 1;
        if(!n)
        {
            if(!a[0] || a[0]>1)cout<<-1<<endl;
            else cout<<1<<endl;
            return 0;
        }
        if(a[0])return cout<<-1<<endl,0;
        tot[0] = 1;
        mx_nlf[0] = 1;
        for(int i=1;ok && i<=n;i++)
        {
            tot[i] = 2LL*mx_nlf[i-1];
            if(tot[i] > M)tot[i] = M;
            mx_nlf[i] = tot[i] - a[i];
            if(mx_nlf[i] < 0)ok = 0;
            if(mx_nlf[i] == 0 && i<n)ok = 0;
        }
        int ans = a[n];
        mx_nlf[n] = 0;
        tot[n] = a[n];
        for(int i=n-1;ok && i>=0;i--)
        {
            if(tot[i+1] > 2LL*mx_nlf[i])ok = 0;
            mx_nlf[i] = min(mx_nlf[i],tot[i+1]);
            tot[i] = mx_nlf[i] + a[i];
            ans += tot[i];
        }
        if(!ok)ans = -1;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 6004
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <cctype>
#include <cstdio>
#include<string>
using namespace std;

int main(){
   int alp[26]={};
   string str;

   while(getline(cin,str)){
      for(int i=0;i<str.size();i++){
         if(str[i]>='a'&&str[i]<='z') alp[str[i]-'a']++;
         else if(str[i]>='A'&&str[i]<='Z') alp[str[i]-'A']++;
      }
   }

   for(int i=0;i<26;i++){
      printf("%c : %d\n",(char)('a'+i),alp[i]);
   }

   return 0;
}



Measured memory_bytes: 3300
object Main extends App {
  import scala.io.StdIn._
  val Array(x, y) = readLine.trim.split(' ').map(_.toInt)
  var top = 0L
  var right = 0L
  var bottom = 0L
  var left = 0L
  println(search())
  def search(a: Long = 1, b: Long = 2, count: Int = 0): Int = {
    if (left <= x && x <= right && bottom <= y && y <= top) return count % 3 + 1
    (count % 4) match {
      case 0 ⇒
        right += a
        search(b, a + b, count + 1)
      case 1 ⇒
        top += a
        search(b, a + b, count + 1)
      case 2 ⇒
        left -= a
        search(b, a + b, count + 1)
      case 3 ⇒
        bottom -= a
        search(b, a + b, count + 1)
      case _ ⇒ ???
    }
  }
}


Measured memory_bytes: 43976
#include <iostream>

using namespace std;

int main(){
    int N, sum = 0;
    cin >> N;
    int V[N], C[N];
    for(int i = 0; i < N; i++)cin >> V[i];
    for(int i = 0; i < N; i++)cin >> C[i];
    for(int i = 0; i < N; i++){
        if(V[i] - C[i] > 0) sum += V[i] - C[i];
    }
    cout << sum << endl;
}

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

using namespace std;


#define MAXN 100001
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, h[MAXN] = {};
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    h[a]++;
    if (a<MAXN-1) h[a+1]++;
    if (a>1) h[a-1]++;
  }
  int ans = 0;
  for (int i = 1; i < MAXN; ++i) {
    ans = max(ans, h[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

bool visited[9];
ll ans = 0;
vector<int> point[9];
int n,m;

void dfs(int x) {
  visited[x] = true;

  for (auto to : point[x]) {
    // 次
    if (!visited[to]) {
      dfs(to);
    }
  }

  bool flag = true;
  for (int i = 1; i <= n; ++i) {
    if (!visited[i]) {
      visited[x] = false;
      return;
    }
  }
  visited[x] = false;
  ans += 1;
  return;
}


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

  rep(i,m) {
    int a,b; cin >> a >> b;
    point[a].pb(b);
    point[b].pb(a);
  }

  dfs(1);
  cout << ans << endl;
}


Measured memory_bytes: 256
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.c
 * Author: kundaikwangwari
 *
 * Created on July 23, 2019, 8:15 PM
 */

#include <stdio.h>
#include <stdlib.h>
#define NIL -1
#define White 0
#define Grey 1
#define Black 2
#define size 105

/*
 * 
 */
int Timetrack,n;
int table[size][size];

void Visit(int V,int *StartTime,int *FinishTime, int *Color){
    
    
    //printf("am now visiting\n");

    Color[V] = Grey;
    //printf("going intp node %d, color %d\n",V,Color[V]);
    StartTime[V] = ++Timetrack;
    for(int u = 1; u < n + 1; u++){
        if(table[V][u] == NIL)continue;
        if(Color[u] == White)Visit(u,StartTime,FinishTime,Color);
    }
    Color[V] = Black;
    FinishTime[V] = ++Timetrack;


}

void DepthFirstSearch(int *Color,int *StartTime,int *FinishTime){
   
    for(int V = 1; V < n + 1; V++){
        Color[V] = White;
        Timetrack = 0;
    }
    
    for(int V = 1; V < n + 1; V++){
        //printf("about to visit...");
        if(Color[V] == White)Visit(V,StartTime,FinishTime,Color);
    }

}
int main(int argc, char** argv) {

    int V,k,edge;
    scanf("%d",&n);
    
    int Color[n+1],StartTime[n+1],FinishTime[n+1];
    for(int i = 1; i < n + 1; i++){
        for(int a = 1; a < n + 1; a++)table[i][a] = NIL;
}
    
    for(int i = 0; i < n ; i++){
        
        scanf("%d%d",&V,&k);
        //printf("V %d edges %d\n",V,edge);
        for(int a = 0; a < k; a++){
            scanf("%d",&edge);
            table[V][edge] = 1;
            //printf("table(%d)(%d) has value %d \n",V,edge,table[V][edge]);
        }
    }
    
    
        DepthFirstSearch(Color,StartTime,FinishTime);
        for(int i = 1; i < n + 1; i++){
            printf("%d %d %d\n",i,StartTime[i], FinishTime[i]);
        }
    
    return (0);
}




Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1.0)
#define pb push_back
#define vi vector<int>
#define mapii map<int , int>
#define mapci map<char, int>
#define mapsi map<string,int>
#define FOR(i,n) for(int i = 0;i<n;i++)
#define CP(n) cout<<"Case "<<n<<": "
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
#define MAX 1000007
#define all(x)(x.begin(),x.end())
#define debug(x,c) cout<<x<<": "<<c<<" ";
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
int main()
{
	int n;
	cin>>n;
	ll a[n];
	FOR(i,n)cin>>a[i];
	ll ans = 0,mx = 0;
	FOR(i,n)
	{
		if(a[i]>mx)
		{
			mx = a[i];
		}
		else
			ans+=(mx - a[i]);
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
    int a,b,c;
    int sum = 0;
    cin >> a >> b >> c;

    for (int i = a; i <= b; ++i) {
        if (c % i == 0) {
            ++sum;
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
map<string,long long int>u;
int main()
{
    u["SAT"]=1;
    u["SUN"]=7;
    u["FRI"]=2;
    u["THU"]=3;
    u["WED"]=4;
    u["TUE"]=5;
    u["MON"]=6;
    long long int n,m,o,p,q,i,j,k,l,s,t,r;
    string a;
    cin>>a;
    cout<<u[a]<<endl;

    return 0;
}


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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  
  int xa = min(a, k);
  k -= xa;
  
  int xb = min(b, k);
  k -= xb;
  
  int xc = k;
  
  cout << xa - xc << endl;
}  

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

vector<int> rs[502];
int a[502][502];

int main(){
	int N,M,Q;
	cin>>N>>M>>Q;
	rep(i,M){
		int l,r;
		cin>>l>>r;
		rs[l].push_back(r);
	}
	
	rep1(i,N){
		sort(rs[i].begin(),rs[i].end());
	}
	int num[502];
	rep1(i,N)num[i]=rs[i].size();
	
	for(int j=N;j>0;j--){
		int p=0;
		for(int i=j;i>0;i--){
			int q=upper_bound(rs[i].begin(),rs[i].end(),j)-rs[i].begin();
			p+=q;
			a[i][j]=p;
		}
	}
	rep(i,Q){
		int p,q;
		cin>>p>>q;
		cout<<a[p][q]<<endl;
	}
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=100010;
int n,k,f1[2010],f2[2010];
ll power(ll x,ll y)
{
  ll ans=1,temp=x;
  while(y)
  {
    if(y&1) ans=(1ll*ans*temp)%mod;
    temp=(1ll*temp*temp)%mod;
    y/=2;
    // cout<<temp<<" "<<ans<<" "<<y<<endl;
  }
  return ans;
}
ll mod_inverse(int x)
{
  return power(x,mod-2);//Mod has to be prime
}
int main()
{
  cin>>n>>k;
  f1[0]=1,f2[0]=1;
  int x=n-k+1;
  for(int i=1;i<=k;i++) f1[i]=(1ll*i*f1[i-1])%mod;
  for(int i=1;i<=x;i++) f2[i]=(1ll*i*f2[i-1])%mod;
  for(int i=1;i<=k;i++)
  {
    int ans=0;
    int y=x-i;
    if(y<0) y=0;
    else y=f2[x-i];
    ans=(1ll*((1ll*f2[x]*mod_inverse(f1[i]))%mod)*mod_inverse(y))%mod;
    y=k-i;
    if(y<0) y=0;
    else y=f1[k-i];
    int temp=(1ll*((1ll*f1[k-1]*mod_inverse(f1[i-1]))%mod)*mod_inverse(y))%mod;
    ans=(1ll*ans*temp)%mod;
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
int main()
{
	int a;
	int b;
	bool aa = false;
	cin >> a >> b;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '-') {
			if (i != a) {
				aa = true;
				break;
			}
		}
		if (s[a] != '-') {
			aa = true;
			break;
		}
	}
	if (aa)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

ans = 0
hand = []
for i in range(K):
    if T[i] == "r":
        ans += P
        hand.append("p")
    elif T[i] == "s":
        ans += R
        hand.append("r")
    else:
        ans += S
        hand.append("s")

for i in range(K, N):
    if T[i] == "r" and hand[i-K] != "p":
        ans += P
        hand.append("p")
    elif T[i] == "s" and hand[i-K] != "r":
        ans += R
        hand.append("r")
    elif T[i] == "p" and hand[i-K] != "s":
        ans += S
        hand.append("s")
    else:
        hand.append("joker")
        
        
print(ans)

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};

int main(){
  int a,b,N;
  cin>>N>>a>>b;
  int now=a;
  string ans="NG";
  for(int i=a ; i<=b ; i++){
    if(i%N==0) ans="OK";
  }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

// http://arc081.contest.atcoder.jp/tasks/arc081_c



int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  string str;
  cin >> str;

  vector<vector<size_t>> xs(26);
  for(size_t i = 0; i < str.size(); ++i)
    xs[str[i] - 'a'].push_back(i);

  typedef struct {
    size_t idx;
    size_t cnt;
    char ch;
  } value_t;

  const auto n = str.size();
  vector<value_t> next(str.size());

  for(size_t x = n - 1; x < n; --x)
  {
    next[x].idx = -1;
    next[x].cnt = -1;
    next[x].ch = '?';

    for(size_t i = 0; i < xs.size(); ++i)
    {
      const auto iter = lower_bound(begin(xs[i]), end(xs[i]), x + 1);
      if (iter != end(xs[i]))
      {
        const auto& v = next[*iter];
        if (v.cnt + 1 < next[x].cnt)
        {
          next[x].idx = *iter;
          next[x].cnt = v.cnt + 1;
          next[x].ch = 'a' + i;
        }
      }
      else
      {
        next[x].idx = -1;
        next[x].cnt = 2;
        next[x].ch = 'a' + i;
        break;
      }
    }
  }

  size_t size = -1, idx = -1;

  for(size_t i = 0; i < xs.size(); ++i)
    if(xs[i].empty())
    {
      cout << ((char) ('a' + i));
      return 0;
    }
    else if (next[xs[i].front()].cnt < size)
    {
      size = next[xs[i].front()].cnt;
      idx = i;
    }

  size_t x = xs[idx].front();
  cout << str[x];

  for(; x != (size_t) -1;)
  {
    cout << next[x].ch;
    x = next[x].idx;
  }

  return EXIT_SUCCESS;
}


Measured memory_bytes: 7060
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**7)
inf = float('inf')
mod = 10**9+7
ans = inf ;count = 0 ;pro = 1

S=input()
C=collections.Counter(S)
print(C["1"])

Measured memory_bytes: 38512
using System;
class Program
{
	static void Main(string[] args)
	{
        int x = int.Parse(Console.ReadLine());
        int ureshisa = 0;
        ureshisa += x / 500 * 1000;
        x = x % 500;
        ureshisa += x / 5 * 5;
        Console.WriteLine(ureshisa);
	}

    static string equalCheck(string target1,string target2){
        if (target1 == target2){
            return "Yes";
        } else {
            return "No";
        }
    }
}

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

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repm(i, a, b) for (int i = (a); i > (b); i--)

using namespace std;
using ll = long long;




int main() {
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  rep(i,0,n) {
    cin >> a[i];
  }

  int max_distance = 0;
  rep(i,0,n) {
    max_distance = max(max_distance, min(abs(a[(i+1)%n]-a[i]), k-abs(a[(i+1)%n]-a[i])));
  }
  cout << k - max_distance << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main() 
{ 
   int N;
   float m;
   scanf("%d",&N);
   if(N%2==0)
    {
    m=0.5;
    printf("%.10f\n",m);
    }
   else
   {
    m=((N+1)/2)/(float)N;

    printf("%.10f",m);

   }
 return 0;
}


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

long long n;
vector<long long> a;

int main() {
  cin >> n;
  a.assign(n, 0);
  for (int i = 0; i < n - 1; ++i) {
    int x;
    cin >> x;
    ++a[x - 1];
  }
  for (int i = 0; i < n; ++i) cout << a[i] << endl;
  return 0;
}

Measured memory_bytes: 4820
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

string S;
LL K;

string ans;

void solve(){
	int N = S.size();
	for(int i=0;i<N;i++){
		if(K==0) break;
		if('z'-S[i]+1<=K && S[i]!='a'){
			K-=('z'-S[i]+1);
			S[i] = 'a';
		}
	}
	K %= 26LL;
	if(((int)S[N-1]) + K>'z') K-=26;
	S[N-1] += K;
	ans = S;
}
 
int main(){
    cin >> S;
    cin >> K;

    solve();

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

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int dx[] = {-1, 0, 1}, dy[] = {0, 1, 0};

unsigned char G[10][10][10001]; // y, x, cost = life

struct P {
    int cost, life, x, y;
    uint16_t visited;

    bool operator >(const P& p) const {
        return cost > p.cost;
    }
};

int main() {
    int w, h;
    while (cin >> w >> h, w|h) {
        int money, max_life, life;
        cin >> money >> max_life >> life;

        vvi field(h, vi(w, 0));
        REP(y, h) REP(x, w) {
            cin >> field[y][x];
        }

        fill_n((unsigned char *)G, 10*10*10001, 0);
        priority_queue<P, vector<P>, greater<P>> que;

        REP(x, w) {
            int l = life-1;
            if (l <= 0) continue;
            int cost = 0;
            int c = field[0][x];
            if (c > 0) {
                l = min(l+c, max_life);
            } else {
                cost += -c;
            }
            if (cost <= money && l >= 1) {
                G[0][x][cost] = l;
                que.push({cost, l, x, 0, (uint16_t)(1<<x)});
            }
        }

        while (!que.empty()) {
            P p = que.top(); que.pop();

            REP(i, 3) {
                int x = p.x + dx[i], y = p.y + dy[i];
                if (y == h) {
                    cout << p.cost << endl;
                    goto END;
                }
                if (0 <= x && x < w && 0 <= y && y < h) {
                    int life = p.life-1;
                    if (life <= 0) continue;
                    int cost = p.cost;
                    if (dy[i] == 0 && p.visited&(1<<x)) {
                    } else {
                        int c = field[y][x];
                        if (c > 0) {
                            life = min(life+c, max_life);
                        } else {
                            cost += -c;
                        }
                    }
                    if (cost <= money && G[y][x][cost] <= life) {
                        G[y][x][cost] = life;
                        que.push({cost, life, x, y, (uint16_t)(dy[i] == 1 ? 1<<x : p.visited|(1<<x))});
                    }
                }
            }
        }
        cout << "NA" << endl;
    END : {}
    }
}

Measured memory_bytes: 3428
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;

template<class T>
using vec = std::vector<T>;

template<class T>
using vec2d = std::vector<std::vector<T>>;


template<class T>
vec2d<T> makeVec2d(const int n1, const int n2) {
  return vec2d<T>(n1, vec<T>(n2));
}


#define FOR(i, n) for (int i = 0; i < (n); ++i)


// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


template <class T>
inline bool get_bit(T mask, int bit) {
    assert(0 <= bit && bit < numeric_limits<T>::digits);
    return mask & ((T)(1) << bit);
}


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}


void solve(istream& in, ostream& out) {
  auto n = next<int>(in);
  vec2d<int64_t> a = makeVec2d<int64_t>(n, n);
  FOR(i, n) {
    FOR(j, n) {
      a[i][j] = next<int64_t>(in);
    }
  }
  vec<int64_t> f(1 << n, 0);
  vec<int64_t> s(1 << n, 0);
  FOR(mask, 1 << n) {
    FOR(i, n) {
      FOR(j, i) {
        if (get_bit(mask, i) && get_bit(mask, j)) {
          s[mask] += a[j][i];
        }
      }
    }
  }

  FOR(mask, 1 << n) {
    for (int subMask = mask; subMask; subMask = (subMask - 1) & mask) {
      f[mask] = max(f[mask], s[subMask] + f[mask - subMask]);
    }
  }
  out << f[(1 << n) - 1] << "\n";
}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,M;
    cin >>N>>M;
    vector<ll>A(N);
    map<ll,ll>m;
    ll sum=0;
    m[0]++;
    rep(i,N){
        cin>>A[i];
        sum+=A[i];
        m[sum%M]++;
    }
    ll ans = 0;
    for (const auto& [key, value] : m){
        ans += value*(value-1)/2;
    }
    
    
    
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 7860
s = gets.chomp.each_char.with_index.to_a
d, a, j = 0, 0, 0
as = []
s.each do |c, i|
  case c
  when ?_
    a += d
  when ?\\
    j = i if d == 0
    d += 1
    a += d - 0.5
  when ?/
    if d > 0
      a += d - 0.5
      d -= 1
      if d == 0
        as << [j, a.to_i]
        a = 0
      end
    end
  end
end
d, a = 0, 0
s.reverse.each do |c, i|
  case c
  when ?_
    a += d
  when ?/
    d += 1
    a += d - 0.5
  when ?\\
    if d > 0
      a += d - 0.5
      d -= 1
      if d == 0
        as << [i, a.to_i]
        a = 0
      end
    end
  end
end
as.uniq!(&:first)
as.sort_by!(&:first)
as.map!(&:last)
p as.inject(0, :+)
puts [as.size, *as].join ' '

Measured memory_bytes: 10124
a,b=map(int,input().split())
if b==1:
    print("0")
elif b>1 and b<=a:
    print("1")
elif b>a:
    if (b-a)/(a-1)==(b-a)//(a-1):
        print((b-a)//(a-1)+1)
    else:
        print((b-a)//(a-1)+2)

Measured memory_bytes: 9196
N = int(input())
A = list(map(int,input().split()))
ans = [0]*(N)

hugou = 1
for i in range(0,N,1):
    ans[0]+=A[i]*hugou
    hugou = hugou *(-1)

for i in range(1,N,1):
    ans[i]=2*A[i-1]-ans[i-1]

print(" ".join(list(map(str,ans))))


Measured memory_bytes: 19224
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;


int main(){
  ll n;cin>>n;
  rep(i,1,3501){
    rep(j,1,3501){
      if(4*i*j-n*i-n*j<=0)continue;
      if((n*i*j)%(4*i*j-n*i-n*j)==0){

        cout<<i<<" "<<j<<" "<<(n*i*j)/(4*i*j-n*i-n*j)<<endl;
        return 0;
      }
    }
  }
}



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

int main(){
	int n,a,b,c,x;
	int y[10000];
	while(cin>>n>>a>>b>>c>>x,n|a|b|c|x){
		for(int i=0;i<n;i++)cin>>y[i];
		int f=0;
		for(int i=0;i<n&&f<=10000;i++){
			while(x!=y[i] && f<=10000){
				x=(a*x+b)%c;
				f++;
			}
			if(i+1<n && f<=10000){
				x=(a*x+b)%c;
				f++;
			}
		}
		cout<<(f<=10000?f:-1)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
using db = double;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
  数値型から文字列に変換　to_string(number);これは簡単
  文字列から数値型に変換　stoi(number)
  文字列からllに変換　stoll(number)
  __gcd(a,b)は最大公約数を取ってくれる、aとb
  の大きい方をNとしたとき、計算量は log(N);
 */
const int mod = 1e9 + 7;
// pie = M_PI
//ここから書き始める
int main(){
	cout << setprecision(10);
	int n, a, b, c, d; 
	cin >> n >> a>> b >> c >> d;
	string s ; cin >> s;

		int bjudge = 1;
		int ajudge = 1;
		for(int i = b - 1; i < d ; i ++){
			if(s[i]=='#'&&s[i+1]=='#'){
				bjudge = 0;
			}
			if(bjudge == 0){
				cout << "No"<<endl;
				return 0 ;
			}
		}
		for(int i = a - 1; i < c ; i ++){
			if(s[i]=='#'&&s[i+1]=='#'){
				ajudge = 0;
			}
			if(ajudge == 0){
				cout <<"No"<<endl;
				return 0 ;
			}
		}
		if(c<d&&ajudge&&bjudge){
			//cout<<"c<d"<<endl;
			cout << "Yes"<<endl;
			return 0 ;
		}
		else{//d<cのときは、連続して3つの空き地がd（dは含まない)より前にあればYesになれる
			int null = 0;
			//Bの1個手前から見て3連続で岩じゃなければいい。
			int x = b - 1; //Bの要素番号」
			for(int i = x  ; i < d ; i ++){
				if(s[i] == '.'){
					if(s[i-1]=='.'&&s[i+1]=='.'){
						null = 1;
					}
				}
			}
			if(null == 0 ){
				cout << "No"<<endl;
				return 0 ;
			}
			if(ajudge&&bjudge&&null){
				//cout<<"null"<<endl;
				cout << "Yes"<<endl;
				return 0;
			}
		}
		cout << "No"<<endl;
}



Measured memory_bytes: 640
// AtCoder Grand Contest 007
// D - Shik and Game

#include <cstdio>
#include <algorithm>
#define MAX_N 100000
#define MAX_ELEMENTS (1 << 17)
#define INF 1e18
using namespace std;


typedef long long int ll;

template <typename T>
class SegmentTree {
public:
  int n;
  T dat[2 * MAX_ELEMENTS - 1];
  void init(int _n);
  void update(int k, T a);
  T query(int a, int b, int k, int l, int r);
  T query(int a, int b);
};

template <typename T>
void SegmentTree<T>::init(int _n) {
  n = 1;
  while (n < _n) {
    n <<= 1;
  }
  for (int i = 0; i < 2 * n - 1; i++) {
    dat[i] = INF;
  }
  return;
}

template <typename T>
void SegmentTree<T>::update(int k, T a) {
  k += n - 1;
  dat[k] = a;
  while (k > 0) {
    k = (k - 1) / 2;
    dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
  }
  return;
}

// [a, b), [l, r)
template <typename T>
T SegmentTree<T>::query(int a, int b, int k, int l, int r) {
  if (r <= a || b <= l) {
    return INF;
  }
  if (a <= l && r <= b) {
    return dat[k];
  }
  return min(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
}

template <typename T>
T SegmentTree<T>::query(int a, int b) {
  return query(a, b, 0, 0, n);
}


int N, E, T;
SegmentTree<ll> st;
int x[MAX_N + 1];
ll dp[MAX_N + 1];

int main() {

  ll dmin = INF;
  int j;

  scanf("%d%d%d", &N, &E, &T);
  x[0] = 0;
  for (int i = 1; i <= N; i++) {
    scanf("%d", &x[i]);
  }
  dp[0] = 0;
  st.init(N);
  st.update(0, dp[0]);
  j = 0;
  for (int i = 1; i <= N; i++) {
    for (; (x[i] - x[j + 1]) * 2 > T; j++) {
      dmin = min(dmin, dp[j] - x[j + 1] * 2);
    }
    dp[i] = dmin + x[i] * 2;
    dp[i] = min(dp[i], st.query(j, i) + T);
    st.update(i, dp[i]);
  }

  printf("%lld\n", dp[N] + E);

  return 0;

}




Measured memory_bytes: 3456
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int k, n;
	cin >> k >> n;
	int a[n];
	for(int i  = 0; i < n; i ++) cin >> a[i];
	sort(a, a + n);
	int ans = 1e9;
	for(int i = 1; i < n; i ++) {
		ans = min(ans, a[i - 1] + k - a[i]);
	}
	reverse(a, a + n);
	for(int i = 1; i < n; i ++) {
		ans = min(ans, a[i - 1] + k - a[i]);
	}
	ans = min(ans, a[0] - a[n - 1]);
	cout << ans;
	return 0;
}


Measured memory_bytes: 1152
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    vector<ll> A(X), B(Y), C(Z);
    for (ll i = 0; i < X; ++i) {
        cin >> A[i];
    }
    for (ll i = 0; i < Y; ++i) {
        cin >> B[i];
    }
    for (ll i = 0; i < Z; ++i) {
        cin >> C[i];
    }

    vector<ll> D(X * Y);
    ll i = 0;
    for (ll a = 0; a < X; ++a) {
        for (ll b = 0; b < Y; ++b) {
            D[i++] = A[a] + B[b];
        }
    }

    sort(D.begin(), D.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());

    ll Dlen = min(X * Y, K);
    ll Clen = min(Z, K);
    std::vector<ll> ans(Clen * Dlen);
    ll j = 0;
    for (ll c = 0; c < Clen; ++c) {
        for (ll d = 0; d < Dlen; ++d) {
            ans[j++] = C[c] + D[d];
        }
    }

    sort(ans.begin(), ans.end(), greater<ll>());

    for (ll i = 0; i < K; ++i) {
        cout << ans[i] << endl;
    }

    return 0;
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nm = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nm[0];
        var m = nm[1];
        var ps = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        Array.Sort(ps);

        var ds = new int[ps.Length];
        for (int i = 1; i < ps.Length; i++)
        {
            ds[i] = ps[i] - ps[i - 1];
        }
        var dsDesc = E.Range(0, ds.Length).ToArray();
        Array.Sort(ds.ToArray(), dsDesc);
        Array.Reverse(dsDesc);

        var k = ps.Last() - ps.First() - dsDesc.Take(n - 1).Sum(x => ds[x]);
        Console.WriteLine(k);
    }
}


Measured memory_bytes: 20576