akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
static inline int partition(std::vector<int>& a, int p, int r) {
  int x = a[r];
  int i = p - 1;
  for (int j = p; j < r; ++j) {
    if (a[j] <= x) {
      ++i;
      std::swap(a[i], a[j]);
    }
  }
  ++i;
  std::swap(a[i], a[r]);
  return i;
}
static inline void print(const std::vector<int>& a, size_t p) {
  for (size_t i = 0; i < a.size(); ++i) {
    bool b = i == p;
    std::cout << (i == 0 ? "" : " ")
      << (b ? "[" : "")
      << a[i]
      << (b ? "]" : "");
  }
  std::cout << std::endl;
}
int main(void) {
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
  }
  int p = partition(a, 0, n - 1);
  print(a, p);
}



Measured memory_bytes: 3108
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    S = input()
    T = input()
    N = len(S)
    answer = 0
    for i in range(N):
        if S[i] != T[i]:
            answer += 1
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9484
N = int(input())
T,A = map(int,input().split())
Hls = list(map(int,input().split()))
mabs = 10**5+1
for i in range(N):
    if abs(A-(T-Hls[i]*0.006)) <= mabs:
        mabs = abs(A-(T-Hls[i]*0.006))
        ans = i
    else:
        pass
print(ans+1)


Measured memory_bytes: 9024
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
sw = [input() for _ in range(H)]

white = 0
for i in range(H):
	white += sw[i].count(".")
# print(white)

count = [[None]*W for _ in range(H)]
q = deque([])

dy = [1, 0, -1, 0]
dx = [0, -1, 0, 1]
def BFS():
	i, j = q.popleft()
	
	for x, y in zip(dx, dy):
		ny = i + y
		nx = j + x
		if 0 <= ny <= H-1 and 0 <= nx <= W-1 and sw[ny][nx] != '#' and count[ny][nx] == None:
			count[ny][nx] = count[i][j] + 1
			q.append((ny, nx))

	if len(q) != 0:
		BFS()


q.append((0, 0))
count[0][0] = 0

BFS()
# for i in count:
# 	print(i)
if count[H-1][W-1]:
	print(white-(count[H-1][W-1]+1))
else:
	print(-1)


Measured memory_bytes: 7124
#include <bits/stdc++.h>
using namespace std;
char s[100005];
int ans[100005];
int main() {
    int n;
    scanf("%d%s", &n, s);
    for (ans[0] = 0; ans[0] < 2; ++ ans[0]) {
        for (ans[1] = 0; ans[1] < 2; ++ ans[1]) {
            for (int i = 2; i < n; ++ i)
                ans[i] = ans[i - 1] ^ ans[i - 2] ^ (s[i - 1] == 'x');
            if (ans[0] ^ ans[n - 2] ^ ans[n - 1] ^ (s[n - 1] == 'x')) continue;
            if (ans[1] ^ ans[n - 1] ^ ans[0] ^ (s[0] == 'x')) continue;
            for (int i = 0; i < n; ++ i) putchar("SW"[ans[i]]);
            puts("");
            return 0;
        }
    }
    puts("-1");
    return 0;
}

