akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
N = int(input())

s = []
b = 2
if N == 0:
    print(0)
    exit()
while N != 0:
    if N % b == 0:
        s.append(str(0))
    else:
        s.append(str(1))
        N -= int(b/2)
    b *= -2

print(''.join(s[::-1]))

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;

int main(void) {
	int i;
	char field[65];
	char image[8][26] = {
		"1100000011",
		"1000000010000000100000001",
		"1111",
		"1000000110000001",
		"11000000011",
		"100000001100000001",
		"110000011"
	};

	while (cin >> field) {
		//cout<<field;
		for (i = 1; i < 8; i++) {
			cin >> image[7];
			strcat(field, image[7]);
			//cout<<field;
		}
		//cout<<endl;
		field[64] = '\0';
		for (i = 0; i < 7; i++) {
			char *pFind = strstr(field, image[i]);
			//cout<<pFind<<endl;
			if (pFind != NULL) {
				cout << char('A' + i) << endl;
				break;
			}
		}
	}

	return 0;
}



Measured memory_bytes: 3080
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int s[10001]={0};
int main(){
int n,m,i,j,a,b,z,u;
cin>>n>>s[0];
u=s[0];
for(i=1;i<=n;i++){
	cin>>a>>b;
	z=s[i-1]+a-b;
	if(z<0)u=0;
	s[i]=z;
	if(u!=0)u=max(u,s[i]);
}
cout<<u<<endl;
return 0;
}

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

int main() {
  int n,m;
  cin>>n>>m;
  int a[2][m];
  for(int i=0;i<m;i++){
    int k,l;
    cin>>k>>l;
    a[0][i]=k;
    a[1][i]=l;
  }
  int b[n];
  if(n==1)b[0]=0;
  else b[0]=1;
  bool ans=true;
  for(int i=1;i<n;i++)b[i]=0;
  for(int i=0;i<m-1;i++){
    for(int j=i+1;j<m;j++){
      if(a[0][i]==a[0][j]&&a[1][i]!=a[1][j])ans=false;
    }
  }
  for(int i=0;i<m;i++){
    b[a[0][i]-1]=a[1][i];
  }
  if(n>1&&b[0]==0)ans=false;
  if(ans){
    for(int i=0;i<n;i++){
      cout<<b[i];
    }
    cout<<endl;
  }
  else cout<<-1<<endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main()
{
	int l,r,d;
	scanf("%d%d%d",&l,&r,&d);
	int c=0;
	for(int i=l;i<=r;i++){
		if(i%d==0){
			c+=1;
		}
	}
	printf("%d",c);
	
	
	
	return 0;
 } 

Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<bitset>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> pll;
const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int H,W,K;
    cin>>H>>W>>K;
    int SS[H][W];
    //cout << 0  << endl;
    REP(i,H){
        REP(j,W){
            char c; cin>>c;
            if(c == '0')SS[i][j] = 0;
            else SS[i][j] = 1;
        }
    }
    //cout << 0 << endl;
    //int ans = INF;
    int mini = INF;
    //if(H >= 2){
        for(int S = 0 ; S < (1<<(H-1)); S++){
            int ans = bitset<32>(S).count();
            //cout <<ans<<endl;
            vector<int> choco(ans+1,0);
            vector<P> divide;
            int start = 0;
            //int end = 0;
            REP(i,H-1){
                if(S & (1<<i)){
                    divide.push_back(P(start,i+1));
                    start = i+1;
                }
            }
            divide.push_back(P(start,H));
            bool flag =true; //そもそもありえるかのflag
            int itr = 0; //これはなに
            REP(i,W){
                bool f = true;
                REP(k,divide.size()){
                    int new_choco = 0;
                    for(int j = divide[k].first; j < divide[k].second; j++){
                        if(SS[j][i] == 1) new_choco++;
                    }
                    choco[k] += new_choco;
                    if(choco[k] > K){
                        f = false; break;
                    }
                }
                if(!f){
                    if(itr == 0){
                        flag = false; break;
                    }
                    else{
                        //if(S ==0) cout << itr<<endl;
                        itr = 0; ans++;
                        REP(k,divide.size()){
                            choco[k] = 0;
                        }
                        /*REP(k,divide.size()){
                            int new_choco = 0;
                            for(int j = divide[k].first; j < divide[k].second; j++){
                                if(SS[i][j] == 1) new_choco++;
                            }
                            choco[k] = new_choco;
                        }*/
                        i--;
                    }
                }
                else{
                    itr++;
                }
            }
            //cout << S << ans<<endl;
            if(!flag) continue;
            else mini = min(ans,mini);
        }
    //}
    cout << mini << endl;
}

Measured memory_bytes: 256
n = int(input())
v = list(map(int, input().split()))

d1 = {}
d2 = {}

largest_key1 = 0
largest_val1 = 0

larger_key1 = 0
larger_val = 0

largest_key2 = 0
largest_val2 = 0

larger_key2 = 0
larger_val2=0

if n == 2 and v[1] == v[2]:
    print(1)
    exit()
elif n == 2:
    print(0)
    exit()

for i in range(0, n, 2):
    if v[i] in d1:
        d1[v[i]] += 1
    else:
        d1[v[i]] = 1
    if d1[v[i]] >= largest_val1:
        if largest_key1 == v[i]:
            largest_val1 += 1
        else:
            larger_key1 = largest_key1
            larger_val1 = largest_val1
            largest_key1 = v[i]
            largest_val1 = d1[v[i]]
    elif d1[v[i]] >= larger_val1:
        larger_key1 = v[i]
        larger_val1 = d1[v[i]]

