akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
public class Main {
  public static void main(String[] args) {
    Main m = new Main();
    m.run();
  }
  private void run() {
    int n = 0;
    Point[] p = null;
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
      n = Integer.parseInt(br.readLine());
      p = new Point[n];
      for (int i=0;i<n;i++) {
        String[] s = br.readLine().split("\\s+");
        int x = Integer.parseInt(s[0]);
        int y = Integer.parseInt(s[1]);
        p[i] = new Point(x,y,i);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
    Edge[] graph = new Edge[2*n-2];
    Arrays.sort(p,Comparator.comparingInt(pt -> pt.x));
    for (int i=0;i<n-1;i++) {
      graph[i] = new Edge(p[i].id,p[i+1].id,(long)(p[i+1].x-p[i].x));
    }
    Arrays.sort(p,Comparator.comparingInt(pt -> pt.y));
    for (int i=0;i<n-1;i++) {
      graph[i+n-1] = new Edge(p[i].id,p[i+1].id,(long)(p[i+1].y-p[i].y));
    }
    Arrays.sort(graph,Comparator.comparingLong(e -> e.cost));
    UnionFind uf = new UnionFind(n);
    long cost = 0L;
    for (Edge e : graph) {
      if (!uf.same(e.from,e.to)) {
        cost += e.cost;
        uf.unite(e.from,e.to);
      }
    }
    System.out.println(cost);
  }
  private class Point {
    private int x;
    private int y;
    private int id;
    Point(int x,int y,int id) {
      this.x = x;
      this.y = y;
      this.id = id;
    }
  }
  private class Edge {
    private int from;
    private int to;
    private long cost;
    Edge(int from,int to,long cost) {
      this.from = from;
      this.to = to;
      this.cost = cost;
    }
  }
  private class UnionFind {
    int n;
    int[] par;
    int[] rank;
    int[] size;
    UnionFind(int n) {
      this.n = n;
      par = new int[n];
      rank = new int[n];
      size = new int[n];
      for (int i=0;i<n;i++) {
        par[i] = i;
        size[i] = 1;
      }
    }
    private int find(int i) {
      if (par[i] == i) return i;
      return par[i] = find(par[i]);
    }
    private boolean same(int i,int j) {
      return find(i) == find(j);
    }
    private int size(int i) {
      return size[find(i)];
    }
    private void unite(int i,int j) {
      i = find(i);
      j = find(j);
      if (i == j) return;
      if (rank[i] < rank[j]) {
        par[i] = j;
        size[j] += size[i];
      } else {
        par[j] = i;
        size[i] += size[j];
        if (rank[i] == rank[j]) rank[i]++;
      }
    }
  }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    string s;
    cin>>n>>s;
    Vec w(n+2,0);
    Vec sw(n+2,0);
    Vec e(n+2,0);
    Vec se(n+2,0);
    rep(i,n){
        if(s[i]=='W'){
            w[i] = 1;
        }else{
            e[i] = 1;
        }
    }
    rep(i,n){
        sw[i+1] = sw[i]+w[i];
    }
    per(i,n-1){
        se[i+1] = se[i+2]+e[i];
    }
//    dbg(sw);
//    dbg(se);
    ll ans = INF;
//    dbg(w);
//    dbg(e);
//    dbg(sw);
//    dbg(se);
    REP(i,1,n+1){
        chmin(ans,sw[i-1]+se[i+1]);
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 10004
// In The Name Of Allah
// Mehrkish Makuei

#include <bits/stdc++.h>

#define pb push_back
#define debug1(x) cerr << #x << " : " << x << endl;
#define debug2(x, y ) cerr << #x << " : " << x << "  " << #y << " : " << y << endl;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef vector <ll> vll;
typedef set <char> sch;
typedef set <ll> sll;

const ll MOD = 1e9 + 7;
const ll MAXN = 1e3 + 19;

ll a, b, c;

int main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> a >> b >> c;
	if ( c >= a and c <= b )
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
int A[101010],B[101010],C[101010];
ll mo=998244353;

ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

map<pair<int,int>,int> mp;

ll dp[101010][1<<4];

int out(int x,int y,int val) {
	if(mp.count({x,y})==0) return 0;
	if(mp[{x,y}]==(val&1)) return 0;
	return 1;
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>A[i]>>B[i]>>C[i];
		A[i]--,B[i]--;
		mp[{A[i],B[i]}]=C[i];
	}

	
	FOR(i,M) if(abs(A[i]-B[i])>2) {
		if(mp.count({B[i],A[i]})) {
			if(mp[{B[i],A[i]}]!=C[i]) return _P("0\n");
		}
		else {
			mp[{B[i],A[i]}]=C[i];
		}
	}
	
	ll fr=0;
	FOR(i,N) fr+=N-(min(N-1,i+2)-max(i-2,0)+1);
	FORR(m,mp) if(abs(m.first.first-m.first.second)>2) fr--;
	fr/=2;
	ll pat=modpow(2,fr);
	
	int mask;
	FOR(mask,1<<4) if(__builtin_popcount(mask)%2==0) {
		int ng=0;
		FOR(y,2) FOR(x,2) ng|=out(x,y,(mask>>(y*2+x))%2);
		if(ng==0) dp[1][mask]++;
	}
	
	for(i=2;i<N;i++) {
		FOR(mask,1<<5) if(__builtin_popcount(mask)%2==0) {
			if(out(i,i,mask>>4)) continue;
			if(out(i-1,i,mask>>3)) continue;
			if(out(i-2,i,mask>>2)) continue;
			if(out(i,i-1,mask>>1)) continue;
			if(out(i,i-2,mask>>0)) continue;
			int mask2;
			FOR(mask2,1<<4) if(__builtin_popcount(mask2)%2==0) {
				int nmask=(mask2>>3)&1;
				nmask |= ((mask>>1)&1)<<1;
				nmask |= ((mask>>3)&1)<<2;
				nmask |= ((mask>>4)&1)<<3;
				if(__builtin_popcount(nmask)%2==0) (dp[i][nmask]+=dp[i-1][mask2])%=mo;
			}
		}
		/*
		FOR(j,16) cout<<dp[i][j]<<" ";
		cout<<endl;*/
	}
	
	ll ret=0;
	FOR(i,1<<4) ret+=dp[N-1][i];
	cout<<ret%mo*pat%mo<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 19584
#include <iostream>
#include <utility>
#include <vector>

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

    std::vector<std::pair<std::pair<std::string, int>, int>> list(n);
    std::string str;
    int p;
    for(int i = 0; i < n; ++i){
        std::cin >> str >> p;
        list.at(i) = std::make_pair(std::make_pair(str, -p), i + 1);
    }

//    std::sort(list.begin(), list.end(), myCompare);
    std::sort(list.begin(), list.end());

    for(int i = 0; i < n; ++i){
        std::cout << list.at(i).second << std::endl;
    }    

    return 0;
}

Measured memory_bytes: 760
#include <iostream>

using namespace std;

int s[14], h[14], c[14], d[14];

int
main(int argc, const char *argv[])
{
    int n;
    cin >> n;
    for (int i = 0; i != n; ++i) {
        char suit;
        int rank;
        cin >> suit >> rank;
        if (suit == 'S') s[rank]++;
        else if (suit == 'H') h[rank]++;
        else if (suit == 'C') c[rank]++;
        else if (suit == 'D') d[rank]++;
    }
    for (int i = 1; i != 14; ++i)
        if (!s[i]) cout << "S " << i << endl;
    for (int i = 1; i != 14; ++i)
        if (!h[i]) cout << "H " << i << endl;
    for (int i = 1; i != 14; ++i)
        if (!c[i]) cout << "C " << i << endl;
    for (int i = 1; i != 14; ++i)
        if (!d[i]) cout << "D " << i << endl;

    return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define M 1000005
#define P 998244353
#define LL long long
using namespace std;
struct node {
	int x,y;
} s[M];
bool cmpx(node A,node B) {
	return A.x<B.x;
}
bool cmpy(node A,node B) {
	return A.y<B.y;
}
int F2[M];
void Add(LL &x,int y) {
	x+=y;
	if(x<0)x+=P;
	if(x>=P)x-=P;
}
int X[M],Y[M],n;
struct BIT {
	int C[M];
	void clear() {
		for(int i=1; i<=n; i++)C[i]=0;
	}
	void Add(int x) {
		while(x<=n) {
			C[x]++;
			x+=x&-x;
		}
	}
	int Query(int x) {
		int res=0;
		while(x>0) {
			res+=C[x];
			x-=x&-x;
		}
		return res;
	}
} bit;
int main() {
	cin>>n;
	F2[0]=1;
	for(int i=1; i<=n; i++)F2[i]=F2[i-1]*2%P;
	for(int i=0; i<n; i++) {
		scanf("%d %d",&s[i].x,&s[i].y);
		X[i]=s[i].x;
		Y[i]=s[i].y;
	}
	sort(X,X+n);
	for(int i=0; i<n; i++)s[i].x=lower_bound(X,X+n,s[i].x)-X+1;
	LL ans=1LL*n*(F2[n]-1)%P;
	bit.clear();
	for(int i=0; i<n; i++) {
		Add(ans,-(F2[i]-1));
		Add(ans,-(F2[n-1-i]-1));
		Add(ans,-(F2[i]-1));
		Add(ans,-(F2[n-1-i]-1));
	}
	sort(s,s+n,cmpy);
	for(int i=0; i<n; i++) {
		Add(ans,F2[bit.Query(s[i].x)]-1);//<x,<y
		Add(ans,F2[i-bit.Query(s[i].x)]-1);//>x,<y
		bit.Add(s[i].x);
	}
	bit.clear();
	for(int i=n-1; i>=0; i--) {
		Add(ans,F2[bit.Query(s[i].x)]-1);//<x,>y
		Add(ans,F2[n-1-i-bit.Query(s[i].x)]-1);//>x,>y;
		bit.Add(s[i].x);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 17408
#include <iostream>
#include <fstream>
#include <string>
#include <limits>
#include <iomanip>

using namespace std;

int main(){
#ifdef CIN
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif

	int a, b;
	int d, r;
	double f;

	cin >> a >> b;

	d = a / b;
	r = a % b;

	f = (double)a / (double)b;

	cout << d << " " << r << " " << fixed << setprecision(15) << f << endl;
	
	return 0;
}

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

int max_points(int a[][3] , int n )
{
    int dp[n][3];
    //Base Case
    for(int i=0; i<3 ;++i)
        dp[0][i] = a[0][i];

    for(int i=1 ; i<n; ++i)
    {
        for(int j =0 ;j<3 ; ++j)
        {
            dp[i][j] = 0;
            for(int k = 0 ;k<3 ;++k)
                if(j!=k)
                    dp[i][j] = max(dp[i][j] ,
                                dp[i-1][k] + a[i][j]);
        }
    }

    return max ({dp[n-1][0] , dp[n-1][1] , dp[n-1][2] });
} 

int main()
{
    int n;
    cin>>n;
    int a[n][3];
    for(int i = 0 ;i<n ;++i)
        for(int j =0 ; j<3 ; ++j)
            cin>>a[i][j];

    cout << max_points (a,n) <<endl;
    return 0;
}

Measured memory_bytes: 2560
import collections
n,m = map(int,input().split())
k_list = []
for _ in [0]*n:
    k_list.extend([int(i) for i in input().split()[1:]])
col = collections.Counter(k_list)
count = 0
for k,v in col.most_common():
    if v == n:
        count += 1
print(count)

Measured memory_bytes: 3316
#include <cstdio>
using namespace std;
#define N 86
int main(void){
  int n;
  long luca[N+1];
  luca[0] = 2; luca[1] = 1;
  for (int i=2; i<=N; i++){
    luca[i] = luca[i-1]+luca[i-2];
  }
  scanf("%d",&n);
  printf("%ld\n",luca[n]);
  return 0;
}
  

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
using namespace std;

typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> ii;
typedef pair<int64, int64> int64int64;
typedef vector<int> vint;
typedef vector<int64> vint64;
typedef vector<uint64> vuint64;
typedef vector<vint> vvint;
typedef vector<vint64> vvint64;
typedef vector<vuint64> vvuint64;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;

#define mp make_pair
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define fori(n) for(int i = 0; i < n; ++i)
#define forj(n) for(int j = 0; j < n; ++j)
#define fork(n) for(int k = 0; k < n; ++k)

template<typename T>
void prinMatrix(string txt, vector<vector<T>> &a){
	cout << txt;
	fori(a.size()){
		forj(a[i].size())
			cout << a[i][j] << ' ';

		cout << endl;
	}
}

template<typename T>
void printVector(string txt, vector<T> &a){
	cout << txt;
	for (int i = 0; i < a.size(); ++i)
		cout << a[i] << ' ';
	cout << endl;
}

int64 a, b;

int64 minFactor(int64 x){
	for (int64 i = 2; i * i <= x; ++i){
		if (x % i == 0)
			return i;
	}

	return x;
}

set<int64> ad, bd;

int64 allFactor(int64 x, set<int64> &s){
	while (x > 1){
		int64 t = minFactor(x);
		s.insert(t);

		while (x % t == 0)
			x /= t;
	}

	return 0;
}

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie();

	cin >> a >> b;
	allFactor(a, ad);
	allFactor(b, bd);

	ad.insert(1);
	bd.insert(1);

	int64 ans = 0;
	for (auto it = ad.begin(); it != ad.end(); ++it){
		if (bd.find(*it) != bd.end())
			++ans;
	}


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


Measured memory_bytes: 256
#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>;
const int INF = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9 + 7;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}

int main() {
  vector<int> a(5);
  rep(i, 5) cin >> a[i];
  int k;
  cin >> k;
  rep(i, 5) {
    rep(j, 5) {
      if (j <= i) continue;
      if (a[j] - a[i] > k) {
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;

  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  cin >> N >> S;
  int ans=0;
  for (int i=1;i<N;i++){
    set<char> s1,s2;
    for (int j=0;j<i;j++){
      s1.insert(S[j]);
    }
    for (int j=i;j<N;j++){
      s2.insert(S[j]);
    }
    int count=0;
    for (auto value : s1){
      if (s2.count(value)){
        count++;
      }
    }
    ans=max(ans,count);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
typedef long long ll;
 
int main(){
int N;
cin>>N;
vector<int>A(N);
 
for(int i=0;i<N;i++){
   cin>>A[i];
}
vector<int>B=A;
sort(B.rbegin(),B.rend());
 
for(int i=0;i<N;i++){
   int a=B[0];
   if(B[0]==A[i]){
      a=B[1];
   }
   cout<<a<<endl;
 
}
 
return 0;
}

Measured memory_bytes: 4844
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

func abs(a int) int {
	if a < 0 {
		return -a
	} else {
		return a
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func countStudents(height []int32) int32 {
	// Write your code here
	// var count int32
	ideal := make([]int32, len(height))
	for i := 0; i < len(height); i++ {
		ideal[i] = height[i]
	}

	for i := 0; i < len(ideal); i++ {
		for j := i; j < len(ideal)-1; j++ {
			if ideal[j] > ideal[j+1] {
				tmp := ideal[j]
				ideal[j] = ideal[j+1]
				ideal[j+1] = tmp
			}
		}
	}

	for i := 0; i < len(height); i++ {
		fmt.Print(height[i])
	}
	var count int32
	for i := 0; i < len(height); i++ {
		if ideal[i] != height[i] {
			count++

		}
	}

	return count
}
func main() {
	sc.Split(bufio.ScanWords)
	n:=nextInt()
	sum:=0
	for i:=0;i<n;i++{
		sum+=nextInt()
	}

	if sum%2==0{
		fmt.Println("YES")
	}else{
		fmt.Println("NO")
	}
}


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

vector<ll> factorize(ll x) {
  vector<ll> factors;
  for (ll i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      while (x % i == 0) {
        x /= i;
      }
      factors.push_back(i);
    }
  }
  if (x > 1) {
    factors.push_back(x);
  }
  return factors;
}

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

  ll a, b;
  cin >> a >> b;

  vector<ll> a_factors = factorize(a);
  vector<ll> b_factors = factorize(b);
  vector<ll> common_factors;
  set_intersection(
    a_factors.begin(), a_factors.end(),
    b_factors.begin(), b_factors.end(),
    back_inserter(common_factors)
  );
  cout << (common_factors.size() + 1) << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  cin >> S;
  int n = S.size();
  int state = 0;
  for (auto c : S) {
    if (state == 0) {
      if (c == 'C') {
        state = 1;
      }
    } else if (state == 1) {
      if (c == 'F') {
        state = 2;
        break;
      }
    }
  }
  if (state == 2) {
    cout << "Yes" << endl;
    return;
  }
  cout << "No" << endl;
  ;
}
void solve() {
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#if 0
SmartCalculator 
教科書がとても丁寧だったので実装は意外とすぐに完成しました。
関数を部品として少しずつ作っていって、最終的に文法の定義通りに
組み合わせるという流れがわかりやすかったです。
構文解析器を作ってみたかったのですが、全学期のPythonの問題ではよくみる実装と
は少し違っていて難しかったので、今回のはとても参考になりました。
もう少し文脈自由文法などとの理論的な結びつきを実感できる様に、いろいろ
遊んでみたいと思いました。
短く書くために後置インクリメントが活用できるのが面白かったです。
勘違いした点としては、int型での計算なので、2／4などが入ると0として
見なされてしまうので、テストケースと予想結果が合わない時がありました。
#endif
#include <iostream>
#include <memory>
#include <vector>
#include <string>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <queue>
#include <cctype>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
using ll = long long;
ll ll_max = numeric_limits<ll>::max();
ll ll_min = numeric_limits<ll>::min();
int int_max = numeric_limits<int>::max();
int int_min = numeric_limits<int>::min();
int N;
string S;
size_t cur = 0;

char readchar() {
    assert(cur < S.size());
    return S[cur++];
}

char peek() {
    assert(cur < S.size());
    return S[cur];
}

int digit() {
    assert(isdigit(peek()));
    int n = readchar() - '0';
    return n;
}

int number() {
    int n = digit();
    while (cur < S.size() && isdigit(peek()))
        n = n * 10 + digit();
    return n;
}

int expression();
int factor() {
    if (peek() != '(') return number();
    cur += 1;
    int n = expression();
    assert(peek() == ')');
    cur += 1;
    return n;
}

int term() {
    int num = factor();
    while (cur < S.size() && (
            peek() == '*' || peek() == '/')) {
        char op = readchar();
        if (op == '*')
            num *= factor();
        else
            num /= factor();
    }
    return num;
}

int expression() {
    int num = term();
    while (cur < S.size() && (
            peek() == '+' || peek() == '-')) {
        char op = readchar();
        if (op == '+')
            num += term();
        else
            num -= term();
    }
    return num;
}

int parse() {
    return expression();
}

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

    cin >> N;
    rep(n, N) {
        cin >> S;
        cur = 0;
        int a = parse();
        // assert(cur == S.size());
        cout << a << endl;
    }

    return 0;
}


Measured memory_bytes: 3068
n = int(input())
h = list(map(int, input().split()))

before = 0
result = 'Yes'
for i in range(len(h)):
    if i == 0:
        before = h[i] - 1
    else:
        if before < h[i]:
            before = h[i] - 1
        elif before == h[i]:
            before = h[i]
        else:
            result = 'No'
print(result)

Measured memory_bytes: 14396
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
const ll mod = 1e9+7;

ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}

const int N = 2e6;
// ll a[N];

// https://cp-algorithms.com/algebra/fft.html
namespace FFT {
    typedef complex<double> base;
    const double PI = acos(-1);
    template<typename T>
    void bit_reverse(vector<T> &A) {
        int n = A.size();
        for(int i = 1, j = 0; i < n; i++) {
	        int bit = n >> 1;
	        for(; j >= bit; bit >>= 1) {
	        	j -= bit;
	        }
	        j += bit;
	        if(i < j) swap(A[i], A[j]);
        }
    }
    void fft(vector<base> &A, bool invert) {
        int n = A.size();
        bit_reverse(A);
        for(int len = 2; len <= n; len *= 2) {
	          double ang = PI * 2.0l / len;
	          base wn(cos(ang), sin(ang) * (invert ? -1 : 1)), w(1, 0), temp;
	          for(int i = 0; i < n; i += len) {
		            w = base(1, 0);
		            for(int j = 0; j < len/2; j++) {
			                temp = A[i + j];
			              	A[i + j] = temp + w * A[i + j + len/2];
			              	A[i + j + len/2] = temp - w * A[i + j + len/2];
			              	w *= wn;
		            }
	          }
        }
        if(invert)
	        for(int i = 0; i < n; i++)
		        A[i] /= n;
    }
    template<typename T>
    vector<ll> multiply(vector<T> const& a, vector<T> const& b) {
        vector<base> fa(a.begin(), a.end()), fb(b.begin(), b.end());
        int n = 1;
        while (n < a.size() + b.size()) 
            n <<= 1;
        fa.resize(n);
        fb.resize(n);

        fft(fa, false);
        fft(fb, false);
        for (int i = 0; i < n; i++)
            fa[i] *= fb[i];
        fft(fa, true);

        vector<ll> result(n);
        for (int i = 0; i < n; i++)
            result[i] = round(fa[i].real());
        return result;
    }
}

signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);    
    
    ll n, m; cin >> n >> m;
    vector<ll> a(1e5+1);
    for(int i = 1; i <= n; i++) {
    	int foo; cin >> foo;
    	a[foo]++;
    }
 	a = FFT::multiply(a, a);
 	ll sum = 0;
 	for(int i = 2e5; i > 0; i--) {
 		ll can = min(m, a[i]);
 		sum += i * can;
 		m -= can;
 		if(m == 0) break;
 	}
 	cout << sum << endl;

    return 0;
    
}
    


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    double l;
    cin >> l;

    printf("%.7f\n", (l / 3) * (l / 3) * (l / 3));

    return 0;
}

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

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

using namespace std;

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

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

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

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

const unsigned long long INF = 1LL << 60;

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

int main() {
    int x = -1;
    int i = 1;
    while (true) {
        cin >> x;
        if (x == 0) break;
        printf("Case %d: %d\n", i, x);
        i++;
    }
}



Measured memory_bytes: 3140
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
typedef pair<int,P> PP;
struct edge { int to; int to2;int cost; };
string s[405];

signed main() {
	int n, h, w; cin >> n >> h >> w;
	cout << (n - h + 1)*(n - w + 1) << endl;
}

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

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max(0, a + b - n) << endl;
    return 0;
}

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

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

    for (int i = 0; i < S.size(); i++) {
        if (i % 2 == 0) {
            if (S[i] != 'R' && S[i] != 'U' && S[i] != 'D') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (S[i] != 'L' && S[i] != 'U' && S[i] != 'D') {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {


  private void solve(InputReader in, PrintWriter out) {
    int n =in.nextInt();
    out.println(n * (n + 1) / 2);

  }


  public static void main(String[] args) {
    new Main().run();
  }

  private void run() {

    try (InputReader in = new InputReader(System.in);
         PrintWriter out = new PrintWriter(System.out)) {
      solve(in, out);
    }
  }


  static class InputReader implements AutoCloseable {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
      //reader = new BufferedReader(new FileReader(stream), 32768);
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    @Override
    public void close() {
    }
  }

}


Measured memory_bytes: 19924
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
 
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
 
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
 
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define T int t = 0; cin >> t; while(t--)
#define pr(a) for(int i = 0; i < (int)a.size(); ++i)cout << a[i] << " ";cout << endl;
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef long double lld;
const ll mod = 1e9 + 7;
const ll mx = 2e5 + 1;
const ll inf = 1e9;
const int sz = 20;

void input(){
    IOS;
    int n, k;
    cin >> n >> k;
    vector<int>a(n);
    f(i, n)cin >> a[i];
    sort(b_e(a));
    int ans = 0;
    f(i, k)ans += a[i];
    cout << ans << endl;
}
int main(){
    input();
    return 0;
} 
/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/

Measured memory_bytes: 3660
n,k=map(int,input().split())
a=list(map(int,input().split()))
d={}
d[1]=0
cnt=1
li=[1]
for i in range(n):
    cnt=a[cnt-1]
    li.append(cnt)
    if cnt in d.keys():
        x=i+1
        break
    else:
        d[cnt]=i+1
if k<d[cnt]:
    print(li[k])
else:
    print(li[((k-d[cnt])%(x-d[cnt]))+d[cnt]])






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

int main() {
  int n,c=0;
  string s;
  cin >>n>>s;
  
  if(n%2==1){
    cout << "No" << endl;
    return 0;
  }
  
  string p,q;
  p = s.substr(0,n/2);
  q = s.substr(n/2,n/2);

  if(p==q) cout << "Yes" <<endl;
  else cout << "No" <<endl;
  
}


Measured memory_bytes: 256
#ifdef _WIN32
#define DEBUG	1
#endif

#define _CRT_SECURE_NO_WARNINGS
#define MATH_PI 3.14159265358979323846264338327950288419716939
#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;

#ifdef DEBUG
#include "include.h"
#else
inline void wait(){}
inline void dout(const char *arg, ...){}
#endif

template<typename T>inline void swap(T a, T b){T t = a; a = b; b = t;}

#define CLIP(ptr, min, max) {if((min)<=(max)){if(ptr<(min)){ptr=(min);}if(ptr>(max)){ptr=(max);}}}
#define max(a, b) a > b ? a : b;
#define min(a, b) a > b ? b : a;
#define Sin(deg) sin((deg)*MATH_PI/180)
#define Cos(deg) cos((deg)*MATH_PI/180)
#define Tan(deg) tan((deg)*MATH_PI/180)
#define Rad(deg) ((deg)*MATH_PI/180)
#define ff(param, num) for(int param=0 ; param<num ; ++param)
#define fi(num) for(int i=0 ; i<num ; ++i)
#define fj(num) for(int j=0 ; j<num ; ++j)
#define fk(num) for(int k=0 ; k<num ; ++k)
#define fl(num) for(int l=0 ; l<num ; ++l)
#define ffr(param, num) for(int param=num-1 ; param>=0 ; --param)
#define fir(num) for(int i=num-1 ; i>=0 ; --i)
#define fjr(num) for(int j=num-1 ; j>=0 ; --j)
#define fkr(num) for(int k=num-1 ; k>=0 ; --k)
#define flr(num) for(int l=num-1 ; l>=0 ; --l)
#define gi(p) Scanf("%d", p)
#define gi2(p1, p2) Scanf2("%d %d", p1, p2)
#define gi3(p1, p2, p3) Scanf3("%d %d %d", p1, p2, p3)
#define gi4(p1, p2, p3, p4) Scanf4("%d %d %d %d", p1, p2, p3, p4)
#define gll(p) Scanf("%lld", p)
#define gll2(p1, p2) Scanf2("%lld %lld", p1, p2)
#define gll3(p1, p2, p3) Scanf3("%lld %lld %lld", p1, p2, p3)
#define gll4(p1, p2, p3, p4) Scanf4("%lld %lld %lld %lld", p1, p2, p3, p4)
#define gf(p) Scanf("%f", p)
#define gf2(p1, p2) Scanf2("%f %f", p1, p2)
#define gf3(p1, p2, p3) Scanf3("%f %f %f", p1, p2, p3)
#define gf4(p1, p2, p3, p4) Scanf4("%f %f %f %f", p1, p2, p3, p4)
#ifdef DEBUG
#define gc(buf) fscanf(local_in.fp, "%s", buf)
#define Scanf(expr, p) fscanf(local_in.fp, expr, &p)
#define Scanf2(expr, p1, p2) fscanf(local_in.fp, expr, &p1, &p2)
#define Scanf3(expr, p1, p2, p3) fscanf(local_in.fp, expr, &p1, &p2, &p3)
#define Scanf4(expr, p1, p2, p3, p4) fscanf(local_in.fp, expr, &p1, &p2, &p3, &p4)
#else
#define gc(buf) Scanf("%s", buf)
#define Scanf(expr, p) scanf(expr, &p)
#define Scanf2(expr, p1, p2) scanf(expr, &p1, &p2)
#define Scanf3(expr, p1, p2, p3) scanf(expr, &p1, &p2, &p3)
#define Scanf4(expr, p1, p2, p3, p4) scanf(expr, &p1, &p2, &p3, &p4)
#endif
#define ans(p) cout << p << endl;
signed main() {

	int ii, jj, kk, ll;
	int N;
	int ret = 0;
	int flag = 0;
	char cbuf[8192];

	int a, b, c, d, e, k;
	gi4(a, b, c, d);
	gi2(e, k);

	if(e - a <= k){
		ans("Yay!");
	}
	else{
		ans(":(");
	}

	wait();

	return 0;
}

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


int main(){
  string N;
  cin >> N;
  if( N[0] == '7' || N[1] == '7' || N[2] == '7'){
   cout << "Yes" << endl;
  }
  else {
   cout << "No" << endl; 
  }
  
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

struct QueueItem
{
  uint64_t value, count;
  QueueItem(uint64_t value, uint64_t count) : value(value), count(count) {}
  bool operator<(const QueueItem &item) const { return value < item.value; }
  bool operator>(const QueueItem &item) const { return value > item.value; }
};

std::ostream& operator<<(std::ostream &os, const QueueItem &item)
{
  os << '(' << item.value << ", " << item.count << ')';
  return os;
}

int main(int argc, char **argv)
{
  uint64_t N, M;
  std::cin >> N >> M;
  
  std::priority_queue<QueueItem, std::vector<QueueItem>, std::greater<QueueItem>> pq;
  N_TIMES(n, N) {
    uint64_t A;
    std::cin >> A;
    
    pq.emplace(A, 1);
  }
  
  N_TIMES(m, M) {
    uint64_t B, C;
    std::cin >> B >> C;
    
    int64_t x = B;
    uint64_t count = 0;
    do {
      QueueItem item = pq.top();
      
      if (item.value >= C) { break; }
      pq.pop();
      
      if (x >= item.count) {
        count += item.count;
        x -= item.count;
      } else {
        count = B;
        pq.emplace(item.value, item.count - x);
        break;
      }
    } while(x > 0);
    if (count > 0) { pq.emplace(C, count); }
  }
  
  uint64_t S = 0;
  while (!pq.empty()) {
     QueueItem item = pq.top(); pq.pop();
     S += item.value * item.count;
  }
  std::cout << S << std::endl;
  
  return 0;
}

Measured memory_bytes: 2420
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ForYellow
{
    class ABC165_E
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int n = nm[0];
            int m = nm[1];

            int even = m / 2;
            if (m % 2 == 1)
            {
                even++;
            }
            int odd = m - even;
            for(int i = 0; i < even; i++)
            {
                int left = i + 1;
                int right = left + (even - 1 - i) * 2 + 1;
                WriteLine(left + " " + right);
            }

            for(int i = 0; i < odd; i++)
            {
                int left = even * 2 + 1 + i;
                int right = left + (odd - 1 - i) * 2 + 2;
                WriteLine(left + " " + right);
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 37644
import sys
input = sys.stdin.readline
from collections import Counter, deque


INF = float('inf')

""" Input
S = input()
N = int(input())
D = [int(input()) for _ in range(N)]
"""

def main():
    N, M = map(int, input().split())
    A = sorted(list(map(int, input().split())), reverse=True)
    total_score = sum(A)
    threshold = total_score * (1 / (4 * M))

    counter = 0
    for a in A:
        if threshold <= a:
            counter += 1

    if counter < M:
        print('No')
    else:
        print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define ll          long long
#define pll         vector< pair<ll ,ll> >
#define vll         vector<ll>
#define vi          vector<int>
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pb          push_back
#define F           first
#define S           second
#define mp          make_pair
#define all(v)      v.begin(), v.end()
#define lb          lower_bound  //value not less than(>=)
#define ub          upper_bound  //value greater than(>)
#define bs          binary_search
#define pcont(v)    for(auto it:v) cout<<it<<" ";cout<<endl
#define ret(x)      return cout << x,0;
#define pi          pair<ll,pair<ll,ll> >
int const MAX = 1e5 + 5;
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    ll d,n;
    cin >> d >> n;
    if(d==0)
    {
        if(n<100) ret(n);
        if(n==100) ret(101);
    }
    if(d==1)
    {
        if(n<100) ret(n*100);
        if(n==100) ret(10100);
    }
    if(d==2)
    {
        if(n<100) ret(n*10000);
        if(n==100) ret(1010000);
    }
}


Measured memory_bytes: 256
N = int(input())
B6 = [6**i for i in range(1,8)]
B9 = [9**i for i in range(1,7)]
L = sorted(list(set((B6+B9))))
dp = [i for i in range(N+1)]
for i in L :
    for j in range(i,N+1) :
        dp[j] = min(dp[j], dp[j-i]+1)
print(dp[-1])


Measured memory_bytes: 7064
#include "bits/stdc++.h"
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif
const int N = 5e5+5;
class DSU{

    public:
    int par[N];
    int sz[N];
    void init(int n){
        for(int i=0;i<=n;i++){
            par[i] = i;
            sz[i] = 1;
        }
    }
    int parent(int x){
        while(x!=par[x]){
            par[x] = par[par[x]];
            x = par[x];
        }
        return x;
    }
    void merge(int x,int y){
        int a = parent(x);
        int b = parent(y);
        if(a==b){
            return;
        }
        if(sz[a]>sz[b]){
            swap(a,b);
        }
        sz[b] += sz[a];
        sz[a] = 0;
        par[a] = b;
    }
};

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k,l;
    cin>>n>>k>>l;
    DSU road;
    DSU railway;
    road.init(n);
    railway.init(n);
    for(int i=0;i<k;i++){
        int u,v;
        cin>>u>>v;
        road.merge(u,v);
    }
    for(int i=0;i<l;i++){
        int u,v;
        cin>>u>>v;
        railway.merge(u,v);        
    }
    map<pair<int,int>,int>m;
    for(int i=1;i<=n;i++){
        int x = road.parent(i);
        int y = railway.parent(i);
        m[{x,y}]++;
    }
    for(int i=1;i<=n;i++){
        int x = road.parent(i);
        int y = railway.parent(i);
        cout<<m[{x,y}]<<" ";
    }
    
    return 0;
    
}


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

int main() {
  int N;
  cin >> N;
  int p=0;
  for (int i = 0; i < N; i++){
      int l,r;
      cin >> l >> r;
      p+=(r-l+1);
    
  }
  cout << p;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
typedef  long long ll;
const int maxn=2e5+50;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int HASH=131;

int n;
int main()
{
    cin>>n;
    n^=1;
    cout<<n<<endl;
}


Measured memory_bytes: 3120
#include <cstdio>
#include <iostream>
#include <string>
#define INF (1<<21)
using namespace std;

int main(){
  int i,j,n,m,s,t,cost,a[100][100],d[100],f[100],min,p,sum;
  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0) break;
    for(i=0;i<n;i++){
      d[i] = INF;
      f[i] = 0;
      for(j=0;j<n;j++){
	a[i][j] = INF;
      }
    }

    for(i=0;i<m;i++){
      cin >> s >> t >> cost;
      a[s][t] = a[t][s] = cost;
    }

    d[0] = 0;
    while(1){
      min = INF;
      for(i=0;i<n;i++){
	if(d[i]<min && f[i] == 0){
	  min = d[i];
	  p = i;
	}
      }
      if(min == INF) break;
      f[p] = 1;
      for(i=0;i<n;i++){
	if(f[i] == 1) continue;
   	if(a[p][i] < d[i]) d[i] = a[p][i];
      }
    }
    
    sum = 0;
    for(i=0;i<n;i++){
      sum += d[i];
    }

    cout << sum << endl;
  }
  return 0;
}

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

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


int A[2010];
int dp[2010][2010];
int N;

int dfs(int x, int y){
    if(dp[x][y] >= 0) return dp[x][y];
    int res = 0;
    if(x == N - 1 || y == N - 1) res = abs(A[x] - A[y]);
    else{
        if(x < y){
            if(x == 0){
                res = 0;
                for(int i = y + 1; i < N; i++)
                    res = max(res, dfs(i, y));
            }
            else{
                res = dfs(0, y);
            }
        }
        else{
            if(y == 0){
                const int INF = (1 << 30) - 1;
                res = INF;
                for(int i = x + 1; i < N; i++)
                    res = min(res, dfs(x, i));
            }
            else{
                res = dfs(x, 0);
            }
        }
    }
    return dp[x][y] = res;
}

int main(){

    int Z, W;
    cin >> N >> Z >> W;
    A[0] = Z; A[1] = W;
    for(int i = 0; i < N; i++) cin >> A[i + 2];
    N += 2;

    memset(dp, -1, sizeof(dp));
    cout << dfs(0, 1) << endl;
    

    return 0;
}


Measured memory_bytes: 16128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

int main()
{
	char S[10];
	scanf("%s", S);
	
	if(S[2] == S[3] && S[4] == S[5]){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}

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

int main()
{
	constexpr int inf{1 << 30};
	int N, M;
	scanf("%d%d", &N, &M);
	// {company, p, q}
	std::vector<std::array<int, 3>> edges(M);
	for (auto& e: edges)
	{
		scanf("%d%d%d", &e[1], &e[2], &e[0]);
		e[1]--;
		e[2]--;
	}
	std::sort(edges.begin(), edges.end());

	// 各社に属する頂点
	std::vector<std::vector<int>> companies;
	companies.reserve(M);
	for (int i{}, prev{-1}; i < M; i++)
	{
		if (edges[i][0] != prev) companies.push_back({});
		companies.back().push_back(edges[i][1]);
		companies.back().push_back(edges[i][2]);
		prev = edges[i][0];
		edges[i][0] = (int)companies.size() - 1;	// 座圧
	}
	
	// 各駅ごとに出てる路線(会社順ソート)
	std::vector<std::vector<std::pair<int, int>>> edgeList(N);
	for (auto& e: edges)
	{
		edgeList[e[1]].push_back({e[0], e[2]});
		edgeList[e[2]].push_back({e[0], e[1]});
	}
	for (auto& e: edgeList)
	{
		std::sort(e.begin(), e.end());
		e.push_back({1ll << 30, 1 << 30});
	}

	std::vector<std::vector<int>> graph(N);
	graph.reserve(N + M);
	std::vector<int> indices(N);
	for (int c_i{}; c_i < (int)companies.size(); c_i++)
	{
		for (auto& e: companies[c_i])
		{
			if (edgeList[e][indices[e]].first > c_i) continue;
			graph.push_back({});
			std::queue<int> bfs;
			bfs.push(e);
			while (!bfs.empty())
			{
				auto now{bfs.front()};
				bfs.pop();
				graph[now].push_back((int)graph.size() - 1);
				graph[(int)graph.size() - 1].push_back(now);
				while (edgeList[now][indices[now]].first == c_i)
				{
					int next{edgeList[now][indices[now]].second};
					if (edgeList[next][indices[next]].first == c_i)
						bfs.push(next);
					indices[now]++;
				}
			}
		}
	}

	std::vector<int> distance(graph.size(), 1 << 30);
	distance[0] = 0;
	std::queue<int> bfs;
	bfs.push(0);
	while (!bfs.empty())
	{
		auto now{bfs.front()};
		bfs.pop();
		for (auto& e: graph[now])
		{
			if (distance[e] <= distance[now] + 1) continue;
			distance[e] = distance[now] + 1;
			bfs.push(e);
		}
	}
	if (distance[N - 1] == (1 << 30)) puts("-1");
	else printf("%d\n", distance[N - 1] / 2);

	return 0;
}


Measured memory_bytes: 40792
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
const int MaxN = 1e5 + 4;
typedef long long LL;
int main(){
	int a,b;
	cin>>a>>b;
	if(a+b == 15) cout<<"+"<<endl;
	else if(a*b == 15) cout<<"*"<<endl;
	else cout<<"x"<<endl;
	return 0;
}

Measured memory_bytes: 256