akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
#define N 100010
char a[N];
int s1[N],s2[N],t1[N],t2[N];
int main()
{
    int i,j,k,x,y,flag,n,m,k1,k2;
    int r1,r2;
    scanf("%s",a);
    scanf("%d%d",&n,&m);
    k=strlen(a);
    i=0;
    while(a[i]=='F'&&i<k)
    {
        n--;
        i++;
    }
    if(i==k)
    {
        if(n==0&&m==0)
        printf("Yes\n");
        else
        printf("No\n");
        return 0;
    }
    flag=0;
    k1=0;
    k2=0;
    x=0;
    y=0;
    for(;i<k;i++)
    {
        if(a[i]=='T')
        {
            if(flag==0)
            {
                if(x>0)
                s1[k1++]=x;
                x=0;
                flag=1;
            }
            else
            if(flag==1)
            {
                if(y>0)
                s2[k2++]=y;
                y=0;
                flag=0;
            }
        }
        else
        if(a[i]=='F')
        {
            if(flag==0)
            x++;
            else
            if(flag==1)
            y++;
        }
    }
    if(flag==0)
    {
        if(x>0)
        s1[k1++]=x;
        x=0;
        flag=1;
    }
    else
    if(flag==1)
    {
        if(y>0)
        s2[k2++]=y;
        y=0;
        flag=0;
    }
    r1=0;
    for(i=0;i<k1;i++)
    r1=r1+s1[i];
    r2=0;
    for(i=0;i<k2;i++)
    r2=r2+s2[i];
    n=fabs(n);
    m=fabs(m);
    if(r1<n||r2<m)
    {
        printf("No\n");
        return 0;
    }
    memset(t1,0,sizeof(t1));
    memset(t2,0,sizeof(t2));
    t1[r1]=1;
    for(i=0;i<k1;i++)
    for(j=r1;j>=s1[i];j--)
    t1[j-s1[i]]=t1[j]||t1[j-s1[i]];
    t2[r2]=1;
    for(i=0;i<k2;i++)
    for(j=r2;j>=s2[i];j--)
    t2[j-s2[i]]=t2[j]||t2[j-s2[i]];
    if(t1[(r1+n)/2]&&t2[(r2+m)/2]&&(r1+n)%2==0&&(r2+m)%2==0)
    printf("Yes\n");
    else
    printf("No\n");
    return 0;
}


Measured memory_bytes: 1024
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)

	sc.Scan()
	elems := strings.Split(sc.Text(), " ")
	N, _ := strconv.Atoi(elems[0])
	Q, _ := strconv.Atoi(elems[1])

	tree := make([][]int, N)
	for i := 0; i < N; i++ {
		tree[i] = []int{}
	}
	sousa := make([]int, N)

	for i := 0; i < N-1; i++ {
		sc.Scan()
		text := sc.Text()
		elems := strings.Split(text, " ")
		a, _ := strconv.Atoi(elems[0])
		b, _ := strconv.Atoi(elems[1])
		a--
		b--
		tree[a] = append(tree[a], b)
		tree[b] = append(tree[b], a)
	}

	for i := 0; i < Q; i++ {
		sc.Scan()
		text := sc.Text()
		elems := strings.Split(text, " ")
		p, _ := strconv.Atoi(elems[0])
		x, _ := strconv.Atoi(elems[1])
		p--
		sousa[p] += x
	}

	counter := make([]int, N)

	rec(0, -1, 0, counter, sousa, tree)

	fmt.Print(counter[0])
	for i := 1; i < N; i++ {
		fmt.Printf(" %d", counter[i])
	}
	fmt.Println("")
}

func rec(pos, parent, count int, counter, sousa []int, tree [][]int) {
	counter[pos] += sousa[pos] + count
	children := tree[pos]
	for _, child := range children {
		if child == parent {
			continue
		}
		rec(child, pos, sousa[pos]+count, counter, sousa, tree)
	}
}


