akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"math/rand"
	"os"
	"strconv"
	"time"
)

const (
	limitSecs = 2.0
)

// D
var (
	D         int
	c         [26]int
	s         [][26]int
	startTime time.Time
)

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func calcScore(t []int) int {
	var last [26]int
	score := 0
	S := 0
	for i := 0; i < 26; i++ {
		last[i] = -1
	}
	for d := 0; d < len(t); d++ {
		S += s[d][t[d]]
		last[t[d]] = d
		for i := 0; i < 26; i++ {
			S -= c[i] * (d - last[i])
		}
		score += max(1000000+S, 0)
	}
	return score
}

func solution3() []int {
	var t []int
	for d := 0; d < D; d++ {
		score := -1
		best := -1
		t = append(t, 0)
		for i := 0; i < 26; i++ {
			t[len(t)-1] = i
			newScore := calcScore(t)
			if newScore > score {
				best = i
				score = newScore
			}
		}
		t[len(t)-1] = best
	}
	return t
}

func optimize1(t []int) []int {
	score := calcScore(t)
	for time.Now().Sub(startTime).Seconds()+0.15 < limitSecs {
		d := rand.Intn(D)
		q := rand.Intn(26)
		old := t[d]
		t[d] = q
		newScore := calcScore(t)
		if newScore < score {
			t[d] = old
		} else {
			score = newScore
		}
	}
	return t
}

func main() {
	defer flush()

	startTime = time.Now()

	D = readInt()
	for i := 0; i < 26; i++ {
		c[i] = readInt()
	}
	s = make([][26]int, D)
	for i := 0; i < D; i++ {
		for j := 0; j < 26; j++ {
			s[i][j] = readInt()
		}
	}

	t := solution3()
	t = optimize1(t)
	for d := 0; d < D; d++ {
		println(t[d] + 1)
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 2188
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
double eps=1e-8;
ll mod=1e9+7;
ll inf=1e9;
priority_queue<P,vector<P>,greater<P> > pq;

template <typename T>
int Count(const vector<T> &v, T l,T r){
  //counting [l,r]
  auto L = lower_bound(v.begin(), v.end() , l );
  auto R = upper_bound(v.begin(), v.end(), r );
  // [l,r) change upper -> lower

  return R-L;
}

int main(){
  ll n,a[10000],b[10000],as=0,bs=0;
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++){
    cin>>b[i];
    ll s=b[i]-a[i];
    if(s>0){
      as+=(s+1)/2;
      bs+=s%2;
    }
    else bs-=s;
  }
  if(bs<=as)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n, k;
    cin >> n >> k;
    vl a(n);
    vvi pos(200000 + 1);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        pos[a[i]].push_back(i);
    }
    int curr = 0;
    ll loop  = 0;
    while (loop < k - 1) {
        auto it = upper_bound(pos[a[curr]].begin(), pos[a[curr]].end(), curr);
        if (it == pos[a[curr]].end()) {
            loop++;
            curr = pos[a[curr]].front() + 1;
        } else {
            curr = *it + 1;
        }
        if (curr == n) {
            loop++;
            loop += (k - 1 - loop) / loop * loop;
            curr = 0;
        }
    }
    vector<ll> ret;
    map<ll, int> cnt;
    for (int i = curr; i < n; ++i) {
        ret.push_back(a[i]);
        cnt[a[i]]++;
        if (cnt[a[i]] == 2) {
            while (cnt[a[i]] > 0) {
                cnt[ret.back()]--;
                ret.pop_back();
            }
        }
    }
    print(ret);
    return 0;
}

Measured memory_bytes: 28016
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <vector>
#include <cmath>
#include <map>
#include <stack>
#include <algorithm>
typedef long long int ll;
using namespace std;

struct card{char suit,value;};

void bubble(struct card a[],int n)
{
    for (int i=0; i<n; i++) {
        for (int j=n-1; j>=i; j--) {
            if (a[j].value<a[j-1].value) {
                card t=a[j];
                a[j]=a[j-1];
                a[j-1]=t;
            }
        }
    }
}
void myselect(struct card a[],int n)
{
    for (int i=0; i<n; i++) {
        int minj=i;
        for (int j=i; j<n; j++) {
            if (a[j].value<a[minj].value) {
                minj=j;
            }
        }
        card t=a[i];a[i]=a[minj];a[minj]=t;
    }
}

void print(struct card a[],int n)
{
    for (int i=0; i<n; i++) {
        if (i) {
            cout<<' ';
        }
        cout<<a[i].suit<<a[i].value;
    }
    cout<<endl;
}

bool istable(struct card c1[],struct  card c2[],int n)
{
    for (int i=0; i<n; i++) {
        if (c1[i].suit!=c2[i].suit) {
            return false;
        }
    }
    return true;
}