for i in range(1, n, 2):
    if v[i] in d2:
        d2[v[i]] += 1
    else:
        d2[v[i]] = 1
    if d2[v[i]] >= largest_val2:
        if largest_key2 == v[i]:
            largest_val2 += 1
        else:
            larger_key2 = largest_key2
            larger_val2 = largest_val2
            largest_key2 = v[i]
            largest_val2 = d2[v[i]]
    elif d2[v[i]] >= larger_val2:
        larger_key2 = v[i]
        larger_val2 = d2[v[i]]

if largest_key1 != largest_key2:
    print(n - largest_val1 - largest_val2)
else:
    print(n-max(largest_val1 + larger_val2, larger_val1 + largest_val2))
    


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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

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;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int main(){
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    cout<<max({a+b,a-b,a*b});   
    return 0;
}

Measured memory_bytes: 256
use std::io;

fn main() {
    b_shift_only();
}

fn split_input(input: &str) -> Vec<i32> {

    let vec: Vec<&str> = input.split(" ").collect();
    let mut int_vec: Vec<i32> = Vec::new();

    for v in vec {
        //int_vec.push(
        let input_num: i32 = match v.trim().parse() {
            Ok(num) => num ,
            Err(_)  => panic!("input wrong number."),
        };

        int_vec.push(input_num);
    }

    int_vec
}

fn b_shift_only() {

    let mut _n = String::new();
    io::stdin().read_line(&mut _n)
        .expect("Failed to read line")
        ;

    let mut input_str = String::new();
    io::stdin().read_line(&mut input_str)
        .expect("Failed to read line")
        ;

    let input_numbers = split_input(&input_str);


    println!("{}", count_vec(&input_numbers));

}

fn count_vec(numbers: &Vec<i32>) -> i32 {

    let mut all_even = true;
    for n in numbers {
        if n % 2 == 1 {
            all_even = false;
            break;
        }
    }

    if all_even {
        let bisected = bisect(&numbers);
        return 1 + count_vec(&bisected);
    }

    0
}

fn bisect(numbers: &Vec<i32>) -> Vec<i32> {

    let mut new_vec: Vec<i32> = Vec::new();
    for n in numbers {
        new_vec.push( n / 2 );
    }
    new_vec
}



Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>
#define buf 100
 
int main(void){
	int i,n,w,x,y,tmp;
	int A[buf];
	char str[buf],*line;

	fgets(str,sizeof(str),stdin);
	sscanf(str,"%d",&w);
	for(i=1;i<=w;i++)
		A[i]=i;
	fgets(str,sizeof(str),stdin);
	sscanf(str,"%d",&n);
	for(i=0;i<n;i++){
		fgets(str,sizeof(str),stdin);
		line = strtok(str,",");
		sscanf(line,"%d",&x);
		line = strtok(NULL,",");
		sscanf(line,"%d",&y);
		tmp = A[x];
		A[x] = A[y];
		A[y] = tmp;
	}
	for(i=1;i<=w;i++)
		printf("%d\n",A[i]);
	return 0;
}

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

long long gcd(long long a, long long b){
    // 最大公約数
    // ユークリッドの互除法
    if(a < b){
        long long temp = a;
        a = b;
        b = temp;
    }
    long long r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
long long lcm(long long a, long long b){
    // 最小公倍数
    return a * b / gcd(a, b);
}
int main(){
    long long a, b;
    cin >> a >> b;
    cout << lcm(a ,b);
    return 0;
}

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

#define MAXLEN (100000 + 7)

int check(char *str, int len, char first){
    int i, cnt = 0;
    for(i = 0; i < len; ++i) {
        if(str[i] != first) { ++cnt; }
        first = (first == '1') ? '0' : '1';
    }
    return cnt;
}

void solve(char *str, int len) {
    int try1, try2;
    try1 = check(str, len, '0');
    try2 = check(str, len, '1');
    //printf("try1 : %d try2 : %d\n", try1, try2);
    printf("%d\n", (try1 < try2) ? try1 : try2);
}

int main()
{
    int len;
    char *str = (char*)malloc(MAXLEN * sizeof(char));
    scanf("%s", str);
    len = strlen(str);
    solve(str, len);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main()
	{
		int N = GetInt();
		long X = GetLong();

		long[] numP = new long[N+1];
		long[] numTotal = new long[N+1];
		numP[0] = 1L;
		numTotal[0] = 1L;
		for(int i = 1; i <= N; i++)
		{
			numP[i] = 1L + 2L * numP[i-1];
			numTotal[i] = 3L + 2L * numTotal[i-1];
		}

		Solver solver = new Solver(numP, numTotal);
		Console.WriteLine(solver.eat(N, X));		
	}
}


public class Solver
{
	private long[] m_numP;
	private long[] m_numTotal;

	public Solver(long[] numP, long[] numTotal)
	{
		m_numP = numP;
		m_numTotal = numTotal;
	}

	public long eat(int level, long length)
	{
		if(level == 0)
			return (length <= 0) ? 0L : 1L;

		if(length <= 1L + m_numTotal[level - 1])
			return eat(level - 1, length - 1L);

		return m_numP[level - 1] + 1L + eat(level - 1, length - 2L - m_numTotal[level - 1]);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


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

#define xx first
#define yy second



void solve() {
    string s, t; cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < ((int)(s.size())); i++)
        if (s[i] != t[i])
            ans++;
    cout << ans << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


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

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var d = new Dictionary<long, long>();
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, long.Parse);
        var w = 0L; d[w] = 1;
        for (int i = 0; i < n; i++)
        {
            w += a[i];
            if (d.ContainsKey(w)) d[w]++;
            else d[w] = 1;
        }
        Console.WriteLine(getAns(d));
    }
    public static long getAns(Dictionary<long, long> d)
    {
        var ret = 0L;
        foreach (var x in d)
            if (x.Value >= 2) ret += (x.Value * (x.Value - 1) )/ 2;
        return ret;
    }
}


