akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    string S,f,b;
    int Q,flag=0;
    cin >> S >> Q;
    for(int i=0;i<Q;i++){
        int T,F;
        char C;
        cin >> T;
        if(T==2){
            cin >> F >> C;
            if(flag%2==0){
                if(F==1){
                    f=C+f;
                }
                else{
                    b=b+C;
                }
            }
            else{
                if(F==1){
                    b=b+C;
                }
                else{
                    f=C+f;
                }
            }
        }
        else{
            flag++;
        }
    }
    if(flag%2==1){
        if(f.size()!=0) reverse(f.begin(),f.end());
        if(b.size()!=0) reverse(b.begin(),b.end());
        reverse(S.begin(),S.end());
        S=b+S+f;
    }
    else{
        S=f+S+b;
    }
    cout << S << endl;
}

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

int main() {
  int a;
  cin>>a;
  map<string,int> memo;
  for(int i=0;i<a;i++){
  	string s;
    cin>>s;
    memo[s] +=1;
  }
  
  int max;
  for(const auto& x : memo){
  	int v = x.second;
    if(v>max)max=v;
  }
  for(auto it = memo.begin();it!=memo.end();it++){
  	if(it->second == max){
    	cout<<it->first<<endl;
    }
  }
   return 0;
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

const int MAX_N = 12345678;
bool flag[MAX_N+1];
int prime[MAX_N+1];
int N, P;

int getPrime(int MAX_N = MAX_N, bool* flag = flag, int* prime = prime)
{
  int ptr = 0;
  prime[ptr++] = 2;
  flag[1] = true;
  for(int i=4; i<=MAX_N; i+=2) flag[i] = true;
  for(int i=3; i<=MAX_N; i+=2){
    if(!flag[i]){
      prime[ptr++] = i;
      for(int j=2*i; j<=MAX_N; j+=i) flag[j] = true;
    }
  }
  return ptr;
}


int main()
{
  int ptr = getPrime();

  while((cin >> N >> P) && N >= 0){
    int s = upper_bound(prime, prime + ptr, N) - prime;
    vi can;
    erep(i, 0, P) erep(j, i, P) can.pb(prime[s + i] + prime[s + j]);
    sort(ALL(can));
    cout << can[P - 1] << endl;
  }

  return 0;
}

Measured memory_bytes: 18548
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <queue>

#define ll long long
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){ return (a % b)? gcd(b, a%b) : b; }
template<typename T> T lcm(T a, T b){ return a * b / gcd(a, b); }

ll f(int d, pair<ll, ll> x){
    if(d == 0) return x.first - x.second;
    return x.first + x.second;
}