int main(){
    //freopen("/Users/mac/Desktop/C++?¨????/test/test.txt", "r", stdin);
    card c1[110],c2[110];
    int n;
    cin>>n;
    for (int i=0; i<n; i++) {
        cin>>c1[i].suit>>c1[i].value;
    }
    for (int i=0; i<n; i++) {
        c2[i]=c1[i];
    }
    bubble(c1, n);
    myselect(c2, n);
    print(c1, n);
    cout<<"Stable"<<endl;
    print(c2,n);
    if (istable(c1, c2, n)) {
        cout<<"Stable"<<endl;
    }
    else{
        cout<<"Not stable"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcoder1127
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力を受け取る
            int N = int.Parse(Console.ReadLine());
            string[] t_input = Console.ReadLine().Split();
            double[] input_a = t_input.Select(i => double.Parse(i)).ToArray();

            //aの平均値を計算
            double Ave_a = input_a.Average();

            //それぞれの要素の差の絶対値を計算
            double[] sub_a = input_a.Select(i => Math.Abs(Ave_a - i)).ToArray();

            //差の最小値
            double min_sub_a = sub_a.Min();
            int result = 0;

            //最小値の探索
            for(int i = 0; i < N;i++)
            {
                if (sub_a[i] == min_sub_a)
                {
                    result = i;
                    break;
                }
            }

            //結果の出力
            Console.WriteLine(result);
            
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<numeric>
#include<queue>

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<vector<int>> g(n, vector<int>());
	int a, b;
	for (int i = 0; i < n - 1; i++) {
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<int> fd(n,1000000);
	queue<int> que;
	que.push(0);
	fd[0] = 0;
	while (que.size()) {
		int k = que.front(); que.pop();
		for (auto e : g[k]) {
			if (fd[e] > fd[k] + 1) {
				fd[e] = fd[k] + 1;
				que.push(e);
			}
		}
	}
	int snk = 1;
	que.push(n-1);
	fd[n - 1] = 0;
	while (que.size()) {
		int k = que.front(); que.pop();
		for (auto e : g[k]) {
			if (fd[e] > fd[k] + 1) {
				fd[e] = fd[k] + 1;
				que.push(e);
				snk++;
			}
		}
	}
	cout << ((snk * 2 >= n) ? "Snuke" : "Fennec") << endl;
	return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define ll long long
#define foru(i,a,n) for(int i=(a); i<=(n); i++)
using namespace std;
const int N = 101010;

int main()
{
    string s;
    cin >>s;
    cout <<(s[0] + s[1] + s[2])-3*48;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[100001];
vector<int> adj[100001];
int solve(int i) {
    if(dp[i] >= 0) return dp[i];
    if(adj[i].size() == 0) {
        dp[i] = 0;
        return dp[i];
    }
    for(auto k : adj[i]) 
        dp[i] = max(dp[i], 1 + solve(k));
    return dp[i];
}
int main() {
    int n, m, i, x, y;
    cin >> n >> m;
    memset(dp, -1, sizeof(dp));
    for(i = 0; i < m; ++i) {
        cin >> x >> y;
        adj[x].push_back(y);
    }
    for(i = 1, x = -1; i <= n; ++i)
        x = max(x, solve(i));
    cout << x;
    return 0;
}

Measured memory_bytes: 11392
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int a[4]={0,0,0,0};
  string r[4]={"AC","WA","TLE","RE"};
  cin>>n;
  while(n--){
  string s;
    cin>>s;
    int i=0;
    while(r[i]!=s){
      i++;
    }
    a[i]++; 
  }
  for(int i=0;i<4;i++){
    cout<<r[i]<<" x "<<a[i]<<endl;
  }
  
  return(0);
}




Measured memory_bytes: 3608
#include <deque>
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  deque<ll> Q;
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    if (i % 2 == 1)
      Q.push_back(a);
    else
      Q.push_front(a);
  }

  if (n % 2 == 0) {
    for (int i = Q.size() - 1; i >= 0; i--) {
      cout << Q.at(i) << ' ';
    }
  } else {
    for (int i = 0; i < Q.size(); i++) {
      cout << Q.at(i) << ' ';
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3840
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
la = [0]
lb = [0]
mx = 0
for i in range(n): 
    if la[i] + a[i] > k:
        break
    la.append(la[i]+a[i])
for j in range(m):
    if lb[j] + b[j] > k:
        break
    lb.append(lb[j]+b[j])
now = len(lb)-1
for l in range(len(la)):
    cnt = l
    q = now
    while la[l] + lb[q] > k:
        q -= 1
    now = q
    cnt += q
    if cnt > mx:
        mx = cnt
print(mx)

Measured memory_bytes: 40564
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define Int long long


Int N ;//= 700000;
map<Int,Int>a;



int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    Int n;
    cin>>n;
    N=n;
    Int ans=0;
    for(Int i = 1;i<=n;i++)
    {
        Int x = (n/i);
        ans+=(Int)(i*((x)*(x+1))/2);
    }
    //Int x = n/2;
    //ans+=(Int)((n*(n+1)/2)-(x*(x+1)/2));
    cout<<ans<<endl;
}


Measured memory_bytes: 3604
from collections import defaultdict
N, X, M = map(int, input().split())
A = [X]
visited = set()
visited.add(X)

idx = defaultdict()
idx[X] = 0

iii = -1

for i in range(1, M):
    tmp = (A[-1]**2) % M
    if tmp not in visited:
        A.append(tmp)
        visited.add(tmp)
        idx[tmp] = i
    else:
        iii = idx[tmp]

ans = 0
# ループの頭の直前まで
ans += sum(A[:iii])
N -= iii
if N > 0:
    # ループの長さ
    l = len(A) - iii
    ans += (N // l) * sum(A[iii:])
    N -= N // l * l
if N > 0:
    # ループに満たないN
    ans += sum(A[iii:iii + N])

print(ans)
exit()


Measured memory_bytes: 91324
#include <stdio.h>
#include <ctype.h>
int main(void){

  char mozi;
  int co[26] = {0};
  int i;
  int ii = 0;
  int c = 0;
    
  while(scanf("%c", &mozi) != EOF){
    mozi = toupper(mozi);
    if((mozi > 64) || (mozi < 91)){
      co[mozi - 65] += 1;
    }
  }
  for(i = 0;i < 26; i++){
    printf("%c : %d\n", 'a' + i, co[i]);
  }
  return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

	int N;
	cin >> N;

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

	vector<int> B;
	temp = 0;
	for(int i=0; i<N; i++){
		cin >> temp;
		B.push_back(temp);
	}

	vector<P> val;
	REP(i,N){
		val.push_back(make_pair(B[i],A[i]));
	}
	sort(val.begin(),val.end());

/*	REP(i,N){
		cout << val[i].second << "," << val[i].first << "\n";
	}
*/

	REP(i,N){
		A[i] = val[i].second;
		B[i] = val[i].first;	
	}

	REP(i,N){
		val[i] = make_pair(A[i],i);
	}
	sort(val.begin(),val.end());

	// 1:そもそもどっちも昇順ソートで行ける？
	REP(i,N){
		if(val[i].first > B[i]){
			cout << "No" << "\n";
			return 0;
		}
	}

	// 2:行けるならまずサイクルは2分割？
	int now = 0;
	int j = N-1;
	while(j > 0){
		now = val[now].second;
		if(now == 0){
			cout << "Yes" << "\n";
			return 0;
		}
		j--;
	}

	// 3:サイクルが一つ --> このままではN-1回SWAP
	// でも，B_i <= A_i+1 なら A_i と A_i+1を変えてもOK
	// この時サイクルは2つに分かれるからOK
	bool flg = false;
	REP(i,N-1){
		if(val[i+1].first <= B[i]){
			flg = true;
			break;
		}
	}
	if(flg == true){
		cout << "Yes" << "\n";
		return 0;
	}

	cout << "No" << "\n";
	return 0;


return 0;
}

Measured memory_bytes: 2168
import java.util.*

fun main(args: Array<String>) {
    val line = readLine()!!.split(" ")

    val p = Array<Int>(line[0].toInt(), init = { i -> 0 })

    for (i in 0 until line[2].toInt()) {
        val line = readLine()
        val place = line!!.toInt() - 1
        p[place] = p[place] + 1

    }

    for (pp in p) {
        //println((line[2].toInt() - line[1].toInt()).toString())
        if ((line[2].toInt() - line[1].toInt()) < pp) {
            println("Yes")
        } else {
            println("No")
        }
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  bool allok = true;
  for (int a : A) {
    if (a % 2 != 0) continue;
    if (a % 3 != 0 && a % 5 != 0) {
      allok = false;
    }
  }
  if (allok) {
    cout << "APPROVED" << endl;
  } else {
    cout << "DENIED" << endl;
  }
}

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const long double eps = 1e-8;

const i64 MAXN = 3 * 1'000 + 5;

i64 n;
i64 s;

i64 a[MAXN];
i64 dp[MAXN][MAXN];

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n >> s;
    for (i64 i = 1; i <= n; i++) {
        cin >> a[i];
    }

    dp[0][0] = 1;
    for (i64 j = 0; j <= s; j++) {
        for (i64 i = 1; i <= n; i++) {
            dp[j][i] = 2 * dp[j][i - 1];
            dp[j][i] %= smod;
            if (j >= a[i]) {
                dp[j][i] += dp[j - a[i]][i - 1];
                dp[j][i] %= smod;
            }
        }
    }

    cout << dp[s][n] << endl;

    return 0;
}

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

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

    int a[n+1];
    for(int i = 1; i <= n; i++)  cin >> a[i];

    int cnt = 0;
    for(int i = 1; i <= n; i++){
        if(i == a[a[i]])    cnt++;
    }

    cout << cnt/2 << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int partition(int a [], int l, int r) {
    int i = l - 1;
    int j = r;
    int temp;
 
    int pivot = a[r];
 
    while (1) {
        while (a[++i] < pivot) ;
        while (i < --j && pivot < a[j]) ;

        if (i >= j) break;
 
        temp = a[i];
        a[i] = a[j];
        a[j] = temp;
    }
    temp = a[i];
    a[i] = a[r];
    a[r] = temp;
    return i;
}

void quickSort(int a[], int l, int r) {
    int v;
    if (l >= r) {
        return;
    }
    v = partition(a, l, r);
    quickSort(a, l, v - 1);
    quickSort(a, v + 1, r);
}

int main() {
	int N, M;
	scanf("%d %d", &N, &M);
	int a[N], b[N], s, t, k = 0, l = 0;
	for (int i = 0; i < M; i++) {
		scanf("%d %d", &s, &t);
		if (s == 1) {
			a[k] = t;
			k++;
		} else if (t == N) {
			b[l] = s;
			l++;
		}
	}
	if (k == 0 || l == 0) {
		printf("IMPOSSIBLE");
	    return 0;
	} 
	quickSort(a, 0, k - 1);
	quickSort(b, 0, l - 1);
	s = 0, t = 0;
	while (1) {
	    if (s > k || t > l) {
	    	printf("IMPOSSIBLE");
	    	return 0;
	    }
		if (a[s] == b[t]) {
			printf("POSSIBLE");
			return 0;
		} else if (a[s] > b[t]) {
			t++;
		} else {
			s++;
		}
	}
}

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

#define rep(i,c) for(int i = 0; i < (int)c; ++i)
using llint = long long int ;
using namespace std;

int main(){
    string S;
    cin>>S;

    rep(i,S.size()){
        cout<<"x";
    }
    cout<<endl;
}

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

#define F(i, a, b) for (int i = a; i <= b; i ++)
#define add(a, b) ((a) = (long long)(a + b) % Mo)

const int N = 55 * 2;
const int Mo = 1e9 + 7;

using namespace std;

int n, Ans;
int a[N], f[N][N][N];

int main() {
	scanf("%d", &n);
	F(i, 1, 2 * n - 1)
		scanf("%d", &a[i]);
	sort(a + 1, a + 2 * n);

	f[1][1][1] = 1;
	F(i, 1, n - 1) {
		int pl = a[n - i] != a[n - i + 1];
		int pr = a[n + i] != a[n + i - 1];
		F(j, 1, i * 2 - 1)
			F(k, 1, j)
				if (f[i][j][k]) {
					int t = j + pl + pr;
					F(p, 1, k + pl - 1)
						add(f[i + 1][t - (k + pl - p) + 1][p], f[i][j][k]);
					add(f[i + 1][t][k + pl], f[i][j][k]);
					F(p, k + pl + 1, t)
						add(f[i + 1][t - (p - k - pl) + 1][k + pl + 1], f[i][j][k]);
				}
	}

	F(j, 1, 2 * n - 1)
		F(k, 1, j)
			add(Ans, f[n][j][k]);

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

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

int main(){
    ll A, B, K; cin >> A >> B >> K;
    if(A >= K) cout << A - K << " " << B << endl;
    else if(A + B >= K){
        cout << 0 << " " << B - (K - A) << endl;
    }else{
        cout << 0 <<" " << 0 << endl;
    }
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

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

  map<lli, lli> m;
  for (lli i = 2; i < 1e4; ++i) {
    m[i * (i - 1) / 2] = i;
  }

  int n;
  while (cin >> n) {
    if (m.count(n) == 0) {
      cout << "No" << endl;
      continue;
    }

    const int N = m[n];
    vector<int> v[N];
    int cnt = 1;
    for (int i = 0; i < N; ++i) {
      for (int j = i + 1; j < N; ++j) {
        v[i].push_back(cnt);
        v[j].push_back(cnt);
        ++cnt;
      }
    }

    cout << "Yes" << endl;
    cout << N << endl;
    for (int i = 0; i < N; ++i) {
      cout << v[i].size();
      each (j, v[i]) cout << ' ' << j;
      cout << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 2944
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a, b;
        String[] inputLine;
        inputLine = sc.nextLine().split(" ");

        a = inputLine[0];
        b = inputLine[1];
        if (a.equals("H") && b.equals("H")) {
            System.out.println("H");
        } else if (a.equals("H") && b.equals("D")) {
            System.out.println("D");
        } else if (a.equals("D") && b.equals("H")) {
            System.out.println("D");
        } else if (a.equals("D") && b.equals("D")) {
            System.out.println("H");
        }
    }
}


Measured memory_bytes: 23764
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC070
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            var T = new long[n];
            for (int i = 0; i < n; i++)
            {
                T[i] = long.Parse(Console.ReadLine());
            }
            long m = T[0];
            for (int i = 1; i < n; i++)
            {
                m = LCM(m, T[i]);
            }
            Console.WriteLine(m);
        }

        static long LCM(long a, long b)
        {
            long a0 = a, b0 = b;
            if (a < b)
            {
                var tmp = a;
                a = b;
                b = tmp;
            }
            var r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return a0 / b * b0;
        }
    }
}

Measured memory_bytes: 11092
a = []
for i in range(5):
    a.append(int(input()))

a.sort(key = lambda x:x % 10)
su = 0
c = 0
for i in range(5):
    if a[i] % 10 == 0:
        su += a[i]
    else:
        if c == 0:
            su += a[i]
            c += 1
        else:
            su += (a[i]//10 + 1)*10
print(su)



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

int main() {
 string b;
  cin >> b;
  for (int i = 1; i < 4; i++){
  if(b.size() == i){
    if (b.at(i-1) == '2' || b.at(i-1) == '4' || b.at(i-1) == '5' || b.at(i-1) == '7' || b.at(i-1) == '9'){
      cout << "hon" << endl;
    }
    else if (b.at(i-1) == '0' || b.at(i-1) == '1' || b.at(i-1) == '6' || b.at(i-1) == '8'){
      cout << "pon" << endl;
    }
    else if (b.at(i-1) == '3'){
      cout << "bon" << endl;
    }
  }
}
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>


using namespace std;

int main(){
    long long N;
    long long K;
    cin >> N >> K;
    long long ans = 0;
    for(long long i=K; i<=N+1; i++){
        ans += (N-i+1)*i + 1;
        ans %= 1000000000 + 7;
    }
    cout << ans;
}

Measured memory_bytes: 3620
/*
    Code written by Talant I.D.
*/
   
#include <bits/stdc++.h>
   
using namespace std;
   
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
   
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9
#define all(v) v.begin(),v.end()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);
#define curMod 998244353

int main(){
		//do_not_disturb
		int n, i;
		cin >> n;
		for(i = 1; i <= n; i++){
			if(n % i == 0){
				if(i < 10 && n/i < 10){
					cout << "Yes";
					return 0;
				}
			}
		}cout << "No";
    return 0;
} // What is to be written here?


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

int main() {
	long n, k;
	cin >> n >> k;

	long amari = n % k;
	long sa = k - amari;

	if (amari < sa) {
		cout << amari << endl;
	} else {
		cout << sa << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  string s; cin >> s;
  FOR(i, 1, s.length()) {
    if (s[i - 1] == s[i]) {
      cout << i << ' ' << i + 1 << '\n';
      return 0;
    }
  }
  FOR(i, 2, s.length()) {
    if (s[i - 2] == s[i]) {
      cout << i - 1 << ' ' << i + 1 << '\n';
      return 0;
    }
  }
  cout << "-1 -1\n";
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	int q;

	if(a>=b&&a>=c){
		a=a*10;
	}else if(b>=a&&b>=c){
		b=b*10;
	}else if(c>=b&&c>=a){
		c=c*10;
	}
	
	printf("%d",a+b+c);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N=4000002;
char s[N],t[N];
int a,b,ne[N],ans,g[N],i,j;
int main(){
	scanf("%s%s",s+1,t+1),a=strlen(s+1),b=strlen(t+1);
	for (;a<b*2;a*=2)
		for (i=1;i<=a;i++) s[i+a]=s[i];
	for (i=1;i<=a;i++) s[i+a]=s[i];
	a*=2;
//	for (i=2,j=1;i<=b;i++){
//		while (j>1 && t[i]!=t[j]) j=ne[j-1];
//		if (t[i]==t[j]) j++;
//		ne[i]=j;
//	}
//	for (i=1,j=1;i<=a;i++){
//		while (j>1 && s[i]!=t[j]) j=ne[j-1];
//		if (s[i]==t[j]) j++;
//		if (j==b+1) ans=max(ans,g[i]=g[i-b]+1);
//	}
	for (i=1;i<=b;i++){
		j=i;
		while (j>1 && t[ne[j-1]]!=t[i]) j=ne[j-1]-1;
		ne[i]=ne[j-1]+1;
	}
	for (i=1,j=1;i<=a;i++){
		while (j && s[i]!=t[j]) j=ne[j-1];
		if (++j==b+1) ans=max(ans,g[i]=g[i-b]+1);
	}
	printf("%d",ans>=a/b-1?-1:ans);
}


Measured memory_bytes: 23040
# -*- coding: utf-8 -*-

def main():
    n = int(input())
    d = dict()

    for i in range(n):
        s = input()
        if s in d.keys():
            d[s] += 1
        else:
            d[s] = 1

    d_m = max(d.values())
    m_list = [kv[0] for kv in d.items() if kv[1] == d_m]
    m_list = sorted(m_list)
    print('\n'.join(m_list))

if __name__ == "__main__":
    main()


Measured memory_bytes: 35672
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

int main()
{
        string s; cin>>s;
        ll n=s.length();
        ll sz=0; ll ans=0;
        for(int i=0;i<n;i++)
        {
            if(s[i]=='A'){sz++;continue;}
            if(s[i]=='B'&&(i+1<n)&&s[i+1]=='C'&&sz){i++;ans+=sz;continue;}
            sz=0;
        }
        cout<<ans;
      return 0;
}


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

int main()
{
	int64_t a, b, c, d;
	std::cin >> a >> b >> c >> d;
	int64_t ans = a * c;
	ans = std::max<int64_t>(ans, a * d);
	ans = std::max<int64_t>(ans, b * d);
	ans = std::max<int64_t>(ans, b * c);
	if (a < 0 && b > 0) {
		ans = std::max<int64_t>(0, ans);
	}
	if (c < 0 && d > 0) {
		ans = std::max<int64_t>(0, ans);
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int vtoi(vector<int> v){
    int n=0;
    for(int i=0;i<v.size();++i){
        n += v[i] * pow(10, i);
    }
    return n;
}

vector<int> itov(int n, int L){
    vector<int> v;
    for(int i=0;i<L;++i){
        v.push_back(n%10);
        n = n / 10;
    }
    return v;
}

int main(){
    while(true){
        vector<int> a;
        int L;
        int n;
        int i=0, j=0;
        int x, y;
        cin >> n >> L;
        if(!(n||L)) break;
        a.push_back(n);
        for(i=0;;++i){
            vector<int> v = itov(a.back(), L);
            sort(v.begin(), v.end(), greater<int>());
            x = vtoi(v);
            sort(v.begin(), v.end());
            y = vtoi(v);
            for(j=0;j<i;++j){
                if(a[j] == y-x) break;
            }
            if(a[j] == y-x) break;
            a.push_back(y-x);
        }
        cout << j << ' ';
        cout << y-x << ' ';
        cout << i-j+1 << endl;
    }
}

Measured memory_bytes: 1264
#include "bits/stdc++.h"
using namespace std;
#define int long long int
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;*/
#define rep(i,a,b) for(int i = a; i < b; i++)
#define rrep(i,a,b) for(int i = (a-1); i >= b; i--) 
#define fi first
#define se second
#define tit(v,i,c) get<c>(v[i])
#define mt make_tuple 
#define pb push_back
#define mp make_pair
#define endl "\n"
#define mod 1000000007
int in(){
int n;cin>>n;
return n;}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
	int t=1;
	while(t--){
		//int n=in();
		long double n;cin>>n;
		n=n*1.000000000;
		long double ans,pi=3.14159265358979323846264;
		ans=2.0000000000000*pi*n*1.000000000;
		cout<<ans<<endl;
	}
	return 0;
	}

Measured memory_bytes: 3760
n, k = map(int, input().split())
plis = list(map(int, input().split()))
plis = list(map(lambda p : (1+p)/2, plis))
slis = [plis[0]]
for i in range(1, n):
    slis.append(slis[-1] + plis[i])
ans = slis[k-1]
for i in range(1, n-k):
    ans = max(ans, slis[i+k] - slis[i])
print(ans)

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

typedef struct Card {
    char suit;
    int value;
} CARD;

bool isStable(CARD *C1, CARD *C2, int N){
    for(int i=0; i<N; i++){
        if(C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

void bubbleSort(CARD *A, int N){
    
    for(int i=0; i<N; i++){
        for(int j=N-1; j>i; j--){
            if(A[j].value < A[j-1].value){
                CARD temp = A[j];
                A[j] = A[j-1];
                A[j-1] = temp;
            }
        }
    }
}

void selectionSort(CARD *A, int N){
    int minj;
    for(int i=0; i<N; i++){
        minj = i;
        for(int j=i; j<N; j++){
            if(A[j].value < A[minj].value)
                minj = j;
        }
        if(A[i].value != A[minj].value){
            CARD temp = A[i];
            A[i] = A[minj];
            A[minj] = temp;
        }
    }
}
void print(CARD *C, int N){
    for(int i=0; i<N; i++){
        if(i>0) cout << " ";
        cout << C[i].suit << C[i].value;
    }
    cout << endl;
}

int main(){
    int N;
    cin >> N;
    CARD C1[N], C2[N];
    for(int i=0; i<N; i++) {
        cin >> C1[i].suit;
        cin >> C1[i].value;
    }
    for(int i=0; i<N; i++) C2[i] = C1[i];
    
    bubbleSort(C1, N);
    selectionSort(C2, N);

    print(C1, N);
    cout << "Stable" << endl;
    
    print(C2, N);
    if(isStable(C1, C2, N)) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
}


Measured memory_bytes: 3084
import heapq
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
ans=0
line=[]
heapq.heappush(line,-A[0])
for i in range(1,N):
    ans-=heapq.heappop(line)
    heapq.heappush(line,-A[i])
    heapq.heappush(line,-A[i])
print(ans)

Measured memory_bytes: 31788
#include<stdio.h>



int main(){
int n,k;
int l[51];
int i,j;
int temp;
int x=0;
scanf("%d%d",&n,&k);
for(i=0;i<n;i++){
	
	scanf("%d",&l[i]);
	
}
for(i=0;i<n;i++){
	for(j=n-1;j>i;j--){
		if(l[j]>l[j-1]){
			temp=l[j-1];
			l[j-1]=l[j];
			l[j]=temp;
			
			
			
			
			
			
			
			
			
			
			
			
		}
		
		
	}
}

for(i=0;i<k;i++){
	
	x+=l[i];
	
	
	
}
printf("%d\n",x);
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

//降順
int comp(const void *c1, const void *c2){
  int tmp1 = *(int *)c1;
  int tmp2 = *(int *)c2;

  if (tmp1 > tmp2) return -1;
  if (tmp1 == tmp2) return 0;
  if (tmp1 < tmp2) return 1;
}

int main(void)
{
  int N[10];
  int i, j;

  for (i = 0; i < 10; i++){
    scanf("%d", &N[i]);
  }

  qsort (N, 10, sizeof(int), comp);

  for (i = 0; i < 3; i++){
    printf("%d\n", N[i]);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main(){
  int N, A[210], count = 0;
  bool dividable = true;
  cin >> N;
  for(int i = 0;i < N; i++){
    cin >> A[i];
  }
  while(dividable){
    for(int i = 0;i < N;i++){
      if(A[i] % 2 == 1){
        dividable = false;
        break;
      }
      A[i] = A[i] / 2;
    }
    count++;
  }
  count--;
  cout << count << endl;
}

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

using namespace std;

const int maxn = 1e5;
int n, k, h[maxn], a[maxn];

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    a[0] = 0;
    for (int i = 1; i < n; i++) {
        int newval = abs(h[i]-h[i-1])+a[i-1];
        for (int j = i-2; j >= 0 && j >= i-k; j--) {
            newval = min(abs(h[i]-h[j])+a[j],newval);
        } 
        a[i] = newval;
    }
    cout << a[n-1] << '\n';
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    double a,b,sum,tmp;
    int count;
    sum=0.0;
    tmp=0.0;
    count=0;
    char c;
    while (cin>>a>>c>>b) {
        sum=sum+a*b;
        tmp=tmp+b;
        count++;
    }
    cout<<sum<<endl;
    double ave=round(tmp/count);
    cout<<ave<<endl;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}


int main(){
  ll n; cin >> n;
  vector<ll> v(n); cin >> v;
  map<ll,ll> cnt;
  for(auto e:v)cnt[e]++;
  ll sum = 0;
  for(auto e:cnt)sum += e.second*(e.second-1)/2;
  vector<ll> ans;
  ans.reserve(n);
  for(int i = 0; i < n; ++i){
    ll x = cnt[v[i]];
    ll y = x*(x-1)/2;
    ll z = y - (x - 1);
    ans.push_back(sum - y + z);
  }
  for(auto e:ans) cout << e << endl;
  return 0;
}


Measured memory_bytes: 13824
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef long double ld;

int main(){
    int n,i,j,l;
    cin>>n;
    ld dp[n+1][n+1];
    ld a[n+1];
    for(i=0;i<n;i++) cin>>a[i+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1.0;
    for(int i=1;i<=n;i++){
        for(int j=i;j>=0;j--){
            if(j>0)
                dp[j][i-j]+=dp[j-1][i-j]*a[i];
            if(i-j-1>=0)
                dp[j][i-j]+=dp[j][i-j-1]*(1.0-a[i]);
        }
    }
    
    ld ans=0;
    int x;
    x=n/2 + 1;
    for(i=n;i>=x;i--){
        j=n-i;
        ans=ans+dp[i][j];
    }



    cout<<fixed<<setprecision(20)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 140928
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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;}

int main(){
  int N; cin >> N;
  vector<ll> A(N); rep(i,N) cin >> A[i];
  ll ans = 1000;
  ll kb = 0;
  rep(i,N-1){
    if(A[i] < A[i+1]){
      kb = ans/A[i];
      ans -= kb*A[i];
      ans += kb*A[i+1];
      kb = 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll frac[2000005];

ll comb(ll a, ll b) {
  ll ans = frac[a];
  ll tmp1, tmp2;
  ll h = mod-2;
  ll two;
  while(h>0) {
    two = 1;
    tmp1 = frac[b];
    tmp2 = frac[a-b];
    while(2*two<h) {
      two *= 2;
      tmp1 *= tmp1;
      tmp1 %= mod;
      tmp2 *= tmp2;
      tmp2 %= mod;
    }
    h -= two;
    ans *= tmp1*tmp2%mod;
    ans %= mod;
  }
  return ans;
}

ll mypow(ll a, ll b) {
  ll two;
  ll ans = 1;
  ll tmp;
  while(b>0) {
    two = 1;
    tmp = a;
    while(2*two<b) {
      two *= 2;
      tmp *= tmp;
      tmp %= mod;
    }
    b -= two;
    ans *= tmp;
    ans %= mod;
  }
  return ans;
}

int main() {
  frac[0] = 1;
  for(ll i=1;i<2000005;++i) frac[i] = frac[i-1]*i%mod;
  ll K;
  cin>>K;
  string S;
  cin>>S;
  ll ans = 0;
  ll N = S.size();
  for(ll i=N;i<=N+K;++i) {
    ans += comb(i-1, N-1)*mypow(25, i-1-(N-1))%mod*mypow(26, N+K-i)%mod;
    ans %= mod;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 20944
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use feature qw/say/;

my @ns = split(/\s+/, <STDIN>);
@ns = sort { $a <=> $b } @ns;
if ($ns[0] == 5 && $ns[1] == 5 && $ns[2] == 7) {
    say 'YES';
} else {
    say 'NO';
}

Measured memory_bytes: 768
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<utility>
using namespace std;
int main(){
  pair<int,int> a[110];
  pair<int,int> b[110];
  int n,ans=0,i,j,min=(1<<29),k=-1;
  scanf("%d\n",&n);
  for(i=0;i<n;i++){
    scanf("%d %d\n",&a[i].first,&a[i].second);
  }
  for(i=0;i<n;i++){
    scanf("%d %d\n",&b[i].first,&b[i].second);
  }
  sort(a,a+n,greater<pair<int,int> >() );
  sort(b,b+n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(a[i].first<b[j].first && a[i].second<b[j].second && b[j].second<min){
        min=b[j].second,k=j;
      }
    }
    if(k!=-1){
      ans++,b[k].first=0,b[k].second=0;
    }
    k=-1,min=(1<<29);
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(a) for(int k=head[a];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=5e5+5,M=5e3+5,INF=1e9,mod=924844033;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
struct edge{int t,ne,w;}e[N];
int head[N],cnt,n;
void adde(int a,int b,int c){e[++cnt]=(edge){b,head[a],c};head[a]=cnt;}
int siz[N];
ll ans=0;
vector<int>gp;
void dfs(int x,int f){
	siz[x]=1;int mx=-1;
	run(x)if(v!=f){
		dfs(v,x);
		siz[x]+=siz[v];
		gmax(mx,siz[v]);
		ans+=2ll*e[k].w*min(siz[v],n-siz[v]);
	}gmax(mx,n-siz[x]);
	if(mx<=n/2)gp.pb(x);
}
int main(){
	read(n);
	re(i,1,n){
		int a,b,c;read(a,b,c);
		adde(a,b,c);adde(b,a,c);
	}
	dfs(1,0);
	if(gp.size()==2){
		int x=gp[0],y=gp[1];
		run(x)if(v==y)ans-=e[k].w;
	}else{
		int x=gp[0];ll mn=1e18;
		run(x)gmin(mn,e[k].w);
		ans-=mn;
	}
	cout<<ans<<endl;
}

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

int main(){
  int N, K; cin >> N >> K;
  vector<int> vec(N, 0);
  for(int i = 0; i < K; i++){
    int d; cin >> d;
    for(int j = 0; j < d; j++){
      int a; cin >> a;
      vec.at(a-1)++;
    }
  }
  
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(vec.at(i) == 0){
      ans++;
    }
  }
  cout << ans << endl;
}


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

int main() {
  long long a,b,c,d,l,r;
  cin >> a >> b>>c;
  l=0;
  for(int i=1;i<a+1;i++){
    d=i%10+(i/10)%10+(i/100)%10+(i/1000)%10+(i/10000)%10;
  if (d>=b&&d<=c) {
    l+=i;
  }
  }
    cout<<l<<endl;

}


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

int main() {
  string S;
  cin >> S;
  
  if (S == "SUN") {
    cout << 7 << endl;
  }
  if (S == "MON") {
    cout << 6 << endl;
  }
  if (S == "TUE") {
    cout << 5 << endl;
  }
  if (S == "WED") {
    cout << 4 << endl;
  }
  if (S == "THU") {
    cout << 3 << endl;
  }
  if (S == "FRI") {
    cout << 2 << endl;
  }
  if (S == "SAT") {
    cout << 1 << endl;
  }
}

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

using namespace std;

int main() {
    string s;
    cin >> s;

    int ans = 0, l = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G') {
            l++;
        } else {
            ans = l > ans ? l : ans;
            l = 0;
        }
    }
    ans = l > ans ? l : ans;

    cout << ans << endl;

    return 0;
}

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

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

    for(long long i = -1000; i <= 1000; i++){
        for(long long j = -1000; j <= 1000; j++){
            if(i*i*i*i*i-j*j*j*j*j == x){
                printf("%lld %lld\n", i, j);
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3676
N, Ma, Mb = map(int, input().split())
e = [tuple(map(int, input().split())) for _ in range(N)]

N_max = 40
a_max = 10
b_max = 10
c_max = 100

inf = N_max * c_max + 1
dp = [[inf] * (N_max * b_max + 1) for _ in range(N_max * a_max + 1)]
dp[0][0] = 0

for i, (aa, bb, cc) in enumerate(e):
    for a in reversed(range(a_max * i + 1)):
        for b in reversed(range(b_max * i + 1)):
            if dp[a][b] == inf: continue
            if a + aa < N_max * a_max + 1 and b + bb < N_max * b_max + 1:
                dp[a + aa][b + bb] = min(dp[a + aa][b + bb], dp[a][b] + cc)

ans = inf
for i in range(1, N_max * a_max + 1):
    if i * Ma >= N_max * a_max + 1 or i * Mb >= N_max * b_max + 1: break
    # a:b=Ma:Mb
    # b*Ma=a*Mb
    ans = min(ans, dp[i * Ma][i * Mb])

print(ans if ans < inf else -1)


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

int main() {
	vector<int> a;
	for (int i = 0;i < 3; i++) {
		int x;
		cin >> x;
		a.push_back(x);
	}
	sort(a.begin(), a.end());
	cout << a[0] + a[1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<list>
#include<map>
using namespace std;

int main(){
	while(true){
		int tmp,n=0,l;
		list<int>cur;
		map<int,int> as;
		map<int,int>::iterator mi;
		cin>>tmp>>l;
		if(l==0)break;
		do{
			int big=0,small=0;
			cur.clear();
			as.insert(pair<int,int>(tmp,n));
			n++;
			for(int i=0;i<l;i++){
				cur.push_back(tmp%10);
				tmp=tmp/10;
			}
			cur.sort();
			for(list<int>::iterator it=cur.begin();it!=cur.end();++it){
				small=small*10;
				small+=*it;
			}
			for(list<int>::reverse_iterator it=cur.rbegin();it!=cur.rend();++it){
				big=big*10;
				big+=*it;
			}
			tmp=big-small;
			mi=as.find(tmp);
		}while(mi==as.end());
		cout<<(*mi).second<<' '<<(*mi).first<<' '<<n-(*mi).second<<endl;
	}
	return 0;
}

Measured memory_bytes: 1196
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
#narr = lambda d, f: narr(d[:-1], lambda: [f() for _ in range(d[-1])]) if d else f() # narr((2,3), int)
mat = lambda x, y, v: [[v]*y for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

H, W = rl()
C = rl()
D = rl()
M = []
for i in range(H):
	s = rs()
	M.append(s)

start = tuple([C[0]-1, C[1]-1])
end = tuple([D[0]-1, D[1]-1])

queue = deque()
queue.append((start, 0))
#visited = narr((H, W), lambda: float('inf'))
#visited = [[float('inf')] * W for _ in range(H)]
visited = mat(H, W, float('inf'))
visited[start[0]][start[1]] = 0

ds = [(1,0),(-1,0),(0,1),(0,-1)]
while queue:
	n, d = queue.popleft()
	if n == end:
		print(d)
		exit()
	i, j = n
	if visited[i][j] != d:
		continue
	nd = d
	for di, dj in ds:
		ni, nj = i+di, j+dj
		if not (0 <= ni < H and 0 <= nj < W): continue
		if M[ni][nj] == '#': continue
		if nd < visited[ni][nj]:
			queue.appendleft(((ni,nj), nd))
			visited[ni][nj] = nd
	nd = d+1
	for di in range(-2, 3):
		for dj in range(-2, 3):
			if (di, dj) == (0,0): continue
			ni, nj = i+di, j+dj
			if not (0 <= ni < H and 0 <= nj < W): continue
			if M[ni][nj] == '#': continue
			if nd < visited[ni][nj]:
				queue.append(((ni,nj), nd))
				visited[ni][nj] = nd
print(-1)


Measured memory_bytes: 99844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	// your code goes here
	ll n,d;
	ll count = 0;
	cin>>n>>d;
	//ll mult = d*d;
	for(ll i =0; i<n; i++)
	{
		ll x,y;
		cin>>x>>y;
		x = (x)*(x);
		y = (y)*(y);
		ll res = x+y;
		double root = sqrt(res);
		//cout<<root<<endl;
		if(d>=(root))
		{
			count++;
		}
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 3636
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] In = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int a = In[0];
            int b = In[1];
            Console.WriteLine(a * b / 2);
        }
    }
}


Measured memory_bytes: 28180
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>

#define LL long long int
#define pb push_back
#define mp make_pair
#define MAX 100005
#define MOD 1000000007

using namespace std;

int main() {
	double pie = 3.14159265358979323846;
	int r;
	cin>>r;
	cout<<2*pie*r<<endl;
    return 0;
}



Measured memory_bytes: 3784