akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)

ll solve(ll *s, int c,int N){
    ll ans = 0;
    ll temp = 0;
    int left = 0;
    int right = N-1;
    while(true){
        temp += s[left] + s[right];
        ans = max(temp,ans);
        left += c;
        right -= c;
        if(right == left || right == left-c) break;
        if(right<c) break; 
    }
    return ans;
}

int main(){
    int N;
    cin>>N;
    ll *s = new ll[N];
    rep(i,N) cin>>s[i];
    ll ans = 0;
    Rep(c,1,N-1){
        // cout<<c<<" "<<solve(s,c,N)<<endl;
        ans = max(ans,solve(s,c,N));
    }
    // cout<<endl;
    cout<<ans<<endl;
    delete[] s;
    return 0;
}

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

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x) for (auto&& v : (x))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))

ll a[200100];
int main() {
  ll h, n;
  cin >> h >> n;
  rep(i, n) cin >> a[i];
  ll sum = 0;
  rep(i, n) sum += a[i];
  cout << (sum >= h ? "Yes" : "No") << endl;
}


Measured memory_bytes: 4320
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>
#include <complex>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define ALLOF(c) c.begin(), c.end()
#define RANGEOF(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define EPS 1e-9
#define INF 1000000000
using namespace std;

template <class T> T read() { T t; cin >> t; return t; }
template <class T> vector<T> read(int n) { vector<T> v; REP(i,n) { v.push_back(read<T>()); } return v; }
template <class T> vector<vector<T>> read(int n, int m)
{
	vector<vector<T>> v;
	REP(i,n) { v.push_back(read<T>(m)); }
	return v;
}

template <class T> void write(const T &t) { cout << t << endl; }
template <class T> void write(const T &t, const T &t2) { cout << t << ' ' << t2 << endl; }
template <class T> void write(const vector<T> &v)
{
	ostringstream ss; 
	for (auto x : v) ss << x << ' ';
	auto s = ss.str();
	cout << s.substr(0, s.length() - 1) << endl;
}

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__

void solve();
int main() { solve(); return 0; }

/// template end ///



void solve()
{
	while (true)
	{
		READ(int, H, W);
		if (!(W|H)) { break; }
		auto field = read<string>(W);
		for (auto &f : field) { f.insert(f.begin(), '#'); f.push_back('#'); }
		field.insert(field.begin(), string(H+2, '#'));
		field.push_back(string(H+2, '#'));
		W += 2; H += 2;

		int sx = 0, sy = 0;
		REP(x,W) REP(y,H) if (field[x][y] == '@') { sx = x; sy = y; }

		typedef complex<int> P;
		queue<P> q;
		int count = 0;
		q.push(P(sx, sy));
		while (!q.empty())
		{
			P cur = q.front(); q.pop();
			if (field[cur.real()][cur.imag()] == '#') { continue; }
			count++;
			field[cur.real()][cur.imag()] = '#';
			if (field[cur.real() + 1][cur.imag()] != '#') q.push(P(cur.real() + 1, cur.imag()));
			if (field[cur.real() - 1][cur.imag()] != '#') q.push(P(cur.real() - 1, cur.imag()));
			if (field[cur.real()][cur.imag() + 1] != '#') q.push(P(cur.real(), cur.imag() + 1));
			if (field[cur.real()][cur.imag() - 1] != '#') q.push(P(cur.real(), cur.imag() - 1));
		}
		write(count);
	}
}

Measured memory_bytes: 1236
import math
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

x = listA[0][0]
r = 100
for i in range(1, 10**180):
  r = math.floor(r*1.01)
  if r >= x:
    print(i)
    break

Measured memory_bytes: 9072
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<long long,long long>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a);}
                a=(a*a);
                b>>=1;
        }
    return ans;
        
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    srand(time(0));
    int n,k;
    cin>>n>>k;
    int ans=n%k;
    ans=min(ans,min(n%k,k-n%k));
    cout<<ans;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

ll cnt[502][502];

int main() {
	int n;
	cin >> n;
	if (n >= 1000)cout << "ABD" << endl;
	else cout << "ABC" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)
#include <iostream>
#include <vector>
#include <cstdlib>
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; }

const long long INF = 1LL << 60;