Measured memory_bytes: 768
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] ar = br.readLine().split(" ");
        int row = Integer.parseInt(ar[0]);
        int col = Integer.parseInt(ar[1]);
        int[][] a = new int[row][col];
        int[] b = new int[col];
        for(int i = 0; i < a.length; i++){
            ar = br.readLine().split(" ");
            for(int n = 0; n < a[i].length; n++){
                a[i][n] = Integer.parseInt(ar[n]);
            }
        }
        for(int i = 0; i < b.length; i++){
            b[i] = Integer.parseInt(br.readLine());
        }
        for(int i = 0; i < a.length; i++){
            int ans = 0;
            for(int n = 0; n < a[i].length; n++){
                ans += a[i][n] * b[n];
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 27476
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>

#define VLIST_MIN 10
typedef uint64_t vlist_element_type;

typedef struct {
    int size, asize;
    vlist_element_type *a;
} vlist;

vlist *vlist_init()
{
    vlist *vl = malloc(sizeof(vlist));
    vl->size = 0;
    vl->asize = VLIST_MIN;
    vl->a = malloc(sizeof(vlist_element_type) * vl->asize);
    return vl;
}

void vlist_add(vlist *vl, vlist_element_type x)
{
    if(vl->size == vl->asize){
        vl->asize *= 2;
        vl->a = realloc(vl->a, sizeof(vlist_element_type) * vl->asize);
    }
    vl->a[vl->size] = x;
    vl->size++;
}

void vlist_term(vlist *vl)
{
    free(vl->a);
    free(vl);
}

void update_counter_r(int p, int c, int N, vlist **vs, uint64_t *counter_query, uint64_t *counter)
{
    if(c==0){
        counter[c] = counter_query[c];
    } else {
        counter[c] = counter_query[c] + counter[p];
    }
    for(int vi=0; vi<vs[c]->size; vi++){
        if(vs[c]->a[vi] != p){
            update_counter_r(c, vs[c]->a[vi], N, vs, counter_query, counter);
        } 
    }
}

int main()
{
    int N, Q;
    scanf("%d%d\n", &N, &Q);

    vlist **vs = malloc(sizeof(vlist*) * N);
    for(int ni=0; ni<N; ni++){
        vs[ni] = vlist_init();
    }

    for(int ni=0; ni<N-1; ni++){
        int a, b;
        scanf("%d%d", &a, &b);
        vlist_add(vs[a-1], b-1);
        vlist_add(vs[b-1], a-1);
    }

    uint64_t *counter_query = malloc(sizeof(uint64_t) * N);
    for(int ni=0; ni<N; ni++){
        counter_query[ni] = 0;
    }
    for(int qi=0; qi<Q; qi++){
        int p, x;
        scanf("%d%d", &p, &x);
        counter_query[p-1] += x;
    }

    uint64_t *counter = malloc(sizeof(uint64_t) * N);
    update_counter_r(-1, 0, N, vs, counter_query, counter);

    for(int ni=0; ni<N; ni++){
        printf("%"PRIu64" ", counter[ni]);
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 44544
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#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

char S[1300020];
char S2[200000];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	fread(S, 1, 1300020, stdin);

	int saidai = strlen(S);
	int L = -1;
	int R = min(int(strlen(S)) - 2, 99999);
	while (L + 1 < R) {
		int H = (L + R) / 2;
		if (S[H] >= 'a' && S[H + 1] >= 'a') L = H;
		else R = H;
	}
	int N = R + 1;
	char* ci = S + N + 1;
	char ct;
	int Q = 0;
	while ((ct = *ci++) >= '0') Q = Q * 10 + ct - '0';

	int nagasa = saidai - (ci - S) + 1;
	nagasa -= Q * 2;
	int kazu = nagasa / 4;
	bool dotti = (Q - kazu) % 2;

	ci += 4;
	
	if (dotti) {
		char* smae = S2, * sato = S2 + kazu;
		bool gyaku = 0;
		rep(i, Q) {
			char c = *ci;
			if (c < 'a') {
				ci += 2;
				gyaku = !gyaku;
			}
			else {
				bool f = *(ci - 2) - '1';
				if (f ^ gyaku)* --sato = c;
				else *smae++ = c;
				ci += 6;
			}
		}
		reverse(S, S + N);
		fwrite(sato, 1, kazu - (sato - S2), stdout);
		fwrite(S, 1, N, stdout);
		fwrite(S2, 1, smae - S2, stdout);
	}
	else {
		char* smae = S2 + kazu, * sato = S2;
		bool gyaku = 0;
		rep(i, Q) {
			char c = *ci;
			if (c < 'a') {
				ci += 2;
				gyaku = !gyaku;
			}
			else {
				bool f = *(ci - 2) - '1';
				if (f ^ gyaku)* sato++ = c;
				else *--smae = c;
				ci += 6;
			}
		}
		fwrite(smae, 1, kazu - (smae - S2), stdout);
		fwrite(S, 1, N, stdout);
		fwrite(S2, 1, sato - S2, stdout);
	}


	Would you please return 0;
}

Measured memory_bytes: 1920
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int W = sc.nextInt();
   int H = sc.nextInt();
   int x = sc.nextInt();
   int y = sc.nextInt();
   double ans =0.0;
	int ans2 = 0;
   ans = (double)W*(double)H/2;
   if(2*x == W && 2*y == H) ans2 =1;
     System.out.println(ans+ " " + ans2);
 }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=25005,K=405,mod=1e9+7;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
int n,k,m;
int a[N];
int dp[N][K],s[N][K];
int vis[K];
int Fac[N],Inv[N];
void prework(){
	int n=N-1;
	Fac[0]=1;
	For(i,1,n)
		Fac[i]=(LL)Fac[i-1]*i%mod;
	Inv[n]=Pow(Fac[n],mod-2);
	Fod(i,n,1)
		Inv[i-1]=(LL)Inv[i]*i%mod;
}
int C(int n,int m){
	if (m<0||m>n)
		return 0;
	return (LL)Fac[n]*Inv[m]%mod*Inv[n-m]%mod;
}
int check(){
	static int las[N];
	if (m<k)
		return 0;
	int s=0;
	For(i,1,m){
		s=max(s,las[a[i]]);
		las[a[i]]=i;
		if (i-s>=k)
			return 1;
	}
	return 0;
}
int main(){
	prework();
	n=read(),k=read(),m=read();
	For(i,1,m)
		a[i]=read();
	For(i,1,k-1)
		dp[0][i]=1,s[0][i]=i;
	For(i,1,n)
		For(j,1,k-1){
			dp[i][j]=((LL)dp[i-1][j+1]*(k-j)+s[i-1][j])%mod;
			s[i][j]=Add(s[i][j-1]+dp[i][j]);
		}
	if (check()){
		outtag(1);
		int ans=(LL)(n-m+1)*Pow(k,n-m)%mod;
		cout<<ans<<endl;
		return 0;
	}
	clr(vis);
	int pR=m;
	while (pR>0&&!vis[a[pR]])
		vis[a[pR--]]=1;
	clr(vis);
	int pL=1;
	while (pL<m+1&&!vis[a[pL]])
		vis[a[pL++]]=1;
	int ans=0;
	if (!pR){
		For(i,1,n-m+1){
			int now=Pow(k,n-m);
			if (i+m-1<k)
				Del(now,(LL)C(k-m,i-1)*Fac[i-1]%mod
					*dp[n-(i+m-1)][i+m-1]%mod);
			For(j,1,min(i-1,k-m)){
				int tmp=(LL)C(k-m,j-1)*Fac[j-1]%mod;
				tmp=(LL)tmp*dp[n-(i+m-1)][m+j-1]%mod;
				tmp=(LL)tmp*s[i-j-1][m+j-1]%mod;
				Del(now,tmp);
			}
			Add(ans,now);
		}
	}
	else {
		For(i,1,n-m+1){
			Add(ans,Pow(k,n-m));
			Del(ans,(LL)dp[i-1][pL-1]*dp[n-(i+m-1)][m-pR]%mod);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 79616
N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()

if N%2:
    ma = A[N//2]
    mb = B[N//2]
    print(max(0, mb - ma + 1))
else:
    ma = A[N//2] + A[N//2-1]
    mb = B[N//2] + B[N//2-1]
    print(max(0, mb - ma + 1))

Measured memory_bytes: 25416
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
//const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=305;
ll n,m,mod,DP[M][M],dp[M][M];

int main(){
	cin>>n>>m>>mod;
	DP[0][0]=1;
	for(int i=1;i<M;i++) for(int j=0;j<M;j++){
		ll t=1;
		for(int k=0;k<=j;k++){
			(DP[i][j]+=DP[i-1][j-k]*t)%=mod;
			(t*=i)%=mod;
		}
	}
	dp[0][0]=1;
	for(int i=1;i<M;i++) for(int j=0;j<M-1;j++){
		for(int k=0;k<M;k++) if(j+k<M){
			(dp[i][j+k]+=dp[i-1][j]*DP[j+1][k])%=mod;
		}
	}
	cout<<dp[m][n]<<endl;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);
	int a = sca.nextInt();
	int b = sca.nextInt();
	long c = (long)a*(long)b;
	int index;
	if(a > b) {
		index = b;
	}
	else {
		index = a;
	}
	for(int i = index; i >= 1; i--) {
		if(a % i == 0 && b % i == 0) {
			System.out.println(c/i);
			break;
		}
	}

	sca.close();
	}
}

Measured memory_bytes: 21972
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int a[1000007],c[1000007];
char s[1000007];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    cin>>s+1;
    --n;
    for(int i=1;i<=n;++i)
        a[i]=abs(s[i]-s[i+1]);
    int flag=0;
    for(int i=1;i<=n;++i)
        if(a[i]==1)
            flag=1;
    if(!flag)
        for(int i=1;i<=n;++i)
            a[i]>>=1;
    for(int i=1;i<=n;++i){
        int x=i;
        while(!(x&1))
            ++c[i],x>>=1;
        c[i]+=c[i-1];
    }
    int ans=0;
    for(int i=1;i<=n;++i)
        ans^=c[n-1]-c[i-1]-c[n-i]?0:(a[i]&1);
    if(!flag)
        ans<<=1;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 9088
<?php
  $n = trim(fgets(STDIN));

  dfs("a", $n, 1);

  function dfs($s, $end, $index){
    $x='abcdefghijklmnopqrstuvwxyz';
    if(strlen($s) >= $end){
      echo $s.PHP_EOL;
      return;
    }else{
      for($i=1;$i<=$index+1;$i++){
        $m = max($i, $index);
        dfs($s.$x[$i-1], $end, $m);
        if(strlen($s)==0){
          break;
        }
      }
//      echo "--loop end--".PHP_EOL;
    }
  }

Measured memory_bytes: 5880
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int n,m,x,y;
    cin>>n>>m;
    vector<pair<int,int>> list(n);
    rep(i,n){
        cin>>x>>y;
        list[i]=make_pair(x,y);
    }
    sort(all(list));
    long long int ans=0;
    for(i=0;m>=0;i++){
        if(list[i].second>=m){
            ans+=(long long int)m*list[i].first;
            break;
        }else{
            ans+=(long long int)list[i].first*list[i].second;
            m-=list[i].second;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

int main(void) {
    long double A, B, H, M;
    cin >> A >> B >> H >> M;
    printf("%.15Lf\n", sqrt(A*A + B*B - 2.0*A*B*cos(abs(H*2.0*M_PI/12.0 - M*2.0*M_PI/60.0 + M*2.0*M_PI/720.0))));
    return 0;
}


Measured memory_bytes: 4148
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		final long M = 1_000_000_007;

		long[][] c = new long[n + 2][n + 2];
		c[0][0] = 1;

		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= i; j++) {
				c[i + 1][j] = (c[i + 1][j] + c[i][j]) % M;
				c[i + 1][j + 1] = (c[i + 1][j + 1] + c[i][j]) % M;
			}
		}

		for (int i = 1; i <= k; i++) {
			System.out.println((c[n - k + 1][i] * c[k - 1][i - 1]) % M);
		}
	}
}


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

using namespace std;

using Int = long long;
using P = pair<int, int>;

const long long MOD = 1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-9;


int main() {
  int N;
  cin >> N;
  map<int, int> m;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    m[a]++;
  }
  int res = 0;
  for (auto itr = m.begin(); itr != m.end(); ++itr) {
    if (itr->second % 2 == 1) res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 4864
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
//添字ヒープを使うための関数達!
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMAX）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]>N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int n,m;
int main(){
  int i,s,a,b,c[100010]={};
  int p[100010]={};
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    hin(a);
  }
  b=-1;
  for(i=0;i<n;i++){
    a=N[hout()];
    if(b==a){
      p[a%m]++;
      b=-1;
    }
    else b=a;
    c[a%m]++;
  }
  //for(i=0;i<m;i++)printf("%d %d %d\n",i,c[i],p[i]);
  s=c[0]/2;
  if(m%2==0)s+=c[m/2]/2;
  for(i=1;i*2<m;i++){
    if(c[i]>c[(m-i)%m]){
      //printf("%d %d %d %d\n",c[i],c[m-i],p[i],p[m-i]);
      a=MIN((c[i]-c[m-i])/2,p[i]);
      c[i]-=a*2;
    }
    else{
      a=MIN((c[m-i]-c[i])/2,p[m-i]);
      c[m-i]-=a*2;
    }
    s+=MIN(c[i],c[m-i]);//printf("%d ",s);
    s+=a;//printf("%d\n",s);
  }
  printf("%d\n",s);
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(),x.end()
#define pri 1000000007
#define nonod numberofnodes
#define pr pair <ll,ll>
#define mnx  1000001
#define inf 10000000000000000001
#define prin(x) cout<<setprecision(7)<<fixed<<x<<endl;
using namespace std;


void masterstroke(){
ll n;
cin>>n;
set <ll> adj[n+1];
for(ll i=1;i<n;i++){
	ll a,b;
	cin>>a>>b;
	adj[a].insert(b);
	adj[b].insert(a);
}
vector <ll> c;

for(ll i=0;i<n;i++)
{
	ll x;
	cin>>x;
	c.PB(x);

}  	
sort(all(c));	
if(n==1){
	cout<<0<<endl;
	cout<<c[0]<<endl;
	return;
	
}

queue <ll> q;
ll s=0,j=0;
ll vis[n+1]={0};
ll ans[n+1]={0};
for(ll i=1;i<=n;i++){
	if(adj[i].size()==1){
		q.push(i);
		//cout<<i<<"d"<<endl;
		//s+=c[j];
		//j++;
		vis[i]=1;
		
	}
}
while(!q.empty()){
	ll f=q.front();
	q.pop();
	//cout<<f<<endl;
	if(adj[f].size()!=0)
	{s+=c[j];}
	
	ans[f]=j;
	j++;
	vis[f]=1;
	
	for(auto k: adj[f]){
    if(adj[k].size()==2){q.push(k);}
    adj[k].erase(adj[k].find(f));
    }
    

}
cout<<s<<endl;
for(ll i=1;i<=n;i++){
	cout<<c[ans[i]]<<" ";
}
cout<<endl;



}




int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)masterstroke();
}

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    int xo;

    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if(i == 0) xo = x;
        else xo ^= x;
    }

    if(xo == 0) {
        cout << "Yes\n";
    }else {
        cout << "No\n";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;

const int maxn = 100010;

ll a[maxn];

int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	
	//sum[1] : positive
	int sgn = 1;
	ll cursum = 0;
	ll ans1 = 0;
	for (int i=1;i<=n;i++,sgn=1-sgn)
	{
		cursum += a[i];
		if (sgn == 1)
		{
			if (cursum > 0) continue;
			else ans1 += (1LL-cursum), cursum = 1;
		}
		else
		{
			if (cursum < 0) continue;
			else ans1 += (cursum + 1LL), cursum = -1;
		}
	}
	
	//sum[1] : negative
	sgn = 0;
	cursum = 0;
	ll ans2 = 0;
	for (int i=1;i<=n;i++,sgn=1-sgn)
	{
		cursum += a[i];
		if (sgn == 1)
		{
			if (cursum > 0) continue;
			else ans2 += (1LL-cursum), cursum = 1;
		}
		else
		{
			if (cursum < 0) continue;
			else ans2 += (cursum + 1LL), cursum = -1;
		}
	}
	cout<<min(ans1,ans2)<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main()
{
	int n;
	scanf("%d",&n);
	int a,b;
	int ans=0;
	while(n--)
	{
		scanf("%d %d",&a,&b);
		if(a!=b)
		{
			ans+=(b-a+1);
		}
		else
		{
			ans+=1;
		}
	 } 
	 printf("%d\n",ans);
	 return 0;
 } 

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

int main() {
  int a, b;
  cin >> a >> b;

  if (a+b==15) {
    cout << '+' << endl;
  } else if (a*b==15) {
    cout << '*' << endl;
  } else {
    cout << 'x' << endl;
  }
}

Measured memory_bytes: 3596
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    vector<int> v(3);
    for(int i=0; i<3; ++i)
        cin >> v[i];

    sort(v.begin(), v.end());
    int ans = v[2] - v[0];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MaxN 110
#define MaxV 0x3f3f3f3f
double v[MaxN];
double t[MaxN];
double cal(double x)
{
	return x*x/2;
}
double max(double a,double b)
{
	return a>b ? a:b;
 } 
 double min(double a,double b)
 {
 	return a<b ?a:b;
  } 
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%lf",&t[i]);
	for(int i=0;i<n;i++)
		scanf("%lf",&v[i]);
	double now_v=0;
	double sum=0;
	for(int i=0;i<n;i++)
	{
		double limit=MaxV;
		double times=0;
		for(int k=i+1;k<=n;k++)
		{
			limit=min(limit,times+v[k]);
			times+=t[k];
		}
		double up,down,bet;
		up=min((limit+t[i]-now_v)/2,v[i]-now_v);
		up=min(up,t[i]);
		down=max(now_v+up-limit,0);
		bet=t[i]-up-down;
		sum+=((now_v+up)*(up+bet)-cal(up));
		sum+=((now_v+up)*down-cal(down));
		now_v+=up;
		now_v-=down;
	}
	printf("%.15lf\n",sum);
	return 0;
 } 

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <cstdlib>
#include <queue>
#include <vector>
#include <set>
#include <stdio.h>
#include <cstdio>
using namespace std;
int n,m,a,b,ab,ba,x1,x2,y1,y2;
int co[20][20];
int main() {
	scanf("%d%d", &n, &m); 
	for (int i=0; i <n;i++) {
		for (int j = 0; j < n;j++) {
			if( i == j ) co[i][j] = 0;
			else co[i][j] = 1000*20;
		}
	}
	for (int i=0; i<m; i++) {
		scanf("%d,%d,%d,%d", &a, &b, &ab, &ba);
		co[a-1][b-1] = ab;
		co[b-1][a-1] = ba;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j< n;j++) {
			for (int k = 0; k < n; k++) {
				if(co[k][j] > co[k][i] + co[i][j] ) 
				co[k][j] = co[k][i] + co[i][j];
			}
		}
	}
	scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
	cout  << y1 - y2 - co[x1-1][x2-1] - co[x2-1][x1-1] << endl;
}

Measured memory_bytes: 1208
N = int(input())
A = [int(a) for a in input().split()]

p = 0
for i in range(N):
    if A[i] < 0:
        p += 1
        A[i] *= (-1)
        
if 0 in A:
    p = -1
        
if p == -1:
    print(sum(A))
elif p%2 == 0:
    print(sum(A))
else:
    print(sum(A)-2*min(A))

Measured memory_bytes: 14412
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

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; }

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

	ll h, w, m;
	cin >> h >> w >> m;

	map<pii, ll> mp;
	rep(i, m){
		int r, c;
		ll v;
		cin >> r >> c >> v;
		mp[{r-1, c-1}] = v;
	}

	ll INF = 1e17;
	vector<vector<vector<ll>>> dp(h, vector<vector<ll>>(w, vector<ll>(4, -INF)));
	dp[0][0][0] = 0;
	if(mp.count({0, 0}) == 1) dp[0][0][1] = mp[{0, 0}];

	rep(i, h) rep(j, w){
		if(j+1 < w){
			rep(k, 4) chmax(dp[i][j+1][k], dp[i][j][k]);
			if(mp.count({i, j+1}) == 1) rep(k, 3) chmax(dp[i][j+1][k+1], dp[i][j][k] + mp[{i, j+1}]);
		}

		if(i+1 < h){
			rep(k, 4) chmax(dp[i+1][j][0], dp[i][j][k]);
			if(mp.count({i+1, j}) == 1) rep(k, 4) chmax(dp[i+1][j][1], dp[i][j][k] + mp[{i+1, j}]);
		}

	}

	cout << *max_element(dp[h-1][w-1].begin(), dp[h-1][w-1].end()) << endl;
}