Measured memory_bytes: 44004
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto K = RD;

	writeln(K == 1 ? 0 : N - K);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N,an=0;
	cin >> N;
	if (N % 2 != 0)cout << 0 << endl;
	else {
		N /= 2;
		rep(i, 1000) {
			an += N / 5;
			N /= 5;
		}
		cout << an << endl;
	}
	

}

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

using namespace std;

class Dice
{
private:
	int top_;		// ?????¢
	int north_;		// ?????¢
	int south_;		// ?????¢
	int east_; 		// ??±??¢
	int west_; 		// ?\???¢
	int bottom_;	// ?????¢

private:
	Dice() {}

public:
	Dice( const int& topNumber
		, const int& northNumber
		, const int& southNumber
		, const int& eastNumber
		, const int& westNumber
		, const int& bottomNumber )
	{
		top_	= topNumber;
		north_	= northNumber;
		south_	= southNumber;
		east_	= eastNumber;
		west_	= westNumber;
		bottom_	= bottomNumber;
	}

	~Dice() {}

	int getTopNumber() {
		return top_;
	}

private:
	// ?????¢?£??????¢??°
	void rotate(int& a, int& b, int& c, int& d) const {
		int tmp = a;
		a = b;
		b = c;
		c = d;
		d = tmp;
	}

public:
	void rotateNorth()	{ rotate(top_, south_, bottom_, north_); }
	void rotateSouth()	{ rotate(top_, north_, bottom_, south_); }
	void rotateEast()	{ rotate(top_, west_, bottom_, east_); }
	void rotateWest()	{ rotate(top_, east_, bottom_, west_); }
#if 0	// ??????????????¨?????????
	void rotateClockwise()		{ rotate(north_, west_, south_, east_); }
	void rotateAnticlockwise()	{ rotate(north_, east_, south_, west_); }

#endif
};

void diceRotate(Dice& dice, const string& commands)
{
	for ( unsigned int i = 0; i < commands.size(); ++i ) {

		const char& command  = commands[i];
		if ( command == 'N' ) {
			dice.rotateNorth();
		} else if ( command == 'S' ) {
			dice.rotateSouth();
		} else if ( command == 'E' ) {
			dice.rotateEast();
		} else if ( command == 'W' ) {
			dice.rotateWest();
		}

	}
}

int main(int, char**)
{
	const int diceSize = 6;
	int diceNumbers[diceSize];
	for ( int i = 0; i < diceSize; ++i) {
		cin >> diceNumbers[i];
	}

	Dice dice(diceNumbers[0]	// ?????¢
			, diceNumbers[4]	// ?????¢
			, diceNumbers[1]	// ?????¢
			, diceNumbers[2]	// ??±??¢
			, diceNumbers[3]	// ?\???¢
			, diceNumbers[5]);	// ?????¢

	string commands;
	cin >> commands;

	diceRotate(dice, commands);

	cout << dice.getTopNumber() << endl;

	return 0;
}

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

bool p[1000100];

void erato(){
	fill(p, p+1000100, true);
	p[0] = p[1] = false;

	for(int i=0; i < 1000100; i++){
		if(!p[i]) continue;
		for(int j=i+i; j < 1000100; j += i){
			p[j] = false;
		}
	}
}

