akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
//BEGIN CUT HERE
struct BiconectedGraph{
  typedef pair<int,int> P;
  vector<vector<int> > G,C,T;
  vector<int> ord,low,belong;
  vector<P> B;
  int n;
  BiconectedGraph(){}
  BiconectedGraph(int n):n(n){
    G.clear();
    C.clear();
    T.clear();
    G.resize(n);
    C.resize(n);
    T.resize(n);
  }
  
  void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
  }

  void input(int m,int offset){
    int a,b;
    for(int i=0;i<m;i++){
      cin>>a>>b;
      add_edge(a+offset,b+offset);
    }
  }
  
  bool is_bridge(int u,int v){
    if(ord[u]>ord[v]) swap(u,v);
    return ord[u]<low[v];
  }
  
  void dfs(int u,int p,int &k){
    ord[u]=low[u]=k;
    ++k;
    for(int v:G[u]){
      if(v==p) continue;
      if(ord[v]>=0){
	low[u]=min(low[u],ord[v]);
      }else{
	dfs(v,u,k);
	low[u]=min(low[u],low[v]);
      }
      if(is_bridge(u,v)) B.push_back(P(u,v));
    }
  }
  
  void fill_component(int c,int u){
    C[c].push_back(u);
    belong[u]=c;
    for(int v:G[u]){
      if(belong[v]>=0||is_bridge(u,v)) continue;
      fill_component(c,v);
    }
  }
  
  void add_component(int u,int &k){
    if(belong[u]>=0) return;
    fill_component(k++,u);
  }
  
  int build(){
    int k=0;
    ord.clear();
    low.clear();
    belong.clear();
    ord.resize(n,-1);
    low.resize(n);
    belong.resize(n,-1);
    for(int u=0;u<n;u++){
      if(ord[u]>=0) continue;
      dfs(u,-1,k);
    }
    k=0;
    for(int i=0;i<(int)B.size();i++){
      add_component(B[i].first,k);
      add_component(B[i].second,k);
    }
    for(int u=0;u<n;u++) add_component(u,k);
    for(int i=0;i<(int)B.size();i++){
      int u=belong[B[i].first],v=belong[B[i].second];
      T[u].push_back(v);
      T[v].push_back(u);
    }
    return k;
  }
};
//END CUT HERE

signed main(){
  int v,e;
  cin>>v>>e;
  BiconectedGraph bcc(v);
  bcc.input(e,0);
  bcc.build();
  typedef pair<int,int> P;
  vector<P> B=bcc.B;
  for(P &p:B) if(p.first>p.second) swap(p.first,p.second);
  sort(B.begin(),B.end());
  for(P p:B) cout<<p.first<<" "<<p.second<<endl;
  return 0;
}

/*
  verified on 2017/10/21
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_B&lang=jp
*/

Measured memory_bytes: 5728
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	string S;
	cin >> S;
	int N = S.size();
	VI ans(N,0),R(N),L(N);
	
	
	int cnt = 0, tmp = 0;

	for (int i = N - 1; i >= 0; i--) {
		if (S[i] == 'R')R[i] = tmp;
		else tmp = i;
	}
	tmp = 0;
	REP(i, N) {
		if (S[i] == 'L')L[i] = tmp;
		else tmp = i;
	}

	REP(i, N) {
		//cout << R[i] << " " << L[i] << endl;
	}

	REP(i, N) {
		if (S[i] == 'R') {
			if ((R[i]-i) % 2) ans[R[i]-1]++;
			else ans[R[i]]++;
		}
		else {
			if ((i-L[i]) % 2) ans[L[i]+1]++;
			else ans[L[i]]++;
		}
		
	}
	REP(i, N) {
		cout << ans[i];
		if (i != N - 1) {
			cout << " ";
		}
		else
			cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3152
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	A := sc.nextIntSlice(5)
	k := sc.nextInt()
	ok := true
	for i := 0; i < 5; i++ {
		for j := i + 1; j < 5; j++ {
			if abs(A[i]-A[j]) > k {
				ok = false
			}
		}
	}
	if ok {
		fmt.Println("Yay!")
	} else {
		fmt.Println(":(")
	}
}


Measured memory_bytes: 640
# https://atcoder.jp/contests/abc142/tasks/abc142_d
# これは,A,Bの最大公約数を見つけてからそれを素因数分解し、累乗の底の個数＋1が答えとなる。

from fractions import gcd


def factorization(n: int):
    if n == 1:
        return []  # 1は素数ではない

    # 素因数分解
    arr = []
    temp = n
    for i in range(2, int(n**0.5) + 1):  # ここにバグがないか心配
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append((i, cnt))

    if temp != 1:
        arr.append((temp, 1))

    if arr == []:
        arr.append((n, 1))

    return arr


A, B = list(map(int, input().split()))


G = gcd(A, B)
ans = len(factorization(G)) + 1
print(ans)


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