Measured memory_bytes: 648764
#![allow(unused_imports, non_snake_case)]

use std::io::*;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::str::FromStr;

const MOD: i32 = 1_000_000_007;

macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, m) = get!(i64, i64);
    if (n - m).abs() > 1 {
        println!("0");
        return;
    }
    let mut fact: Vec<i64> = vec![1; 100001];
    for i in 1..fact.len() {
        let j = i as i64;
        fact[i] = (fact[i - 1] * j) % (MOD as i64);
    }
    let mut ans = (fact[n as usize] * fact[m as usize]) % (MOD as i64);
    if n == m {
        ans = ans * 2 % (MOD as i64);
    }
    println!("{}", ans);
}

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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)
#define forall(it, c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); ++ it)

template <typename T> inline void read(T &x) {
	x = 0; bool f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	for (;  isdigit(c); c = getchar()) x = x * 10 + (c & 15);
	if (!f) x = -x;
}

#define ld long double

int n;
vector <ld> a, b, c;
vector <int> stk;

bool chk(int x, int y, int z) {
	return ((a[y] + c[y]) - (a[x] + c[x])) * (z - y) <= ((a[z] + c[z]) - (a[y] + c[y])) * (y - x);
}

ld calc(int x, int y) {
	return ((a[x] + c[x]) + (a[y] + c[y])) * (y - x + 1) / 2 - (a[y] + c[y]);
}