int main(){
	erato();
	int n;
	while(cin >> n, n){
		int count = 0;
		for(int i= n+1; i <= 2*n; i++){
			if(p[i]) count++;
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 2136
from heapq import heappush,heappop
n=int(input()); a=[int(_) for _ in input().split()]
fh=[]; lh=[]
for i in range(n):
    heappush(fh, a[i])
    heappush(lh, -1*a[-i-1])
f=[sum(fh)]; l=[-1*sum(lh)]
for i in range(n,2*n):
    heappush(fh, a[i]); f.append(f[-1]+a[i]-heappop(fh))
    heappush(lh, -1*a[-i-1]); l.append(l[-1]+a[-i-1]+heappop(lh))
ans=-10**15
for i,j in zip(f,l[::-1]):ans=max(ans, i-j)
print(ans)

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

std::vector<int> factorialSmallerN(int N)
{
    std::vector<int> e(N, 0);
    std::vector<int> p = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
    for(int i = 2; i <= N; i++)
    {
        int cur = i;
        for(int j = 0; j < p.size(); j++)
        {
            while( cur % p[j] == 0)
            {
                e[p[j]]++;
                cur = cur / p[j];
            }
        }
    }
    return e;
}

long getLargeDivisor(int th, std::vector<int> d_vec)
{
    return std::count_if(d_vec.begin(), d_vec.end(), [=](int x){return x >= th;});
}

int main()
{
    int N = 0;
    cin >> N;
    long ret = 0;
    auto d_vec = factorialSmallerN(N);
    ret = getLargeDivisor(74, d_vec);
    ret += getLargeDivisor(24, d_vec) * (getLargeDivisor(2, d_vec) - 1);
    ret += getLargeDivisor(14, d_vec) * (getLargeDivisor(4, d_vec) - 1);
    ret += getLargeDivisor(4, d_vec) * (getLargeDivisor(4, d_vec) - 1) * (getLargeDivisor(2, d_vec) - 2) / 2;
    cout << ret;
    return 0;
}


Measured memory_bytes: 256
my $s = <>;chomp $s;
my @dat = split(//,$s);
#print "$dat[-1]\n"; 
if( $dat[-1] == 3){
    print "bon";
}elsif($dat[-1]==0||$dat[-1]==1||$dat[-1]==6||$dat[-1]==8){
    print "pon";
}else{
    print "hon";
}


Measured memory_bytes: 4836
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

int main() {
  size_t N;
  double T, A;

  std::cin >> N;
  std::cin >> T >> A;

  std::vector<double> diffA(N);

  for (size_t i=0; i<N; i++) {
    double h;
    std::cin >> h;
    auto Ti = T - h * 0.006;
    diffA[i] = std::abs(A - Ti);
  }

  auto imin = std::min_element(diffA.begin(), diffA.end());
  auto ans = std::distance(diffA.begin(), imin) + 1;

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<ll,ll>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):0;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    inline ll qpower(ll x,ll e)
    {
        ll ans=1;
        while(e){if(e&1)ans=ans*x%MOD;x=x*x%MOD;e>>=1;}
        return ans;
    }
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

	char str[N];
	int fl[N],fr[N];
	void main()
	{
		scanf("%s",str+1);int n=strlen(str+1);
		for(int i=1;i<=n;i++) fl[i]=i-1,fr[i]=i+1;fr[n]=0;
		int now=1;
		while(fr[now])
		{
			if(str[now]=='S' and str[fr[now]]=='T')
			{
				int x=fl[now],y=fr[fr[now]];
				if(!x and !y) {puts("0");return;}
				fl[y]=x,fr[x]=y;
				if(!x) now=y; else now=x;
			}
			else now=fr[now];
		}
		int cnt=1;while(fl[now]) cnt++,now=fl[now];write(cnt);
	}
};
int main()
{
	srand(time(0));
	mine::main();
}

Measured memory_bytes: 7168
n, l = map(int, input().split())
ans = 0
if l >= 0:
    for i in range(1,n):
        ans += l + i
    print(ans)
else:
    if abs(l) >= n:
        for i in range(n-1):
            ans += l + i
        print(ans)
    else:
        for i in range(n):
            ans += l + i
        print(ans)

Measured memory_bytes: 3064
import java.util.ArrayDeque;import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner s = new Scanner(System.in);ArrayDeque<Integer> ad = new ArrayDeque<Integer>();while (s.hasNextInt()) {int n = s.nextInt();if (n == 0) {System.out.println(ad.pollLast());} else {ad.add(Integer.valueOf(n));}}}}

Measured memory_bytes: 12000
n,m,x=gets.split(" ").map(&:to_i)
a = []
a = gets.split(" ").map(&:to_i)

sum1 = 0;sum2 = 0
a.each do |i|
  if i < x
    sum1 += 1
  elsif i > x
    sum2 += 1
  end
end

if sum1 <= sum2
  print("#{sum1}\n")
else
  print("#{sum2}\n")
end

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
int n,m;
int a[200005];
int find(int x){
	if(x==a[x])  return x;
    return a[x]=find(a[x]);
}
void Union(int x,int y){
    int pa=find(x);
    int pb=find(y);
    if(pa!=pb) a[pa]=pb;
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		a[i]=i;
	}
	for(int i=1;i<=m;i++){
		int x,y;
		cin>>x>>y;
		Union(x,y);
	}
	for(int i=1;i<=n;i++){
		find(i);
	}
	map<int,int> mapp;
	int ma=-1;
	for(int i=1;i<=n;i++){
		mapp[a[i]]++;
		ma=max(ma,mapp[a[i]]);
	}
	cout<<ma<<endl;
}

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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)


typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
//////////////////////////


ll SOLVE(){
    ll n,k;cin>>n>>k;
    ll s=(n-1)*(n-2)/2;
    if(s<k){
        cout<<-1<<endl;
    }else{
        vector<l_l>ans;
        ll cnt=1;
        rep(i,2,n){
            rep(j,i+1,n){
                if(cnt<=s-k){
                    ans.pb({i,j});
                    cnt++;
                }
            }
        }
        rep(i,2,n)ans.pb({1,i});
        cout<<ans.size()<<endl;
        for(auto x:ans){
            cout<<x.fi<<" "<<x.se<<endl;
        }
    }
    
    return 0;
}

int main(){fastio
    
    clock_t start = clock();
    SOLVE();
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    cerr<<endl<<time<<"ms"<<endl;
    
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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; }
const int64_t INF = 1LL << 60;

int main() {
 int m1,d1,m2,d2;
 cin>>m1>>d1>>m2>>d2;
 if(m1<m2){cout<<1<<endl;}
 else if(m1==12&&m2==1){cout<<1<<endl;}
 else{cout<<0<<endl;}
return 0;
} 

Measured memory_bytes: 256
N = int(input())
ans = N