int main()
{
  int n;cin>>n;
  vector<int> a(n);
  int i;
  bool ok=true;
  for(i=0;i<n;i++)cin>>a.at(i);
  for(i=0;i<n;i++)
  {
    if(a.at(i)%2==0)
    {
      if(a.at(i)%3!=0&&a.at(i)%5!=0)ok=false;
    }
  }
  if(ok)cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

class Summation {
public:
	void addplus(string str, unsigned long long sum);
	void set_result(string str);
	unsigned long long get_result();
private:
	unsigned long long result = 0;
};

void Summation::addplus(string str, unsigned long long sum) {
	for (int i = 1; i < str.size(); i++) {
		string bstr = str.substr(0,i);
		string astr = str.substr(i);
		unsigned long long dsum = sum + stoull(bstr);
		result += dsum + stoull(astr);
		addplus(astr, dsum);
	}
}

void Summation::set_result(string str) {
	result = stoull(str);
}

unsigned long long Summation::get_result() {
	return result;
}

int main() {

	string S;
	cin >> S;

	Summation calsum;
	calsum.set_result(S);
	calsum.addplus(S, 0);

	cout << calsum.get_result() << endl;

	return 0;
}



Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#A
def A():
    a, b, c, d = LI()
    x = abs(a - b)
    y = abs(b - c)
    z = abs(a - c)
    if (x <= d and y <= d) or z <= d:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    return

#C
def C():
    s = stdin.readline().rstrip()
    K = II() - 1
    ans = []
    for i in range(len(s)):
        for k in range(K+1):
            b = s[i:i + k + 1]
            ans.append(b)
    ans = list(set(ans))
    ans.sort()
    print(ans[K])
    return

#D
def D():
    n, m = LI()
    p = LI_()
    xy = LIR_(m)
    size = [1 for _ in range(n)]
    height = [1 for _ in range(n)]
    par = [i for i in range(n)]
    def find(x):
        if par[x] == x:
            return x
        else:
            par[x] = find(par[x])
            return par[x]
    def union(x, y):
        s1 = find(x)
        s2 = find(y)
        if s1 != s2:
            if height[s1] < height[s2]:
                par[s1] = s2
                size[s2] += size[s1]
                size[s1] = 0
            else:
                par[s2] = s1
                size[s1] += size[s2]
                size[s2] = 0
                if height[s1] == height[s2]:
                    height[s1] += 1

    for x,y in xy:
        union(x, y)
    ans = 0
    for i in range(n):
        if find(p[i]) == find(i):
            ans += 1
    
    print(ans)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 40048
#include <iostream>

using namespace std;

// 500, 100, 50円
int a, b, c;
int x;

bool check_sum(int i) {
    if (i == x) {
        return true;
    }
    return false;
}

int main() {
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> x;

    int total = 0;
    int tmp1, tmp2, tmp3;

    int count = 0;

    for (int i = 0; i <= a && i*500 <= x; i++) {
        tmp1 = 500 * i;
        if (check_sum(total + tmp1)) {
            count++;
            break;
        }
        total += tmp1;
        for (int j = 0; j <= b && total + j*100 <= x; j++) {
            tmp2 = 100 * j;
            if (check_sum(total + tmp2)) {
                count++;
                break;
            }
            total += tmp2;
            for (int k = 0; k <= c; k++) {
                tmp3 = 50 * k;
                if (check_sum(total + tmp3)) {
                    count++;
                    break;
                }
            }
            total -= tmp2;
        }
        total -= tmp1;
    }

    cout << count << endl;
    return 0;
}


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

#define MAXN 200001

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;
    vector<int64_t> a(n), dp(n), os(n);
    for (auto &i: a) cin >> i;
    for (int i = 0; i < n; ++i) {
        os[i] = (i ? os[i-1] : 0) + (i % 2 ? 0 : a[i]);
    }
    for (int i = 0; i < n; ++i) {
        if (i) dp[i] = a[i] + (i > 1 ? dp[i-2] : 0);
        if (i % 2) {
            dp[i] = max(dp[i], os[i-1]);
        } else if (i){
            dp[i] = max(dp[i], dp[i-1]);
        }
    }
    cout << dp[n-1];
}

Measured memory_bytes: 7952
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 200005
#define M 2000005
#define seed 23333
#define mo 1000000007

using namespace std;
int pw[N],i,j,m,n,p,k,l=1000000,r=999999,zh,fa,start;
char c[N];
int now[M];
map<int,int>mp;
void print()
{
		for (i=l;i<=r;++i)
			for (j=1;j<=now[i];++j)
				printf("%c",'A'+(start^((i-l)&1)));	
}
void work()
{
		if (!start)
		{
				start^=1;
				if (now[l]==1)
				{ 
					now[l+1]+=now[l];
					++l;
				}
				else
				{
					--now[l];
					now[--l]=1;
				}
		}
		else 
		{
				start^=1;
				if (now[l]==1) 
				{
						start^=1;
						++l;
				}
				else 
				{
						--now[l];
				}
				if (((r-l)&1)^start) now[++r]=1;
				else now[r]++;
		}
}
int main()
{
		scanf("%d%d",&n,&k);
		scanf("%s",c+1);
		pw[0]=1;
		for (i=1;i<N;++i) pw[i]=1ll*pw[i-1]*seed%mo; 
		for (i=1;i<=n;++i) 
				if (c[i]==c[i-1]) ++now[r];
				else now[++r]=1;
		start=(c[1]=='B');
		if(k > (n << 1))
		{
			k = (n << 1) + (k & 1);
		}
		for (i=0;i<k;++i)	work();
		print();
}
	