int main() {
	read(n);
	a.resize(n);
	rep(i, n) read(a[i]);
	b.resize(n);
	rep(i, n) read(b[i]);
	int mx = 0;
	rep(i, n) if (a[i] > a[mx]) mx = i;
	vector <ld> na, nb;
	for (int i = mx; i < n; ++ i) na.pb(a[i]), nb.pb(b[i]);
	rep(i, mx + 1) na.pb(a[i]), nb.pb(b[i]);
	na.swap(a); nb.swap(b);
	n = a.size();
	c.resize(n);
	for (int i = 2; i < n; ++ i)
		c[i] = 2 * c[i - 1] - 2 * b[i - 1] - c[i - 2];
	ld ans = 0;
	rep(i, n) {
		while (stk.size() >= 2 && chk(stk[stk.size() - 2], stk[stk.size() - 1], i)) {
			ans -= calc(stk[stk.size() - 2], stk[stk.size() - 1]);
			stk.pop_back();
		}
		if (stk.size()) ans += calc(stk[stk.size() - 1], i);
		stk.pb(i);
	}
	rep(i, n - 1) ans -= c[i];
	ans /= n - 1;
	printf("%.10Lf\n", ans);
	return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> v(2 * M);
for(int i = 0; i < 2 * M; i++){
  cin >> v.at(i);
}
  for(int j = 0; j < N; j++){
  int sum = 0;
  for(int i = 0; i < 2 * M; i++){
    if(v.at(i) == j + 1){
      sum += 1;
    }
  }
    cout << sum << endl;
  }
}

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

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> X(n);
    rep(i, n) cin >> X[i];
    ll ans = 0;
    rep(i, n - 1)
    {
        if ((X[i + 1] - X[i]) * a <= b)
            ans += (X[i + 1] - X[i]) * a;
        else
            ans += b;
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N * 2);
  for(int i = 0;i < N * 2;i++) {
    cin >> vec.at(i);
  }
  int answer = 0;
  sort(vec.begin(),vec.end());
  int S = N / 2;
  for(int i = 0;i < N;i++) {
    answer += vec.at(i * 2);
  }
  cout << answer << endl;
}

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

