akhauriyash/Code-Regression huggingface dataset:
N = int(input())
sum = 0

if (1 <= N and N <= 10 ** 6):

    for i in range(1,N + 1):
        if ( i % 3 == 0) and ( i % 5 == 0):
        #if i % 15 ==0:
            N = 'Fizz Buzz'
        elif i % 3 == 0:
            N = 'Fizz'
        elif i % 5 == 0:
            N = 'Buzz'
        else:
            sum += i
    print(sum)


Measured memory_bytes: 9128
from itertools import combinations
n=int(input())
a=[input() for i in range(n)]
cnt=[0]*5
for ai in a:
    if ai[0]=='M':
        cnt[0]+=1
    if ai[0]=='A':
        cnt[1]+=1
    if ai[0]=='R':
        cnt[2]+=1
    if ai[0]=='C':
        cnt[3]+=1
    if ai[0]=='H':
        cnt[4]+=1
comb=combinations(cnt, 3)
ans=0
for c in comb:
    ans+=c[0]*c[1]*c[2]
print(ans)

Measured memory_bytes: 9772
// Undone
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
  public static void Main() {
    ReadLine();
    int[] line = ReadIntArray();
    if (line.Max()*2 < line.Sum()) {
      Console.WriteLine("Yes");
    } else {
      Console.WriteLine("No");
    }
  }

  private static string ReadLine() { return Console.ReadLine(); }
  private static int ReadInt() { return int.Parse(Console.ReadLine()); }
  private static double ReadDouble() { return double.Parse(Console.ReadLine()); }
  private static long ReadLong() { return long.Parse(Console.ReadLine()); }
  private static char ReadChar() { return Console.ReadLine()[0]; }
  private static string[] ReadStringArray() { return Console.ReadLine().Split(' '); }
  private static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
  private static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
  private static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
  private static char[] ReadCharArray() { return Console.ReadLine().ToArray(); }
  private static string[] ReadCharStringArray() { return Console.ReadLine().ToCharArray().Select(c => c.ToString()).ToArray(); }
}


Measured memory_bytes: 13396
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadLong();
            for (int i = 1; i <= 9; i++)
            {
                if (N % i == 0 && N / i <= 9)
                {
                    Println("Yes");
                    return;
                }
            }
            Println("No");
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());
        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}



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

using namespace std;

int main()
{
	int n, d;
	vector<vector<int> > x;

	cin >> n >> d;

	x.resize(n);

	for(int i = 0; i < n; ++i)
	{
		x[i] = vector<int>(d);
		for(int j = 0; j < d; ++j)
		{
			cin >> x[i][j];
		}
	}

	// 40 ^ 2 * 10 = 16000
	// 500 ^ 2     = 250000
	
	int cnt = 0;
	for(int i = 0; i < n; ++i)
	{
		for(int j = i + 1; j < n; ++j)
		{
			int distance = 0;
			for(int k = 0; k < d; ++k)
			{
				distance += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			}

			for(int k = 0; k < 500; ++k)
			{
				if(distance == k * k)
				{
					++cnt;
				}
			}
		}
	}

	cout << cnt << endl;
}

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

int main(){
	long long A,B,C,K;
	cin >> A >> B >> C >> K;
	long long ans=0;
	ans+=min(A,K);
	K-=A+B;
	if(K>0)ans-=K;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
int N;
ll A[100000];

int main(){
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> A[i];
	}

	sort(A, A+N);
	int b = A[0];
	for(int i=0; i<N-1; i++){
		if(abs(A[N-1]-2*A[i]) < abs(A[N-1]-2*b)){
			b = A[i];
		}
	}

	cout << A[N-1] << " " << b << endl;

	return 0;
}


Measured memory_bytes: 1024
import sys
from math import gcd
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline

N, *AB = map(int, read().split())
mod = 10 ** 9 + 7

ab = []
zero = 0
for A, B in zip(*[iter(AB)] * 2):
    if A == 0 and B == 0:
        zero += 1
        continue
    if A == 0:
        B = -1
    elif B == 0:
        A = 1
    else:
        g = gcd(A, B)
        A //= g
        B //= g
    if A < 0:
        A, B = -A, -B
    ab.append((A, B))

cnt = Counter(ab)
answer = 1
checked = set()
ok = 0