Measured memory_bytes: 7168
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n, m;

  	cin >> n >> m;
	vector<int> v(m);
	
	for(int i=0;i<m;i++){
		cin>> v[i];
	}
	sort(v.begin(), v.end());
	vector<int> dp(n+1);
	
	dp[0] = 0;
	for(int i=1;i<n+1;i++){
		int x = i;
		for(int j=0;j<m;j++){
			if(v[j]<=i){
				x= min(dp[i-v[j]]+1, x);
			}
		}
		dp[i] = x;
	}
	cout<<dp[n] <<endl;
}


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

int main(){
  int N, K;
  string S;
  cin >> N >> K >> S;

  if(S.at(K-1)=='A') S.at(K-1)='a';
  else if(S.at(K-1)=='B') S.at(K-1)='b';
  else if(S.at(K-1)=='C') S.at(K-1)='c';

  cout << S << endl;
}

Measured memory_bytes: 256
// ABC152C2.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

//#include "pch.h"
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int ans = 0;
	int min = 2 * 100000 + 1;
	int N;
	cin >> N;
	vector<int>P(N);
	for (int i = 0; i < N; i++)
	{
		cin >> P.at(i);
		if (min>=P.at(i))
		{
			ans++;
			min = P.at(i);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
n = int(input())
ls_s = list(input())

ls_a = [0]*len(ls_s)

for i in range(len(ls_s)):
    num_si = ord(ls_s[i])
    if num_si + n <= 90:
        num_ai = num_si + n
    else:
        num_ai = 64 + (num_si + n) % 90
    ls_a[i] = chr(num_ai)

ans = "".join(ls_a)
print(ans)

Measured memory_bytes: 3188
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


class BinaryIndexTree:  # 1-indexed
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


if __name__ == "__main__":
    N = int(input())
    bit = BinaryIndexTree(N+10)

    A = list(map(int, input().split()))
    d = {a: i+1 for i, a in enumerate(sorted(A))}

    ans = 0
    for a in A:
        i = d[a]
        ans += (i - bit.sum(i) - 1)
        bit.add(i, 1)
    print(ans)



Measured memory_bytes: 39860
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	int x=c-a,y=d-b;
	cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b;
  cin >> a >> b;
  if(a==b){
  cout << a << endl;
  }
  else if (a<b){
  cout << a << endl;
  }
  else{
  cout << a-1 << endl;
  }
  
}
  
  

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

            var S = GetStr().ToCharArray();
            var ans = new string(S.Select(s => s == ',' ? ' ' : s).ToArray()) ;


            Console.WriteLine(ans);


            Console.Out.Flush();
            Console.ReadKey();
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public char GetChar() { return Console.ReadLine().Trim()[0]; }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public Double[] GetDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V,W>(out T a, out U b, out V c, out W d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
        }
        static void Multi<T, U, V, W,X>(out T a, out U b, out V c, out W d,out X e)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);e = cv<X>(ar[4]);
        }
    }
}

Measured memory_bytes: 13396
// Author: Amey Bhavsar
// IDE: Geany/Ubuntu
// Platform: *

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

typedef long long ll;

#define rep(i,a,b) for(auto i=a;i<b;i++)
#define repD(i,a,b) for(auto i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
// traversal function to avoid long template definition
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())
// ll fe (ll x, ll y) {
	// ll ans = 1;
	// while (y>0) {
		// if (y&1) {
			// ans = (x*ans) % MOD;
		// }
		// y /= 2;
		// x = (x*x) % MOD;
	// }
	// return (ans % MOD);
// }

// ll modmul(ll a, ll b) {
    // return ((a%MOD) * (b%MOD)) % MOD;
// }

// ll modadd(ll a , ll b){
    // return((a%MOD)+(b%MOD)+MOD)%MOD;
// }

// ll modsub(ll a , ll b){
    // return((a%MOD) - (b%MOD) + MOD)%MOD;
// }
#define MOD 1000000007
// int n;
// vector<int> a;
// void solution() {
	// cin >> n;
	// a.resize(n);
	// for (auto& e:a) {
		// cin >> e;
	// }
// }

int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int a,b;
	cin >> a >> b;
	if (a >= 10) {
		cout << b;
	} else {
		cout << 100*(10-a) + b;
	}
	return 0;
}


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

int n;
vector<int> ab[100001];
vector<bool> vis(100001,false);
vector<int> fdis(100001,0);
vector<int> sdis(100001,0);
bool fen=true;

void dfs(int node,int d){
    if(vis[node]){
        return ;
    }
    vis[node]=true;
    if(fen){
        fdis[node]=d;
    }else{
        sdis[node]=d;
    }
    for(int i=0;i<ab[node].size();i++){
        dfs(ab[node][i],d+1);
    }
}

int main(){

    cin >> n;

    rep(i,n-1){
        int s,t;
        cin>>s>>t;
        ab[s].push_back(t);
        ab[t].push_back(s);
    }

    dfs(1,0);
    fen=false;
    rep(i,n+1)vis[i]=false;
    dfs(n,0);
    int fe=0;
    int su=0;
    for(int i=1;i<=n;i++){
        if(fdis[i]<=sdis[i]){
            fe++;
        }else{
            su++;
        }
    }

    if(fe>su){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }

    return 0;
}