Measured memory_bytes: 123008
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//ここまでテンプレ
int main(){
	int ans=0;
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		while((a&1)==0){
			ans++;
			a=a>>1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a,b) << " " << max(0,a+b-n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{int a,b;
	scanf("%d %d",&a,&b);
	if(a<b)
	printf("a < b\n");
	else if(a > b)
	printf("a > b\n");
	else if(a == b)
	printf("a == b\n");
	
	return 0;
}

Measured memory_bytes: 580
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node{
  Node *right, *left, *parent;
  int key;
};

Node *root, *NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else{
    if(z->key < y->key) y->left = z;
    else y->right = z;
  }
}

void inorder(Node *u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node *u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i, x;
  string com;
  
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    cin >> com;
    if ( com == "insert"){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

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

struct prime{
	int val;
	int num;
};

int main(){
	int n, k;
	std::cin>>n>>k;

	std::vector<int> aList(n);
	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	int sum=0;
	for(int i=0; i<n; i++)
		sum+= aList[i];

	int sqSum= std::sqrt(sum);
	std::vector<bool> isPrime(sqSum+1, true);
	isPrime[0]= false;
	isPrime[1]= false;

	for(int i=2; i<sqSum+1; i++)
		if(isPrime[i])
			for(int j=2; j*i< sqSum+1; j++)
				isPrime[j*i]= false;
		
	std::vector<prime> primeList;

	for(int i=0; i<sqSum+1; i++)
		if(isPrime[i])
			primeList.push_back({i,0});

	int tmp= sum;

	for(int i=0; i<primeList.size(); i++){
		while(tmp% primeList[i].val ==0){
			tmp/= primeList[i].val;
			primeList[i].num++;
		}
	}

	if(tmp != 1)
		primeList.push_back({tmp, 1});

	std::vector<std::vector<int>> divDP(primeList.size()+1);
	divDP[0].push_back(1);

	for(int i=0; i<primeList.size(); i++){
		int prod= 1;
		for(int j=0; j<primeList[i].num+1; j++){
			for(int k=0; k<divDP[i].size(); k++)
				divDP[i+1].push_back(divDP[i][k]*prod);
			
			prod*= primeList[i].val;
		}
	}

	std::sort(divDP[primeList.size()].begin(), divDP[primeList.size()].end(), [](int x, int y){return x>y;});

	int ans=0;

	for(int i=0; i<divDP[primeList.size()].size(); i++){
		std::vector<int> modList(n);

		for(int j=0; j<n; j++)
			modList[j]= aList[j]%divDP[primeList.size()][i];

		std::sort(modList.begin(), modList.end(), [](int x, int y){return x>y;});

		int fwNum=0;
		int bkNum=0;
		int bkIdx= n;

		for(int j=0; j<n; j++){
			if(j>=bkIdx)
				break;

			fwNum+= divDP[primeList.size()][i]-modList[j];

			while(bkNum<fwNum){
				bkIdx--;
				bkNum+= modList[bkIdx];
			}
		}

		if(fwNum<=k){
			ans= divDP[primeList.size()][i];
			break;
		}		
	}

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

//	for(int i=0; i<divDP[primeList.size()].size(); i++)
//		std::cout<<divDP[primeList.size()][i]<<std::endl;

}

Measured memory_bytes: 20224
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#include <cstdlib>
#include <stdlib.h>
#define FasterIO     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<n;i++)
#define f1n(i,n) for(i=1;i<=n;i++)
#define szf sizeof()
#define sz size()
#define ln length()
#define MOD 1000000007
using namespace std;
using ll=long long;
int cnt,element;
int main()
{
    FasterIO
ll n,i,j,k,taka=0,rafi=0;
cin>>n;
    taka=100;
    while(taka<n)
    {
        taka=taka+(taka/100);
        rafi++;
    }
    cout<<rafi<<endl;
    return 0;
}


Measured memory_bytes: 3640
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;


int main(void) {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	


	string s;
	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		cout << 'x';
	}

    return 0;





	return 0;
}



Measured memory_bytes: 256
local h, w = io.read("*n", "*n", "*l")
for i = 1, w + 2 do io.write("#") end
io.write("\n")
for i = 1, h do
  io.write("#" .. io.read() .. "#\n")
end
for i = 1, w + 2 do io.write("#") end
io.write("\n")


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

using fint64 = int_fast64_t;
template<fint64 MOD>
struct ModInt{
    fint64 x;
    ModInt():x(0){}
    ModInt(fint64 x):
        x(x>=0?x%MOD:(MOD-(-x)%MOD)%MOD)
        {}
    // 負号
    ModInt operator -() const{
        return ModInt(-x);
    }
    // 加算
    ModInt &operator +=(const ModInt &rhs){
        x+=rhs.x;
        if(x>=MOD) x-=MOD;
        return (*this);
    }
    ModInt operator +(const ModInt &rhs) const{
        return ModInt(*this)+=rhs;
    }
    // 減算
    ModInt &operator -=(const ModInt &rhs){
        x+=MOD-rhs.x;
        if(x>=MOD) x-=MOD;
        return (*this);
    }
    ModInt operator -(const ModInt &rhs) const{
        return ModInt(*this)-=rhs;
    }
    // 乗算
    ModInt &operator *=(const ModInt &rhs){
        x*=rhs.x;
        if(x>=MOD) x%=MOD;
        return (*this);
    }
    ModInt operator *(const ModInt &rhs) const{
        return ModInt(*this)*=rhs;
    }
    // 除算
    ModInt &operator /=(const ModInt &rhs){
        (*this)*=rhs.inverse();
        return (*this);
    }
    ModInt operator /(const ModInt &rhs) const{
        return ModInt(*this)/=rhs;
    }
    // 等号
    bool operator ==(const ModInt &rhs){
        return x==rhs.x;
    }
    bool operator !=(const ModInt &rhs){
        return x!=rhs.x;
    }
    // 累乗
    ModInt pow(fint64 n) const{
        fint64 tmp=x;
        fint64 ret=1;
        while(n>0){
            if(n&1) ret=ret*tmp%MOD;
            tmp=tmp*tmp%MOD;
            n>>=1ll;
        }
        return ModInt(ret);
    }
    // 逆元
    ModInt inverse() const{
        fint64 a=x,b=MOD,s=1,t=0;
        while(b>0){
            fint64 u=a/b;
            a-=u*b;
            s-=u*t;
            swap(a,b);
            swap(s,t);
        }
        return ModInt(s);
    }
    // 入出力
    friend istream &operator >>(istream &lhs,ModInt<MOD> &rhs){
        fint64 x; lhs>>x;
        rhs=ModInt<MOD>(x);
        return lhs;
    }
    friend ostream &operator <<(ostream &lhs,const ModInt<MOD> &rhs){
        return lhs<<rhs.x;
    }
};

int main(){
    const int MOD=1000003;
    using mint=ModInt<MOD>;
    mint fac[MOD];
    fac[0]=1;
    for(int i=1;i<MOD;i++) fac[i]=fac[i-1]*i;
    int q; cin>>q;
    while(q--){
        int x,d,n; cin>>x>>d>>n;
        if(d==0){
            cout<<mint(x).pow(n)<<endl;
            continue;
        }
        int a=(mint(x)/mint(d)).x;
        if(a+(n-1)>=MOD && a-1<MOD){
            cout<<0<<endl;
            continue;
        }
        cout<<fac[mint(a+(n-1)).x]/fac[mint(a-1).x]*mint(d).pow(n)<<endl;
    }
    return 0;
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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




int a[3005];
LL sum[3005];

int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int i,j,n,s;
    LL ans=0,mod=998244353;
    cin >> n >> s;
    for(i=1;i<=n;i++)cin >> a[i];
    sum[a[1]]=1;
    for(i=2;i<=n;i++)
    {
        for(j=s;j>a[i];j--)sum[j]+=sum[j-a[i]],sum[j]%=mod;
        sum[a[i]]+=i;
        sum[a[i]]%=mod;
        ans+=(sum[s]%mod);
        ans%=mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace A___Palindromic_Number
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine();
            if(n[0]==n[2])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13140
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n=sc.nextInt(), m=sc.nextInt();
		int[][] map = new int[n+1][n+1];

		for(int[] tmp : map) Arrays.fill(tmp,-1);
		for(int i=0;i<m;i++){
			String[] s = sc.next().split(",");
			int a=Integer.parseInt(s[0]), b=Integer.parseInt(s[1]);
			map[a][b] = Integer.parseInt(s[2]);
			map[b][a] = Integer.parseInt(s[3]);
		}

		String[] s = sc.next().split(",");
		int x1=Integer.parseInt(s[0]), x2=Integer.parseInt(s[1]);
		int ans = Integer.parseInt(s[2]) - Integer.parseInt(s[3]);

		ans -= minCost(x1,x2,map);
		ans -= minCost(x2,x1,map);

		System.out.println(ans);
	}

	static int minCost(int s,int g,int[][] map){
		Queue<State> open = new PriorityQueue<State>();
		Set<State> closed = new HashSet<State>();

		State st = new State(0,s);
		open.add(st);

		State ans = null;
		while(!open.isEmpty()){
			st = open.poll();
			if(closed.contains(st)) continue;
			closed.add(st);
			if(st.n == g){
				ans = st;
				break;
			}
			open.addAll(st.nexts(map));
		}

		return ans.cost;
	}

	static class State implements Comparable<State>{
		int cost, n;

		State(int cost,int n){
			this.cost = cost;
			this.n = n;
		}

		List<State> nexts(int[][] map){
			List<State> sts = new ArrayList<State>();
			for(int i=1;i<map.length;i++){
				if(n == i) continue;
				if(map[n][i] >= 0) sts.add(new State(cost+map[n][i],i));
			}
			return sts;
		}

		public int compareTo(State st){
			return cost - st.cost;
		}

		public boolean equals(Object o){
			State st = (State)o;
			return this.n == st.n;
		}

		public int hashCode(){
			return this.n;
		}
	}
}

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

void addOne(vector<bool> &per)
{
	int i=1;
	while(per[i]!=0)
	{
		per[i]=0;
		i++;
	}
	per[i]=1;
}

int main(void)
{
	ios_base::sync_with_stdio(false);    
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n,m,x;
	cin>>n>>m>>x;
	
	vector<int> cost(n+1);
	vector<vector<int> > A(n+1,vector<int> (m+1));
	
	for(int i=1;i<=n;i++)
	{
		cin>>cost[i];
		for(int j=1;j<=m;j++)
		{
			cin>>A[i][j];
		}
	}
	
	vector<bool> per(n+1);
	int times=pow(2,n);
	ll min_cost=1e18;
	
	for(int i=1;i<pow(2,n);i++)
	{
		addOne(per);
		ll total=0;
		bool ctr=1;
		vector<int> c(m+1,x);
		for(int k=1;k<=n;k++)
		{
			if(per[k])
			{
				total+=cost[k];
				for(int j=1;j<=m;j++)
				{
					c[j]-=A[k][j];
				}
			}
		}
		
		for(int k=1;k<=m;k++)
		{
			if(c[k]>0)
			{
				ctr=0;
				break;
			}
		}
		
		if(ctr)
		{
			if(total<min_cost)
			{
				min_cost=total;
			}
				
		}
		
	}
	
	if(min_cost==1e18)
		cout<<-1<<"\n";
	else cout<<min_cost<<"\n";
	
	return 0;
}

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

ll n;
ll arr[100005];
ll pre[100005];
ll total,moves;

int main(){
	//freopen("input.txt","r",stdin);
	
	scanf("%lld",&n);
	for (int x=0;x<n;x++) scanf("%lld",&arr[x]);
	for (int x=0;x<n;x++) total+=arr[x];
	moves=n*(n+1)/2;
	
	if (total%moves){
		printf("NO\n");
		return 0;
	}
	moves=total/moves;
	
	
	pre[0]=arr[0]-arr[n-1];
	for (int x=1;x<n;x++){
		pre[x]=arr[x]-arr[x-1];
	}

	for (int x=0;x<n;x++){
		pre[x]=moves-pre[x];
		if (pre[x]%n || pre[x]/n>moves || 0>pre[x]){
			printf("NO\n");
			return 0;
		}
		
	}
	printf("YES\n");
}


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

int main() {
  string str;
  cin >> str;
  string ans = "Yes";
  for (int i = 0; i < str.size(); i++) {
    if ((i+1)%2 == 0) {
      if (str.at(i) == 'R') {
        ans = "No";
      }
    } else if ((i+1)%2 == 1) {
      if (str.at(i) == 'L') {
        ans = "No";
      }
    }
  }
  cout << ans << endl;
}

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


int main() {
    int n; cin >> n;
    vector<int> vec(n);
    for(int i = 0; i < n; i++){
        cin >> vec.at(i);
    }
    int max = vec.at(0);
    vector<int> c_vec;
    int count = 0;
    rep(i, n){
        int min = vec.at(i);
        if(max >= min) {
            count++;
            max = min;
        }else{
            c_vec.push_back(count);
            count=0;
            max = min;
        }
    }
    c_vec.push_back(count);
    std::sort(c_vec.begin(), c_vec.end(), std::greater<int>());
    cout << c_vec.at(0) << endl;
    return 0;
}


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

int heights[20];

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

	for(int i = 0; i < n; ++i){
		cin >> heights[i];
	}

	int max = 0;
	int count = 0;

	for(int i = 0; i < n; ++i){
		if(heights[i] >= max){
			++count;
			max = heights[i];
		}else{
			//nothing
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int tafel[2048][2048];
int yokotafel[2048][2048];
int tatetafel[2048][2048];

int main(){
	int h, w; cin >> h >> w;
	for( int i = 0; i < h; ++i ){
		string tmp; cin >> tmp;
		for( int j = 0; j < w; ++j ){
			if( tmp[j] == '#' ) tafel[i][j] = -1;
		}
	}
	for( int i = 0; i < h; ++i ){
		int cnt = 0;
		tafel[i][w] = -1;
		for( int j = 0; j <= w; ++j ){
			if( tafel[i][j] == -1 ){
				if( j-1 != -1 && tafel[i][j-1] != -1 ) yokotafel[i][j-1] = cnt;
				yokotafel[i][j] = -1;
				cnt = 0;
			} else {
				++cnt;
			}
		}
		for( int j = w-1; j >= 0; --j ){
			if( j-1 != -1 && yokotafel[i][j] != -1  && yokotafel[i][j-1] != -1 ){
				yokotafel[i][j-1] = yokotafel[i][j];
			}
		}
	}
	cout << endl;
	for( int i = 0; i < w; ++i ){
		int cnt = 0;
		tafel[h][i] = -1;
		for( int j = 0; j <= h; ++j ){
			if( tafel[j][i] == -1 ){
				if( j-1 != -1 && tafel[j-1][i] != -1 ) tatetafel[j-1][i] = cnt;
				tatetafel[j][i] = -1;
				cnt = 0;
			} else {
				++cnt;
			}
		}
		for( int j = h-1; j >= 0; --j ){
			if( j-1 != -1 && tatetafel[j][i] != -1  && tatetafel[j-1][i] != -1 ){
				tatetafel[j-1][i] = tatetafel[j][i];
			}
		}
	}
	int ans = 0;
	for( int i = 0; i < h; ++i ){
		for( int j = 0; j < w; ++j ){
			// cout << tatetafel[i][j] + yokotafel[i][j] - 2 + 1 << ' ';
			ans = max(ans, tatetafel[i][j] + yokotafel[i][j] - 2 + 1 ); 
		}
		// cout << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 49408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


int main(void){
    int n, m;
    cin >> n >> m;
    vector<int> s[10];
    rep(i,m){
        int k;
        cin >> k;
        s[i].resize(k);
        rep(j,k){
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    vector<int> p(m);
    rep(i,m){
        cin >> p[i];
    }
    int res = 0;
    rep(mask, 1<<n){
        bool ok = true;
        rep(i,m){
            int cnt = 0;
            rep(j,s[i].size()){
                if(mask & (1<<s[i][j])) cnt++;
            }
            if (cnt%2 != p[i]) ok = false;
        }
        if(ok) res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
ps = []
for _ in range(n):
    a, b = map(int, input().split())
    ps.append([a, b, 0])
for _ in range(n):
    c, d = map(int, input().split())
    ps.append([c, d, 1])
ps = sorted(ps, key=lambda x: x[0])    

c = 0
for i in range(len(ps)):
    b = ps[i]
    # redもしくは、既にペアが決まっていたら飛ばす
    if b[2] == 0 or b[2] == 2:
        continue

    j = 0
    maxy = -1
    rec = -1
    while j < i:
        r = ps[j]
        # blue もしくは、既にペアが決まっていたら飛ばす
        if r[2] == 1 or r[2] == 2:
            j += 1
            continue

        if r[1] > maxy and r[1] < b[1]:
            maxy = r[1]
            rec = j
        j += 1
    if rec == -1:
        continue
    
    # ペアになったものを記録
    ps[rec][2] = 2
    c += 1
print(c)


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

using namespace std;

long long int factmod(long long int a,long long int m) {
    if(a==1)
        return 1;
    else
        return a*factmod(a-1,m)%m;
}

const long long int mod =1000000007;

int main(){

    long long int n,m,l;
    int s=0;

    cin >> n >> m ;

    if(n == m){
        l = factmod(n,mod);
        s = (2*l%mod)*l % mod;
    }
    else if(n == m+1){
        l = factmod(m,mod);
        s = (l*l%mod)*(m+1) % mod;
    }
    else if(n == m-1){
        l = factmod(n,mod);
        s = (l*l%mod)*(n+1) % mod;
    }


    cout <<  s << endl;


}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    string n, m;
    cin >> n >> m;
    int r=1000;
    for (int i=0; i<n.size()-m.size()+1; ++i)
    {
        int t=0;
        for (int ii=i; ii<i+m.size(); ++ii)
        {
            if (n[ii]!=m[ii-i])
                t+=1;
        }
        //cout << t << endl;
        r=min(r, t);
    }
    cout << r << endl;
}


Measured memory_bytes: 3624
using ll=long long;using ull=unsigned long long;
#include<limits>
namespace pcl{template<typename T>constexpr T TNF=std::numeric_limits<T>::max()/2;constexpr int INF=TNF<int>;constexpr ll LNF=TNF<ll>;constexpr double DNF=TNF<double>;constexpr double EPS=1e-8;constexpr int P7=1'000'000'007;constexpr int DX[]={1,0,-1,0,1,1,-1,-1};constexpr int DY[]={0,1,0,-1,-1,1,1,-1};}
#include<algorithm>
#include<cmath>
#include<iostream>
namespace pcl{template<typename T>void updmax(T&a,T const&b){a=std::max(a,b);}template<typename T>void updmin(T&a,T const&b){a=std::min(a,b);}template<typename T,typename U,typename V>bool in_range(T const&begin,U const&mid,V const&end){return begin<=mid&&mid<end;}template<typename T,typename U,typename V>bool in_range(T const&begin,std::initializer_list<U>list,V const&end){auto p=std::minmax_element(list.begin(),list.end());return begin<=*p.first&&*p.second<end;}template<typename T,typename U,typename V>bool in_range_strict(T const&begin,std::initializer_list<U>list,V const&end){if(!std::is_sorted(list.begin(),list.end()))return false;return in_range(begin,list,end);}template<typename T>inline T cget(){T x;std::cin>>x;return x;}}
#include<iostream>
#include<vector>
namespace pcl{template<typename T>std::ostream&operator<<(std::ostream&os,std::vector<T>const&v){os<<'[';for(size_t i=0;i<v.size();i++){if(i!=0)os<<",";os<<v[i];}os<<']';return os;}template<typename T>std::istream&operator>>(std::istream&is,std::vector<T>&v){for(size_t i=0;i<v.size();i++)is>>v[i];return is;}}
#include<bits/stdc++.h>
using namespace std;using namespace pcl;int main(){int N,M;cin>>N>>M;vector<vector<int>>graph(N*3);for(int i=0;i<M;i++){int u,v;cin>>u>>v;u--,v--;graph[u*3].push_back(v*3+1);graph[u*3+1].push_back(v*3+2);graph[u*3+2].push_back(v*3);}int S,T;cin>>S>>T;S--,T--;S*=3,T*=3;queue<pair<int,int>>que;que.push(make_pair(0,S));vector<bool>visited(N*3);while(!que.empty()){int dist,curr;tie(dist,curr)=que.front();que.pop();if(visited[curr])continue;if(curr==T){cout<<dist/3<<endl;return 0;}visited[curr]=true;for(int to:graph[curr])que.push(make_pair(dist+1,to));}cout<<-1<<endl;}


Measured memory_bytes: 16640
import math

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

li = [A, B, C, D, E]
temp = min(li)

if N <= min(li):
    print(5)
else:
    print(math.ceil(N/temp) + 4)


Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <math.h>

using namespace std;

struct Point{
	bool operator<(const struct Point &arg) const{
		if(y != arg.y)return y < arg.y;
		return x < arg.x;
	};
	double x,y;
};

//true?????????
bool calcGaiseki(Point left,Point base, Point right){
	double gaiseki = (left.x-base.x)*(right.y - base.y)-(left.y-base.y)*(right.x-base.x);
	if(gaiseki < -0.00000001)return false;
	else{
		return true;
	}
}

void func(int n){
	vector<Point> V,UP,DOWN;
	double x,y;

	for(int i = 0; i < n; i++){
		scanf("%lf,%lf",&x,&y);
		V.push_back(Point());
		V[i].x = x;
		V[i].y = y;
	}

	sort(V.begin(),V.end());

	UP.push_back(V[0]);
	UP.push_back(V[1]);

	DOWN.push_back(V[V.size()-1]);
	DOWN.push_back(V[V.size()-2]);

	for(int i = 2; i < V.size(); i++){
		while(UP.size() > 1 && calcGaiseki(UP[UP.size()-2],UP[UP.size()-1],V[i]) == false)UP.pop_back();
		UP.push_back(V[i]);
	}

	for(int i = V.size()-3; i >= 0; i--){
		while(DOWN.size() > 1 && calcGaiseki(DOWN[DOWN.size()-2],DOWN[DOWN.size()-1],V[i]) == false){
			DOWN.pop_back();
		}
		DOWN.push_back(V[i]);
	}

	printf("%d\n",n-(UP.size()+DOWN.size()-2));
}

int main(){

	int n;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		func(n);
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	string a;
	string b;
	string c;
	cin >> a >> b >> c;

	cout << a[0] << b[1] << c[2] << endl;
}

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

int main(){
  int N,Y;
  cin>>N>>Y;
  bool t=1;
  for(int i=0;i<=N;i++){
    if (t!=1){
      break;
    }
    for(int j=0;j<=N-i;j++){
      if (t!=1){
        break;
      }
      int k=N-i-j;
      int sum=10000*i+5000*j+1000*k;
      if(sum==Y){
        cout<<i<<" "<<j<<" "<<k<<endl;
        t=0;
        break;
      }
    }
  }
  if(t){
    cout<<"-1 -1 -1"<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int memo[20][1<<13];
int m[20];
int n;

int solve(int who, int rest){
  if(rest == 0) return 1;
  if(memo[who][rest] != -1) return memo[who][rest];

  rep(i,1,m[who]+1){
    if(!solve((who+1)%(n+n), rest - i))
      return memo[who][rest] = 1;
    if(rest - i == 0) break;
  }
  return memo[who][rest] = 0;
}

int main(){
  while(n = getInt()){
    int s = getInt();

    REP(i,n+n) m[i] = getInt();
    memset(memo,-1,sizeof(memo));

    print(solve(0, s) == 1 ? 1 : 0);
  }
  return 0;
}

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

using namespace std;

int main(){

    int n, m, a, c;
    cin >> n >> m;

    vector<int> adj[m], status(m), cur(n);
    for(int i = 0; i < m; i++){
        cin >> c;
        for(int j = 0; j < c; j++){
            cin >> a;
            adj[i].push_back(a);
        }
    }

    for(int i = 0; i < m; i++)
        cin >> status[i];

    int cnt = 0;
    for(int i = 0; i < (1<<n); i++){
        for(int j = 0; j < n; j++)
            cur[j] = ((i>>j)&1);

        bool valid = true;
        int cc;
        for(int l = 0; l < m; l++){
            cc = 0;
            for(int a : adj[l])
                cc += cur[a-1];
            if( cc%2 != status[l] )
                valid = false;
        }
        if( valid )
            cnt++;
    }

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

Measured memory_bytes: 256
N, P = map(int, input().split())
As = list(map(int, input().split()))
dic = {0:0, 1:0}
for a in As:
  if a % 2 == 0:
    dic[0] += 1
  else:
    dic[1] += 1

if P == 1 and dic[1] == 0:
  print(0)
  exit()
  
rlt = 2**dic[0]
tmp = 0
for i in range(dic[1]+1):
  if i == 0:
    t = 1
  else:
    t = t*(dic[1]+1-i)//i
  if (P == 0 and i%2==0) or (P == 1 and i%2==1):
    tmp += t
      
rlt *= tmp

print(rlt)

Measured memory_bytes: 61608
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

int main(){

    while(true){
        int w,h;
        cin >> w >> h;
        if(w == 0) break;
        int sy,sx,gy,gx;
        cin >> sx >> sy >> gx >> gy;
        sx--,sy--,gx--,gy--;
        int n;
        cin >> n;
        vector<vector<int> > color(h,vector<int>(w));
        for(int block=0;block<n;block++){
            int c,d,x,y;
            cin >> c >> d >> x >> y;
            x--;y--;
            // yoko
            if(d == 0){
                for(int i=0;i<2;i++){
                    for(int j=0;j<4;j++){
                        color[y+i][x+j] = c;
                    }
                }
            }else{
                for(int i=0;i<4;i++){
                    for(int j=0;j<2;j++){
                        color[y+i][x+j] = c;
                    }
                }
            }
        }
        // for(int i=0;i<h;i++){
        //     for(int j=0;j<w;j++){
        //         cerr << color[i][j];
        //     }
        //     cerr << endl;
        // }
        int c = color[sy][sx];
        vector<vector<char> > visited(h,vector<char>(w));
        queue<pair<int,int> > Q;
        Q.push(make_pair(sy,sx));
        while(not Q.empty()){
            int y = Q.front().first;
            int x = Q.front().second;
            Q.pop();

            if(y >= h or y < 0 or x >= w or x < 0) continue;
            if(color[y][x] != c) continue;
            if(visited[y][x]) continue;
            visited[y][x] = true;
            for(int i=0;i<4;i++){
                Q.push(make_pair(y+dy[i],x+dx[i]));
            }
        }
        if(visited[gy][gx]){
            cout << "OK" << endl;
        }else{
            cout << "NG" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1268
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 600000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000 大きいとワ―シャルフロイドでオーバーフローを起こす
#define PI 3.14159265358979
#define MAXI 7500000

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

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

long long int gcd(long long int a, long long int b) { //最大公約数
	if (b == 0) {
		return a;
	}
	return gcd(b, a%b);
}

long long int lcm(long long int a, long long int b) { //最小公倍数
	long long int g = gcd(a, b);
	return a / g * b;
}


int main(void) {
	
	long long int n;
	long long int a, b;
	bool flag = true;
	long long int time = 0;


	cin >> n;
	vector< P > pa(n);
	FOR(i, 1, n) {
		cin >> a >> b;
		pa[i - 1].first = b;
		pa[i - 1].second = a;
	}

	sort(pa.begin(), pa.end());

	FOR(i, 0, n - 1) {
		if (time + pa[i].second <= pa[i].first) {
			time += pa[i].second;
		}
		else {
			flag = false;
			break;
		}
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

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

int main()
{
  int N;
  cin >> N;
  vector<long> a;
  long sum = 0;
  rep(i, N)
  {
    long in_a;
    cin >> in_a;
    sum += in_a;
    a.push_back(in_a);
  }

  long x = a[0];
  sum -= a[0];
  long ans = 2 * pow(10, 9);
  ans = min(ans, abs(x - sum));
  for (int i = 1; i < N - 1; i++)
  {
    x += a[i];
    sum -= a[i];
    ans = min(ans, abs(x - sum));
  }

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

Measured memory_bytes: 2420
import math
s = input()
rl_position = []
for i in range(1, len(s)):
    if s[i - 1:i + 1] == 'RL':
        r_num = 0
        jr = 1
        while i - 1 - jr >= 0 and s[i - 1 - jr] == 'R':
            r_num += 1
            jr += 1
        l_num = 0
        jl = 1
        while i + jl <= len(s) - 1 and s[i + jl] == 'L':
            l_num += 1
            jl += 1

        rl_position.append({'posi': i - 1, 'R': r_num, 'L': l_num})

# print(rl_position)
ans_list = [0] * len(s)
for i in range(len(rl_position)):
    ans_list[rl_position[i]['posi']] = 1 + math.floor(rl_position[i]['R'] / 2) + math.ceil(rl_position[i]['L'] / 2)
    ans_list[rl_position[i]['posi'] + 1] = 1 + math.ceil(rl_position[i]['R'] / 2) + math.floor(rl_position[i]['L'] / 2)
print(*ans_list)


Measured memory_bytes: 23248
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		int maxv = 0;
		int maxi = 0;
		for(int i = 0; i< N; i++) {
			A[i] = sc.nextInt();
			if(maxv < A[i]) {
				maxv = A[i];
				maxi = i;
			}
		}
		Arrays.sort(A);
		if(A[N -2] == A[N - 1]){
			for(int i = 0; i < N; i++) {
				System.out.println(A[N - 1]);
			}
		}else {
			for(int i = 0; i < N; i++) {
				if(i == maxi) {
					System.out.println(A[N - 2]);
				}else {
					System.out.println(A[N - 1]);
				}
			}
		}

	}

}


Measured memory_bytes: 93816
n, x, m = map(int, input().split())
X = [-1] * m
P = []
sum_p = 0
while X[x] == -1: # preset
    X[x] = len(P) # pre length
    P.append(sum_p) # pre sum_p
    sum_p += x # now sum_p
    x = x*x % m
P.append(sum_p) # full sum_p
p_len = len(P) - 1
cyc_times, nxt_len = divmod(n - X[x], p_len - X[x])
cyc = (sum_p - P[X[x]]) * cyc_times
remain = P[X[x] + nxt_len]
print(cyc + remain)


Measured memory_bytes: 13708
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


class UnionFind
{
public:
  UnionFind(int n)//0~n-1までitemを初期化
  {
    parent=vector<int>(n,-1);//親なら-size
  }
  int root(int a)
  {
    if(parent[a]<0)return a;
    return parent[a]=root(parent[a]);
  }
  int size(int a)
  {
    return -parent[root(a)];
  }
  bool connect(int a,int b)
  {
    int A=root(a);
    int B=root(b);
    if(A==B)return false;
    if(size(A)>size(B))swap(A,B);
    parent[B]+=parent[A];
    parent[A]=B;
    return true;
  }
private:
  vector<int> parent;

};
struct edge
{
  int to;
  int from;
  int cost;
};
struct city
{
  int num;
  int x;
  int y;
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  int n;
  cin>>n;
  UnionFind uni(n+1);
  vector<city> town(n);
  rep(i,n)
  {
    city nc;
    nc.num=i+1;
    cin>>nc.x>>nc.y;
    town[i]=nc;
  }
  sort(all(town),[](city a,city b){return a.x<b.x;});
  vector<edge> edges;
  rep(i,n-1)
  {
    edge ne;
    ne.cost=town[i+1].x-town[i].x;
    ne.to=town[i+1].num;
    ne.from=town[i].num;

    edges.push_back(ne);

  }
  sort(all(town),[](city a,city b){return a.y<b.y;});
  rep(i,n-1)
  {
    edge ne;
    ne.cost=town[i+1].y-town[i].y;
    ne.to=town[i+1].num;
    ne.from=town[i].num;

    edges.push_back(ne);

  }
  sort(all(edges),[](edge a,edge b){return a.cost<b.cost;});
  int res=0;
  rep(i,edges.size())
  {
    if(uni.root(edges[i].to)==uni.root(edges[i].from))continue;
    uni.connect(edges[i].to,edges[i].from);
    res+=edges[i].cost;
  }
  cout<<res<<endl;
  return 0;

}


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

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int main()
{
    int n, a, b;
    cin >> n;
    cin >> a;
    for (int i = 1; i < n; i++)
    {
        cin >> b;
        a = gcd(a, b);
    }
    cout << a << endl;

    return 0;
}

Measured memory_bytes: 3580
import bisect,sys
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac =fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % mod) % mod
        
    return CONV()



sys.setrecursionlimit(200005)

def main():
    X,Y,Z = isRaw()
    ans = " ".join([str(a) for a in [Z,X,Y]])
    return ans

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 38384
H, W = [int(i) for i in input().split()]
s = [list(input()) for _ in range(H)]

answer = True
for i in range(H):
  for j in range(W):
    if s[i][j] == '#':
      count = 0
      if i != 0 and s[i - 1][j] == '.':
        count += 1
      if i != H - 1 and s[i + 1][j] == '.':
        count += 1
      if j != 0 and s[i][j - 1] == '.':
        count += 1
      if j != W - 1 and s[i][j + 1] == '.':
        count += 1
      if count == 4:
        answer = False

if answer:
  print('Yes')
else: 
  print('No')



Measured memory_bytes: 3064
function Main (K) {
  K = parseInt(K.split("\n")[0], 10);
  console.log([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1,
               2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2,
               5, 4, 1, 4, 1, 51][K-1]);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22204
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>
 
using namespace std;
 
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"
 
typedef long long int  ll;
 
 
int main()
{
	FAST;
	int n;
	cin >> n;
	int arr[100005];
 
	for(int i=1 ; i<=n ; i++)
		cin >> arr[i];
 
 
	int count = 0;
	int current = 1;
	while(count < n)
	{
		current = arr[current];
		if(current == 2)
		{
			cout << count+1;
			return 0;
		} 
		count++;
	}
	cout << "-1";
	return 0;
}

Measured memory_bytes: 640
N = int(input())

p = [0]*10**6
for i in range(2, 10**6):
    if p[i] == 0:
        p[i] = 1
        j = 2
        while i*j < 10**6:
            p[i*j] = -1
            j += 1

ans = 0
for i in range(10**6):
    if p[i] < 1:
        continue
    j = 1
    while N%pow(i, j) == 0:
        N //= pow(i, j)
        j += 1
        ans += 1

for i in range(10**6):
    if p[i] < 1:
        continue
    while N%i == 0:
        N //= i
    
if N > 10**6:
    i = 2
    f = True
    while i <= N**0.5:
        if N%i == 0:
            f = False
            break
        i += 1
    if f:
        ans += 1

print(ans)

Measured memory_bytes: 16796
#include<algorithm>
#include<iostream>
using namespace std;
bool cmp(int x,int y)
{
    return x>y;
}
int a[101];
int main()
{
    int n,ans1=0,ans2=0;
    cin>>n;
    for(int i=1;i<=n;i++)
		cin>>a[i];
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++)
	{
        if(i%2!=0) ans1+=a[i];
        if(i%2==0) ans2+=a[i];
    }
    cout<<ans1-ans2;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;


int main(){
    ll n,m;
    cin >> n >> m;
    ll h[n] = {};
    vector<ll> elist[n];
    bool memo[n] = {false};
    rep(i,0,n) cin >> h[i];
    rep(i,0,m){
        ll a,b;
        cin >> a >> b;
        if(h[a-1] <= h[b-1]) elist[a-1].push_back(b-1);
        if(h[a-1] >= h[b-1]) elist[b-1].push_back(a-1);
    }

    ll ans = 0;
    rep(i,0,n){
        if((ll)elist[i].size() == 0) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8828
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll h,w;
    cin>>h>>w;
    ll num;
    ll a[h][w];
    string s[h];
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    ll dx[8]={-1,-1,-1,0,0,1,1,1};
    ll dy[8]={-1,0,1,-1,1,-1,0,1};
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            num=0;
            for(int k=0;k<8;k++){
                ll x=j+dx[k];
                ll y=i+dy[k];
                if(x>=0&&x<w&&y>=0&&y<h){
                    if(s[y][x]=='#')num++;
                }
            }
            a[i][j]=num;
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                cout << "#";
            }else{
                cout<<a[i][j];
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int w, h, x, y;
  cin >> w >> h >> x >> y;

  double ans = (double)w * h / 2.0;
  if ((double)x == w / 2.0 && (double)y == h / 2.0) {
    cout << ans << " " << 1 << endl;
  } else {
    cout << ans << " " << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 256