int N, M;
vector<int> v(1000);

int main(int argc, char **argv)
{
	cin >> N >> M;
	for (int i = 0; i < N; ++i)
		cin >> v[i];

	int sum = accumulate(v.begin(), v.end(), 0);
	double limit = (1.0 / (4 * M)) * sum;
	
	vector<int> select(M);
	int count = 0;
	while (count != M)
	{
		int max = -1;
		int max_i = -1;
		for (int i = 0; i < N; ++i)
		{
			if (max < v[i])
			{
				max = v[i];
				max_i = i;
			}
		}
		if (max < limit) goto exit;
		else
		{
			select[count++] = max;
			v[max_i] = -1;
		}
	}

 exit:
	std::cout << ((count == M) ? "Yes" : "No")<< std::endl;
}


Measured memory_bytes: 256
var
	a,b,i,c,a0: Longint;
begin
	readln(a,b);
	a0:=b;
	i:=0;
	while a0>0 do
	begin
		inc(i);
		a0:=a0 div 10;
	end;
	a0:=a;
	while i>0 do
	begin
		dec(i);
		a0:=a0*10;
	end;
	c:=a0+b;
	a0:=trunc(sqrt(c));
	if (a0*a0=c) then 
	begin
		writeln('Yes');
	end
	else 
	begin
		writeln('No');
	end;
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define tam 2000010
#define tamlog 12
#define offset 50000
#define mp make_pair
using namespace std;
typedef long long  ll;
typedef pair<ll,ll> ii;
typedef pair<string,ll> si;
typedef pair<ll,ii> iii;
const ll INF=1e11;
vector<ii> grafo[tam];
map<int,int> dummy[100010];
int cuniv;
void add(int iz,int der,int tipo)
{
    int dam1,dam2;
    if (dummy[iz][tipo]==0)
        dummy[iz][tipo]=cuniv++;
    dam1=dummy[iz][tipo];
    if (dummy[der][tipo]==0)
        dummy[der][tipo]=cuniv++;
    dam2=dummy[der][tipo];
    //cout<<dam1<<" "<<dam2<<endl;
    grafo[dam1].pb(ii(dam2,0));
    grafo[dam2].pb(ii(dam1,0));
}
int peso[tam];
int main()
{
    int n,m;
    cin>>n>>m;
    int iz,der,val;
    cuniv=n+10;
    forr(i,0,m)
    {
        cin>>iz>>der>>val;
        add(iz,der,val);
        //aristas[val].pb(ii(iz,der));
    }
    
    forr(i,1,n+1)
    {
        int dampadre=-1;
        for(map<int,int>::iterator ite=dummy[i].begin();ite!=dummy[i].end();ite++)
        {
            if (dampadre==-1)
                dampadre=cuniv++;
            grafo[ite->se].pb(ii(dampadre,1));
            grafo[dampadre].pb(ii(ite->se,0));
        }
    }   
    //check point
    deque<ii> cola;
    for(map<int,int>::iterator ite=dummy[1].begin();ite!=dummy[1].end();ite++)
    {
        cola.push_back(ii(ite->se,1));
    }
    
    memset(peso,-1,sizeof peso);
    
    int auxp,hijo,auxar;
    while(!cola.empty())
    {
        int num=cola.front().fi;
        auxp=cola.front().se;

        cola.pop_front();
        if (peso[num]!=-1)
            continue;
        peso[num]=auxp;
        forr(i,0,grafo[num].size())
        {
            hijo=grafo[num][i].fi;
            auxar=grafo[num][i].se;
            if (peso[hijo]==-1)
            {
                if (auxar)
                    cola.push_back(ii(hijo,auxp+auxar));
                else
                    cola.push_front(ii(hijo,auxp));
            }

        }
    }
    int minn=1e9;
    for(map<int,int>::iterator ite=dummy[n].begin();ite!=dummy[n].end();ite++)
    {
        minn=min(minn,peso[ite->se]);
    }
    if (minn==1e9)
        cout<<-1<<endl;
    else
        cout<<minn<<endl;
}


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

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

  for (int i = 0; i < N; i++) {
    string str;
    
    cin >> str;
    if (str == "Y") {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
    

}

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

def dfs(n):
  global ans
  if n > N:
    return
  else:
    if all(str(n).count(c) > 0 for c in "357"):
      ans += 1
    dfs(10*n + 3)
    dfs(10*n + 5)
    dfs(10*n + 7)

dfs(0)
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>

typedef struct {
	char name[20];
	int start,max;
} era_t;

int era_max,query_max;
era_t era[1000];

int main(void) {
	int i,j;
	int query;
	int found;
	while(1) {
		scanf("%d%d",&era_max,&query_max);
		if(era_max==0 && query_max==0)break;
		for(i=0;i<era_max;i++) {
			scanf("%s%d%d",&era[i].name,&era[i].max,&era[i].start);
			era[i].start-=era[i].max-1;
		}
		for(i=0;i<query_max;i++) {
			scanf("%d",&query);
			found=0;
			for(j=0;j<era_max;j++) {
				if(era[j].start<=query && query-era[j].start+1<=era[j].max) {
					printf("%s %d\n",era[j].name,query-era[j].start+1);
					found=1;
					break;
				}
			}
			if(!found)puts("Unknown");
		}
	}
	return 0;
}

Measured memory_bytes: 640
S = list(input())
N = len(S)

RL = []
LR = []



for i in range(N-1):
    if S[i] == 'R' and S[i+1] == 'L':
        RL.append(i)
    if S[i] == 'L' and S[i+1] == 'R':
        LR.append(i)

#print(RL)
#print(LR)

#if S[0] == 'L':
#    RL.insert(0,0)
#if S[-1] == 'R':
#    RL.append(N-1)

LR.insert(0, -1)
LR.append(N-1)

#print('RL 記入')
#print(RL)
#print('LR 区切り')
#print(LR)

ans = ['0'] * N
for i in range(len(LR)-1):
    tmp = LR[i+1] - LR[i]
#    if RL[i] == 0:
#        ans[0] = str(tmp)
#    elif RL[i] == N-1:
#        ans[N-1] = str(tmp)
#        RL.remove(N-1)
#    else:
    tmplist = S[LR[i]+1:LR[i+1]+1]
    tmpR = tmplist.count('R')
    tmpL = tmplist.count('L')
    #print(tmplist)

    if (tmpR + tmpL) % 2 == 0:
        ans[RL[i]] = str(tmp // 2)
        ans[RL[i]+1] = str(tmp // 2)
    elif tmpR %2 == 1 and tmpL%2==0:
        ans[RL[i]] = str(tmp // 2 + 1)
        ans[RL[i]+1] = str(tmp // 2 )
    elif tmpR %2 == 0 and tmpL%2==1:
        ans[RL[i]] = str(tmp // 2 )
        ans[RL[i]+1] = str(tmp // 2 + 1)

print(' '.join(ans))




Measured memory_bytes: 14760
// Created by sz
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int N = 2e5 + 5;
int n;

struct job {
    ll a,b;
    
    bool operator<(const job& rhs)const{
        return b<rhs.b;
    }
};

job jobs[N];


int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n;

    for (int i = 0; i < n; i++){
        cin>>jobs[i].a>>jobs[i].b;
    }
    
    sort(jobs, jobs+n);
    
    ll tot_time=  0;
    int ok = 1;
    for (int i = 0; i < n; i++){
        tot_time += jobs[i].a;
        if (tot_time>jobs[i].b){
            ok = 0;
            break;
        }
    }
    
    if(ok ){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    
    
    return 0;
}



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

int main(){
  int N,L;
  cin >> N >>L;
  int sum=0;
  for(int i=0;i<N;i++){
    sum+=L+i;
  }
  if(0<=L){
    sum-=L;
  }
  else if(L+N-1<=0){
    sum-=L+N-1;
  }
  cout << sum << endl;
}
    
    
  

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

typedef long long ll;

#define MAX 1000000000000000000LL

vector<ll> v;

string itos(ll x){
  stringstream ss;
  ss << x;
  return ss.str();
}

ll intLength(ll x){
  stringstream ss;
  ss << x;
  return ss.str().length();
}

ll getFizzBuzzLength(ll start){
  ll res = 0;

  for(ll i = 0; i < 15LL; i++){
    if((start + i) % 15LL == 0){
      res += 8;
    }
    else if((start + i) % 3LL == 0){
      res += 4;
    }
    else if((start + i) % 5LL == 0){
      res += 4;
    }
    else{
      res += intLength(start + i);
    }
  }

  return res;
}

string getFizzBuzzStr(ll start){
  string res = "";

  for(ll i = start; i <= start + 100; i++){
    if(i % 15LL == 0){
      res += "FizzBuzz";
    }
    else if(i % 3LL == 0){
      res += "Fizz";
    }
    else if(i % 5LL == 0){
      res += "Buzz";
    }
    else{
      res += itos(i);
    }
  }

  return res;
}

int main(){
  for(ll i = 10; i <= MAX / 10LL; i *= 10LL){
    ll div = i / 15LL + 1;
    v.push_back(15LL * div - 14);
  }

  ll n;

  while(cin >> n){
    ll len = 0;
    ll start = -1;

    for(int i = 0; i < v.size(); i++){
      ll tmp = getFizzBuzzLength(v[i]);

      if(len + tmp >= n){
        start = v[i];
        break;
      }

      len += tmp;

      tmp = getFizzBuzzLength(v[i] + 15);
      tmp *= (v[i + 1] - v[i] - 1) / 15;

      if(len + tmp >= n){
        tmp = getFizzBuzzLength(v[i] + 15);
        ll diff = n - len;
        ll tm = diff / tmp;

        len += tm * tmp;
        start = v[i] + (tm + 1) * 15LL;

        break;
      }

      len += tmp;
    }

    string ans = getFizzBuzzStr(start);

    cout<<ans.substr(n - len - 1, 20)<<endl;
  }
}

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

int main()
{
    int A, B, ans;
    cin >> A >> B;
    if (A <= 9 && B <= 9)
    {
        ans = A * B;
    }
    else
    {
        ans = -1;
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    
    int n;
    cin >> n;
    
    int cnt = 0;
    
    vector<int> ar(n);
    
    for (int &x : ar)
        cin >> x;
    
    sort(ar.begin(), ar.end(), greater<int>());
    
    for (int i = 0; i < n; ++i)
    {
        for (int j = i + 1; j < n; ++j)
        {
            for (int k = j + 1; k < n; ++k)
            {
                if (ar[i] < ar[j] + ar[k] && ar[i] != ar[j] && ar[i] != ar[k] && ar[j] != ar[k])
                {
                    ++cnt;
                }
            }
        }
    }
    
    cout << cnt;
}

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

using vi = vector<int>;
#define rep(i, a, b) for(auto i=(a); i<(b); ++i)
#define trav(a, x) for(auto& a: x)

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, k;
  cin >> n >> k;
  vi a(n);
  trav(i, a) cin >> i;
  vi dp(k + 1); // 0 -> lose, 1 -> win
  rep(i, 1, k + 1)
    trav(step, a) if (step <= i)
      dp[i] |= (1 - dp[i - step]);
  cout << (dp[k] ? "First" : "Second") << '\n';
}


Measured memory_bytes: 640
(* O(n) *)
let n, x0 = Scanf.scanf " %d %d" @@ fun a b -> a, b
let xs = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let rec gcd a b = if b = 0 then a else gcd b (a mod b)
let f g x = gcd g @@ abs @@ x0 - x
let _ = Array.fold_left f 0 xs |> Printf.printf "%d\n"

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#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()
typedef long long ll;


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

vector<vector<ll>> p(5001);
bool C(pair<ll,ll> w) {
    if(0<=w.first && w.first<=5000 && w.second >= 0 && w.second <= 5000) {
        if(upper_bound(p[w.first].begin(),p[w.first].end(),w.second) != lower_bound(p[w.first].begin(),p[w.first].end(),w.second)){
           return true;
        }
        else {
            return false;
        }
    }
    else {
        return false;
    }
    
}

int main() {
    string s,t;
    cin >> s >> t;
    string ans = "Yes";
    REP(i,s.size()){
        if(s[i] != t[i]){
            ans ="No";
            break;
        }
    }
    if(s.size() + 1 != t.size()){
        ans = "No";
    }
    cout << ans <<endl;
}


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

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

    vector<vector<int64_t>> dp(n.size(), vector<int64_t>(3, 0));
    int c0 = n.at(0) - '0';
    dp.at(0).at(0) = c0;

    int k_max = 1;
    for (int i = 1; i < n.size(); i++)
    {
        int ci = n.at(i) - '0';

        dp.at(i).at(0) = 9 + dp.at(i - 1).at(0);

        for (int j = 1; j < 3; j++)
        {
            if (k_max == j)
                dp.at(i).at(j) = 9 * (dp.at(i - 1).at(j - 1) - 1) + ci + dp.at(i - 1).at(j);
            else
                dp.at(i).at(j) = 9 * dp.at(i - 1).at(j - 1) + dp.at(i - 1).at(j);
        }

        if (ci != 0)
            k_max++;
    }

    cout << dp.at(n.size() - 1).at(k - 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N;
  cin >> N;
  vector<pair<int, int>> A(N);
  rep(i, N)
  {
    cin >> A[i].first;
    A[i].second = i + 1;
  }
  sort(A.begin(), A.end());
  vector<int> ans(N);
  int l = A[N / 2 - 1].first;
  int r = A[N / 2].first;
  rep(i, N)
  {
    if (i + 1 <= N / 2)
      ans[A[i].second - 1] = r;
    else
      ans[A[i].second - 1] = l;
  }
  printVector(ans);
  return 0;
}

Measured memory_bytes: 4480
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        int k = sc.nextInt();
        TreeSet<Long> set = new TreeSet<>();
        for (long i = a; i < Math.min(a + k, b); i++) {
            set.add(i);
        }
        for (long i = Math.max(a, b - k + 1); i <= b; i++) {
            set.add(i);
        }
        for (long i : set) {
            System.out.println(i);
        }
    }
}

Measured memory_bytes: 36420
//Sqrt Inequality

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    long double a,b,c;cin>>a>>b>>c;
    if(sqrtl(a*b)<(c-a-b)/2)cout<<"Yes"<<nnn;
    else cout<<"No"<<nnn;
    return 0;
}

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

typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


//===

const ll mod = static_cast<ll>(1e9 + 7);



int main() {
	int n, x;
	cin >> n >> x;
	Vi L(n);
	Vi D(n + 1);
	for (int i = 0; i < n; ++i) {
		cin >> L[i];
		D[i + 1] = D[i] + L[i];
	}

	set<int> Ds;
	for (const auto& val : D) {
		Ds.insert(val);
	}

	int ans = 0;
	for (int i = 0; i <= min(x, D[n]); ++i) {
		if (Ds.find(i) != Ds.end()) ++ans;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <limits>
#include <regex>
#include <time.h>
#include <complex>
using namespace std;
using ll=long long;
using pl  = pair<ll,ll>;
using pii  = pair<int,int>;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

map<ll,ll> M;

int main(){
  ll N,K;
  ld A[200007],X=0,ans=0;
  cin >> N >> K;
  rep(i,N){
    cin  >> A[i];
    X+=(1.0+A[i])/2;
    if(i>=K){
      X-=(1.0+A[i-K])/2;
    }
    if(i>=K-1){
      ans=max(X,ans);
    }
  }
  cout << stpr(8) << ans << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,a,b,c,n;
	cin>>n;
	ll an=0;
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			for(k=1;k<=n;k++){
				a=__gcd(i,__gcd(j,k));
				an+=a;
			}
		}
	}
	cout<<an;
	return 0;
}

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

using namespace std;


int main(void){

    int n, m;
    cin >> n >> m;
    
    if(!(n-m==0 || m-n==1 || m-n==-1)) {
        cout << 0 << endl;
        return 0;
    }
    
    long long result = 1;
    long long limit = 1000000000+7;
    for(int i=1; i<=n; i++) {
        result *= i;
        if(result > limit) {
            long long temp = result/limit;
            result -= limit * temp;
        }

    }
    for(int i=1; i<=m; i++) {
        result *= i;
        if(result > limit) {
            long long temp = result/limit;
            result -= limit * temp;
        }
    }

    if((n-m)%2==0) {
        result*=2;
        if(result > limit) {
            long long temp = result/limit;
            result -= limit * temp;
        }
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256