int main(void){
    int n;
    cin >> n;
    pair<ll, ll> r[n];
    REP(i,n){
        cin >> r[i].first >> r[i].second;
    }

    ll ans = -1;
    REP(d,2){
        ll M = f(d, r[0]), m = f(d, r[0]);
        REP(i,n){
            M = max(f(d, r[i]), M);
            m = min(f(d, r[i]), m);
        }
        ans = max(ans, M-m);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 6696
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll c[30],s[370][30];
int a[370],last[30];

unsigned seed=chrono::steady_clock::now().time_since_epoch().count();
mt19937 rng(seed);

ll f(int d)
{
    ll x=0;
    memset(last,-1,sizeof(last));
    for(int i=0;i<d;i++){
        x+=s[i][a[i]];
        last[a[i]]=i;
        for(int j=0;j<26;j++){
            x-=c[a[j]]*(ll)(i-last[a[j]]);
        }
    }
    return x;
}

int main()
{
    auto start=chrono::high_resolution_clock::now();
    ll x=LLONG_MIN,sc=0;
    int d,ans[370];
    scanf("%d",&d);
    for(int i=0;i<26;i++){
        scanf("%lld",&c[i]);
        sc+=c[i];
    }
    for(int i=0;i<d;i++){
        for(int j=0;j<26;j++){
            scanf("%lld",&s[i][j]);
        }
    }
    if(sc==0){
        for(int i=0;i<d;i++){
            int mx=-1,j=-1;
            for(int k=0;k<26;k++){
                if(s[i][k]>mx) mx=s[i][k],j=k;
            }
            printf("%d\n",j+1);
        }
        return 0;
    }
    while(true){
        for(int i=0;i<d;i++) a[i]=rng()%26;
        ll y=f(d);
        if(y>x) copy(a,a+d,ans),x=y;
        auto stop=chrono::high_resolution_clock::now();
        int duration=chrono::duration_cast<chrono::microseconds>(stop-start).count();
        if(2000000-duration<100000) break;
    }
    for(int i=0;i<d;i++){
        printf("%d\n",ans[i]+1);
    }
    return 0;
}

Measured memory_bytes: 3952
import java.util.Scanner;
import java.util.Arrays;
class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for (int i=0; i<3; i++) {
        	  a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        System.out.println(a[0]+" "+a[1]+" "+a[2]);
    }
}


Measured memory_bytes: 26268
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
// #define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;
ll dp[100005][13];

signed main(void) {
	ll N, M;
	cin >> N >> M;
	vector<vector<double> > A;
	vector<double> tmpA;
	rep(i, N) {
		double tmp;
		cin >> tmp;
		tmpA.pb(tmp);
	}
	A.pb(tmpA);

	sort(A[0].begin(), A[0].end(), greater<double>() );
	// vector<float> R;
	rep(i, M) {
		double maxValue = 0;
		ll maxIndex = 0;
		rep(i, A.size()) {
			if (A[i].size() > 0) {
				if (A[i][0] > maxValue) {
					maxValue = A[i][0];
					maxIndex = i;
				}
			}
		}

		if (maxValue == 0) {
			break;
		}

		ERASE(A[maxIndex], 0);

		maxValue = maxValue/2;
		ll maxtmp = maxValue;
		if(maxtmp == 0) {
			maxValue = 0;
		}

		if (maxIndex == A.size()-1) {
			vector<double> tmpA_;
			tmpA_.pb(maxValue);
			A.pb(tmpA_);
		} else {
			A[maxIndex+1].pb(maxValue);
		}

	}

	ll ans = 0;

	rep(i, A.size()) {
		rep(j, A[i].size()) {
			ll tmp = A[i][j];
			ans += tmp;
		}
	}

	cout << ans << endl;
}


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


int main() {
  string s;
  cin >> s;
  deque<int>a;
  rep(i,s.size()){
    if(s.at(i)=='0'){
      a.push_back(0);
    }
    if(s.at(i)=='1'){
      a.push_back(1);
    }
    if(s.at(i)=='B'){
      if(!a.empty()){
        a.pop_back();
      }
    }
  }
  while(!a.empty()){
    cout<<a.front();
    a.pop_front();
  }
 
}



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

using namespace std;

#define scnaf scanf
#define sacnf scanf
#define sancf scanf

#define ln '\n'
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define MP(a,b) make_pair((a),(b))
#define PB(a) push_back((a))
#define P(p) cout << (p) << endl;
#define S(s) cin >> (s);
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

#define reps(i,a,b) for(int (i)=(a); (i)<(b); ++(i))
#define rep(i,n) reps(i,0,(n))
#define rreps(i,a,b) for(int (i)=(a); (i)>=(b); --(i))
#define rrep(i,n) reprt(i,n,0)

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;
const double EPS = 1e-9;
const double PI  = acos(-1.0);

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

void Yes(bool f) {if(f){P("Yes");}else{P("No")}}
void yES(bool f) {if(f){P("yES");}else{P("nO")}}
void Yay(bool f) {if(f){P("Yay!");}else{P(":(")}}

/*********TEMPLATE**********/

ll N;
ll A[234567],A_S[234567];

void init() {

  S(N);
  rep(i,N) scnaf("%lld",A+i);
  rep(i,N) A_S[i+1]=A_S[i]+A[i];

}

signed main() {

  init();

  map<ll,ll> mp;
  rep(i,N+1) {
    ll v = A_S[i];
    if (mp.count(v)==0) {
      mp[v] = 1;
    } else {
      ++mp[v];
    }
  }

  ll ans = 0;
  for(auto i=mp.begin(); i!=mp.end(); ++i) {
    ll q = i->second;
    //P(i->first);P(q);P(-1);
    if (q > 1) {
      ans += q * (q-1) / 2;
    }
  }
  P(ans);

}


Measured memory_bytes: 15872
m, k = map(int, input().split())

if m == 1:
    if k == 0:
        print(*[0, 0, 1, 1])
    else:
        print(-1)
    exit()

n = 2 ** m
if k >= n:
    print(-1)
    exit()

ans = [0] * (n * 2)
i = 1
for v in range(n):
    if v == k:
        ans[0] = ans[n] = v
        continue
    ans[i] = ans[2 * n - i] = v
    i += 1
print(*ans)


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

int main() {

  int N,K,S;
  
  S=0;
  
  cin >> N >> K;
  
  vector<int> p(N); 

   for (int i=0; i<N; i++) {
    cin >> p.at(i);
  }

  sort(p.begin(), p.end());
  
  for (int i=0; i<K; i++) {
     S = p.at(i) + S;
  }
  cout << S << endl;
}


Measured memory_bytes: 3628
package main

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

const (
  InputSize = 500000 // 10^5
)
var (
  rdr = bufio.NewReaderSize(os.Stdin, InputSize)
)

func readLine() string {
  buf := make([]byte, 0, InputSize)
  for {
    l, p, e := rdr.ReadLine()
    if e != nil {
      panic(e)
    }
    buf = append(buf, l...)
    if !p {
      break
    }
  }
  return string(buf)
}


func getStringArray() []string {
  return strings.Split(readLine(), " ")
}


func nextLineValue() int {
  v, _ := strconv.Atoi(readLine())
  return v
}

func nextLineValues() []int {
  return getIntArray(readLine())
}

func getInt(s string) int {
  v, _ := strconv.Atoi(s)
  return v
}

func getIntArray(s string) []int {
  var v []int
  valstr := strings.Split(s, " ")
  for _, c := range valstr {
    va, _ := strconv.Atoi(c)
    v = append(v, va)
  }
  return v
}

func digitTotal(v int) int {
  total := 0
  d := strings.Split(strconv.Itoa(v), "")
  for _, c := range d {
    dv, _ := strconv.Atoi(c)
    total += dv
  }
  return total
}

func sortDesc(v *[]int) {
  sort.Sort(sort.Reverse(sort.IntSlice(*v)))
}

func removeDupIntSlice(values *[]int) []int {
  m := make(map[int]bool)
  uniq := []int{}
  for _, v := range *values {
    if !m[v] {
      uniq = append(uniq, v)
      m[v] = true
    }
  }
  return uniq
}

func removeDupStringSlice(values *[]string) []string {
  m := make(map[string]bool)
  uniq := []string{}
  for _, v := range *values {
    if !m[v] {
      uniq = append(uniq, v)
      m[v] = true
    }
  }
  return uniq
}

func countUniqIntInSlice(values *[]int) map[int]int {
  uniq := make(map[int]int)
  for _, v := range *values {
    if _, ok := uniq[v]; !ok {
      uniq[v] = 1
    } else {
      uniq[v] += 1
    }
  }
  return uniq
}

func countUniqStringInSlice(values *[]string) map[string]int {
  uniq := make(map[string]int)
  for _, v := range *values {
    if _, ok := uniq[v]; !ok {
      uniq[v] = 1
    } else {
      uniq[v] += 1
    }
  }
  return uniq
}


func main() {
  strings := strings.Split(readLine(), "")
  res := removeDupStringSlice(&strings)
  if len(res) == 2 {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}


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

#define rep(i,n) for(ll i = 0; i < (n); i++)
#define REP(i,n) for(ll i = 1; i < (n); i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1) / (b);}


signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
  else cout << "No" << 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;
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 3 && i % 5) ans += i;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3608
# 入力
N, M, Q = map(int, input().split())
a = [0] * Q
b = [0] * Q
c = [0] * Q
d = [0] * Q
for i in range(Q):
    a[i], b[i], c[i], d[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1

# スコア計算
def score(A):
    tmp = 0
    for ai, bi, ci, di in zip(a, b, c, d):
        if A[bi] - A[ai] == ci:
            tmp += di
    return tmp

# DFS
def dfs(A):
    if len(A) == N:
        return score(A) # 数列 A のスコアを返す
    res = 0
    prev_last = A[-1] if len(A) > 0 else 0
    for v in range(prev_last, M):
        A.append(v)
        res = max(res, dfs(A)) # 再帰呼出しながら、スコア最大値も更新
        A.pop()
    return res

# 求める
print(dfs([]))

Measured memory_bytes: 9164
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;i--)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);i--)
#define rep0(i,n) for(i=0;i<(n);++i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