Measured memory_bytes: 11136
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

char o(int n, char a){
    if(n==0) return a;
    if (a=='a') return o(n-1,'Z');
    if (a=='A') return o(n-1,'z');
    return o(n-1, (char)((int)a-1));
}

int main(){
    for(;;){
        int n;
        cin >>n;
        if(!n)break;
        vector<int> key(n);
        rep(i,n) cin >> key[i];
        string s;
        cin >> s;
        string ans="";
        int j=0;
        for (int i=0; i<s.length(); i++) {
            ans += o(key[j],s[i]);
            j++;
            if(j==key.size()) j=0;
        }
        cout << ans << endl;
    }
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int a[4][4];
int b[15];
int f[4][4];

int main(void)
{
    REP(i,3) {
        REP(j,3) {
            cin >> a[i][j];
            f[i][j] = 0;
        }
    }
    int n;
    cin >> n;
    REP(i ,n) {
        cin >> b[i];
        REP(j, 3) {
            REP(k, 3) {
                if(a[j][k] == b[i]) f[j][k] = 1;
            }
        }
    }
    bool r = false;
    REP(i, 3) {
        if(f[i][0] + f[i][1] + f[i][2] == 3) r = true;
        if(f[0][i] + f[1][i] + f[2][i] == 3) r = true;
    }
    if(f[0][2]+f[1][1]+f[2][0] == 3) r = true;
    if(f[0][0]+f[1][1]+f[2][2] == 3) r = true;
    cout << (r?"Yes":"No") << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

void sub1(int *hp,int *wp)
{
	int i,j;
	int y;
	int h=*hp;
	int w=*wp;
	int base,min;
	
	base=pow(h,2)+pow(w,2);
	min=(149,2)+pow(150,2);
	for(i=1;i<=149;i++){
		for(j=i+1;j<=150;j++){
			y=pow(i,2)+pow(j,2);
			if(base<=y&&y<min){
				if(base==y){
					if(h<i){
						*hp=i;
						*wp=j;
						min=y;
					}
				}else{
					*hp=i;
					*wp=j;
					min=y;
				}
			}
		}
	}
}
int main(void)
{
	int height,width;
	int len;
	
	while(1){
		scanf("%d %d",&height,&width);
		if(height==0&&width==0)break;
		sub1(&height,&width);
		printf("%d %d\n",height,width);
	}
	return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

int main() {
    int n; cin >> n;
    int p[n]; rep(i, n) cin >> p[i];

    int ans = 0;
    rep(i, n){
        int i1 = i + 1;
        int i2 = i + 2;
        if(n <= i1 || n <= i2) break;
        if((p[i] < p[i1] && p[i1] < p[i2]) || (p[i2] < p[i1] && p[i1] < p[i])) ans++;
    }
    OP(ans);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    String S=gs();
	    
	    for(int i=0; i<S.length(); i++) {
	    	char c=S.charAt(i);
	    	if (i%2==0 && c=='L') {
	    		System.out.print("No");
	    		return;
	    	}
	    	if (i%2==1 && c=='R') {
	    		System.out.print("No");
	    		return;
	    	}
	    }

        System.out.print("Yes");
//        if (c<=2) {
//        	System.out.println("YES");
//        }else {
//        	System.out.println("NO");
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35324
#coding:utf-8

import sys
import copy

def main():
    line = sys.stdin.readline()
    #case
    while line.split() != ["0","0"]:
        analy(line)
        line = sys.stdin.readline()
    return

def analy(line):
    #整列
    field = [int(n) for n in line.split()]
    # 横、縦
    num = int(sys.stdin.readline())
    data = []
    for i in range(num):
        a = sys.stdin.readline()
        b = [int(n) for n in a.split()]
        #横、縦
        data.append(b)
    print (compute(field, data))

def compute(field, ng):
    list = []
    for i in range(field[1]):
        for j in range(field[0]):
            #横→縦に移動していく
                if i == 0 :
                    #一番下
                    if [j+1,i+1] in ng:
                        list.append(0)
                    elif j == 0:
                        #左がない
                        list.append(1)
                    else:
                        list.append(list[j-1])
                else:
                    if [j+1,i+1] in ng:
                        list[j] = 0
                    elif j != 0:
                    #no left >> the same.
                        list[j] = list[j-1] + list[j]
    return list[len(list)-1]

if __name__ == "__main__":
    main()

Measured memory_bytes: 4296
#![allow(unused_imports, unused_macros)]

use std::io::*;
use std::str::*;
use std::collections::BTreeSet;
use std::collections::VecDeque;

macro_rules! get{
    ($t:ty) => {
        {
            let cin = stdin();
            let mut cin = cin.lock();
            
            let token =
                cin.by_ref().bytes().map(|c| c.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect::<String>();
            token.parse::<$t>().ok()
        }
    }
}

macro_rules! input{
    ($($id:ident: $t:ty),*) => {
        $(
            let $id = get!($t).unwrap();
        )*;
    }
}

macro_rules! input_vec{
    ($id:ident: Vec<$t:ty>, $n:expr) => {
        let $id = (0..$n).map(|_| get!($t).unwrap()).collect::<Vec<$t>>();
    }
}


fn main(){
    input!(n: u32, s: String);
    solve(n,s);
}

fn solve(n: u32, s: String){
    let rh = RollingHash::new(&s, 31, 1_000_000_007);


    let check = |l: u32| {
        let mut st: BTreeSet<u64> = BTreeSet::new();
        let mut q = VecDeque::new();

        for i in 0..n-l+1 {
            let h = rh.hash_between(i as usize,(i+l) as usize);

            

            if st.contains(&h) {
                return true;
            }

            if q.len() as u32 == l-1 {
                q.push_back(h);
                let t = *(q.front().unwrap());
                q.pop_front();
                st.insert(t);
            }else{
                q.push_back(h);
            }
        }
        
        false
    };


    let mut lb = 0i32;
    let mut ub = n as i32;
    let mut mid: i32;

    while (ub-lb).abs() > 1 {
        mid = (lb+ub) / 2;

        if check(mid as u32) {
            lb = mid;
        }else{
            ub = mid;
        }
    }
        
    let ans = lb;

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



struct RollingHash{
    m: u64,
    pow: Vec<u64>,
    hash: Vec<u64>,
}

impl RollingHash{
    fn new(s: &String, base: u64, m: u64) -> RollingHash{
        let n = s.len();
        
        let pow = vec![1; n+1].iter().scan(1, |prev,_| {
            let ret = *prev;
            *prev = (*prev * base) % m;
            Some(ret)
        }).collect::<Vec<u64>>();

        let mut hash = vec![0; n+1];
        let ref s = s.chars().collect::<Vec<char>>();

        for i in 1..n+1 {
            hash[i] = (hash[i-1] * base + (s[i-1] as u64)) % m;
        }

        RollingHash {
            m: m,
            pow: pow,
            hash: hash
        }
    }

    /// [i,j)
    fn hash_between(&self, i: usize, j: usize) -> u64{
        (self.hash[j] + self.m - (self.hash[i] * self.pow[j-i]) % self.m) % self.m
    }
}


Measured memory_bytes: 4352
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))

point = 0

for i,j in enumerate(a):
    if i%2 == 0 and j%2 == 1:
        point += 1

print(point)

Measured memory_bytes: 9112
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#define mmod 924844033
#define N 210000
#define M 550000
#define grt 5
#define LL long long
using namespace std;
int jc[M],ny[M];
struct node{int y,nex;}a[2*N];
struct NTT{
	int a[M],b[M],c[M],bitrev[M],m,g[M],ng[M];
	int qmod(int a,int b)
	{
		int t=1;
		while(b)
		{
			if(b%2) t=1ll*t*a%mmod;
			b/=2;
			a=1ll*a*a%mmod;
		}
		return t;
	}
	void ntt_pre(int n)
	{
		int len=0;
		while((1<<len)<n) len++;
		len--;
		for(int i=0;i<n;i++)
		{
			int k=0;
			for(int j=0;j<=len;j++) if(i&(1<<j)) k|=1<<(len-j);
			bitrev[i]=k;
		}
	}
	void ntt(int *x,int n,int o)
	{
		for(int i=0;i<n;i++) if(i>bitrev[i]) swap(x[i],x[bitrev[i]]);
		for(int s=2;s<=n;s*=2)
		{
			if(o==1 && g[s]==0) g[s]=qmod(grt,(mmod-1)/s);
			if(o==-1 && ng[s]==0) ng[s]=qmod(grt,mmod-1-(mmod-1)/s);
			int wn;
			if(o==1) wn=g[s];
			else wn=ng[s];
			for(int i=0;i<n;i+=s)
			{
				int w=1;
				for(int j=0;j<s/2;j++)
				{
					int t1=x[i+j],t2=1ll*w*x[i+j+s/2]%mmod;
					x[i+j]=(t1+t2)%mmod;
					x[i+j+s/2]=(t1-t2)%mmod;
					w=1ll*w*wn%mmod;
				}
			}
		}
	}
	void work()
	{
		m*=2;
		int n=1;
		while(n-1<m) n*=2;
		ntt_pre(n);
		ntt(a,n,1);ntt(b,n,1);
		for(int i=0;i<n;i++) c[i]=1ll*a[i]*b[i]%mmod;
		ntt(c,n,-1);
		int ny=qmod(n,mmod-2);
		for(int i=0;i<n;i++) c[i]=1ll*c[i]*ny%mmod;
		int oo=1;
	}
}g;
int fir[N],len,n,siz[N],cnt[N],ans[N];
void ins(int x,int y)
{
	a[++len].y=y;a[len].nex=fir[x];fir[x]=len;
}
void dfs(int x,int fa)
{
	siz[x]=1;
	for(int k=fir[x];k;k=a[k].nex)
	{
		int y=a[k].y;
		if(y==fa) continue;
		dfs(y,x);
		siz[x]+=siz[y];
		cnt[siz[y]]++;
	}
	cnt[n-siz[x]]++;
}
int C(int n,int m)
{
	return 1ll*jc[n]*ny[m]%mmod*ny[n-m]%mmod;
}
int main()
{
	jc[0]=jc[1]=ny[0]=ny[1]=1;
	for(int i=2;i<M;i++) jc[i]=1ll*jc[i-1]*i%mmod,ny[i]=1ll*(-mmod/i)*ny[mmod%i]%mmod;
	for(int i=2;i<M;i++) ny[i]=1ll*ny[i-1]*ny[i]%mmod;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		ins(x,y);ins(y,x);
	}
	dfs(1,0);
	for(int i=1;i<=n;i++) 
		g.a[i]=1ll*cnt[i]*jc[i]%mmod,g.b[i]=ny[n-i];
	g.m=n;
	g.work();
	for(int i=1;i<=n;i++) ans[i]=1ll*n*C(n,i)%mmod;
	for(int i=1;i<=n;i++) ans[i]=(ans[i]-(1ll*ny[i]*g.c[n+i]%mmod))%mmod;
	for(int i=1;i<=n;i++) printf("%d\n",(ans[i]+mmod)%mmod);
	return 0;
}

Measured memory_bytes: 33792
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
  int N;
  int A = 0, B = 0;
  scanf("%d", &N);
  vector<int> a(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%d", &a.at(i));
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  for (int i = 0; i < N; i++)
  {
    if (i%2==0)
    {
      A += a.at(i);
    }
    else
    {
      B += a.at(i);
    }
  }
  printf("%d\n", A - B);
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <math.h>
#include <utility>
#include <map>
#include <queue>
#include <stack>

using namespace std;

#define INF 210000000
#define int long long

int gcd(int a, int b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

int lcm(int a, int b) { return a * b / gcd(a, b); }

signed main() {
		vector<int> a;
		for(int i=0;i<3;i++){
				int tmp;
				cin >> tmp;
				a.push_back(tmp);
		}
		sort(a.begin(),a.end());
		cout << a[0] * a[1] / 2;
}



Measured memory_bytes: 256
W, H, N = list(map(int, input().split()))

L, R = 0, W
D, T = 0, H

for i in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        if L < x:
            L = x
    elif a == 2:
        if x < R:
            R = x
    elif a == 3:
        if D < y:
            D = y
    elif a == 4:
        if y < T:
            T = y

if (R - L) > 0 and (T - D) > 0:
    print((R - L) * (T - D))
elif (R - L) > 0 and (T - D) < 0:
    print((R - L))
elif (R - L) < 0 and (T - D) > 0 > 0:
    print(T - D)
else:
    print(0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(void) {
    stack<int> st;
    string s;
    while(cin >> s) {
        if(s == "+" || s == "-" || s == "*") {
            int a = st.top();
            st.pop();
            int b = st.top();
            st.pop();
            if(s == "+") st.push(b + a);
            if(s == "*") st.push(b * a);
            if(s == "-") st.push(b - a);
        }
        else {
            st.push(atoi(s.c_str()));
        }
    }
    cout << st.top() << endl;
}


Measured memory_bytes: 3204
import heapq
N, M = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for _ in range(N)]
day_gain = [[] for _ in range(10**5 + 1)]
for a, b in AB:
    day_gain[a] += [b]
ans = 0
work = 0
H = []
for d in range(M + 1):
    for g in day_gain[d]:
        heapq.heappush(H, -g)
    if H:
        ans -= heapq.heappop(H)
print(ans)


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

int main() {
  int d;
  cin>>d;
  if (d==25) {
    cout<<"Christmas";
  } else if (d==24) {
    cout<<"Christmas Eve";
  } else if (d==23) {
    cout<<"Christmas Eve Eve";
  } else if (d==22) {
    cout<<"Christmas Eve Eve Eve";
  }
}

Measured memory_bytes: 256
l, r = map(int, input().split())
mod = 2019
if r - l > 3000:
  print(0)
else:
  ans = mod
  for i in range(l, r + 1):
    for j in range(r, l, -1):
      #print(str(i) + ' ' + str(j))
      if j <= i: break
      ans = min(ans, (i * j) % mod)
  print(ans)
      

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
 ll a,b,c;
  cin >> a >> b >> c;
  cout << (a - c) / (b + c) << endl;
}

Measured memory_bytes: 256
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 100000

int a,b,c,x,y;

int input() {
	if (scanf("%d %d %d %d %d", &a, &b, &c, &x, &y) < 0) return 0;
	return 1;
}

void init() {
}

long solve() {
	if (c*2 < a+b) {
		int d = min(x,y), z;
		if (d==x) {
			z = min(c*2, b)*(y-d);
		}
		else {
			z = min(c*2, a)*(x-d);
		}
		return d*2*c + z;
	}
	else {
		return x*a + y*b;
	}
	return 1;
}

void output(long ans) {
	printf("%ld\n", ans);
}

void cleanup() {
}

int main() {
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 128
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		int M = sc.nextInt();
        int total = N + M ;
        int count =0;
        int ref = N;
        
        while(ref > 0){
            count += ref;
            ref--;
        }
        count = count - N;
        int ref1= M;
        int c =0;
        while(ref1 > 0){
            c = c + ref1;
            ref1--;
        }
        c = c - M;
        System.out.println(count + c);
	}
}


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

int main() {
  int N;
  cin >> N;
  int count = 0;
  vector<int> vN (N);
  for (int i=0; i<N; i++) {
    cin >> vN[i];
    while (vN[i] % 2 == 0) {
      vN[i] = vN[i] / 2;
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import sys
import string
import time


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


def I():
    return int(input())


def S():
    return input()


def MI():
    return map(int, input().split())


def MS():
    return map(str, input().split())


def LI():
    return list(map(int, input().split()))


def LI_():
    return [int(i) - 1 for i in input().split()]


def StoI():
    return [ord(i) - 97 for i in input()]


def ItoS(nn):
    return chr(nn + 97)


N = {False: 'No', True: 'Yes'}
MOD = 10 ** 9 + 7
inf = float('inf')
IINF = 10 ** 10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
# sys.setrecursionlimit(10 ** 6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


def main():
    s = S()
    ans = 0
    # there're 2^(n-1) patterns
    for i in range(2 ** (len(s) - 1)):
        idx = 0
        rng = 1
        # we must scan all spaces between each number
        for n in range(len(s) - 1):
            if (1 << n) & i:
                ans += int(s[idx:idx + rng])
                idx += rng
                rng = 1
            else:
                rng += 1
        ans += int(s[idx:idx + rng])
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

vector<vector<pair<int,int> > > G;
vector<long long> dist;

void dfs(int v, int prev, long long d) {
	dist[v] = d;
	for(auto&e:G[v]) {
		if(e.first==prev) continue;
		dfs(e.first,v,d+e.second);
	}
}

int main() {
	int n; cin >> n;
	G.resize(n);
	for(int i=1;i<n;++i) {
		int a,b,c; cin >> a >> b >> c;
		--a, --b;
		G[a].emplace_back(b,c);
		G[b].emplace_back(a,c);
	}
	dist.assign(n,0);
	int q,k; cin >> q >> k;
	--k;
	dfs(k,-1,0);
	while(q--) {
		int x,y; cin >> x >> y;
		--x, --y;
		cout << dist[x] + dist[y] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 12800
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>

using namespace std;

int main() {
	char S[100001];
	int a, b, c;
	int m1, m0;
	scanf("%s", S);

	a = 0; b = 0; c = 0;
	for (int i = 0; i < strlen(S); i++) {
		if (S[i] == 'a') { a++; }
		if (S[i] == 'b') { b++; }
		if (S[i] == 'c') { c++; }
	}

	m1 = a; m0 = a;
	if (m1 < b) { m1 = b; }
	if (m1 < c) { m1 = c; }

	if (m0 > b) { m0 = b; }
	if (m0 > c) { m0 = c; }
	
	if (m1 - m0 <= 1) { printf("YES\n"); }
	else { printf("NO\n"); }

}

Measured memory_bytes: 256
import sys
from io import StringIO
import unittest


def resolve():
    n, m = map(int, input().split())
    item = []*n
    item = input().split()

    all = 0
    for i in range(len(item)):
        all += int(item[i])

    # リストの作成
    dicta = {}
    for i, a in enumerate(item):
        dicta[i] = int(a)
    dicta_sorted = sorted(dicta.items(), key=lambda x: x[1], reverse=True)

    # えらべるか判定
    choice_count = 0
    i = 0
    for i in range(m):
        aaa = 4 * m
        if dicta_sorted[i][1] < all/aaa:
            continue
        choice_count += 1

    if choice_count >= m:
        print("Yes")
    else:
        print("No")


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4 1
5 4 2 1"""
        output = """Yes"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3 2
380 19 1"""
        output = """No"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """12 3
4 56 78 901 2 345 67 890 123 45 6 789"""
        output = """Yes"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

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

int main() {
	string S, T;

	int k = 0;

	cin >> S;
	cin >> T;

	for (int i = 0; i < S.size(); i++) {
		if (S[i] != T[i]) {
			k++;
		}
	}

	cout << k;

}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

string s;
int pos = 0;

int main() {
    cin >> s;
    for (char c : s) {
        if (pos == 0 && c == 'C') {
            ++pos;
        }
        if (pos == 1 && c == 'F') {
            ++pos;
        }
    }
    if (pos == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

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

	for(int i = 1; i<= n; i++)
	{
		if(i%3 == 0){
			printf(" %d",i);
		}else{
			x = i;
			do{
				if(x%10 == 3){
					printf(" %d",i);
					break;
				}
				x /=10;
			}while(x);
		}
	}
	printf("\n");
}





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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)                                                             \
  sort(x.begin(), x.end());                                                    \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y)                                                           \
  cerr << "(" << #x << ", " << #y << ") = "                                    \
       << "(" << x << ", " << y << ")" << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

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

  ll a, b, c, k;
  cin >> a >> b >> c >> k;

  //   if (a + b >= k) {
  //     cout << a << endl;
  //   } else if (k - (a + b) <= c) {
  //     cout << a - c * (k - (a + b)) << endl;
  //   }

  if (k <= a) {
    cout << k << endl;
    return 0;
  }

  k = k - a;

  if (k <= b) {
    cout << a << endl;
    return 0;
  }
  k = k - b;
  cout << a - k << endl;
  return 0;
}

Measured memory_bytes: 3656
import numpy as np
W, H, N = [int(x) for x in input().split()]
matrix = np.array([[1 for i in range(W)] for j in range(H)])
rects = []
for i in range(N):
    rects.append([int(x) for x in input().split()])
for rect in rects:
    if rect[2] == 1:
        matrix[:, :rect[0]] = 0
    elif rect[2] == 2:
        matrix[:, rect[0]:] = 0
    elif rect[2] == 3:
        matrix[:rect[1], :] = 0
    elif rect[2] == 4:
        matrix[rect[1]:, :] = 0
print(sum(sum(matrix)))

Measured memory_bytes: 12768
#include <stdio.h>

int main(){
  int n;
  int i;
  int count=0;
  
  scanf("%d",&n);
  
  for(i=1;i<=n;i++){
    if(i>=1 && i<10){
      count++;
    } else if(i>=100 && i<1000){
      count++;
    } else if(i>=10000 && i<100000){
      count++;
    }
  }
  printf("%d",count);
}


Measured memory_bytes: 128
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
const long long MAXN=100005,INF=1e9;
long long n,C;
long long x,y,z,d[MAXN][2];
struct Node
{
	long long x;
	Node(){}
	Node(long long xx)
	{
		x=xx;
	}
	bool operator<(const Node a)const
	{
		return a.x<x;
	}
};
priority_queue<Node>Q;
struct node
{
	long long a,b;
	node(){}
	node(long long aa,long long bb)
	{
		a=aa,b=bb;
	}
}a[MAXN];
bool cmp(node a,node b)
{
	if(a.a-a.b==b.a-b.b)
		return a.a>b.a;
	return a.a-a.b>b.a-b.b;
}
int main()
{
	scanf("%lld %lld %lld",&x,&y,&z);
	n=x+y+z;
	for(long long i=1;i<=n;i++)
	{
		long long A,B,c;
		scanf("%lld %lld %lld",&A,&B,&c);
		A-=c;
		B-=c;
		C+=c;
		a[i]=node(A,B);
	}
	sort(a+1,a+n+1,cmp);
	long long ans=0,now=0;
	while(!Q.empty())
		Q.pop();
	for(long long i=1;i<=x;i++)
	{
		now+=a[i].a;
		Q.push(Node(a[i].a));
		d[i][0]=now;
	}
	for(long long i=x+1;i<=n;i++)
	{
		Q.push(Node(a[i].a));
		now+=a[i].a;
		now-=Q.top().x;
		Q.pop();
		d[i][0]=now;
	}
	now=0;
	while(!Q.empty())
		Q.pop();
	for(long long i=n;i>n-y;i--)
	{
		now+=a[i].b;
		Q.push(Node(a[i].b));
		d[i][1]=now;
	}
	for(long long i=n-y;i>=1;i--)
	{
		Q.push(Node(a[i].b));
		now+=a[i].b;
		now-=Q.top().x;
		Q.pop();
		d[i][1]=now;
	}
	for(long long i=x;i<=n-y;i++)
	{
		ans=max(ans,d[i][0]+d[i+1][1]+C);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 4472
A, B, K = map(int, input().split())

cnt = 0
while cnt < K:
  A = A // 2
  B = B + A
  cnt += 1
  #print(cnt,A,B)
  if cnt >= K:
    break
  
  B = B // 2
  A = A + B
  cnt += 1
  #print(cnt,A,B)
  
print(A,B)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<P ,ll> P3;
typedef pair<P ,P> PP;
const ll MOD = 998244353;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll n, a[MAX_N], dp[MAX_N][2];
    cin >> n;
    REP(i,n) cin >> a[i];
    REP(i,n+1) dp[i][0] = dp[i][1] = -LLINF/3;
    dp[1][0] = a[0];
    for(int i=1;i<n;i++){
        dp[i+1][0] = max(dp[i][0], dp[i][1]) + a[i];
        dp[i+1][1] = max(dp[i][0]-a[i-1]*2, dp[i][1]+a[i-1]*2)-a[i];
    }
    cout << max(dp[n][0], dp[n][1]) << endl;
    return 0;
}

Measured memory_bytes: 2560
/*
	Name: None
	Copyright: zhangjingcanËùÓÐ£¬Î´¾­ÔÊÐí²»µÃ×ªÔØ
	Author: zhangjingcan
	Date:   25/02/20 18:40
	Description: C++ÎÄ¼þ
*/
#include <bits/stdc++.h>
using namespace std;
int a,b;
int main(int argc, char** argv) {
	ios::sync_with_stdio(false);
	cin>>a>>b;
	cout<<max(a-b,0)<<"\n";
	return 0;
}


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

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int s, w;
    cin >> s >> w;
    if(w >= s){
    	cout << "unsafe" << endl;

    }
    else {
    	cout << "safe" << endl;
    }
    return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  REP(i,ty-sy) cout << "U";
  REP(i,tx-sx+1) cout << "R";
  REP(i,ty-sy+1) cout << "D";
  REP(i,tx-sx+1) cout << "L";
  cout << "U";
  cout << "L";
  REP(i,ty-sy+1) cout << "U";
  REP(i,tx-sx+1) cout << "R";
  REP(i,ty-sy+1) cout << "D";
  REP(i,tx-sx) cout << "L";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256