int main(){
    ll n,k;cin>>n>>k;
    vl a(n);rep(i,n){cin>>a[i];a[i]--;}
    vl mem(n);
    ll cnt=0;
    ll ans=0;

    rep(i,n)mem[a[i]]++;

    rep(i,n){
        if(mem[i]>0)cnt++;
    }

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

    rep(i,n){
        if(mem[i]>0&&cnt>k){
ans+=mem[i];
cnt--;
        }
    }


cout<<ans<<endl;



}

Measured memory_bytes: 3328
#include <iostream>
#include <queue>

using namespace std;
int main()
{
    int n,q;
    cin>>n>>q;
    vector<queue<int>> A(n);
    while(q--)
    {
        int act,t,x;
        cin>>act;
        if(act==0)
        {
            cin>>t>>x;
            A[t].push(x);
        }
        else if(act==1)
        {
            cin>>t;
            if(A[t].size()>0)
            //if(!A[t].empty())
            {
                cout<<A[t].front()<<'\n';
            }
        }
        else{
            cin>>t;
            if(A[t].size()>0)
            {
                A[t].pop();
            }

        }
    }
    return 0;
}




Measured memory_bytes: 4260
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define pii pair<ll,ll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(ll i=a;i<=(ll)b;++i)
#define per(i,a,b) for(ll i=a;i>=(ll)b;--i)
#define ll long long
#define lowbit(x) ((x)&(-x))

const int maxn=2e5+5;
int a[maxn];
int main()
{
    IOS
    int n,k;cin>>k>>n;
    rep(i,1,n) cin>>a[i];
    vector<int>v;
    rep(i,2,n) v.pb(a[i]-a[i-1]);
    v.pb(k-a[n]+a[1]);
    sort(v.begin(),v.end());
    cout<<k-v[n-1]<<"\n";
}

Measured memory_bytes: 2168
#include<stdio.h>

int main(){
  char a[200001] = {0};
  char b[200001] = {0};
  
  scanf("%s",&a);
  scanf("%s",&b);
  
  int i = 0;
  int count = 0;
  for(i = 0; i < 200001;i++){
    if(a[i] != b[i])
      count++;
  }
  printf("%d",count);
  
 return 0;
}