for (i, j), n in cnt.items():
    if (i, j) in checked:
        continue
    if j < 0:
        c, d = -j, i
    else:
        c, d = j, -i
    if (c, d) in cnt:
        m = cnt[(c, d)]
        answer = (answer * (pow(2, n, mod) + pow(2, m, mod) - 1)) % mod
        checked.add((c, d))
    else:
        ok += n

answer *= pow(2, ok, mod)
answer -= 1
answer += zero
answer %= mod
print(answer)


Measured memory_bytes: 72600
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	N := ReadInt()
	a := ReadInts(3 * N)
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	v := 0
	for i := 0; i < N; i++ {
		v += a[i*2+1]
	}
	fmt.Println(v)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 6820
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
    int d[4][3],k[5]={0,},p=0,n=0;
    for(int t=1;t<=3;t++){
        scanf("%d%d",&d[t][1],&d[t][2]);
    }
    for(int i=1;i<=3;i++){
        p=d[i][1];
        k[p]++;
        p=d[i][2];
        k[p]++;
    }
    for(int o=1;o<=4;o++){
        if(k[o]>=3){
            n=1;
        }
    }
    if(n==1){
        printf("NO");
    }
    else{
        printf("YES");
    }
}

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

const int N=1000;
const int M=100;

int main(){
	while(1){
		int n, m, a;
		int trip[M];
		int ans[M];
		
		scanf(" %d %d", &n, &m);
		if(n==0 && m==0) break;
		
		for(int i=0; i<m; ++i) trip[i]=0;
		
		for(int i=0; i<n; ++i){
			for(int j=0; j<m; ++j){
				scanf(" %d", &a);		
				trip[j]+=a;
			}
		}
	
		for(int i=0; i<m; ++i) ans[i]=-1;
		
		int count=0;
		for(int i=n; i>=0; --i){
			for(int j=0; j<m; ++j){
				if(trip[j]==i){
					ans[count]=j+1;	
					++count;
				}
			}
		}

		for(int i=0; i<m; ++i){
			if(i>0) printf(" ");
			printf("%d", ans[i]);
		}
		printf("\n");
	
	}
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define _GLIBCXX_DEBUG
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
const ll INF = 9223372036854775807;

int main() {
  string x,y;cin >> x >> y;
  cout << y << x << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N, M; cin >> N >> M;
  ll nN = N == 1 ? 1 : N - 2;
  ll nM = M == 1 ? 1 : M - 2;
  auto ans = nN * nM;
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {

	ll M = 100000;

	vector<bool> p(M+1, 1);

	p[1] = 0;

	for (int i = 2; i <= M; i++) {
		if (p[i] == 0) { continue; }
		
		for (int j = 2*i; j <= M; j += i) {
			p[j] = 0;
		}
	}

	vector<ll> num(M + 1, 0);

	repn(i, M) {
		if (i % 2 == 0) { num[i] = num[i - 1]; }
		else if (p[i] == 0 || p[(i + 1) / 2] == 0) { num[i] = num[i - 1]; }
		else { num[i] = num[i - 1] + 1; }
	}

	ll Q;
	cin >> Q;

	repn(i, Q) {
		ll l, r;
		cin >> l >> r;
		cout << num[r] - num[l - 1] << endl;
	}

	system("PAUSE");

	

}


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

constexpr int MAX_N = 256;
using E = array<bool, MAX_N>;

map<string,E> table;
bool error = false;

E add(E a, E b){
    E res;
    res.fill(false);
    for(int i=0;i<MAX_N;i++){
        for(int j=0;j<MAX_N;j++){
            if(a[i]&&b[j]){
                res[(i+j)%MAX_N] = true;
            }
        }
    }
    return res;
}

E sub(E a, E b){
    E res;
    res.fill(false);
    for(int i=0;i<MAX_N;i++){
        for(int j=0;j<MAX_N;j++){
            if(a[i]&&b[j]){
                res[(i-j+MAX_N)%MAX_N] = true;
            }
        }
    }
    return res;
}

E mul(E a, E b){
    E res;
    res.fill(false);
    for(int i=0;i<MAX_N;i++){
        for(int j=0;j<MAX_N;j++){
            if(a[i]&&b[j]){
                res[(i*j)%MAX_N] = true;
            }
        }
    }
    return res;
}

E div(E a, E b){
    if(b[0]) error = true;
    E res;
    res.fill(false);
    for(int i=0;i<MAX_N;i++){
        for(int j=1;j<MAX_N;j++){
            if(a[i]&&b[j]){
                res[(i/j)%MAX_N] = true;
            }
        }
    }
    return res;
}

int solve(){
    int m, n;
    cin >> m;
    for(int i=0;i<m;i++){
        string name;
        int l, u;
        cin >> name >> l >> u;
        E var;
        var.fill(false);
        for(int j=l;j<=u;j++){
            var[j] = true;
        }
        table[name] = var;
    }
    stack<E> s;
    cin >> n;
    for(int i=0;i<n;i++){
        string e;
        cin >> e;
        if(isdigit(e.front())){
            int x = stoi(e);
            E num;
            num.fill(false);
            num[x] = true;
            s.push(num);
        }else if(isalpha(e.front())){
            E var = table[e];
            s.push(var);
        }else{
            E a, b;
            b = s.top(); s.pop();
            a = s.top(); s.pop();
            if(e == "+"){
                s.push(add(a,b));
            }else if(e == "-"){
                s.push(sub(a,b));
            }else if(e == "*"){
                s.push(mul(a,b));
            }else{
                s.push(div(a,b));
            }
        }
    }
    cout << (error ? "error" : "correct") << endl;
    return 0;
}

int main(){
    solve();
    return 0;
}



Measured memory_bytes: 3248
#include<cstdio>
#include<iostream>
#include<algorithm>
#define SIZE 100100

using namespace std;

char s[SIZE];

int main()
{
    scanf("%s",s);
    int i,total1=0;
    int total0=0;
    for(i=0;s[i];i++)
    {
        if((s[i]&1)^(i&1))
            total1++;
        else
            total0++;
    }
    printf("%d\n",min(total0,total1));
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int n,m;cin>>n>>m;
    vvll d = vvll(n);
    ll kake = 1010101;
    rep(i, m){
        ll p, y;
        cin>>p>>y;
        d[p-1].push_back(y*kake+i);
    }
    rep(i, n){
        sort(all(d[i]));
    }
    vll ans(m);
    rep(i, n){
        rep(j, d[i].size()){
            ans[d[i][j]%kake] = (i+1)*1000000ll+(j+1);
        }
    }
    rep(i, m){
        printf("%012ld\n", ans[i]);
    }
    
    return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

//-----------------------------------------------------------------------------

int h,w;
int fld[1000][1000];
priority_queue<PP,vector<PP>,greater<PP> > pq;
int cnt[1000][1000];
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

void bfs(P p) {
	queue<P> q;
	q.push(p);
	bool reach[1000][1000]={};
	while(!q.empty()) {
		P p=q.front();q.pop();
		int x=p.fi,y=p.se;
		REP(i,4) {
			int nx=x+dx[i],ny=y+dy[i];
			if(nx<0||nx>=w||ny<0||ny>=h||reach[ny][nx]||fld[ny][nx]<fld[y][x]) continue;
			reach[ny][nx]=true;
			cnt[ny][nx]++;
			q.push(P(nx,ny));
		}
	}
}

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

	cin>>h>>w;
	REP(i,h) {
		REP(j,w) {
			cin>>fld[i][j];
			pq.push(PP(fld[i][j],P(j,i)));
		}
	}
	while(!pq.empty()) {
		PP p=pq.top();pq.pop();
		if(cnt[p.se.se][p.se.fi]!=0) continue;
		bfs(p.se);
	}
	int ans=0;
	REP(i,h) REP(j,w) if(cnt[i][j]>=2) ans++;
	cout<<ans<<endl;


	return 0;
}



Measured memory_bytes: 23440
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int a=n*2,b=n*4,c=m%2;
	if(m>=a&&m<=b&&!c)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl; 
 } 


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
      int Z = S - (X + Y);
      if (Z < 0 || Z > K) continue;
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc106_c.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string S;
  int K;
  cin >> S >> K;

  int ans = 1;
  int N = min(K, (int)S.size());
  rep(i, N) {
    int j = S[i] - '0';
    if (j != 1) {
      ans = j;
      break;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3660
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

n,m = map(int, input().split())
G = [[] for i in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    G[a].append(b)

from collections import deque

inf = float("inf")
ans = inf
ss = []
def bfs(i):
    global ans, ss
    dist = [inf]*n
    prev = [None]*n
    que = deque()
    # 一個先から始める
    for to in G[i]:
        que.append(to)
        dist[to] = 1
        prev[to] = i
    while que:
        cur = que.popleft()
        if cur == i:
            break
        for to in G[cur]:
            if dist[to] != inf:
                continue
            dist[to] = dist[cur]+1
            prev[to] = cur
            que.append(to)

    if dist[i] < ans:
        ans = dist[i]
        ss = [i]
        for _ in range(ans-1):
            ss.append(prev[ss[-1]])
        #print(ss)

for i in range(n):
    bfs(i)

if ans == inf:
    print(-1)
else:
    print(0)
    exit()
    print(ans)
    #print(ss)
    for i in reversed(ss):
        print(i+1)

Measured memory_bytes: 44508
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//みなさん天才すぎないすか

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline ll getint() {
	ll A = 0;
	if (ci - cn + 24 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}


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


	int N = getint();
	ll kazu[20] = {};
	const int mod = 1e9 + 7;
	const ll m = 1 + (1 << 20) + (1ll << 40);
	//なんではやいのかな？ブロック化的な奴なの？
	rep(i, N / 3) {
		ll a = getint();
		ll b = getint();
		ll c = getint();
		rep(j, 20) {
			kazu[j] += a >> j & m;
			kazu[j] += b >> j & m;
			kazu[j] += c >> j & m;
		}
	}
	rep(i, N % 3) {
		ll a = getint();
		rep(j, 20) kazu[j] += a >> j & m;
	}

	ll kotae = 0;
	const ll m2 = (1 << 20) - 1;
	rep(j, 20) {
		ll tmp = (1ll << j) % mod;
		ll tmpk = (kazu[j] & m2);
		tmpk = tmpk * (N - tmpk) % mod;
		kotae += tmp * tmpk % mod;

		tmp = (1ll << (j + 20)) % mod;
		tmpk = (kazu[j] >> 20 & m2);
		tmpk = tmpk * (N - tmpk) % mod;
		kotae += tmp * tmpk % mod;

		tmp = (1ll << (j + 40)) % mod;
		tmpk = (kazu[j] >> 40 & m2);
		tmpk = tmpk * (N - tmpk) % mod;
		kotae += tmp * tmpk % mod;
	}

	printf("%lld", kotae% mod);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int i = 0, j = n - 1;
    int ans = 0;
    while (i < j) {
        while (s[i] == 'R' && i < j) {
            i++;
        }
        while (s[j] == 'W' && i < j) {
            j--;
        }
        if (i < j) {
            ans++;
            i++, j--;
        }
    }
    cout << ans << '\n';
    return 0;
}

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

int main(){
	string w;
	cin>>w;
	int cha[26]={};
	rep(i,w.size()){
		cha[w[i]-'a']++;
	}
	rep(i,26){
		if(cha[i]%2!=0){
			puts("No");
			return 0;
			}
	}
	puts("Yes");
}


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

//　バケット法
/*int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) cin >> vec.at(i);

    vector<int> vec2(110);
    for (int i=0; i<n; i++)
    {
        vec2.at(vec.at(i))++;
    }

    int ans = 0;
    for (int i =1; i<= 100; i++) {
        if(vec2.at(i)) {
            ans++;
        }
    }
    
    cout << ans << endl;
}
*/

// std::setを用いる
int main() {
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) cin >> vec.at(i);

    set<int> values;
    for(int i = 0; i<n; i++)
    {
        values.insert(vec.at(i));
    }
    cout << values.size() << endl;
}

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

using namespace std;
typedef long long ll;

int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans=(n/(a+b))*a;
	ll r=n%(a+b);
	if(r>=a)  ans+=a;
	else ans+=r;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-11;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    string s, t;
    int m;
    cin >> m;
    REP(k,m){
        cin >> s >> t;
        int n=s.size(), l=-1;
        REP(i,n){
            if(s[i]!=t[i]){
                l = i;
                break;
            }
        }
        if(l<0){
            cout << 0 << endl;
        }
        else{
            int ans = 0;
            REPR(r,n-1) {
                if(s[r]=='1'){
                    ans += abs(r-l);
                    break;
                }
            }
            REPR(r,n-1){
                if(t[r]=='1'){
                    ans += abs(r-l);
                    break;
                }
            }
            cout << ans << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3212
/*
	*#*#*#* Author GaryMr *#*#*#*
########################################################################
	是否可以简化问题：
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	匹配括号 左减右>=0
	多组数据清空？
	dp优化用g？
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define IT iterator
#define FIR first
#define SEC second
using namespace std;
const int MAX=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	int a,b,t;
	cin>>a>>b>>t;
	int TOT=t/a;
	cout<<TOT*b;
	return 0;
}

Measured memory_bytes: 256
input_a = int(input())
list_b = list(map(int, input().split()))
count = 0
breakcount = 0
while breakcount == 0:   
    for i in range(input_a):
        if list_b[i] % 2 == 0:
            list_b[i] /= 2
        else:
            breakcount = 1
            break
    count += 1
print(count - 1)

Measured memory_bytes: 3060
#include<iostream>
#include<set>
#include<string.h>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int n, d; 
signed main(){
   while (~scanf("%d%d", &n, &d))
		printf("%d\n", (n + 2 * d) / (2 * d + 1)); 
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cerr << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

ll f(ll n) {
    if(n == 0 || n == 1) return 1;
    return n*f(n-1);
}

void smoothing(vector<ll> &C) {
    C[0] = 1;
    for(int i = 1;i < C.size();i++) {
        if(C[i-1] + 1 < C[i]) {
            C[i] = C[i-1] + 2;
        }
    }
}

int main() {

    //freopen("input07.txt","r",stdin);
    //freopen("output_file_name.txt","w",stdout);
    ll n;
    cin>>n;
    vector<ll> B(n);
    vector<ll> K(n);
    vector<ll> A(n);
    rep(i, n) cin>>B[i];

    // play with B
    smoothing(B);

    // fill K
    K[0] = 0;
    ll toremove = 0;
    ll v = 3;

    for(int i = 1;i < B.size();i++) {
        if(B[i] < v) {toremove++;}
        else {v += 2;}
        K[i] = toremove;
    }

    A[0] = 1;
    for(int i = 1;i < A.size();i++) {
        A[i] = (A[i-1]*(i-K[i-1]+1))%mod;
    }

    cout<<A[n-1]<<endl;

    return 0;
}


Measured memory_bytes: 2560
import math

D, G = map(int, input().split())
p = [0] * D
c = [0] * D
for i in range(D):
  p[i], c[i] = map(int, input().split())

ans = 1e9
for mask in range(1 << D):
  s, num, rest_max = 0, 0, -1
  for i in range(D):
    if mask >> i & 1:
      s += 100 * (i+1) * p[i] + c[i]
      num += p[i] # 問題数
    else:
      rest_max = i # 完全に解いた問題以外のうち最大点数の問題

  if s < G: # Gに満たない
    s1 = 100 * (rest_max + 1)
    need = math.ceil((G - s) / s1)     
    if need >= p[rest_max]:
      continue # 完全に解く＋中途半端に解くがG点に満たない
    num += need
  
  ans = min(ans, num)
    
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#define SIZE 102
using namespace std;


char mass[SIZE][SIZE];
int  d[SIZE][SIZE];
int  dx[4]={1,0,-1,0};
int  dy[4]={0,1,0,-1};
int  sx,sy;
int  h,w,cnt=0;
char mark;

int dfs(int x,int y);

int main(){

  int i,j;

  while(1){

    cin>>h>>w;

    if(h==0 && w==0)break;

    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	cin>>mass[i][j];
      }
    }

    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(mass[i][j]!='.'){
	  mark=mass[i][j];
	  cnt++;
	  dfs(j,i);
	}
      }
    }

    cout<<cnt<<endl;
    cnt=0;

  }

  return 0;

}

int dfs(int x,int y){

  int i;
  mass[y][x]='.';

  for(i=0;i<4;i++){

    int nx=x+dx[i];
    int ny=y+dy[i];

    if(nx>=0 && nx<w && ny>=0 && ny<h && mass[ny][nx]==mark){
      dfs(nx,ny);
    }
  }

  return 0;
}

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

int main()
{
    //(A+B)/2 = C
    //A+B = 2C
    //A = 2C-b

    int A;
    int B;
    cin >> A;
    cin >> B;
    cout << 2 * B - A << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  
  if (a < 13) {
    if (a < 6) {
      cout << "0" << endl;
    } else {
      cout << b / 2 << endl;
    }
  } else {
    cout << b << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int a = sc.nextInt();
      int b = sc.nextInt();
      String s = String.valueOf(b);

      a = a*10*(int)Math.pow(10,s.length()-1);

      for(int i = 0;i*i<=a+b;i++){
        if(a+b==i*i){
            System.out.println("Yes");
            System.exit(0);
        }
      }
      System.out.println("No");
  }
}

Measured memory_bytes: 23252
S = input()
l = len(S)
ans_list = [0]  * (l + 1)
S = ">" + S + "<"

for i in range(0, l  + 1):
    if S[i] == ">":
        ans_list[i] = 0
    else:
        ans_list[i] = ans_list[i - 1] + 1
ans_list2 =  [0]  * (l + 1)

for i in range(l + 1,0,-1 ):
    if S[i] == "<":
        ans_list2[i - 1] =max( 0 ,ans_list2[i - 1])
    else:
        ans_list2[i - 1] = max( ans_list2[i - 1], ans_list2[i] + 1)

# print(ans_list)
# print(ans_list2)
final_ans = []
for a,b in zip(ans_list,ans_list2):
    final_ans.append(max(a,b))
# print(final_ans)
print(sum(final_ans))




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

using namespace std;

#define f first
#define s second
#define pub push_back
#define pob pop_back

typedef vector<int> vi;
typedef vector<vi> graf;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> wgraf;

typedef vector<double> vd;
typedef pair<double,double> dd;
typedef vector<dd> vdd;

typedef uint64_t ui64;

int main(){

	int n, k, h;

	cin >> n >> k;
	int cont = 0;

	for(int i = 0; i < n; i++){

		cin >> h;

		if(h >= k)
			cont ++;

	}

	cout << cont << endl;

	return 0;
}


Measured memory_bytes: 256
function F()
  S = parse(BigInt,readline())
  
  if S<3
    ans = 0
  elseif S<6
    ans = 1
  else
   N = Int(floor(S/3))
   c = 1
   for i= 2:N
      s = BigInt(S-3*i)
      c += binomial(s+i-1,s)
    end
    ans = c
  end 
    
  ans = mod(ans,10^9+7)
  println(Int(ans))

end

F()

Measured memory_bytes: 172016
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
typedef long long ll;
ll dp[1001][1001];
int main()
{
    ll n,i,j,w;
    cin>>n>>w;
    string a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    if(a[0][0]=='.')
    dp[0][0]=1;
    for(i=0;i<n;i++)
    {
        for(j=0;j<w;j++)
        {
                if(j-1>=0&&a[i][j]!='#')
                dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
                if(i-1>=0&&a[i][j]!='#')
                dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
        }
    }
    cout<<dp[n-1][w-1];
}

Measured memory_bytes: 13356
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;
typedef pair<int, double> P;
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = { 0, 1, 0, -1 };



int main() {

	int n;
	cin >> n;
	int l;
	cin >> l;
	vector<string> s(n);
	rep(i, n) cin >> s.at(i);
	string ans;
	sort(s.begin(), s.end());
	rep(i, n) {
		ans += s.at(i);
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l, r) uniform_int_distribution<int>(l, r)(rng)
 
#define LL long long int
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int N = 3e5 + 5;
const int oo = 1e9 + 5;
const LL ooll = (LL)1e18 + 5;
const int MOD = 1e9 + 7;
const int M = 20005;
 
clock_t start = clock();

LL v[105];
void solve() {
	int n;
	cin >> n;
	for (int i=0;i<n;++i) cin >> v[i];
	LL have = 1000;
	multiset<pair<LL,LL>> stock;
	for (int i=0;i<n;++i) {
		while(!stock.empty() && stock.begin()->first < v[i]) {
			stock.insert({v[i], stock.begin()->second});
			stock.erase(stock.begin());
		}
		while(!stock.empty()) {
			auto it = stock.end();
			--it;
			if (it->first > v[i]) {
				have += it->first * it->second;
				stock.erase(it);
			} else {
				break;
			}
		}
		LL go = have / v[i];
		stock.insert({v[i], go});
		have -= go * v[i];
	}
	for (auto it : stock) have += it.first * it.second;
	cout << have << '\n';
}
 
int main() {
	FASTIO;
	int T = 1;
	// pre();
	// cin >> T;
	while(T--) {
		solve();
	}
	// cout << fixed << setprecision(10);
	// cout << (clock() - start) / ((double)(CLOCKS_PER_SEC)) << " s\n";
	return 0;
} 

Measured memory_bytes: 3548
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

class program
{
	static void Main()
	{
		long log=0;
		int test = int.Parse(Console.ReadLine());
		var que = new Queue<long>();
		for(int i=1;i<10;i++){
			que.Enqueue(i);
		}
		for(int x=0;x<test;x++){
			log = que.Dequeue();
			if(log%10!=0){
				que.Enqueue(10*log+(log%10)-1);
			}
			que.Enqueue(10*log+(log%10));
			if(log%10!=9){
				que.Enqueue(10*log+(log%10)+1);
			}
		}
		Console.WriteLine(log);
	}
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll a;
  string s;
  IN(a);
  IN(s);
  if(a>=3200){
    OUT(s);
  }else{
    OUT("red");
  }

  return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string a;
    cin >> a;
    if(a[2] == a[3] && a[4] == a[5])
        cout << "Yes\n" ;
    else
        cout << "No\n";
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[1005];
int cnt[1005];
int main()
{
  scanf("%s",s+1);
  int n=strlen(s+1);
  for(int i=1;i<=n;i++) cnt[s[i]-'A']++;
  if((cnt['S'-'A']&&!cnt['N'-'A'])||(cnt['N'-'A']&&!cnt['S'-'A'])||
     (cnt['W'-'A']&&!cnt['E'-'A'])||(cnt['E'-'A']&&!cnt['W'-'A']))
    puts("No");
  else puts("Yes");
  return 0;
}

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

int main () {
  vector<int> line(3) ;
  for ( int i = 0 ; i < 3 ; i++ ) {
    cin >> line.at(i) ;
  }
  sort(line.begin() , line.end() ) ;
  
  cout << line.at(2) - line.at(0) << endl ;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

l = []
for i in range(M):
    P, Y = map(int, input().split())
    row = [i, P, Y]
    l.append(row)

l.sort(key=lambda x: (x[1], x[2]))

new_l = []
P = 0
cnt = 1
for num, row in enumerate(l):
    if num != 0:
        if P != row[1]:
            cnt = 1
            
    P = row[1]
    p_name = '{0:06d}'.format(P)
    c_name = '{0:06d}'.format(cnt)
    name = p_name + c_name
    new_l.append([row[0], name])
    cnt += 1

new_l.sort(key=lambda x: x[0])


for n in new_l:
    print(n[1])

Measured memory_bytes: 41400
l, r=len, range
N= int(input())
c1= input().split()
c2=c1[:]
for i in r(l(c1)):
    for j in r(i+1, l(c1))[::-1]:
        if c1[j][1]< c1[j-1][1]:
            c1[j], c1[j-1]= c1[j-1], c1[j]

    m= i
    for j in r(i, l(c2)):
        if c2[j][1] < c2[m][1]: m= j
    c2[i], c2[m]= c2[m], c2[i]
print(*c1)
print("Stable")
print(*c2)
print("Stable" if c1==c2 else "Not stable")

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

int n, k, c;
string s;
vector<int> l, r;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n >> k >> c;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < n && cnt < k; i++)
        if (s[i] == 'o' && (l.empty() || l.back() + c < i)){
            l.push_back(i);
            cnt++;
        }
    
    cnt = 0;
    for (int i = n - 1; i >= 0 && cnt < k; i--)
        if (s[i] == 'o' && (r.empty() || r.back() - c > i)){
            r.push_back(i);
            cnt++;
        }

    for (int i = 0; i < k; i++)
        if (l[i] == r[k - i - 1])
            cout << l[i] + 1 << "\n";
    
    return 0;
}



Measured memory_bytes: 3468
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    ll n;
    cin >> n;
    vector<ll> f(10001);
    for (int x = 1; x < 100; ++x)
    {
        for (int y = 1; y < 100; ++y)
        {
            for (int z = 1; z < 100; ++z)
            {
                ll k = x * x + y * y + z * z + x * y + y * z + z * x;
                if (k < f.size())
                    ++f[k];
            }
        }
    }
    rep(i, n)
    {
        cout << f[i + 1] << endl;
    }
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    string s;
    cin>>s;
    int i,f=0;
    set<char> p;
    for (i=0;i<s.size();i++)
        p.insert(s[i]);
    if (p.size()==s.size())
        cout<<"yes\n";
    else
        cout<<"no\n";
}

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

int main() {
  int n;
  cin>>n;
  vector<pair<int,int>>sigoto(n);
  for(int i=0;i<n;i++){
    cin>>sigoto[i].second>>sigoto[i].first;
  }
  sort(sigoto.begin(),sigoto.end());
  long long sum=0;
  for(int i=0;i<n;i++){
    sum+=sigoto[i].second;
    if(sigoto[i].first <sum){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

struct UnionFind {
    vector<int> d; // 根なら (-サイズ), そうでないなら親の番号
    UnionFind(int N) : d(N, -1){} // 全て根として初期化

    int root(int x) { // データ x が属する木の根を再帰で得る
        if (d[x] < 0) return x;
        return d[x] = root(d[x]);
    }

    bool unite(int x, int y) { // x と y の木を併合. 併合した場合 true
        x = root(x); y = root(y); // x <- x の根, y <- y の根
        if (x == y) return false; 
        // merge technique（データ構造をマージするテク. 小を大にくっつける）
        if (d[x] > d[y]) swap(x, y);    // x の木のサイズ > y の木のサイズにする. d[x], d[y] < 0 に注意.
        d[x] += d[y];   // x の木のサイズ += y の木のサイズ
        d[y] = x;   // y の親は x
        return true;
    }

    bool same(int x, int y) { // 2つのデータ x, y が属する木が同じなら true
        return root(x) == root(y);
    }
    
    int size(int x) { // 素集合のサイズ
        return -d[root(x)]; // d[root(x)] < 0 に注意.
    }
};

void Main(){
    ll n, m; cin >> n >> m;
    // (i, 0) -> i
    // (i, 1) -> n + i
    UnionFind UF(2 * n); 

    rep(i, m){
        int a, b; cin >> a >> b; a--; b--;
        UF.unite(a, n + b);
        UF.unite(b, n + a);
    }

    bool ok = true;
    ll cnt = 0;
    rep(i, n){
        if(UF.same(i, n + i)) ok = false;
        if(UF.same(i, 0)) cnt++;
    }
    
    ll ans = 0;
    if(!ok) ans = n * (n-1) / 2 - m;
    else ans = cnt * (n - cnt) - m;
    cout << ans << endl;    
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 3948
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int main() {
    string s;
    cin >> s;
    int c = 0;
    if(s[0] == '0') {
        for (size_t i = 0; i < s.size(); i++)
        {
            if (i % 2 == 0 && s[i] != '0' || i % 2 == 1 && s[i] != '1')
            {
                c++;
            }
        }
    } else {
        for (size_t i = 0; i < s.size(); i++)
        {
            if (i % 2 == 0 && s[i] != '1' || i % 2 == 1 && s[i] != '0')
            {
                c++;
            }
        }
    }
    cout << c << endl;
}


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

using namespace std;

int main() {
    std::ios::sync_with_stdio(false);

    string s;
    std::cin >> s;
    int ans = 0;
    const int sz = s.size() - 1;
    if (s[sz] == '3') {
        std::cout << "bon\n";
    } else if (s[sz] == '0' || s[sz] == '1' || s[sz] == '6' || s[sz] == '8') {
        std::cout << "pon\n";
    } else{
        std::cout << "hon\n";
    }
    

    return 0;
}


Measured memory_bytes: 3608
// Last Change: 04/19/2020 21:07:05.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll N;
  cin >> N;
  vector<ll> res(N, 0);
  for (ll i = 1; i < N; ++i) {
    ll ipt;
    cin >> ipt;
    ++res[--ipt];
  }
  for (ll i = 0; i < N; ++i) {
    cout << res[i];
    if (i != N - 1) {
      cout << " ";
    }
  }
  cout << endl;
}


Measured memory_bytes: 4372
#include <bits/stdc++.h>
#define full(c) c.begin(), c.end()
#define vector2d(name, type, h, w, init) vector<vector<type>> name(h, vector<type>(w, init))
typedef signed long long int ll;
typedef unsigned long long int ull;
const int PRIME=1000000007;
using namespace std;

int main(){
  int n,k,d;
  cin>>n>>k;
  n--;
  d=k;
  while(n--){
    d*=(k-1);
  }
  cout<<d<<endl;
  return 0;
}

Measured memory_bytes: 256