for i in range(N+1):
    tmp = 0
    t = i
    while t > 0:
        tmp += t % 6
        t //= 6 
    t = N - i
    while t > 0:
        tmp += t % 9
        t //= 9
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 3060
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		long num = 1000000007;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		int n = Integer.parseInt(st.nextToken());
 		int k = Integer.parseInt(st.nextToken());
 		long sum = 0;
 		for(long j = k;j<=n;j++){
 			sum+=(long)((j*(long)(n)-j*j+j+1));
 			sum%= num;
 		}
 		
 		
 		out.println(sum+1);
	 		
 		out.close();
 		
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 25896
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define all(collection) (collection).begin(), (collection).end()
#define loop(i, times) for(int i = 0; i < times; i++)
#define seloop(i, start_index, end_index) for(int i = start_index; i < end_index; i++)
#define eqseloop(i, start_index, end_index) for(int i = start_index; i <= end_index; i++)

class NyaGadgetCpp17
{
public:
	/**
	@brief 最大公約数を計算する関数
	@note
	 aとbの最大公約数を返す
	**/
	template <typename T> static T Gcd(T a, T b)
	{
		return b ? Gcd(b, a % b) : a;
	}
};

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

	if (s.size() == 1)
	{
		cout << 0;
		return 0;
	}

	int index = 0;
	int count = 0;
	while (1)
	{
		if (s[index] != s[index + 1])
		{
			count++;
			s.replace(index, 2, "");
			if (index != 0)
				index--;
		}
		else
		{
			index++;
		}

		if (s.size() == 0)
			break;

		if (index == s.size() - 1)
			break;
	}
	
	cout << count * 2;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>


int main(void)

{	
	long long int n,i,power=1;
	scanf("%lld",&n);
	
	for(i=1;i<=n;i++){
		power=power*i;
		power=power%(10*10*10*10*10*10*10*10*10+7);
	}
	
	printf("%lld\n",power);
	return 0;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
S = [list(input().split()) for i in range(H)]
flag = True
for h in range(H):
    for w in range(W):
        if S[h][w] == 'snuke':
            id = [h,w]
            flag = False
            break
    if not flag:
        break
print(str(chr(w+65))+str(h+1))


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) ((a < b ? a : b))
#define ABS(a, b) ((uint32_t)(a < b ? b - a : a - b))

int32_t A[100001];

int main(void) {
	uint32_t N;
	uint32_t overallCost = 0;

	A[0] = 0;

	scanf("%"PRIu32"\n", &N);
	for (uint32_t idx = 1; idx < N; idx++) {
		scanf("%"PRIu32"\n", &(A[idx]));
		overallCost += ABS(A[idx], A[idx - 1]);
	}
	scanf("%"PRIu32, &(A[N]));
	overallCost += ABS(A[N], A[N - 1]) + ABS(A[N], A[0]);

	for (uint32_t idx = 1; idx < N; idx++) {
		printf("%"PRIu32"\n", overallCost - ABS(A[idx - 1], A[idx]) - ABS(A[idx], A[idx + 1]) + ABS(A[idx - 1], A[idx + 1]));
	}
	printf("%"PRIu32, overallCost - ABS(A[N - 1], A[N]) - ABS(A[N], A[0]) + ABS(A[N - 1], A[0]));

	return 0;
}


Measured memory_bytes: 1536
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;


const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        ll h, w, a, b;
        COMinit();
        cin >> h >> w >> a >> b;
        ll ans = 0;
        for (int i = 0; i < h - a; ++i) {
            ans += COM(b - 1 + i, i) * COM(h - i - 1 + w - b - 1, h - i - 1);
            ans %= MOD;
        }
        cout << ans << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fast_I_O ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int mod = 1e9+7 , INF = 1e9 ,  mx = 100005 ;
main()
{
    fast_I_O;
    int i,j,n,m,x,y,sum=0,p=0,l,k;
    cin>>n;
    for(i=1;i<=1e7;i++)
    {
        p=p*10+7;
        p%=n;
        if(p==0)
        {
            cout<<i;
            return 0;
        }
   }
   cout<<-1;
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	string s; cin >> s;
	unordered_set<char> current;
	int result = 0;;
	for (auto i: s) {
		if (i == 'A' && current.size() == 0) current.insert(i);
		else if (i == 'A' && current.count('A') == 1 && current.count('B') == 0 && current.count('C') == 0) continue;
		else if (i == 'B' && current.count('A') == 1 && current.count('B') == 0 && current.count('C') == 0) current.insert(i);
		else if (i == 'C' && current.count('A') == 1 && current.count('B') == 1 && current.count('C') == 0) current.insert(i);
		else current.clear();
		if (current.count('A') == 1 && current.count('B') == 1 && current.count('C') == 1) {
			result++;
			current.clear();
		}
	}
	cout << result;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String o = sc.next(), e = sc.next();
    String s = "";

    if (o.length() == e.length()) {
      for(int i = 0; i < o.length(); i++) {
        s += o.charAt(i);
        s += e.charAt(i);
      }
    } else {
      for(int i = 0; i < o.length() - 1; i++) {
        s += o.charAt(i);
        s += e.charAt(i);
      }
      s += o.charAt(o.length() - 1);
    }
    System.out.println(s);
  }
}


Measured memory_bytes: 23764
#define _CRT_SECURE_NO_WARNINGS
#define MaxSize 16777215
#include <stdio.h>
#include <stdlib.h>


void insert(char *D, char s[]) {
	int i = -1;
	char c;
	int p = -1;
	while (c = s[++i]) {
		switch (c) {
		case 'A':
			p *= 4;
			p += 4;
			break;
		case 'C':
			p *= 4;
			p += 5;
			break;
		case 'G':
			p *= 4;
			p += 6;
			break;
		case 'T':
			p *= 4;
			p += 7;
			break;
		}
	}
	D[p] = 'Y';
}