Measured memory_bytes: 2128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] b = new int[n+1];
        for(int i = 2; i <= n; i++){
            int a = Integer.parseInt(sc.next());
            b[a]++;
        }
        
        StringBuilder sb = new StringBuilder();
        for(int i = 1; i <= n; i++){
            sb.append(b[i]).append(System.lineSeparator());
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 50896
n, c, *t = map(int, open(0).read().split())
right = [0]
left = [0]
sushi = tuple([(0, 0)]) + tuple(zip(t[::2], t[1::2])) + tuple([(c, 0)])
for i in range(1, n + 1):
    x, v = sushi[i]
    y = sushi[i - 1][0]
    cost = right[-1] + v - (x - y)
    right.append(cost)
    x, v = sushi[n + 1 - i]
    y = sushi[n + 2 - i][0]
    cost = left[-1] + v - (y - x)
    left.append(cost)
ans = max(right + left)
right_max = right[:]
left_max = left[:]
for i in range(1, n + 1):
    right_max[i] = max(right_max[i], right_max[i - 1])
    left_max[i] = max(left_max[i], left_max[i - 1])
for i in range(1, n + 1):
    ans = max(ans, \
            right[i] - sushi[i][0] + left_max[n - i], \
            left[i] - c + sushi[n + 1 - i][0] + right_max[n - i])
print(ans)

Measured memory_bytes: 30024
#include<iostream>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>

#define range(i, n) for (i = 0; i < n; i++) 
#define rrange(i, n) for(i = n-1; i>=0; i--)

using namespace std;

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


int main() {

	int N, K;

	cin >> N >> K;

	vector<pair<long long , long long > >s(N);
	vector<pair<long long , long long > >select;

	vector<bool>neta(N+1, false);
	long long netacount = 0;
	long long sum = 0;
	long long result = 0;

	int i, k, n;
	range(i, N) {
		cin >> s[i].second >> s[i].first;
	}

	sort(s.begin(), s.end());
	reverse(s.begin(), s.end());

	k = 0;
	range(i, K) {
		sum += s[i].first;
		if (neta[s[i].second] == false) {
			neta[s[i].second] = true;
			netacount++;
			continue;
		}
		select.push_back(s[i]);
	}

	result = sum + (netacount * netacount);


	for(i=K-1; i<N; i++) {
		if (netacount >= K)break;
		if (select.size() <= 0)break;
		if (neta[s[i].second] == true) continue;

		sum = (sum - select.back().first) + s[i].first;
		neta[s[i].second] = true;
		netacount++;
		chmax(result, sum + (netacount * netacount));
		select.pop_back();

	}

	cout << dec << result;







	return 0;
}


Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>

int main(void){
    int N;
    scanf("%d\n", &N);
    char S[1000000] = {};
    int count = 0;
    char former;
    char new;
    for(int i=0; i<N; i++){
        scanf("%c", &new);
        if(i != 0){
            if(former != new){
                count++;
                former = new;
                 //printf("%d\n", count);
            }
        }else if(i==0){
            former = new;
            count++;
            //S[0] = new;
             //printf("%d\n", count);
        }

    }
    printf("%d\n", count);


}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int m,n;

int main(){
	while(cin>>m>>n){
		int ans=0;
		for(int i=0;i<20;i++)for(int j=0;j<20;j++){
			for(int k=0;k<20;k++){
				int h=pow(2,i)*pow(3,j)*pow(5,k);
				if(h>=m&&h<=n)ans++;
				if(h>1e+6)break;
			}
			if(pow(2,i)*pow(3,j)>1e+6)break;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var NM = IO.RSInt;

            var dic = new Dictionary<int, List<int>>();
            var a = new List<int[]>();
            for (int i = 0; i < NM[1]; i++)
            {
                var py = IO.RSInt;
                a.Add(py);
                if (!dic.ContainsKey(py[0]))
                {
                    dic[py[0]] = new List<int>();
                }
                dic[py[0]].Add(py[1]);
            }
            foreach (var item in dic)
            {
                item.Value.Sort();
            }
            //ReadLine();
            for (int i = 0; i < a.Count; i++)
            {
                var py = a[i];
                var sb = new StringBuilder();
                sb.Append(py[0].ToString().PadLeft(6, '0'));
                var t = dic[py[0]].BinarySearch(py[1]) + 1;
                sb.Append(t.ToString().PadLeft(6, '0'));
                WriteLine(sb.ToString());
            }
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 44384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,m,n) for (int i = m; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
inline int popcount(const int x) { return __builtin_popcount(x);}
template<class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b;}
template<class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b;}
template<class T> void drop(const T &x) { std::cout<<x<<endl; exit(0);}
void debug_out() { std::cout << "\n";}
template<class T, class... Args> void debug_out(const T &x, const Args &... args) { std::cout<<x<< " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

struct InitIO{
  InitIO() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
  }
}init_io;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(all(a), greater<ll>());
  ll ans = 0;
  if (n&1) {
    rep(i, n/2) ans += a[i];
    rep2(i, 1, n/2+1) ans += a[i];
  }
  else {
    rep(i, n/2-1) ans += a[i];
    rep2(i, 1, n/2) ans += a[i];
    ans += a[n/2-1];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4768
h, w = map(int, input().split())
ans = "Yes"
c = ["0"]*(w+2)
s = []
s.append(c)
for i in range(h):
    S = ["0"]
    S1 = list(input())
    S1.append("0")
    S = S+S1
    s.append(S)
s.append(c)

for i in range(1,h+1):
    for j in range(1, w+1):
        if s[i][j]=="#":
            if s[i-1][j]!="#" and s[i+1][j]!="#" and s[i][j-1]!="#" and s[i][j+1]!="#":
                ans ="No"
            else:
                continue
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const ll INF = 1e9+1;

//尺取り法 間にある0区間の数がKを超えるまで右を進む
//右が停止したら間にある0区間の数がKになるまで左を右に進める

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


    int left = 0;
    int right = N;
    char lc = '1', rc = '1';
    int cnt = 0;

    
    for (int i = 0; i < N; i++) {
        if (lc == '1' && S[i] == '0') cnt++;
        lc = S[i];
        if (cnt == K && S[i] == '1') {
            right = i+1;
        }
    }
    

    
    int res = -1;
    lc = '1';

    if (N == 1 && K == 0) {
        cout << S << endl;
        return 0;
    }

    
    while (right <= N) {
        chmax(res,right-left);
        cout << right << " " << left << endl;
        if (right == N) break;
        if (S[left] == '1') {
            lc = S[left];
            left++;
        }
        while (left < N && !(S[left] == '1' && lc == '0')) {
            lc = S[left];
            left++;
        }
        
        while (right < N && S[right] == '0') right++;
        
        while (right < N && S[right] == '1') right++;
        

    }

    cout << res << endl;
*/


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

    // 「1 の個数」「0 の個数」を交互に記録していく
    vector<int> nums;    
    if (S[0] == '0') nums.push_back(0); // 先頭が 0 だったら
    for (int i = 0; i < S.size();) {
        int j = i;
        while (j < S.size() && S[j] == S[i]) ++j; // S[i] の数値がどこまで続くか
        nums.push_back(j - i);
        i = j;
    }
    if (S.back() == '0') nums.push_back(0); // 最後尾が 0 だったら

    // 累積和
    vector<int> sums((int)nums.size() + 1, 0);
    for (int i = 0; i < nums.size(); ++i) sums[i+1] = sums[i] + nums[i];

    // 偶数番目の添字から始まる、長さ 2K+1 (以下) の区間の総和のうち、最大値を求める
    int res = 0;
    for (int left = 0; left < sums.size(); left += 2) {
        int right = left + K*2+1;
        if (right >= sums.size()) right = (int)sums.size() - 1;
        res = max(res, sums[right] - sums[left]);
    }
    cout << res << endl;
}
    





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

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define PB push_back

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVi;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;

int main(){
	ios::sync_with_stdio(false);
    string s;
    cin>>s;
    for(int i=0;i<4;i++){
        cout<<s[i];
    }
    cout<<" ";
    for(int i=4;i<12;i++){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define INF  numeric_limits<int>::max()
#define NINF numeric_limits<int>::min()

using namespace std;
using ll = long long;

const int N_MAX = 8;
int N, M;
bool edge[N_MAX][N_MAX];
bool reached_vertex[N_MAX];

int dfs(int vertex) {
    int reached_vertex_num = std::accumulate(reached_vertex, reached_vertex + N, 0);
    if(reached_vertex_num == N) {
        return 1;
    }

    int ret = 0;
    REP(i, N) {
        if(!edge[vertex][i] || reached_vertex[i]) continue;

        reached_vertex[i] = true;
        ret += dfs(i);
        reached_vertex[i] = false;
    }

    return ret;
}

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

    std::cin >> N >> M;
    REP(i, N) {
        reached_vertex[i] = false;
    }

    REP(i, M) {
        int a, b;
        std::cin >> a >> b;
        edge[a - 1][b - 1] = edge[b - 1][a - 1] = true;
    }

    reached_vertex[0] = true;
    std::cout << dfs(0) << std::endl;

    return 0;
}


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

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979

int main()
{
	int n, count = 0;
	bool flag = true;							//奇数が1つでも含まれているとfalse
	cin >> n;
	vector<int> a(n);							//nこの要素を持つ配列を定義

	rep(i, n)
	{
		cin >> a[i];							//入力を受け取る
		if (a[i] % 2 != 0) flag = false;		//もし入力時点で奇数があれば計算は何も行われない
	}

	while (flag)
	{
		count++;								//計算できた回数
		rep(i, n)
		{
			a[i] /= 2;							//2で割る
			if (a[i] % 2 != 0) flag = false;	//割った後に奇数になったらこのループまでで止める
		}
	}
	
	cout << count << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
int main()
{
    optimize();
    int i,j;
    int n;
    cin>>n;
    long long sum=0;
    for(i=1;i<=n-1;i++)
    {
        sum+=(n-1)/i;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	ll n;
	cin >> n;
	string s="";
	while(n>0){
		n--;
		s+='a'+n%26;
		n/=26;
	}
	reverse(all(s));
	cout << s << endl;
 	return 0;
}

Measured memory_bytes: 3592
n=int(input())
s=[input() for c in range(n)]
dic={}
ans=[]

for i in s:
  if i in dic:
    dic[i]+=1
  elif i not in dic:
    dic[i]=1
    
cntmax=max(dic.values())

for j in dic.keys():
  if dic[j]==cntmax:
    ans.append(j)
    
ans=sorted(ans)

print(" ".join(ans))

Measured memory_bytes: 37256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 2e5, maxP = 1e3 + 1; int n, k;
int p[maxN];
ldouble acc[maxN + 1];

int main()
{
  ldouble expected[maxP];
  for (int i = 1; i < maxP; i ++)
  {
    expected[i] = 0;
    for (int j = 1; j <= i; j ++)
      expected[i] += j;
    expected[i] /= i;
  }

  while (scanf("%d %d", &n, &k) != EOF)
  {
    for (int i = 0; i < n; i ++)
      scanf("%d", &p[i]);

    for (int i = 0; i < n; i ++)
      acc[i + 1] = acc[i] + expected[p[i]];

    ldouble ans = 0;
    for (int i = 0; i + k - 1 < n; i ++)
      ans = max(ans, acc[i + k] - acc[i]);
    printf("%.15Lf\n", ans);
  }
  return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,m; cin >> n >> m;
    if(m-2*n<0){
        cout<<min(n,m/2)<<endl;
        return 0;
    }
    int k=(m-2*n)/4;
    cout<<min(n+k,m-2*k)<<endl;
}

Measured memory_bytes: 3604
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Beginner067
{
    public class ABC067D_FennecVSSnuke
    {
        public static void Main(string[] args)
        {
            
            int n = int.Parse(Console.ReadLine());

            // 隣接ノードの記憶
            List<int>[] adjacentNode = new List<int>[n + 1];
            for(int i = 1; i <= n; i++)
            {
                adjacentNode[i] = new List<int>();
            }
            for(int i=1; i<n; i++)
            {
                int [] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                adjacentNode[nums[0]].Add(nums[1]);
                adjacentNode[nums[1]].Add(nums[0]);
            }

            // 先手・後手の始点を根としたツリーを作成
            TreeNode[] fennecNode = new TreeNode[n + 1];
            TreeNode[] snukeNode = new TreeNode[n + 1];
            for(int i = 1; i <= n; i++)
            {
                fennecNode[i] = new TreeNode() { no = i };
                snukeNode[i] = new TreeNode() { no = i };
            }
            TreeNode fennecRoot = fennecNode[1];
            TreeNode snukeRoot = snukeNode[n];

            List<int> parent = new List<int>();
            parent.Add(1);
            while(parent.Count != 0)
            {
                foreach(int i in adjacentNode[parent[0]])
                {
                    if(fennecNode[i].parent == null && i != 1)
                    {
                        fennecNode[parent[0]].child.Add(fennecNode[i]);
                        fennecNode[i].parent = fennecNode[parent[0]];
                        fennecNode[i].depth = fennecNode[parent[0]].depth + 1;
                        parent.Add(i);
                    }
                }
                parent.RemoveAt(0);
            }
            
            parent.Add(n);
            while(parent.Count != 0)
            {
                foreach(int i in adjacentNode[parent[0]])
                {
                    if(snukeNode[i].parent == null && i != n)
                    {
                        snukeNode[parent[0]].child.Add(snukeNode[i]);
                        snukeNode[i].parent = snukeNode[parent[0]];
                        snukeNode[i].depth = snukeNode[parent[0]].depth + 1;
                        parent.Add(i);
                    }
                }
                parent.RemoveAt(0);
            }

            // 将来的に取れるノードのカウント
            int fennecPoint = 0;
            int snukePoint = 0;
            for(int i = 1; i <= n; i++)
            {
                if(fennecNode[i].depth <= snukeNode[i].depth)
                {
                    fennecPoint++;
                }
                else
                {
                    snukePoint++;
                }
            }
            
            Console.WriteLine(fennecPoint > snukePoint ? "Fennec" : "Snuke");

        }

        public class TreeNode
        {
            public int no;
            public int depth;
            public TreeNode parent;
            public List<TreeNode> child = new List<TreeNode>();
        }
    }
}

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

int main(){
  ll N,M;cin>>N>>M;
  cout << (1900*M+(N-M)*100)*pow(2,M) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int judge(int, int);
int A[21], n;

int judge(int i, int m){
  int recu;
  if (m == 0) return 1;
  if (i >= n) return 0;
  recu = judge(i + 1, m) || judge(i + 1, m - A[i]);
  return recu;
}

int main(){
  int i, q, m;
  scanf("%d", &n);
  for (i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
  scanf("%d", &q);
  for (i = 0; i < q; i++){
    scanf("%d", &m);
    if (judge(0, m) == 1){
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }
  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using itn = int;//typpo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
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; }
intl kai(intl k){//k!を求める関数
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

//--------------入力受け取る場所,分けてた方がデバッグしやすい気がする---------------------
intl n,m;
intl k[10];
vector<vector<intl> > s;
intl p[10];

void input_var(){
    cin >> n >> m;
    s.resize(m);
    rep(i,m){
        cin >> k[i];
        s[i].resize(k[i]);
        rep(j,k[i]){
            cin >> s[i][j];
        }
    }
    rep(i,m)cin >> p[i];
}
//-------------------------------------------------------------------------------

signed main(){
    cout << fixed << setprecision(10);
    input_var();
    intl cnt = 0;
    for(int i = 0; i < (1 << n); i++){
        bool flag = true;
        rep(j,m){
            intl a = 0;
            rep(l,k[j]){
                if(i & (1 << (s[j][l] - 1)))a++;
            }
            if((a % 2) != p[j])flag = false;
        }
        if(flag)cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC050B_ContestwithDrinksEasy
{
    class Program
    {
        static void Main(string[] args)
        {

            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            List<int> t = new List<int>();
            foreach (var v in input)
            {
                t.Add(int.Parse(v));
            }

            int m = int.Parse(Console.ReadLine());



            List<Dictionary<int, int>> drinkHolder = new List<Dictionary<int, int>>();


            for (int index = 1; index <= m; index++)
            {
                string[] kv = Console.ReadLine().Split(' ');

                Dictionary<int, int> keyValues = new Dictionary<int, int>();

                //index is question number
                keyValues.Add(int.Parse(kv[0]) - 1, int.Parse(kv[1]));

                drinkHolder.Add(keyValues);
            }


            foreach (Dictionary<int, int> kv in drinkHolder)
            {
                //drink num
                int key = kv.First().Key;
                int value = kv.First().Value;
                int result = t.Sum() - t[key] + value;


                Console.WriteLine(result);
            }






        }
    }
}


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

struct Dice{
  vector<int> asp;
  string dir;
};

void rot(vector<int> &asp, char ch){
  switch(ch){
    case 'N': asp={asp[1],asp[5],asp[2],asp[3],asp[0],asp[4]};
              break;
    case 'E': asp={asp[3],asp[1],asp[0],asp[5],asp[4],asp[2]};
              break;
    case 'S': asp={asp[4],asp[0],asp[2],asp[3],asp[5],asp[1]};
              break;
    case 'W': asp={asp[2],asp[1],asp[5],asp[0],asp[4],asp[3]};
              break;
  }
}



int main(){
  Dice d1;
  for(int i=0; i<6; i++){
    int x;
    cin >> x;
    d1.asp.push_back(x);
  }
  cin >> d1.dir;
  for(auto x : d1.dir){
    rot(d1.asp, x);
  }
  cout << d1.asp[0] << endl;
  return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int r,d,init;
    cin >> r >> d >> init;
    init = r*init -d;
    rep(i,10){
        cout << init << endl;
        init = r * init - d;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1);
const int MOD = 317847191;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 200005;
const int MAXV = 10000005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
int arr[MAXN];
char S[MAXN];
char T[MAXN];
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%s", S);
    scanf("%s", T);
    n = strlen(S);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += (S[i] != T[i]);
    }
    printf("%d\n", ans);
    return 0;
}

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

int main() {
	int n,k,i,j;
	cin >> n >> k;
	j=1; i=1;
	while(true){
		j*=k;
		if(j>n){
			cout << i; return 0;
		}
		i++;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl '\n'
#define mp make_pair
#define debug1(x) cout <<#x<<" "<<x<<'\n';
#define debug2(x,y) cout <<#x<<" "<<x <<" "<<#y<<" "<<y <<'\n';
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<'\n';
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9 + 7;
pair<ll, ll>s4[4] = {{ -1, 0}, {1, 0}, {0, -1}, {0, 1}};
pair<ll, ll>s8[8] = {{ -1, -1}, { -1, 0}, { -1, 1}, {0, -1}, {0, 1}, {1, 1}, {1, 0}, {1, -1}};

void judge() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void solve() {
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a, b;
    a.pb(0) , b.pb(0);
    for (int i = 0; i < n; i++) {
        ll x;
        cin >> x;
        a.pb(a.back() + x);
    }
    for (int i = 0; i < m; i++) {
        ll x;
        cin >> x;
        b.pb(b.back() + x);
    }

    ll ans = 0;
    int j = m; // j is on desk b
    /// i is on desk a

    for (int i = 0; i <= n; i++) {
        while (j > 0 && a[i] + b[j] > k) {
            j--;
        }
        if (a[i] + b[j] <= k) {
            ans = max(ans, (ll) i + j);
        }
    }
    cout << ans << nl;

}

signed main() {
    judge();
    boost;
    solve();
}


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

int main() {
    long long H, N;
    cin >> H >> N;
    long long tmp;
    for (long long i=0; i<N; i++) {
        cin >> tmp;
        H-=tmp;
        if (H<=0) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}

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

typedef long long ll;
typedef long long ld;
typedef vector<int> vi;
typedef pair<ll, ll> pii;

struct Node
{
    int node, len;
    Node() {node = len = 0;}
    Node(int node, int len) {this -> node = node, this -> len = len;}
};
typedef vector<Node> vg;

#define MAX 1
#define NON 0
#define MOD 1000000007

#define FOR(type, i, a, b) for(type i = a; i < b; i++)
#define FORR(type, i, b, a) for(type i = b; i > a; i--)
#define FORE(type, i, a, b) for(type i = a; i <= b; i++)
#define FORRE(type, i, b, a) for(type i = b; i >= a; i--)

#define testBit(n, bit) ((n >> bit) & 1)
#define flipBit(n, bit) (n ^ (1ll << bit))
#define randomize mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, k; cin >> n >> k;
    bool cnt[n + 1] = {};
    FORE(int, iii, 1, k){
        int len; cin >> len;
        FORE(int, i, 1, len){
            int num; cin >> num;
            cnt[num] = true;
        }
    }
    int answer = 0;
    FORE(int, i, 1, n)
        if (cnt[i]) continue;
        else answer++;
    cout << answer;
}

Measured memory_bytes: 3644
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
using namespace std;
using lint = long long;
using ld = long double;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
#pragma endregion

const lint INF = 1ll << 60;
const int mod = 1000000007;
vector<string> ans;

int n;

void solve(string s) {
	char c = 'a';
	int cnt = 1;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] > c) c += (char)1, cnt++;
    }
	if (s.length() < n) {
		for (int i = 0; i <= cnt; i++) {
			string t = s;
			t += (char)'a' + (char)i;
			ans.emplace_back(t);
			solve(t);
		}
	}
	return;
}

int main(void) {
	cin >> n;
	if (n == 1) cout << 'a' << endl;
	solve("a");
	for (int i = 0; i < ans.size(); i++)
		if (ans[i].length() == n) cout << ans[i] << endl;

	return 0;
}

Measured memory_bytes: 11556
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;
string s;

int main() {
  int n;cin >> n;
  vector<tuple<int, int, int>> vt;
  for(int i=0;i<n;++i){
    int t,x,y;cin >>t>>x>>y;
    vt.push_back(make_tuple(t,x,y));
  }
  int t0=0;
  int x0=0;
  int y0=0;
  string out = "Yes";
  for(int j=0;j<n;++j){
    int t1 = get<0>(vt[j]);
    int x1 = get<1>(vt[j]);
    int y1 = get<2>(vt[j]);
    int dt = t1 - t0;
    dt -= abs(x1-x0);
    dt -= abs(y1-y0);
    if(dt==0 || (dt%2==0 && dt>0)){
    } else {
      out = "No";
      break;
    }
    t0=t1;
    x0=x1;
    y0=y1;
  }
  cout << out << endl;
  return 0;
}


Measured memory_bytes: 1912
#include<bits/stdc++.h>
using namespace std;
int c=0;
void dfs(vector<int>v[],int *b,int pos, int *vis)
{
	vis[pos]=1;
	for(int i=0;i<v[pos].size();i++)
	{
		if(vis[v[pos][i]]==0)
			dfs(v,b,v[pos][i],vis);
		b[pos]=max(b[pos],1+b[v[pos][i]]);
	}
	
}
 int main()
 {
 	int n,m;
 	cin>>n>>m;
 	int a[m][2],b[n+1];
 	vector<int>v[n+1];
 	if(m==0 || n==1)
 	{
 		cout<<0<<endl;
 	}
 	for(int i=0;i<m;i++)
 	{
 		cin>>a[i][0];
 		cin>>a[i][1];
 		v[a[i][0]].push_back(a[i][1]);
 	}
 	for(int i=1;i<=n;i++)
 	{
 		b[i]=0;
 	}
 	int vis[n+1];
 	memset(vis,0,sizeof(vis));
 	for(int i=1;i<=n;i++)
 	{
 		if(vis[i]==0)
 		{
 			dfs(v,b,i,vis);
 		}
 	}
 	int ans=-1;

//  	int vis[n+1];
 	//memset(vis,0,sizeof(vis));
 	for(int i=1;i<=n;i++)
 	{
 		if(ans<b[i])
 		ans=b[i];
 	}
 	cout<<ans<<endl;
 }


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

int main() {
  int A[9];
  int n;
  for(int i=0;i<9;i++){
    cin >> A[i];
  }
  cin >> n;
  int b[n];
  for(int i=0;i<n;i++){
    cin >> b[i];
    for(int j=0;j<9;j++){
        if(b[i]==A[j]){
          A[j]=0;
      }
    }
  }
  if(A[0]+A[1]+A[2]==0){
    cout << "Yes" << endl;
  }
  else if((A[3]+A[4]+A[5]==0)){
    cout << "Yes" << endl;
  }
  else if((A[6]+A[7]+A[8]==0)){
    cout << "Yes" << endl;
  }
  else if((A[0]+A[3]+A[6]==0)){
    cout << "Yes" << endl;
  }
  else if((A[1]+A[4]+A[7]==0)){
    cout << "Yes" << endl;
  }
  else if((A[2]+A[5]+A[8]==0)){
    cout << "Yes" << endl;
  }
  else if((A[0]+A[4]+A[8]==0)){
    cout << "Yes" << endl;
  }
  else if((A[2]+A[4]+A[6]==0)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

}


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

int main()
{
	int N, C;
	scanf("%d%d", &N, &C);
	using vi = std::vector<int>;
	using vvi = std::vector<vi>;
	vvi event(100'000, vi(C));
	for (int i{}; i < N; i++)
	{
		int s, t, c;
		scanf("%d%d%d", &s, &t, &c);
		s--; t--; c--;
		event[s][c]++;
		event[t][c]--;
	}
	int max{}, count{};
	for (auto& time: event)
	{
		for (auto& e: time)
			if (e > 0)
				count++;
		max = std::max(max, count);
		for (auto& e: time)
			if (e < 0)
				count--;
	}
	printf("%d\n", max);

	return 0;
}

Measured memory_bytes: 17152
#include <bits/stdc++.h> // {{{
// clang-format off
#pragma GCC optimize "O3,omit-frame-pointer,inline"
#pragma GCC target "tune=native,sse4.2"
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template<typename T>inline
#define USE2(T, U) template<typename T,typename U>inline
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

template<typename T>using duo=std::pair<T,T>;
template<typename T>using vec=std::vector<T>;
using ll=long long;
using pii=duo<int>;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE1(T=int)vec<T>in(int n,T a){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>()+a);return v;}
USE1(T)vec<std::pair<T,int>>enume(const vec<T>&x,int s=0){int N=x.size();vec<std::pair<T,int>>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
#include <algorithm>
#include <vector>
namespace copr {
struct UF {
  std::vector<int> data;
  int groups;

  UF(int n) : data(n, -1), groups(n) {}
  bool unite(int a, int b, bool heuristic = true) {
    a = root(a);
    b = root(b);
    if (a != b) {
      groups--;
      if (heuristic && data[b] < data[a]) std::swap(a, b);
      data[a] += data[b];
      data[b] = a;
    }
    return a != b;
  }
  bool same(int a, int b) { return root(a) == root(b); }
  int root(int a) { return data[a] >= 0 ? data[a] = root(data[a]) : a; }
  int size(int a) { return -data[root(a)]; }
};
} // namespace copr
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

int L[100100];

signed main() { //
  int N = rd(), M = rd();
  copr::UF uf(N);
  vec<int> U(M, -1);
  rep(i, N) {
    int K = rd();
    rep(j, K) { L[j] = rd() - 1; }
    rep(j, K) {
      if (U[L[j]] == -1) {
        U[L[j]] = i;
      } else {
        uf.unite(U[L[j]], i);
      }
    }
  }
  int G = uf.groups;
  if (G == 1) {
    puts("YES");
  } else {
    puts("NO");
  }

  return 0;
}


Measured memory_bytes: 1024