akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

const int MAX_S = 101;

char s[3][MAX_S];

int main(){

  for(int i = 0; i < 3; i++)
    scanf("%s", s[i]);


  char card = s[0][0];
  char ans[2];
  int a = 1, b = 0, c = 0;
  while(1){

    if(card == 'a'){
      if(s[0][a] == 0){
        ans[0] = 'A';
        ans[1] = '\0';
        break;
      }
      card = s[0][a];
      a++;
    
    }
    if(card == 'b'){
      if(s[1][b] == 0){
        ans[0] = 'B';
        ans[1] = '\0';
        break;
      }
      card = s[1][b];
      b++;
    }
    if(card == 'c'){
      if(s[2][c] == 0){
        ans[0] = 'C';
        ans[1] = '\0';
        break;
      }
      card = s[2][c];
      c++;
    }
  }

  printf("%s", ans);

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    while(cin>>n){
        cout<<(n%2+(n/2))<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define  ll long long
 using namespace std;
vector<ll>q[200003];
ll l[200003],r[200003];
ll ans;
ll k[200003];
void dfs(ll a,ll fa)
{ l[a]=++ans;k[ans]=a;
    for(ll i=0;i<q[a].size();i++)
    { ll ii=q[a][i];
        if(ii==fa)continue;
        dfs(ii,a);
    }
    r[a]=ans;
}
ll sum[200003],p[200003];
int main()
{
    ll n,m;
    cin>>n>>m;
    for(ll i=1;i<n;i++)
    {
        ll a,b;
        cin>>a>>b;
        q[a].push_back(b);
        q[b].push_back(a);
    }
    dfs(1,0);
    while(m--)
    {
        ll a,b;
        cin>>a>>b;
        sum[l[a]]+=b;
        sum[r[a]+1]-=b;
    }
    for(ll i=1;i<=n;i++)
    {
        sum[i]+=sum[i-1];
       p[k[i]]=sum[i];
    }
      for(ll i=1;i<=n;i++)
    printf(i==n?"%lld\n":"%lld ",p[i]);
return 0;
}


Measured memory_bytes: 30464
import bisect
N, M = map(int, input().split())
A = [0]*M
for i in range(M):
  A[i] = int(input())

def index(a, x):
  i = bisect.bisect_left(a, x)
  if i != len(a) and a[i] == x:
    return i
  else:
    return -1

def dp(a,n):
  if n==N:
    return 1
  if n>N:
    return 0
  if index(a,n)!=-1:
    return 0
  else:
    return (DP[n+1]+DP[n+2])%(10**9+7)
    
DP=[0]*(N+3)

for i in range(N+2,-1,-1):
  DP[i]=dp(A,i)

ans=DP[0]
print(ans)

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

//関数
    
    
    
//main関数
int main() {
    
    
    //入力
    int N;
    cin>>N;
    
    vector<int> L(2*N);
    for(int i=0;i<2*N;i++){
        cin>>L.at(i);
    }
    
    
    
    
    
    
    //計算
    sort(L.begin(),L.end());
    int ans =0;
    for(int i=0;i<N;i++){
        ans+=L.at(2*i);
    }
    
    //出力
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pll pair <ll,ll>
#define Mid ((L+R)/2)
#define Left (2*Node)
#define Right (2*Node+1)

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const ll N = 200200;
const ll M = 4 * N;
const ll Inf = 1e18;

ll n;
pll h[N];
ll a[N];
ll Dp[N];
ll SegTree[M];

void Merge(ll Node)
{
    SegTree[Node] = max(SegTree[Left],SegTree[Right]);
}

void Build(ll Node = 1,ll L = 0,ll R = n)
{
    if(L == R)
    {
        SegTree[Node] = Dp[L];
        return ;
    }

    Build(Left,L,Mid);
    Build(Right,Mid+1,R);

    Merge(Node);
}

void Update(ll i,ll Node = 1,ll L = 0,ll R = n)
{
    if(i < L || R < i)  return ;
    if(i <= L && R <= i)
    {
        SegTree[Node] = Dp[i];
        return ;
    }

    Update(i,Left,L,Mid);
    Update(i,Right,Mid+1,R);

    Merge(Node);
}

ll Query(ll i,ll j,ll Node = 1,ll L = 0,ll R = n)
{
    if(j < L || R < i)      return -Inf;
    if(i <= L && R <= j)    return SegTree[Node];

    return max( Query(i,j,Left,L,Mid)
              , Query(i,j,Right,Mid+1,R) );
}

int main()
{
    cin >> n;

    for(ll i = 0; i < n; i++)   scanf("%lld",&h[i].first), h[i].second = i;
    for(ll i = 0; i < n; i++)   scanf("%lld",a+i);

    sort(h,h+n);

    Dp[n] = 0;
    for(ll i = 0; i < n; ++i)   Dp[i] = -Inf;

    Build();

    for(ll i = n - 1; ~i; --i)
    {
        ll idx = h[i].second;

        Dp[idx] = a[idx] + Query(idx+1,n);

        Update(idx);
    }

    ll Ans = -Inf;

    for(ll i = 0; i < n; i++)   Ans = max(Ans,Dp[i]);

    cout << Ans;
}


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

int main(){
int W,H,N;
  cin>>W>>H>>N;
  
  vector<int>x(N);
  vector<int>y(N);
  vector<int>a(N);
  for(int i=0; i<N; i++){
    cin>>x[i]>>y[i]>>a[i];}
  
  int mx=0, lx=W, my=0, ly=H;
  for(int i=0; i<N; i++){
   if(a[i]==1){mx=max(mx, x[i]);}
   if(a[i]==2){lx=min(lx, x[i]);}
   if(a[i]==3){my=max(my, y[i]);}
   if(a[i]==4){ly=min(ly, y[i]);}
  }
  if(lx<mx){lx=mx;}
  if(ly<my){ly=my;}
  
  cout<<(lx-mx)*(ly-my);
}

Measured memory_bytes: 256
package main

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

func main() {
	io, flush := NewIO()
	defer flush()

	tail := io.ScanBytes()
	q := io.ScanInt()
	reversed := false
	head := make([]byte, 0)
	for i := 0; i < q; i++ {
		if io.ScanInt() == 1 {
			reversed = !reversed
			continue
		}
		f, c := io.ScanInt(), io.ScanBytes()
		if f == 1 && reversed || f == 2 && !reversed {
			tail = append(tail, c...)
		} else {
			head = append(head, c...)
		}
	}
	ReverseBytes(head)
	ans := append(head, tail...)
	if reversed {
		ReverseBytes(ans)
	}
	io.Println(string(ans))
}

func ReverseStrings(s []string) {
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
}

func ReverseBytes(bytes []byte) {
	for i, j := 0, len(bytes)-1; i < j; i, j = i+1, j-1 {
		bytes[i], bytes[j] = bytes[j], bytes[i]
	}
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(s string) {
	fmt.Fprintln(io.writer, s)
}


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

const int N = 1e5 + 5;


long long f(long long a) {
    if (a % 4 == 0) return a;
    if (a % 4 == 1) return 1;
    if (a % 4 == 2) return a + 1;
    return 0;
}



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

    cout<<(f(b)^f(a-1))<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n,i,t,mh=0,res=0;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> t;
    if(t>=mh){
      res++;
      mh=t;
    }
  }
  cout << res << endl;
  return 0;
}

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

vi visit;
vector<vi> to;

int DFS(int p, int n){
    if (visit[p] != 0) return visit[p];

    visit[p] = n + 1;
    for (int i: to[p]){
        int r = DFS(i, n + 1);
        if (r > 0) return r;
    }
    visit[p] = -1;
    return -1;
}

int main(){
    int N, M; cin >> N >> M;
    to.resize(N);
    rep(i,M){
        int A, B; cin >> A >> B;
        A--; B--;
        to[A].push_back(B);
    }

    visit.resize(N);
    set<int> ans;
    rep(i,N){
        visit[i] = 0;
        ans.insert(i);
    }

    rep(i,N){
        int r = DFS(i, 0);
        if (r > 0){
            rep(j,N) if (visit[j] < r) ans.erase(j);
            rep(j,N){
                if (ans.count(j)){
                    for (int k: to[j]){
                        if (ans.count(k)){
                            if (visit[k] < visit[j]) {
                                rep(l,N) if (visit[l] < visit[k] || visit[l] > visit[j]) ans.erase(l);
                            }
                            else rep(l,N) if (visit[l] > visit[j] && visit[l] < visit[k]) ans.erase(l);
                        }
                    }
                }
            }
            cout << ans.size() << endl;
            for (int j: ans) printf("%d\n",j+1);
            break;
        }
        if (i == N-1) puts("-1");
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#define change(x)(x-97)
using namespace std;
int main(){
	string s;
	cin>>s;
	int length=s.length();
	bool table[26];
	for(int i=0;i<26;i++){
		table[i]=true;
	}
	bool check=true;
	for(int i=0;i<length;i++){
		if(table[change(s[i])]){
			table[change(s[i])]=false;
		}else{
			check=false;
			break;
		}
	}
	if(check){
		cout<<"yes"<<endl;
	}else{
		cout<<"no"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
from collections import Counter
C = Counter(A)
A = sorted(list(set(A)))[::-1]
flag = False
x = 0
for a in A:
	if flag == False:
		if C[a] >= 4:
			print(a ** 2)
			exit()
		elif C[a] >= 2:
			flag = True
			x = a
	elif flag == True and C[a] >= 2:
		print(a * x)
		exit()
else:
	print(0)

Measured memory_bytes: 79256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll A, B, C, D, E, F;
ll sug[3005];
ll water[3005];
int main () {
  cin >> A >> B >> C >> D >> E >> F;
 
  for(ll i = 0; 100 * A * i <= F; ++i) {
    for(ll j = 0; 100 * A * i + 100 * B * j <= F; ++j) {
      water[100 * A * i + 100 * B * j] = 1;
    }
  }
 
  for(ll i = 0; C * i <= F; ++i) {
    for(ll j = 0; C * i + D * j <= F; ++j) {
      sug[C * i + D * j] = 1;
    }
  }
 
  ll total = 100 * A;
  ll ss = 0;
  for(ll w = 1; w <= F; ++w) {
    if (water[w] == 0) continue;
      for(ll s = F - w; s >= 0; --s) {
        if (sug[s] == 0) continue;
        if (100 * s <= E * w && s * total > (s + w) * ss) {
          total = s + w;
          ss = s;
        }
    }
  }
 
  cout << total << ' ' << ss << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

	int n; cin >> n;
	map < int,int > cnt;
	REP(i,n) {
		int t; cin >> t;
		cnt[t]++;
	}

	int ans = 0;
	for (auto itr = cnt.begin(); itr != cnt.end(); itr++) {
		if (itr -> first > itr -> second) ans += itr -> second;
		else ans += (itr -> second - itr -> first);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;
 
const ll MOD = 1e9+7;
 

long long int isqrt(long long int n) {
	int i;
	for (i = 1; n > 0; i++) {
		n -= i * 2 + 1;
	}
	return i - 1;
}

int main()
{
	ll s;
	ll ans=0;
	cin>>s;
	cout<<"0 0 ";
	ll x2,y2,x3,y3;
	ll sq=isqrt(s);
	if(sq*sq==s)
		x2=sq;
	else
		x2=sq+1;
	y3=x2;
	ll tmp=x2*y3-s;
	x3=1;
	y2=tmp/x3;
	//cerr<<abs(x2*y3-y2*x3)<<endl;;
	cout<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ld long double
#define ff first
#define ss second

using namespace std;

bool calc(const string &s, const string &t) {
    string comp = t.substr(0, t.size() - 1);

    if(comp == s)
        return true;

    return false;
}

int main() {
    string s, t;

    cin >> s >> t;

    auto r = calc(s, t);

    cout << (r? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3628
package main

import "fmt"

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	var h1, m1, h2, m2, k int
	fmt.Scan(&h1, &m1, &h2, &m2, &k)

	x := h2*60 + m2 - (h1*60 + m1)
	fmt.Println(max(x-k, 0))
}


Measured memory_bytes: 1752
import sys
import numpy as np
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
b = np.array(b)
a= [list(map(int, l.split())) for l in sys.stdin]
a = np.array(a)
counter = 0
for i in range(n):
    if np.dot(a[i],b.T).sum() > -c:
        counter += 1
print(counter)

Measured memory_bytes: 12424
#include<iostream>
using namespace std;
int main()
{
  int t,n;
  for(int i=0;i<4;i++){
    cin>>t>>n;
    if(t==1){
      cout<<n*6000<<'\n';
    }else if(t==2){
      cout<<n*4000<<'\n';
    }else if(t==3){
      cout<<n*3000<<'\n';
    }else{
      cout<<n*2000<<'\n';
    }
  }
  return(0);
}



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

typedef long long int ll;
typedef long double ld;

#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define pll pair<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ln length()
#define M 1000000007
#define endl '\n'
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll n,a[200005],pos[200005];
sll tem;
int main()
{
    FIO;
    cin>>n;
    ll ans=0;
    rep(i,1,n) cin>>a[i],pos[a[i]]=i;
    rep(i,1,n){
        ll ps=pos[i],ps1=1,ps2=n;
        if(tem.lower_bound(ps)!=tem.end()) ps2=*(tem.lower_bound(ps)),ps2--;
        if(tem.size()>0){
            sll::iterator it=tem.lower_bound(ps);
            if(it!=tem.begin()) it--,ps1=*it,ps1++;
        }
        tem.insert(ps);
        //cout<<i<<" "<<ps<<" "<<ps1<<" "<<ps2<<endl;
        ans+=((ps2-ps+1)*(ps-ps1+1)*i);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 12928
#include<bits/stdc++.h>
using namespace std;
#define inf 9123456789123456789
//#define M 998244353
#define F first
#define S second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
#define pb push_back
#define M6 1000009
#define M5 500009
#define pi 3.14159265
// ll power(ll x,ll n){
//     ll res=1;
//     while(n>0){
//         if(n&1) res=(res*x)%M;
//         n/=2;
//         x=(x*x)%M;
//     }
//     return res;
// }
ll n,m;
vector<pll> l1,l2;
ll dis(pll p1,pll p2){
    return (p1.F-p2.F)*(p1.F-p2.F)+(p1.S-p2.S)*(p1.S-p2.S);
}
int  main()
{   //ios_base::sync_with_stdio (0), cin.tie (0);
    //sieve();
    //init();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll tc=1,t=1,flag,i,j,k,a,b,c;
    //cin>>tc;
    while(t<=tc){
        //cout<<"Case #"<<t<<": ";
        cin>>n;
        string s;
        cin>>s;
        a=0,b=0;
        for(i=0;i<n;i++) if(s[i]=='R') a++;
            else b++;
        if(a>b) cout<<"Yes";
        else cout<<"No";
        t++;
    }
    return 0;
} 

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

int trans[26];


void makelist(int a,int b){
	for(int i=0;i<26;i++){
		trans[i]=(a*i+b)%26;
	}
}

string translate(string s){
	for(int i=0;i<s.size();i++){
		if(s[i]>='a' && s[i]<='z'){
			s[i]=trans[s[i]-'a']+'a';
		}
	}
	return s;
}

int main(){
	//a!=2,13 **
	int n;
	cin>>n;
	cin.ignore();
	for(int count=0;count<n;count++){
		string s;
		getline(cin,s);
		string tmp=s;
		int a=0,b=100;
		while(s.find("that")==string::npos && s.find("this")== string::npos){
			b++;
			if(b>=26){
				b=0;
				a++;
			}
			
			while(a%2==0||a%13==0)a++;
			makelist(a,b);
			s=translate(tmp);
			//cout<<s<<endl;
		}
		cout<<s<<endl;
	}
}

Measured memory_bytes: 1216
#ifndef __cplusplus
    cat << EOF
#endif
#include <bits/stdc++.h>
using namespace std;

#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()

template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }

int main() {

    int N, M;
    cin >> N >> M;

    if(M == 1) {
        cout << N << '\n';
        if(N >= 2) cout << "2\n" << N - 1 << " 1\n";
        else cout << "1\n1\n";
        return 0;
    }

    vector<int> A(M);
    vector<int> odd_place;
    rep(i, M) {
        cin >> A[i];
        if(A[i] % 2 == 1) odd_place.push_back(i);
    }

    if(odd_place.size() >= 3) {
        cout << "Impossible\n";
        return 0;
    }

    if(odd_place.size() >= 1) swap(A[0], A[odd_place[0]]);
    if(odd_place.size() >= 2) swap(A[M - 1], A[odd_place[1]]);
    vector<int> answer;
    if(A[0] > 1) answer.push_back(A[0] - 1);
    rep(i, M - 1) answer.push_back(A[i + 1]);
    ++answer.back();

    rep(i, M) {
        cout << A[i];
        cout << (i + 1 == M ? '\n' : ' ');
    }
    cout << answer.size() << '\n';
    rep(i, answer.size()) {
        cout << answer[i];
        cout << (i + 1 == answer.size() ? '\n' : ' ');
    }

}


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

int main(){
    int ans;
    int n, k, x, y;
    cin>>n>>k>>x>>y;
    if (n>=k) ans = k*x + (n-k)*y;
    else if (n<k) ans = n*x;
    cout<<ans<<endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}
int lcm(int a, int b) {return a * b / gcd(a, b); }
intt bpow(intt a,intt b) 
{
  intt res = 1;
  while (b > 0) {
    if (b & 1)res = res * a;
      a = a * a;
      b >>= 1;
  }
  return res;
}
intt fact(intt n) { 
   if ((n==0)||(n==1))
      return 1; 
   else
      return n*fact(n-1);
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("in.txt","r",stdin);
  freopen("out.txt","w",stdout);
  #endif
}

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

map<int,int> mp;
vector<ii> v;



int main() 
{ 
    fast_io
    go();
    int n;cin>>n;
    cout << n+n*n+n*n*n <<"\n";
}

/*!
    You are under no obligation to be the same person you were a minute ago,
    You have the right to grow !
*/




















Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define fi first
#define se second
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    string S;cin >> S;
    vector<char> V;
    REP(i,S.size()) V.pb(S[i]);
    sort ALL(V);
    ll cnt = 0;
    vector<ll> W;
    REP(i,V.size()-1){
        if(V[i] == V[i+1]) cnt++;
        else{
			cnt++;
            W.pb(cnt);
            cnt = 0;
        }
    }
	cnt++;
	W.pb(cnt);
	ll N = S.size();
    ll L = N*(N - 1 ) / 2;
	ll ans = 0;
    REP(i,W.size()){
        ans += W[i]*(W[i]-1)/2;
    }
    cout << L - ans + 1 << endl;
}


Measured memory_bytes: 788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

string s;
int x, y;
int n;
vector<int> vx, vy;
int fx[2][16010], fy[2][16010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> s >> x >> y;
  n = s.size();
  int l, r;
  l = 0, r = 0;
  while (l < n && s[l] == 'F') l++, r++, x--;
  int turn = 0;
  while (l < n) {
    while (l < n && s[l] == 'T') l++, r++, turn ^= 1;
    while (r < n && s[r] == 'F') r++;
    if (r != l) {
      if (turn) vy.emplace_back(r-l);
      else vx.emplace_back(r-l);
    }
    l = r;
  }
  fx[0][8000] = 1;
  fy[0][8000] = 1;
  for (int i = 0; i < vx.size(); i++) {
    fill_n((int*)fx[1], 16010, 0);
    for (int j = 0; j < 16010; j++) {
      if (fx[0][j]) {
        fx[1][j-vx[i]] = 1;
        fx[1][j+vx[i]] = 1;
      }
    }
    swap(fx[0], fx[1]);
  }
  for (int i = 0; i < vy.size(); i++) {
    fill_n((int*)fy[1], 16010, 0);
    for (int j = 0; j < 16010; j++) {
      if (fy[0][j]) {
        fy[1][j-vy[i]] = 1;
        fy[1][j+vy[i]] = 1;
      }
    }
    swap(fy[0], fy[1]);
  }
  cout << (fx[0][x+8000] && fy[0][y+8000] ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 512
n = int(input())

X = [list(map(int, input().split())) for _ in range(n)]

ans = 'No'
cnt = 0
for x1, x2 in X:
    if x1 == x2:
        cnt += 1
        if cnt == 3:
            ans = 'Yes'
            break
    else:
        cnt = 0

print(ans)


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


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

  if (a >= 13){
    cout << b << endl;
  }else if(6 <= a && a < 13){
    cout << b / 2 << endl;
  }else{
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;
 class Main {
	public static void main(String[]args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int count = 0 ;
		int arr[] = new int[n]; 
		for(int i = 0 ; i< n ;i++) {
			arr[i] = scan.nextInt();
		}
		
		//ArrayList<Integer> a = new ArrayList<>();
		for(int i = 1 ; i <n-1 ; i++) {
			if(Second(arr[i-1],arr[i],arr[i+1]) == arr[i]){
				count++;
				
			}
		}
		System.out.print(count);

		
	}

	static int Second(int a , int b , int x) {
		int first = a  , second = b ;

			if(second < first ) {
				first = b ; 
				second = a ;
			}
			if(x < second ) {
				second = x  ;
			}
			if(second < first ) {
				int temp = first ;
				first = second ;
				second = temp ;
			}
		return second ;
		
	}
}

Measured memory_bytes: 20820
A,B = [int(i) for i in input().split()]
S = input()

# 先頭A文字が数字か？,A+1文字目がハイフンか？,残りB文字が数字か？
cond = [True,True,True]
for i in range(A):
  if S[i] not in '0123456789':
    cond[0]=False
if S[A]!='-':
  cond[1]=False
for i in range(A+1,A+B+1):
  if S[i] not in '0123456789':
    cond[2]=False

if all(cond):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

//++時計回り --反時計回り
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};

ll ans[2000001] = {};
ll temp[2000001] = {};
vector<ll> v[2000001];

void dfs(ll id) {
  ans[id] += temp[id];
  REP(i, v[id].size()) {
    ans[v[id][i]] += ans[id];
    dfs(v[id][i]);
  }
}

int main() {
  ll N,Q;
  cin >> N >> Q;
  REP(i, N-1) {
    ll a,b;
    cin >> a >> b;
    a--;
    b--;
    v[a].PB(b);
  }

  REP(i, Q) {
    ll p,x;
    cin >> p >> x;
    p--;
    temp[p] += x;
  }
  dfs(0);

  REP(i, N) cout << ans[i] << (i < N-1 ? ' ': '\n');
}


Measured memory_bytes: 71040
import sys
import bisect


def main():
    n, K, L, R = map(int, sys.stdin.readline().split())
    a = tuple(map(int, sys.stdin.readline().split()))
    m = (n-1)//2
    ls = [[] for _ in range(m+1)]
    for i in range(1 << m):
        cnt = 0
        val = 0
        for j in range(m):
            if i >> j & 1:
                cnt += 1
                val += a[j]
        ls[cnt].append(val)
    for i in range(m+1):
        ls[i].sort()
    ans = 0
    for i in range(1 << n-m):
        cnt = 0
        val = 0
        for j in range(n-m):
            if i >> j & 1:
                cnt += 1
                val += a[m+j]
        if K-m <= cnt <= K:
            ans += bisect.bisect_right(ls[K-cnt], R-val) - bisect.bisect_right(ls[K-cnt], L-val-1)
    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 31236
package main

import "fmt"

func main() {
	var a, b, i int
	var ans [100000]int
	var op string
	
	for i = 0; i != -1; i++ {
		fmt.Scan(&a, &op, &b)

		if op == "?" {
			break
		} else if op == "+" {
			ans[i] = a + b
		} else if op == "-" {
			ans[i] = a - b
		} else if op == "*" {
			ans[i] = a * b
		} else {
			ans[i] = a / b
		}
	}

	for j:= 0; j < i; j++ {
		fmt.Println(ans[j])
	}
}


Measured memory_bytes: 1952
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define foo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define min3(a,b,c)         min(a,min(b,c))
#define max3(a,b,c)         max(a,max(b,c))
#define min4(a,b,c,d)       min(a,min(b,min(c,d)))
#define max4(a,b,c,d)       max(a,max(b,max(c,d)))
#define max5(a,b,c,d,e)     max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e)     min(min3(a,b,c),min(d,e))
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;

int mpow(int base, ll exp); 
void ipgraph(int m);
void DFS(int n);
bool isprime(ll n);
int gcd(int a,int b);
void rstgraph(int n);

const int mod = pow(10,9)+7;
const int N = 3e5, M = N;

//=======================================================================================
vi g[N];
int vis[N];
int nodes=0;
// ll ans=0;
void iluzn(){
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll min=a*c;
if(a*d>min)
   min=a*d;
 if(b*c>min) min=b*c;
 if(b*d>min) min=b*d;
 cout<<min;
}




 
int main() {
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t=1,i;
    // cin>>t;
     while(t--) iluzn();
    return 0;
}
int mpow(int base, ll exp) {
  base %=mod ;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
bool isprime(ll n){
    if(n<=1)
        return false;
    if(n==2)
        return true;
    if(n%2==0)
        return false;
    ll rt = sqrt(n);
    for(ll i=3;i<rt;i+=2){
        if(n%i==0)
            return false;
    }
    return true;
}
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
void ipgraph(int m){
  int u, v;
  while(m--){
    cin>>u>>v;
    g[u].pb(v);
    // g[v].pb(u);
  }
}

void DFS(int n)
{  ++nodes;
    vis[n] = 1;
    for(vector<int>::iterator i = g[n].begin(); i != g[n].end() ; i++)
    {
        if(!vis[*i])
            DFS(*i);
    }
}
void rstgraph(int n){
  int i;
  fo(i,n+1){
    g[i].clear();
    vis[i]=0;
  }
  nodes=0;
}

Measured memory_bytes: 10732
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        
        while (true) {
            c -= b;
            if (c <= 0) {
                System.out.println("Yes");
                break;
            }
            a -= d;
            if (a <= 0) {
                System.out.println("No");
                break;
            }
        }
    }
}


Measured memory_bytes: 35896
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
kill = 0

for i in range(N):
    if A[i] < B[i] :
        kill += A[i]
        B[i] = B[i] - A[i]
        kill += min(B[i] , A[i+1])
        A[i+1] =max(0, A[i+1] - B[i]) 
    else : kill += B[i]

print(kill)

Measured memory_bytes: 18624
// I'm the Topcoder
//C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <time.h>
//C++
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cctype>
#include <stack>
#include <string>
#include <list>
#include <queue>
#include <map>
#include <vector>
#include <deque>
#include <set>
using namespace std;

//*************************OUTPUT*************************
#ifdef WIN32
#define INT64 "%I64d"
#define UINT64 "%I64u"
#else
#define INT64 "%lld"
#define UINT64 "%llu"
#endif

//**************************CONSTANT***********************
#define INF 0x7F7F7F7F
#define eps 1e-8
#define PI acos(-1.)
#define PI2 asin (1.);
typedef long long LL;
//typedef __int64 LL;   //codeforces
typedef unsigned int ui;
typedef unsigned long long ui64;
#define MP make_pair
typedef vector<int> VI;
typedef pair<int, int> PII;
#define pb push_back
#define mp make_pair

//***************************SENTENCE************************
#define CL(a,b) memset (a, b, sizeof (a))
#define sqr(a,b) sqrt ((double)(a)*(a) + (double)(b)*(b))

//****************************FUNCTION************************
template <typename T> double DIS(T va, T vb) { return sqr(va.x - vb.x, va.y - vb.y); }
template <class T> inline T INTEGER_LEN(T v) { int len = 1; while (v /= 10) ++len; return len; }
template <typename T> inline T square(T va, T vb) { return va * va + vb * vb; }

// aply for the memory of the stack
#pragma comment (linker, "/STACK:1024000000,1024000000")
//end

#define CY 105
typedef int typec;

bool inset[CY], vis[CY];
typec wage[CY];
int g[CY][CY];
int N, M;

typec Search(int n, int &s, int &t) {
	memset(vis, false, n * sizeof(vis[0]));
	memset(wage, 0, n * sizeof(wage[0]));
	s = t = -1;
	typec cf, mx;
	int u = 0;
	for (int i = 0; i < n; ++i) {
		mx = -INF;
		for (int j = 0; j < n; ++j) {
			if (!inset[j] && !vis[j] && mx < wage[j]) {
				mx = wage[u = j];
			}
		}
		if (u == t) return cf;
		s = t; t = u;
		cf = mx;
		vis[u] = true;
		for (int v = 0; v < n; ++v) {
			if (!inset[v] && !vis[v]) {
				wage[v] += g[u][v];
			}
		}
	}
	return cf;
}

typec Stoer_Wagner(int n) {
	int s, t;
	typec ans = INF, cf;
	memset(inset, false, n * sizeof(inset[0]));
	for (int i = 1; i < n; ++i) {
		cf = Search(n, s, t);
		ans = min(ans, cf);
		if (ans == 0) return ans;
		inset[t] = true;
		for (int j = 0; j < n; ++j) {
			if (!inset[j] && j != s) {
				g[s][j] += g[t][j];
				g[j][s] += g[j][t];
			}
		}
	}
	return ans;
}

int main(void) {
	while (2 == scanf("%d%d", &N, &M)) {
		if (N == 0 && M == 0) break;
		memset(g, 0, sizeof(g));
		int ans = 0, u, v, c;
		for (int i = 0; i < M; ++i) {
			scanf("%d%d%d", &u, &v, &c);
			if (c > 0) g[u][v] += c, g[v][u] += c;
			else ans += c;
		}
		printf("%d\n", ans + Stoer_Wagner(N));
	}
	return 0;
}

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

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

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> A(n);
  COMinit();
  rep(i, n) cin >> A[i];
  sort(A.begin(), A.end());
  ll ans = 0;
  ll f_min = 0;
  ll f_max = 0;
  rep(i,n){
    f_min += A[i] * COM(n - i - 1, k - 1);
    f_min %= MOD;
  }
  for (int i = n - 1; i >= 0; i--){
    f_max += A[i] * COM(i, k - 1);
    f_max %= MOD;
  }
  cout << (f_max - f_min + 2 * MOD) % MOD << endl;
}

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

using namespace std;

int n, k;
int a[200010];
long long sum;

int main(void)
{
	scanf("%d %d", &n, &k);
	
	for(int i = 0 ; i < n ; i++)
	{
		scanf("%d", &a[i]);
	}
	
	sort(a, a + n);
	
	for(int i = 0 ; i < n - k ; i++)
	{
		sum += a[i];
	}
	
	printf("%lld", sum);
	return 0;
}

Measured memory_bytes: 1024
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

using namespace std;
using ll = long long;
vector<ll> dist;
vector<bool> reach_rev;
vector<bool> reach;

struct Edge {
    int from;
    int to;
    int coins;
    Edge(int _from, int _to, int _coins): from(_from), to(_to), coins(_coins) {}
};

vector<Edge> edges;

int n, m, p;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m >> p;
    dist = vector<ll>(n);
    reach = vector<bool>(n, false);
    reach_rev = vector<bool>(n, false);
    REP(i, m) {
        int ai, bi, ci;
        cin >> ai >> bi >> ci;
        ai--;
        bi--;
        ci = p - ci;
        edges.emplace_back(ai, bi, ci);
    }
    reach[0] = true;
    reach_rev[n - 1] = true;

    REP(i, n) {
        dist[i] = LONG_MAX;
    }
    dist[0] = 0;
    
    REP(i, n) {
        for (auto e : edges) {
            // DDD(e.from, e.to, e.coins);
            // DV(dist);
            int u = e.from;
            int v = e.to;
            ll d = dist[u] == LONG_MAX ? LONG_MAX : dist[u] + e.coins;
            if (dist[v] > d) {
                dist[v] = d;
            }
            if (reach[u]) reach[v] = true;
            if (reach_rev[v]) reach_rev[u] = true;
            // DV(dist);
        }
    }
    REP(i, n) {reach[i] = reach[i] & reach_rev[i];}

    bool valid = true;
    for (auto e : edges) {

        int u = e.from;
        int v = e.to;
        if (!(reach[u] && reach[v])) continue;
        if (dist[u] + e.coins < dist[v]) {
            valid = false;
            break;
        }

    }
    // DV(reach);
    // DV(dist);
    // for (auto e : edges) {DDD(e.from, e.to, e.coins);}
    cout << (valid ? max(-dist[n - 1], 0LL) : -1) << endl;
}


Measured memory_bytes: 508
while true do
  identifier, role = gets.chomp.split(' ')
  break if role == 'X'

  words = Array.new
  if identifier[0] =~ /[A-Z]/ then
    words = identifier.scan(/[A-Z][a-z]*/).map {|x| x.downcase }
  elsif identifier.include? '_' then
    words = identifier.split '_'
  else
    words = identifier.scan(/(?:^[a-z]*)|(?:[A-Z][a-z]*)/).map {|x| x.downcase }
  end

  if role == 'U'
    puts words.map {|x| x.capitalize }.join
  elsif role == 'L'
    print words.shift
    puts words.map {|x| x.capitalize }.join
  elsif role == 'D'
    puts words.join '_'
  end
end

Measured memory_bytes: 6120
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector<pair<int,pair<int,int> > > e;
int par[100005],rem[100005];
long long w[100005];
int find(int x)
{
	if (par[x]!=x)
	par[x]=find(par[x]);
	return par[x];
}
void Union(int x,int y,int c)
{
	x=find(x);
	y=find(y);
	if (x>y)
	swap(x,y);
	if (x!=y)
	{
		par[y]=x;
		w[x]+=w[y];
		rem[x]+=rem[y];
	}
	rem[x]++;
	if (w[x]>=c)
	rem[x]=0;
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	{
		scanf("%lld",&w[i]);
		par[i]=i;
	}
	while (m--)
	{
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		e.push_back({c,{a,b}});
	}
	sort(e.begin(),e.end());
	for (auto p:e)
	Union(p.second.first,p.second.second,p.first);
	printf("%d",rem[1]);
}

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

void EraseWord(string& str,string word){
    for(int c = str.find(word.c_str()); c != string::npos; c = str.find(word.c_str())){
        str.erase(c,word.size());
    }
}

int main(){

    int num_five = 0;
    int num_seven = 0;
    int input;

    for(int i = 0; i < 3; i++){
        scanf("%d", &input);
        if(input == 5){
            num_five++;
        }else if(input == 7){
            num_seven++;
        }

    }

    if(num_five == 2 && num_seven==1){
            printf("YES\n");
    }else{
            printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define all(c) begin(c),end(c)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
 
 
 
 
int main() {
  string s;
  cin>>s;
  if(s=="Sunny")cout<<"Cloudy";
  if(s=="Cloudy")cout<<"Rainy";
  if(s=="Rainy")cout<<"Sunny";



}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
int main(){
  int n;
  cin >> n;
  vector<int> v(n),m(n);
  rep(i,n){
    int a;
    cin >> a;
    rep(j,a){
      int x,y;
      cin >> x >> y;
      x--;
      v[i]|=y<<x;
      m[i]|=1<<x;
    }
  }
  int ans=0;
  rep(i,(1<<n)){
    rep(j,n){
      bool bit=(i>>j)&1;
      if(bit){
        int check=(i^v[j])&m[j];
        if(check>0) break;
      }
      if(j==n-1)ans = max(ans,__builtin_popcount(i));
    }
  }
  cout << ans << endl;
}

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

using namespace std;
using ll = long long;

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

const int mod = 998244353;

ll modpow(ll k, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * k % mod;
    k = k * k % mod;
    n /= 2;
  }
  return res;
}

// ll choose(ll n, ll k) {
//   if (k == 0) return 1;
//   ll x = 1, y = 1;
//   rep(i, k) {
//     x = x * (n - i) % mod;
//     y = y * (i + 1) % mod;
//   }
//   return x * modpow(y, mod - 2) % mod;
// }

int main() {
  int n, m, k;
  cin >> n >> m >> k;

  ll f[200005], fi[200005];
  f[0] = f[1] = 1;
  rep(i, n + 1) { f[i + 1] = f[i] * (i + 1) % mod; }
  rep(i, n + 1) { fi[i] = modpow(f[i], mod - 2); }

  auto choose = [&](ll x, ll y) {
    return (f[x] * fi[x - y] % mod) * fi[y] % mod;
  };

  ll ans = 0;
  for (int i = 0; i <= k; ++i) {
    ans += (m * choose(n - 1, i) % mod) * modpow(m - 1, n - 1 - i) % mod;
    ans %= mod;
  }

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


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

int main()
{
    map<string, int> mp;
    mp["SUN"] = 7;
    mp["MON"] = 6;
    mp["TUE"] = 5;
    mp["WED"] = 4;
    mp["THU"] = 3;
    mp["FRI"] = 2;
    mp["SAT"] = 1;

    string S;
    cin >> S;

    cout << mp[S] << endl;
    return 0;
}

Measured memory_bytes: 256
let rec range x y =
    if x > y then [] else (x :: range (x+1) y)

let solve a b c =
    let ok n = c mod n == 0 in
    range a b |> List.filter ok |> List.length |> Printf.printf "%d\n"

let _ =
     Scanf.scanf "%d %d %d" solve


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

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

    vector<int> a(n);
    for (auto &&i : a)
    {
        cin >> i;
    }

    bool app = true;
    for (auto &&i : a)
    {
        if (i % 2 == 0)
        {
            if (i % 3 == 0)
                app &= true;
            else if (i % 5 == 0)
                app &= true;
            else
                app &= false;
        }
    }

    if (app)
        cout << "APPROVED" << endl;
    else
        cout << "DENIED" << endl;

    return 0;
}

Measured memory_bytes: 256
from scipy.sparse import*
(n,m),*t=[map(int,t.split())for t in open(0)]
*b,a=zip(*[(i,j+n,1)for i,(_,*t)in enumerate(t)for j in t])
print('YNEOS'[1in csgraph.connected_components(csr_matrix((a,b),[n-~m]*2))[1][:n]::2])

Measured memory_bytes: 61092
from itertools import accumulate

N = int(input())
L, R = [0], [0]
for i in range(N):
    li, ri = map(int, input().split())
    L.append(li)
    R.append(ri)

L.sort(reverse=True)
R.sort()

L = list(accumulate(L))
R = list(accumulate(R))

ans = 0
for k in range(N+1):
    ans = max(ans, 2*(L[k] - R[k]))

print(ans)


Measured memory_bytes: 69464
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc054/tasks/abc054_c

int path[15][15];

int main() {
    int N, M; cin >> N >> M;
    REP(i, M) {
        int a, b; cin >> a >> b;
        path[a][b] = 1;
        path[b][a] = 1;
    }

    vector<int> perm(N-1);
    REP(i, N-1) perm[i] = i+2;
    sort(perm.begin(), perm.end());

    int ans = 0;
    do {
        int now = 1;
        for (int i = 0; i < perm.size(); i++) {
            if (!path[now][perm[i]]) break;
            now = perm[i];
            if (i == perm.size()-1) ans++;
        }
    } while(next_permutation(perm.begin(), perm.end()));

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>   
#include <stdio.h>    
 
using namespace std;
     
#define F first
#define S second
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, k, d[101];
vector <pii> ans;
vector <int> g[101];
bool used[101][101];
queue <int> q;

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n >> k;
   for (int i = 2; i <= n; i ++) {
      ans.pb ({1, i});
      used[1][i] = used[i][1] = 1;
   }
   if (k > (n - 1) * (n - 2) / 2) cout << -1, exit (0);
   int val = (n - 1) * (n - 2) / 2 - k;
   for (int i = 2; i <= n; i ++) {
      if (val == 0) break;
      for (int j = i + 1; j <= n; j ++)
         if (!used[i][j]) {
            val --;
            ans.pb ({i, j});
            if (val == 0) break;
         }
   }
   cout << sz (ans) << endl;
   for (auto it : ans) cout << it.F << ' ' << it.S << endl;


}                                     

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
// cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}


Measured memory_bytes: 384