Int a[1000000];

Int gcd(Int x,Int y){
	if(x<y)return gcd(y,x);
	if(y==0)return x;
	return gcd(y,x%y);
}

Int sqrt(Int x,Int m,Int n){
	if(m+1==n)return m;
	Int l=(m+n)/2;
	if(x>=l*l)return sqrt(x,l,n);
	else return sqrt(x,m,l);
}

int main() {
	int n;
	IL{
		cin>>n;
		if(n==0)break;
		n=n*(n+1)/2;
		rep(i,n)cin>>a[i];
		sort(a,a+n);
		Int x=-1,y=-1,z=-1;
		rep(i,n){
			if(a[i]%2==0){
				if(x<0)x=a[i];
				else if(y<0)y=a[i];
			}else if(z<0){
				z=a[i];
			}
		}
//cout<<x<<" "<<y<<" "<<z<<endl;
		Int g=gcd(x,z);
		x/=g;
		z/=g;
		y/=z;
		Int w=x*y;
		w=sqrt(w,0,1LL<<31);
		cout<<w<<endl;
		bool first=true;
		rep(i,n){
			if(a[i]%2==0){
				if(!first)cout<<" ";
				first=false;
				cout<<a[i]/w;
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1120
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>

using namespace std;
using ll = long long int;

int main()
{
  int n, k;
  cin >> n >> k;
  int count = 0;
  for(int i = 0; i < n; i++)
  {
    if(n - i >= k) count++;
  }
  cout << count << endl;
}


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

bool judgePalindromic( int n )
{
    string s = "";
    while( n )
    {
        s += ( n % 10 ) + '0';
        n /= 10;
    }
    int size = s.size();
    if( size == 1 || size == 2 && s[0] == s[1] || size == 3 && s[0] == s[2] || size == 4 && s[0] == s[3] && s[1] == s[2] )
        return true;
    else
        return false;
}

int main()
{
    int n;

    cin >> n;

    if( judgePalindromic(n) )
    {
        cout << n << endl;
        return 0;
    }

    int a = n - 1, b = n + 1;
    while(1)
    {
        if( judgePalindromic(a) )
        {
            cout << a << endl;
            break;
        }
        if( judgePalindromic(b) )
        {
            cout << b << endl;
            break;
        }
        a--;
        b++;
    }

    return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;cin>>S;
  for(int i=0;i<S.size();){
    int x=i;
    while(S.at(i+1)=='R'){
      cout<<"0 ";
      i++;
    }
    int y=i;
    while(i<S.size()-1&&S.at(i+1)=='L')i++;
    cout<<(y-x+2)/2+(i-y)/2<<" "<<(y-x+1)/2+(i-y+1)/2;
    for(y+=2;y<=i;y++)cout<<" 0";
    if(i!=S.size()-1)cout<<" ";
    i++;
  }
  cout<<endl;
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    string s;
    cin >> s;
    char c = s[0];
    if(s[1] == c && s[2] == c){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
// How Many Divisors?
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_3_D
//
// Accepted

use std::io::{Read, stdin};

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    let mut buf = String::new();
    stdin.read_to_string(&mut buf).unwrap();

    let mut data = buf.split_whitespace();

    let a: i32 = data.next().unwrap().parse().unwrap();
    let b: i32 = data.next().unwrap().parse().unwrap();
    let c: i32 = data.next().unwrap().parse().unwrap();

    let mut counter = 0;

    for i in a..(b + 1) {
        if c % i == 0 {
            counter += 1;
        }
    }

    println!("{}", counter);
}


Measured memory_bytes: 5024
input = __import__('sys').stdin.readline
W, H, N = map(int, input().split())
l = [[False]*W for _ in range(H)]
area = 0

for i in range(N):
    x, y, a = map(int, input().split())
    
    if a == 1:
        for i in range(H):
            for j in range(x):
                l[i][j] = True
    elif a == 2:
        for i in range(H):
            for j in range(x, W):
                l[i][j] = True
    elif a == 3:
        for i in range(y):
            for j in range(W):
                l[i][j] = True
    else:
        for i in range(y, H):
            for j in range(W):
                l[i][j] = True

for i in l:
    for j in i:
        if not j:
            area += 1

print(area)

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

int n;
int A[20];


bool solve(int i, int m){
    if (m == 0) return true;
    if (i >= n) return false;
    bool res = solve(i+1, m) || solve(i+1, m-A[i]);
    return res;
}


int main(){
    cin >> n;
    for (int i = 0; i < n; ++i){
        cin >> A[i];
    }
    int q;
    cin >> q;
    int m;
    for (int i = 0; i < q; ++i){
        cin >> m;
        if (solve(0,m)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}


Measured memory_bytes: 3112
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int a[4];
bool vis[4];
int ans = 0x3f3f3f3f;
int abs(int x) {return x>0?x:-x;}
void dfs(int pos, int lst, int sum) {
	if(pos == 4) {
		ans = min(ans, sum);
	}
	if(pos == 1) {
		for(int i=1;i<=3;i++) {
			vis[i]=1;
			dfs(2, a[i], 0);
			vis[i]=0;
		}
	}
	else {
		for(int i=1;i<=3;i++) {
			if(!vis[i]) {
				vis[i] = 1;
				dfs(pos+1, a[i], sum + abs(lst-a[i]));
				vis[i] = 0;
			}
		}
	}
}
int main() {
	for(int i=1;i<=3;i++) cin>>a[i];
	dfs(1, 0, 0);
	printf("%d\n", ans);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        int n = sc.nextInt();

        int ans = 0;

        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
           if ((i + 1) % 2 == 1 && a % 2 == 1) ans++;
        }

        System.out.println(ans);

        sc.close();

    }

}

Measured memory_bytes: 35636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <iomanip>
#include <queue>

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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s-1);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int dir[5] = {1,0,-1,0,1};
int main() {
    int h, w; cin >> h >> w;
    string s[h];
    REP(i, h) cin >> s[i];

    int cnt = 0;
    REP(i, h) REP(j,w) {
        if (s[i][j] == '.') cnt++;
    }

    queue<ii> queue;
    queue.push(make_pair(0, 0));
    int len[h][w];
    fill(len[0], len[h], -1);
    len[0][0] = 0;

    while (!queue.empty()) {
        int y = queue.front().first,
            x = queue.front().second;
        queue.pop();

        REP(i, 4) {
            int Y = y + dir[i],
                X = x + dir[i+1];

            if (Y < 0 || Y >= h || X < 0 || X >= w) continue;
            if (s[Y][X] == '#') continue;
            if (len[Y][X] != -1) continue;
            queue.push(make_pair(Y,X));
            len[Y][X] = len[y][x] + 1;
            if (Y == h-1 && X ==w-1) {
                cout << (cnt - len[Y][X] - 1) << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//符号反転
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(int n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
    fac[0] = fac[1] = 1;
    for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
    finv[MAX-1]=fac[MAX-1].inv();
    for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
    for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*finv[k];
}
// 二項係数計算
mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
int main(){
    int n;
    cin>>n;
    V<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    multiset<int> s;
    mint ans=1;
   for(int i=0;i<3;i++)s.insert(0);
    for(int i=0;i<n;i++){
        int t=s.count(a[i]);
        if(t==0||t>3){
            cout<<0<<endl;
            return 0;
        }
       s.erase(s.find(a[i]));s.insert(a[i]+1);
        ans*=mint(t);
    }
    cout<<ans<<endl;
}



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

#define rep(i, n)     for (int i = 0; i < n; ++i)
#define rep1(i, n)    for (int i = 1; i < n + 1; ++i)
#define repN(i, m, n) for (int i = m; i < n; ++i)
#define repR(i, n)    for (int i = n - 1; i >= 0; --i)

using namespace std;

int main() {
	int d, t, s;
	cin >> d >> t >> s;
	
	if (d <= t * s) {
		cout << "Yes";
	} else {
		cout << "No";
	}

	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
      string a,b;
      int ctn=0;
      cin>>a;
      while(cin>>b&&b!="END_OF_TEXT"){
            transform(b.begin(),b.end(),b.begin(),::tolower);
            if(a==b)ctn++;
      }
      cout<<ctn<<endl;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int n,m;
    cin >> n >> m;
    if(abs(n-m)>1){
        COUT(0);
        return 0;
    }
    ll ans=1;
    if(n==m)ans*=2;
    while(n!=0){
        ans*=n;
        n--;
        if(ans>MOD)ans%=MOD;
    }
    while(m!=0){
        ans*=m;
        m--;
        if(ans>MOD)ans%=MOD;
    }
    COUT(ans);
    return 0;
} 


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

int main() {
	uint64_t n, b;
	double root;
	uint64_t divisor=1;

	cin >> n;
	root = sqrt(n);

	for (int i = 1; i <= root; i++) {
		if (n % i == 0) { divisor = i; }
	}

	b = n / divisor;

	int count = 1;
	while (b / 10 != 0) {
		b /= 10;
		count++;
	}
	cout << count << endl;

}


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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;
//const int MOD = (int) 1e9 + 7;
const int MOD = (int) 998244353;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1e6 + 20;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL MOD)
{
    if(n < 0) a = fp(a, MOD - 2, MOD), n = -n;
    LL res = 1; for(; n; n >>= 1, a = a * a % MOD) if(n & 1) res = res * a % MOD; return res;
}

void work()
{
    string s;
    cin >>s;
    if(s[2] == s[3] && s[4] == s[5]) cout <<"Yes";
    else cout <<"No";
}


int main(int argc, char **argv)
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
//    pre();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


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

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

	cin >> s >> t;

	int ans = INT_MAX;
	for (int i = 0; i <= s.size() - t.size(); i++) {
		int cost = 0;
		for (int j = 0; j < t.size(); j++) {
			if (s[i + j] == t[j]) continue;
			cost += 1;
		}
		ans = min(ans, cost);
	}

	cout << ans << '\n';

	return 0;
}


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

int main(){
  int N;
  int ac=0;
  int wa=0;
  int tle=0;
  int re=0;
  cin >> N;
  vector<string> S(N);
  for(int i=0;i<N;i++){
    cin >> S.at(i);
  }
  for(int i=0;i<N;i++){
    if(S.at(i)=="AC"){
      ac++;
    }
    else if(S.at(i)=="WA"){
      wa++;
    }
    else if(S.at(i)=="TLE"){
      tle++;
    }
    else if(S.at(i)=="RE"){
      re++;
    }
  }
  cout << "AC x " << ac <<endl;
  cout << "WA x " << wa <<endl;
  cout << "TLE x " << tle <<endl;
  cout << "RE x " << re <<endl;
}

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

using namespace std;

struct Panel;

struct Panel {
    string name;
    int x1, y1, x2, y2;
    vector<Panel> child;
    
    Panel(){}    
    Panel(string name, int x1, int y1, int x2, int y2) :
        name(name), x1(x1), y1(y1), x2(x2), y2(y2) {}
};

string s;
int idx;

string get_name()
{
    string name;
    ++idx;
    while (s[idx] != '>') {
        name += s[idx];
        ++idx;
    }
    ++idx;
    return name;
}

int s2i(string &str)
{
    stringstream ss(str);
    int num;
    ss >> num;
    return num;
}

int get_val()
{
    string val;
    while (isdigit(s[idx])) {
        val += s[idx];
        ++idx;
    }
    return s2i(val);
}

void parse(Panel &p)
{
    while (s[idx] == '<' && s[idx+1] != '/') {
        string name = get_name();
        int x1 = get_val(); ++idx;
        int y1 = get_val(); ++idx;
        int x2 = get_val(); ++idx;
        int y2 = get_val();
        Panel panel(name, x1, y1, x2, y2);
        parse(panel);
        p.child.push_back(panel);
        while (s[idx] != '>') {
            idx++;
        }
        idx++;
    }    
}

bool get_panel(int x, int y, const Panel &p)
{
    for (int i = 0; i < (int)p.child.size(); i++) {
        Panel np = p.child[i];
        if (np.x1 <= x && x <= np.x2 && np.y1 <= y && y <= np.y2) {
            if (!get_panel(x, y, np)) {
                cout << np.name << " " << np.child.size() << endl;
            }
            return 1;
        }
    }
    return 0;
}

int main()
{
    int n, x, y;
    while (cin >> n >> s, n) {
        Panel p;
        p.name = "#"; p.x1 = p.y1 = -1; p.x2 = p.y2 = 10001;
        idx = 0;
        parse(p);
        for (int i = 0; i < n; i++) {
            cin >> x >> y;
            if (!get_panel(x, y, p)) {
                cout << "OUT OF MAIN PANEL 1" << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    S = readline().strip()

    dp = [0] * (N + 1)
    ans = 0

    for i in range(N - 1, -1, -1):
        for j in range(i + 1, N):
            dp[j] = dp[j + 1] + 1 if S[i] == S[j] else 0
            if ans < min(dp[j], j - i):
                ans = min(dp[j], j - i)

    print(ans)
    return


if __name__ == '__main__':
    main()


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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define INF 1e9  //
#define INFLL 4e18  //
#define MOD (1e9)+7
#define MP make_pair
#define PB(a) push_back(a)
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

// a 0x61  z 0x7a  0 0x30

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

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

    int abc[26] = {};

    rep(i, w.length()) {
        abc[(int) (w[i] - 'a')]++;
    }

    bool beautiful = true;

    rep(i, 26) {
        if (abc[i] % 2 == 1) {
            beautiful = false;
            break;
        }
    }

    Yes(beautiful);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    int a, b, c, d, e, f;
    cin>>a>>b>>c>>d>>e>>f;

    int anstotal = 0;
    int anssugar = 0;
    double ansconc = 0;
    double tempconc = 0;
    double maxconc = 100.0 * double(e) / (100.0 + double(e));

    bool ansflag = false;
    for(int i=0; i*100*a <= f; i++){
        for(int j=0; j*100*b + i*100*a <= f; j++){
            if(i == 0 && j == 0) continue;

            int mwater = j*100*b + i*100*a;

            for(int ic = 0; mwater+ic*c <= f; ic++){
                for(int id = 0; mwater+ic*c+id*d <= f; id++){

                    int msugar = ic*c + id*d;
                    tempconc = 100.0*msugar / double(mwater + msugar);

                    if(ansconc < tempconc && tempconc <= maxconc){
                        ansconc = tempconc;
                        anstotal = mwater + msugar;
                        anssugar = msugar;
                        ansflag = true;
                    }
                }
            }
        }
    }

    if(ansflag) cout << anstotal << " " << anssugar;
    else cout << 100*a << " " << 0;

    return 0;
}

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

using namespace std;
typedef long long ll;
int main() {
  ll N, H;
  cin >> N >> H;

  vector<int> b(N);
  int maxa = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a >> b[i];
    maxa = max(maxa, a);
  }
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (maxa < b[i]) {
      H -= b[i];
      cnt++;
      if (H <= 0) {
        cout << cnt << endl;
        return 0;
      }
    }
  }

  cnt += H / maxa;
  if (H % maxa) {
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        String s = sc.next();
        if (s.length() <= k) {
            System.out.println(s);
        } else {
            int sub = k - s.length();
            System.out.print(s.substring(0, k));
            System.out.println("...");
        }
    }
}

Measured memory_bytes: 35748
import java.util.*;
import java.lang.*;
import java.io.*;

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

        int sum = 0;
        int bn = 1;
        
        for(int i = 0; i<N; i++){
            L[i]= sc.nextInt();       
        }

        for(int j = 0; j<N; j++){
            sum += L[j];

            if(sum <= X){
                bn++;
            }
                
        }

        System.out.println(bn);

    }
}


Measured memory_bytes: 22740
n = list(input())
flag = 0
dict = {}
for i in n:
    if i in dict:
        dict[i] += 1
    else:
        dict[i] = 1
 
for key,val in dict.items():
    if val != 2:
        flag = 1
 
if flag:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void){
    int N,M; 
    cin>>N>>M; 
    vector<int> oks(N+1,true);
    for(int i=0;i<M;i++){
        int a;
        cin>>a;
        oks[a]=false;
    }
    
    vector<ll> dp(N+1);
    dp[0]=1;
    for(int now=0;now<N;now++){
        for(int next=now+1;next<=min(N,now+2);next++){
            if(oks[next]){
                dp[next]+=dp[now];
                dp[next]%=MOD;
            }
        }
    }
    cout<<dp[N]<<endl;
}

Measured memory_bytes: 1408
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fail {puts("NO");return 0;}
#define suc {puts("YES");return 0;}
using namespace std;
int a,b,c;
char ch[100010];

int main()
{
	scanf("%s",ch);int n=strlen(ch);
	for(int i=0;i<n;i++)
		if(ch[i]=='a')
			a++;
		else if(ch[i]=='b')
			b++;
		else if(ch[i]=='c')
			c++;
	int mn=min(a,min(b,c));
	a-=mn;b-=mn;c-=mn;
	if(a<2&&b<2&&c<2)
		suc
	else
		fail
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n;
    cin >> n;
    // vector<string> vecString(n+1);
    map<string, int> mapCnt;
    long res = 0;
    for(long i = 0; i<n; i++){
        string tempString;
        cin >> tempString;
        sort(tempString.begin(), tempString.end());
        res += mapCnt[tempString];
        mapCnt[tempString]++;
        //cout << vecString[i] << endl;
    }

    cout << res << endl;
    


    return 0;
}


Measured memory_bytes: 11136
#n=int(input())
x,y=map(str,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
l=list('ABCDEF')
xind=l.index(x)
yind=l.index(y)
if xind < yind :
    print('<')
elif xind > yind :
    print('>')
else:
    print('=')



Measured memory_bytes: 9104
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,m,uu,vv,u,pr[100100],vis[100100];
vector<int> ga[100100];
queue<int> q;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>uu>>vv;
		ga[uu].push_back(vv);
		ga[vv].push_back(uu);
	}
	q.push(1);
	vis[1]=true;
	while(q.size()){
		u=q.front();
		q.pop();
		for(int v:ga[u]){
			if(!vis[v]){
				pr[v]=u;
				vis[v]=true;
				q.push(v);
			}
		}
	}
	for(int i=2;i<=n;i++)
		if(!vis[i]){
			cout<<"No"<<endl;
			return 0;
		}
	cout<<"Yes"<<endl;
	for(int i=2;i<=n;i++)
		cout<<pr[i]<<endl;
	cout<<endl;
	return 0;
}


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

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

  int x;
  cin >> x;

  cout << x*x*x << endl;
}



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

int main(){
	int H, W;
	cin >> H >> W;
	for(int i=0; i<W+2; i++){
		cout << '#';
	}
	cout << endl;
	for(int i=0; i<H; i++){
		string S;
		cin >> S;
		cout << "#" + S + "#" << endl;
	}
	for(int i=0; i<W+2; i++){
		cout << '#';
	}	
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        try{
        while(true){

            int H = sc.nextInt();
            int W = sc.nextInt();

            if(H==0&&W==0){
                break;
            }

            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if(i==0||i==H-1||j==0||j==W-1){
                    System.out.print("#");
                }else{
                    System.out.print(".");
                }
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }finally{
        sc.close();
    }
    }
    
}


Measured memory_bytes: 36944
#include <iostream>
#include <stdlib.h>

using namespace std;
//numeric_limits<int>::max()

#define N_MAX 100001
int N, K;
int A[N_MAX];

int main(){
	cin >> N;
	int ans = 0;
	for (int i=0; i<N; i++){
		int tmp;
		cin >> tmp;
		if (tmp > N) ans++;
		else A[tmp]++;
	}
	for (int i=0; i<=N; i++){
		if (A[i] == 0) continue;
		if (A[i] == i) continue;
		ans += A[i] < i ? A[i] : A[i]-i;
	}
	cout << ans <<endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


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

    int x, a, b;
    cin >> x >> a >> b;

    if(a >= b){
        cout << "delicious" << endl;
    }else{
        if(b-a <= x){
            cout << "safe" << endl;
        }else{
            cout << "dangerous" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, m, x[55];
vector<pair<int, int>> v[55];
long long dp[1 << 20];

bool dfs(int a, int b, int c, int d) {
	if (a == c)
		return 1;
	for (auto& i : v[a])
		if (i.first != b && dfs(i.first, a, c, d)) {
			x[i.second] ^= 1 << d;
			return 1;
		}
	return 0;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int ta, tb;
		scanf("%d%d", &ta, &tb);
		v[ta].emplace_back(tb, i);
		v[tb].emplace_back(ta, i);
	}
	scanf("%d", &m);
	for (int i = 0; i < m; i++) {
		int ta, tb;
		scanf("%d%d", &ta, &tb);
		dfs(ta, 0, tb, i);
	}
	dp[0] = 1;
	for (int i = 1; i < n; i++)
		for (int j = (1 << m) - 1; j >= 0; j--)
			dp[j | x[i]] += dp[j];
	printf("%lld\n", dp[(1 << m) - 1]);
}


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

int main(){

    ll n,k;
    cin >> n >> k;
    vector<ll> a(n),f(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        cin >> f[i];
    }

    sort(a.begin(),a.end());
    sort(f.begin(),f.end(),greater<ll>());
    ll ma=0L;
    rep(i,n){
        ma=max(a[i]*f[i],ma);
    }

    ll l=0,r=ma;
    while(l<r){
        ll kt=k;
        ll v=(l+r)/2;
        for(int i=0;i<n;i++){
            if(a[i]*f[i]>v){
                kt-=a[i]-v/f[i];
            }
        }
        //cout <<l<<" "<<r<<" "<<v<<endl;
        if(kt<0){
            l=v+1;
        }else if(kt>=0){
            r=v;
        }
        
    }
    cout << l << endl;

    return 0;
}

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

typedef long long ll;

const int maxN = 1e5 + 5;
int N, mod;
vector<int> adj[maxN];
ll dp[maxN], ans[maxN];

void dfs_one(int u, int p) {
    dp[u] = 1;
    for (int v : adj[u]) {
        if (v == p) {
            continue;
        }
        dfs_one(v, u);
        dp[u] = (dp[u] * dp[v]) % mod;
    }
    dp[u] = (dp[u] + 1) % mod;
}

void dfs_two(int u, int p, ll ways) {
    vector<ll> pref, suff;
    pref.push_back(1);
    for (int v : adj[u]) {
        if (v == p) {
            continue;
        }
        pref.push_back(dp[v]);
        suff.push_back(dp[v]);
    }
    suff.push_back(1);
    for (int i = 1; i < (int) pref.size(); i++) {
        pref[i] = (pref[i] * pref[i - 1]) % mod;
    }
    for (int i = (int) suff.size() - 2; i >= 0; i--) {
        suff[i] = (suff[i] * suff[i + 1]) % mod;
    }
    ans[u] = pref.back() * ways % mod;
    int i = 0;
    for (int v : adj[u]) {
        if (v == p) {
            continue;
        }
        ll new_ways = pref[i] * suff[i + 1] % mod;
        new_ways = new_ways * ways % mod;
        new_ways++;
        new_ways %= mod;
        dfs_two(v, u, new_ways);
        i++;
    }
}

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

    cin >> N >> mod;
    for (int i = 0; i < N - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    dfs_one(0, -1);
    dfs_two(0, -1, 1);
    for (int i = 0; i < N; i++) {
        cout << ans[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 28924
#include <bits/stdc++.h>
using namespace std;
//vector<vector<?v?f???^>> ??????(?v?f??1, vector<?v?f???^>(?v?f??2, ?????l))
int main(){
    int n;
    cin >> n;
    n = n % 10;
    if(n == 3){
        cout << "bon" << endl;
    }else if(n == 0 || n == 1 || n == 6 || n == 8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3632
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int l = Integer.parseInt(sc.next());

    if(l<0 && n+l-1<0){
      System.out.println((2*l+n-2)*(n-1)/2);
    }else if(l>0){
      System.out.println((2*l+n)*(n-1)/2);
    }else{
      System.out.println((2*l+n-1)*n/2);
    }

  }
}

Measured memory_bytes: 21844
#include <stdio.h>
#define INFTY 2000000000
void merge(int*, int, int, int);
void mergeSort(int*, int, int);
int L[250002],R[250002];
int count;
 
int main(){
  int A[500000],n;
  int i;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }
  mergeSort(A,0,n);
 
  for(i = 0; i < n-1; i++){
    printf("%d ",A[i]);
  }
  printf("%d\n%d\n",A[i],count);
  return 0;
}
 
void merge(int* A, int left,int mid, int right){
  int n1,n2;
  int i,j,k;
  n1 = mid - left;
  n2 = right - mid;
 
  for(i = 0; i < n1; i++){
    L[i] = A[left + i];
  }
  for(i = 0; i < n2; i++){
    R[i] = A[mid + i];
  }
  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0; 
  j = 0;
  for(k = left; k < right; k++){
    count++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else{
      A[k] = R[j];
      j = j + 1;
    }
  }
}
 
void mergeSort(int* A, int left, int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

 
 



Measured memory_bytes: 5628
#include <stdio.h>
#include <string.h>
int main(void)
{
  int a=0;int b=0;
  char x[2000000];
  char y[2000000];
  scanf("%s",x);
  scanf("%s",y);
  for(a=0;a<strlen(x);a++){
    if(x[a]!=y[a]){
      b++;
    }
  }
  printf("%d\n",b);
  return 0;
}

Measured memory_bytes: 2108