int find(char *D, char s[]) {
	int i = -1;
	char c;
	int p = -1;
	while (c = s[++i]) {
		switch (c) {
		case 'A':
			p *= 4;
			p += 4;
			break;
		case 'C':
			p *= 4;
			p += 5;
			break;
		case 'G':
			p *= 4;
			p += 6;
			break;
		case 'T':
			p *= 4;
			p += 7;
			break;
		}
	}
	return D[p] == 'Y';
}

int main() {
	char *D = (char *)malloc(sizeof(char) * MaxSize);
	int i;
//	for (i = 0; i < MaxSize; ++i) {
//		D[i] = 'N';
//	}

	char com[7];
	char s[13];
	int n;
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		scanf("%s%s", com, s);
		if (com[0] == 'i') {
			insert(D, s);
		}
		else {
			if (find(D, s)) {
				printf("yes\n");
			}
			else {
				printf("no\n");
			}
		}
	}


	free(D);

	return 0;
}

Measured memory_bytes: 3380
#include<stdio.h>
int main(void){
    int r,g,b,wa;
    
    scanf("%d %d %d",&r,&g,&b);

    wa=100*r + 10*g + b;

    if(wa%4==0){
         printf("YES");
    }else{
         printf("NO");
    }

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff(i,n) for(i=0;i<n;i++)
#define pb push_back
ll bg =  998244353;
ll fac[300000];
ll power(ll x,ll y)
{
    if(y==0)
	    return 1;
	ll d = power(x,y/2)%bg;
	ll f = (d*d)%bg;
	if(y%2==0)
	  return f;
	else
	  return (f*x)%bg;	 	
}
ll modinv(ll m)
{
	return power(m,bg-2);	
}
ll ncr(ll n,ll r)
{
	ll s1 = fac[n],s2 = fac[r],s3 = fac[n-r];
	ll d1 = (s1*modinv(((s2*s3)%bg)))%bg;
	return d1;
}
int main()
{
	fac[0]=1;
	for(ll j=1;j<300000;j++)
	  fac[j] = (j*fac[j-1])%bg;
	ll t;
	t=1;
	while(t--)
	{
		ll a,b,c,k;
		cin>>a>>b>>c>>k;
		if(k<=a)
		  cout<<k;
		else if(k<=(a+b))
		  cout<<a;
		else if(k<=(a+b+c))
		  cout<<(2*a-k+b);  
	}
	 return 0;
}

Measured memory_bytes: 5980
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N 200100
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
#define INF 100000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


signed main()
{
    
    speed
    int n;
    cin>>n;
    int ans=0;
    rep(i,1,n){
        if(i%3==0 || i%5==0)continue;
        ans+=i;
    }
    cout<<ans<<endl;
   
    
    
    
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include<list>
#include<vector>
using namespace std;

int main()
{
	int n, q;

	cin >> n >> q;

	vector<list<int>> v(n);

	for (int i = 0; i < q; i++) {
		int command, t;
		cin >> command >> t;

		if (command == 0) {
			int x;
			cin >> x;

			v[t].push_back(x);
		}		
		else if (command == 1) {
			list<int>::iterator itr = v[t].begin();

			for (; itr != v[t].end(); itr++) {
				if (itr != v[t].begin()) {
					cout << " ";
				}
				cout << *itr;
			}
			
			cout <<endl;
		}
		else if (command == 2) {
			//都合上sとtが逆
			int s;
			cin >> s;
			v[s].splice(v[s].end(), v[t]);
		}
	}

	return 0;
}



Measured memory_bytes: 18656
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int cnt[200001];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K; cin >> N >> K;
  int num = 0;
  FOR(i,0,N) {
    int in; cin >> in;
    if(cnt[in] == 0) num++;
    cnt[in]++;
  }
  sort(cnt, cnt + 200001);
  int nokori = num - K;
  int ans = 0;
  int i = 0;
  while(nokori > 0 && i <= 200001) {
    if(cnt[i] > 0) {
      ans += cnt[i];
      nokori--;
    }
    i++;
  }
  cout << ans << endl;
  return 0;
}

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

public class Main {
	
	public String species(String snake){
		if( snake.length() < 5 || snake.charAt(0) != '>' || snake.charAt(snake.length()-1) != '~' ){
			return "NA";
		}
		if( snake.charAt(1) == '\'' ){
			int count = 0;
			boolean flag = true;
			for(int i = 2; i < snake.length()-1; i++){
				if( flag ){
					if( snake.charAt(i) == '=' ){
						count++;
					} else if( snake.charAt(i) == '#' ){
						flag = false;
					} else {
						return "NA";
					}
				} else {
					if( snake.charAt(i) == '=' ){
						count--;						
					} else {
						return "NA";
					}
				}
			}
			if( count != 0 ){
				return "NA";
			}
			return "A";
		} else if( snake.charAt(1) == '^' ){
			for(int i = 2; i < snake.length()-2; i += 2){
				if( snake.charAt(i) == 'Q' && snake.charAt(i+1) == '=' ){
					continue;
				}
				return "NA";
			}
			if( snake.charAt(snake.length()-2) != '~' ){
				return "NA";
			}
			return "B";
		}
		return "NA";
	}
	public void solve() throws IOException{
		int n = nextInt();
		for(int i = 0; i < n; i++){
			String snake = nextToken();
			writer.println(species(snake));
		}
		writer.flush();
	}			
	public static void main (String args[]) throws IOException{
		new Main().run();
	}
	
	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;
	
	public void run() throws IOException{
		try{
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e){
			e.printStackTrace();
			System.exit(1);
		}
	}
	public int nextInt() throws IOException{
		return Integer.parseInt(nextToken());
	}		
	public String nextToken() throws IOException{
		while( tokenizer == null || !tokenizer.hasMoreTokens() ){
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,INF=1<<30;

int main(){
    
    int N,W;cin>>N>>W;
    vector<pair<ll,ll>> S(N);
    ll dp[W*2+2];
    for(int i=0;i<W*2+2;i++){
        dp[i]=0;
    }
    for(int i=0;i<N;i++){
        cin>>S[i].first>>S[i].second;
    }
    for(int i=0;i<N;i++){
        for(int j=W-1;j>=0;j--){
            if(j==0||dp[j]!=0) dp[j+S[i].first]=max(dp[j+S[i].first],dp[j]+S[i].second);
        }
    }
    ll ans=0;
    for(int i=0;i<=W;i++){
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
    }


Measured memory_bytes: 1792
from collections import deque
from collections import Counter

n,x,y = map(int, input().split())

graph = [[] for _ in range(n+1)]

for i in range(1,n):
  a,b = i,i+1
  graph[a].append(b)
  graph[b].append(a)
graph[x].append(y)
graph[y].append(x)

l = []
for j in range(1,n+1):
  dist = [-1] * (n+1)
  dist[0] = 0
  dist[j] = 0

  d = deque()
  d.append(j)

  while d:
    v = d.popleft()
    for i in graph[v]:
      if dist[i] != -1:
        continue
      dist[i] = dist[v] + 1
      d.append(i)

  l.extend(dist[1:])

c = Counter(l)
for i in range(1,n):
  print(int(c[i]/2))

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

using namespace std;

typedef long long ll;

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  bool flag = false;
  cin >> n;
  while(n){
    int a;
    a  = n % 10;
    if(a == 7) flag = true;
    n /= 10;
  }
  if(flag) cout <<"Yes";
  else cout <<"No";

  return 0;
}

/*
         ,--"""",--.__,---[],-------._         
       ,"   __,'            \         \--""""""==;-
     ," _,-"  "/---.___     \       ___\   ,-'',"
    /,-'      / ;. ,.--'-.__\  _,-"" ,| `,'   /
   /``""""-._/,-|:\       []\,' ```-/:;-. `. /
             `  ;:::      ||       /:,;  `-.\
                =.,'__,---||-.____',.=
                =(:\_     ||__    ):)=
               ,"::::`----||::`--':::"._
             ,':::::::::::||::::::::::::'.
    .__     ;:::.-.:::::__||___:::::.-.:::\     __,
       """-;:::( O )::::>_|| _<::::( O )::::-"""
   =======;:::::`-`:::::::||':::::::`-`:::::\=======
    ,--"";:::_____________||______________::::""----.          , ,
         ; ::`._(    |    |||     |   )_,'::::\_,,,,,,,,,,____/,'_,
       ,;    :::`--._|____[]|_____|_.-'::::::::::::::::::::::::);_
      ;/ /      :::::::::,||,:::::::::::::::::::::::::::::::::::/
     /; ``''''----------/,'/,__,,,,,____:::::::::::::::::::::,"
     ;/                :);/|_;| ,--.. . ```-.:::::::::::::_,"
    /;                :::):__,'//""\\. ,--.. \:::,:::::_,"
   ;/              :::::/ . . . . . . //""\\. \::":__,"
   ;/          :::::::,' . . . . . . . . . . .:`::\
   ';      :::::::__,'. ,--.. . .,--. . . . . .:`::`
   ';   __,..--'''-. . //""\\. .//""\\ . ,--.. :`:::`
   ;    /  \\ .//""\\ . . . . . . . . . //""\\. :`::`
   ;   /       . . . . . . . . . . . . . . . . .:`::`
   ;   (          . . . . . . . . . . . . . . . ;:::`
   ,:  ;,            . . . . . . . . . . . . . ;':::`
   ,:  ;,             . . . . . . . . . . . . .;`:::
   ,:   ;,             . . . . . . . . . . . . ;`::;`
    ,:  ;             . . . . . . . . . . . . ;':::;`
     :   ;             . . . . . . . . . . . ,':::;
      :   '.          . . . . . . . .. . . .,':::;`
       :    `.       . . . . . . . . . . . ;::::;`
        '.    `-.   . . . . . . . . . . ,-'::::;
          `:_    ``--..___________..--'':::::;'`
             `._::,.:,.:,:_ctr_:,:,.::,.:_;'`
________________`"\/"\/\/'""""`\/"\/""\/"____________________________
 
*/

Measured memory_bytes: 3664
N,M = map(int,input().split())
array = [10]*N
T_F = True

for i in range(M):
  s,c = map(int,input().split())
  if s>N or (array[s-1] != 10 and array[s-1] !=c) or (s == 1 and c == 0 and N != 1):
    T_F = False
    break
  else:
    array[s-1] = c

ans = 0
if T_F:
  for i in range(N):
    if array[i] == 10:
        array[i] = 0
    ans += array[i]*(10**(N-i-1))
  if array[0] or N == 1:
    print(ans)
  else:
    print(ans+10**(N-1))
else:
  print(-1)

Measured memory_bytes: 3064
h, w, k = map(int, input().split())
ans = 0
c = [input() for i in range(h)]
for i in range(1<<h):
    for j in range(1<<w):
        cnt = 0
        for l in range(h):
            for m in range(w):
                if c[l][m] == '#' and (i >> l) & 1 and (j >> m) & 1:
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

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

int main() {
  int a=0;
  string S;
  cin >> S;
  for(int i=0;i<4;i++){
    if(S[i]=='+'){
      a++;
    }else{
      a--;
    }
  }
  cout << a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define N 202100
const ll mod = 1e9 + 7;

int n, m;
int a[N];
ll sum[N];

ll solve(int x, int in1, int in2) {
	if(in1 < 0 || in2 < 0) return 1e18;
	ll l1 = sum[in1], r1 = sum[x] - sum[in1];
	ll l2 = sum[in2] - sum[x], r2 = sum[n] - sum[in2];
	ll ans = 0;
	ans = max(ans, abs(l1 - r1));
	ans = max(ans, abs(l2 - r2));
	ans = max(ans, abs(l1 - l2));
	ans = max(ans, abs(r1 - r2));
	ans = max(ans, abs(r1 - l2));
	ans = max(ans, abs(r2 - l1));
	return ans;
}

ll solve(int x) {
	ll l1, r1, l2, r2;
	
	int ind = lower_bound(sum, sum + x, sum[x] / 2) - sum;
	
//	cout << "ind = " << ind << " x = " << x << " sum[x] = " << sum[x] << endl;
	
	int ind2 = lower_bound(sum, sum + n, (sum[n] - sum[x])/ 2 + sum[x]) - sum;
	
//	cout << "ind = " << ind << " x = " << x << endl;
	
//	cout << "---" << l1 << " " << r1 << " " << l2 << " " << r2 << endl;

	ll ans = 1e18;

	ans = min(ans, solve(x - 1, ind, ind2));
	ans = min(ans, solve(x - 1, ind - 1, ind2));
	ans = min(ans, solve(x - 1, ind, ind2 - 1));
	ans = min(ans, solve(x - 1, ind - 1, ind2 - 1));
	ans = min(ans, solve(x, ind, ind2));
	ans = min(ans, solve(x, ind - 1, ind2));
	ans = min(ans, solve(x, ind, ind2 - 1));
	ans = min(ans, solve(x, ind - 1, ind2 - 1));
	return ans;
}

int main() {
	ios::sync_with_stdio(0);
	while(cin >> n){
		sum[0] = 0;
		for(int i = 1; i <= n; i++) cin >> a[i], sum[i] = sum[i - 1] + a[i];
		ll ans = 1e18;
		for(int i = 2; i < n; i++) {
			ans = min(ans, solve(i));
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <cstring>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

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

typedef pair<int, int> P;

bool ps1(const P &forall_a_in_P, const P &forall_b_in_P)
{ //first昇順
    return forall_a_in_P.first < forall_b_in_P.first;
}
bool ps2(const P &forall_a_in_P, const P &forall_b_in_P)
{ //first降順
    return forall_a_in_P.first > forall_b_in_P.first;
}
bool ps3(const P &forall_a_in_P, const P &forall_b_in_P)
{ //second昇順
    return forall_a_in_P.second < forall_b_in_P.second;
}
bool ps4(const P &forall_a_in_P, const P &forall_b_in_P)
{ //second降順
    return forall_a_in_P.second > forall_b_in_P.second;
}
ll GCD(ll x, ll y) {
	return x ? GCD(y % x, x) : y;
}

ll LCM(ll m, ll n)
{
	if ((0 == m) || (0 == n))
		return 0;

	return ((m / GCD(m, n)) * n); // lcm = m * n / GCD(m,n)
}
void solve(){
   int n;
   cin>>n;
   vector<string>s(n);
   map<string,int>cnt;
   rep(i,n){
       cin>>s[i];
       cnt[s[i]]++;
   }
   int ma=0;
   rep(i,n){
       ma=max(ma,cnt[s[i]]);
   }
   map<string,int>used;
   vector<string>ans;
   rep(i,n){
       if(ma==cnt[s[i]]){
           if(!used[s[i]]){
               ans.push_back(s[i]);
               used[s[i]]++;
           }
       }
   }
   sort(all(ans));
   rep(i,ans.size()){
       cout<<ans[i]<<endl;
   }
   

}


int main()
{
    ios::sync_with_stdio(false);
	cin.tie(nullptr);
    solve();
}

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

int main() {
	string S, T;
	cin>>S;
	cin>>T;
	int s = S.size();
	int t = T.size();
	int dp[s+1][t+1];

	for(int i = 0; i <= s; i++){
		for(int j = 0; j <= t; j++){
			if(i==0 || j==0)
				dp[i][j] = 0;
			else{
				if(S[i-1] == T[j-1]){
					dp[i][j] = dp[i-1][j-1] + 1;
				}
				else
					dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
			}
		}
	}
	// cout<<dp[s][t]<<endl;
	stack<char> st;
	int i = s, j = t;
	while(i>0 && j>0){
		if(S[i-1]==T[j-1]){
			st.push(S[i-1]);
			i--;
			j--;
		}
		else{
			if(dp[i-1][j] > dp[i][j-1]){
				i--;
			} else {
				j--;
			}
		}
	}
	while(!st.empty()){
		cout<<st.top();
		st.pop();
	}
	cout<<endl;
}

Measured memory_bytes: 35456