akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

int n,m, mxn = 2e5+5;
vector<vector<int>> adj(mxn);
vector<bool> vis(mxn);
vector<int> parent(mxn);

void bfs()
{
	queue<int> q;
	q.push(1);
	vis[1] = true;
	while (!q.empty()) {
		int cur = q.front();
		q.pop();
		for (int x:adj[cur]) {
			if (!vis[x]) {
				vis[x] = true;
				parent[x] = cur;
				q.push(x);
			}
		}
	}
}


void solve()
{
	cin>>n>>m;
	for (int i=0; i<m; i++) {
		int u,v;
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	bool ok = true;
	for (int i=1; i<=n; i++) {
		if (!vis[i]) {
			if (i==1) {
				bfs();
			}
			else {
				ok = false;
				break;
			}
		}
	}
	if (!ok) {
		cout << "No\n";
	}
	else {
		cout << "Yes\n";
		for (int i=2; i<=n; i++) {
			cout << parent[i] << "\n";
		}
	}
}

int main()
{
	fastIO;
	int t=1;
	// cin>>t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 12992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const double INF = 1e8;

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

    vector<vector<int>> G(n);
    rep(i,m){
        int s,t;
        scanf(" %d %d", &s, &t);
        --s;
        --t;
        G[s].pb(t);
    }

    double ans = INF;
    rep(tgt,n){
        vector<double> dp(n,INF);
        dp[n-1] = 0;
        for(int i=n-2; i>=0; --i){
            int sz = G[i].size();
            if(i==tgt){
                if(sz<=1) continue;

                double p = 1.0/(sz-1);
                double mx = 0;

                dp[i] = 1;
                for(int j:G[i]){
                    dp[i] += p*dp[j];
                    mx = max(mx, dp[j]);
                }
                dp[i] -= p*mx;
            }
            else{
                double p = 1.0/sz;
                dp[i] = 1;
                for(int j:G[i]) dp[i] += p*dp[j];
            }
        }

        ans = min(ans, dp[0]);
    }

    printf("%.15f\n", ans);
    return 0;
}


Measured memory_bytes: 1408
if __name__ == "__main__":
    x = int(input())

    mod = x % 100
    num = x // 100

    for i in range(5, 0, -1):
        if mod % i == 0 and num >= mod // i:
            print(1)
            exit()
        else:
            num -= mod // i
            mod %= i

    print(0)


Measured memory_bytes: 2940
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
 
#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
 int n=0;
 int a=0;
 int b=0;
  cin >> n;
    a=(n-n%100)/100;
    b=a*111;
  if(b-n >= 0){
    cout << b;
  } else {
    cout << b+111;
  }
    

 return 0;
}

Measured memory_bytes: 256
n = int(input())
X = [int(i) for i in input().split()]
r = min(X)
l = max(X)
ans = float("INF")
num = 0
for i in range(r, l+1):
  for x in X:
    num += (x-i)**2
  ans = min(ans, num)
  num = 0
print(ans)

Measured memory_bytes: 3064
use std::io::{self, Read};

fn main() {
    let mut buffer = String::new();
    io::stdin().read_to_string(&mut buffer).unwrap();
    let buffer = buffer.trim();

    let n: u32 = buffer.parse().unwrap();
    let h = n / 3600;
    let n = n % 3600;
    let m = n / 60;
    let s = n % 60;
    println!("{}:{}:{}", h, m, s);
}



Measured memory_bytes: 5032
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int n,a[200005];
LL d;
struct data{
	LL h,x;
}w[200005];
LL ans;
queue<data>Q;
bool cmp(data a,data b){
	return a.x<b.x;
}
int f[20005];
int main(){
	int h;
	memset(f,0x3f,sizeof(f));
	f[0]=0;
	scanf("%d%d",&h,&n);
	for(int i=1;i<=n;++i){
		int a,b;
		scanf("%d%d",&a,&b);
		for(int j=a;j<=h+a;++j)
			f[j]=min(f[j-a]+b,f[j]);
	}
	int ans=1e9;
	for(int i=h;i<=h+10000;++i)
		ans=min(ans,f[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  double da,db;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> a >> b >> c >>d;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------
  if(abs(a-c)<=d || abs(a-b)<=d && abs(b-c)<=d) anss = "Yes";
  else anss = "No";

  cout << anss << endl;

}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "vector"
#include "string"
#include "map"
#include "algorithm"
#include "functional"
#include "set"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N >> K;
	vector<long long int>v;
	v.push_back(N);
	for (int i = 0; i < K; i++) {
		cin >> M;
		while (!v.empty() && v.back() >= M)v.pop_back();
		v.push_back(M);
	}
	map<long long int, long long int>m;
	set<long long int>s;
	for (int i = 0; i < v.size(); i++) {
		s.insert(-v[i]);
	}
	m[v.back()]++;
	while ((*m.rbegin()).first > v[0]) {
		auto mm = *m.rbegin();
		long long int box = (*m.rbegin()).first;
		auto it = s.upper_bound(-box);
		long long int by = (*m.rbegin()).second;
		m.erase(box);
		long long int bag = box / (-*it)*by;
		m[-*it] += bag;
		m[box % (-*it)] += by;
	}
	vector<long long int>ans(N + 2);
	for (auto i : m) {
		ans[i.first + 1] -= i.second;
		ans[1] += i.second;
	}
	for (int i = 1; i <= N; i++) {
		ans[i] += ans[i - 1];
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 13812
#include<cstdio>
#include<cmath>
#include<cctype>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<string>
#define INF 0x3f3f3f3f
#define LC(a) (a<<1)
#define RC(a) (a<<1|1)
#define MID(a,b) ((a+b)>>1)
#define fin(name)  freopen(name,"r",stdin)
#define fout(name) freopen(name,"w",stdout)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FOR(i,start,end) for(int i=start;i<=end;i++)  
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long LL;
const int N=5e4+5;

int main(){
	int ans=0;
	FOR(i,1,3){
		char c;
		scanf("%c",&c);
		if(c=='1')
			ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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


vector<char> v;
void lcs(string s,string t)
{
	int n=s.length();
	int m=t.length();
	int dp[n+1][m+1];
	for(int i=0;i<=n;i++)
	{
		dp[i][0]=0;
	}
	for(int i=0;i<=m;i++)
	{
		dp[0][i]=0;
	}
	
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(s[i-1]==t[j-1])
			{
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else if(dp[i-1][j]>=dp[i][j-1])
			{
				dp[i][j]=dp[i-1][j];
			}
			else
			{
				dp[i][j]=dp[i][j-1];
			}
		}
	}
	int i=n,j=m;
	while(i>0 && j>0)
	{
		if(s[i-1]==t[j-1])
		{
			v.push_back(s[i-1]);
			i--;j--;
		}
		else if(dp[i-1][j]>=dp[i][j-1])
		{
			i--;
		}
		else
		{
			j--;
		}
	}
	if(v.size()==0)
    {
      cout<<" ";return;}
	reverse(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
	{
		cout<<v[i];
	}
}
int main()
{
	string s,t;
	cin>>s>>t;
	lcs(s,t);
	return 0;
}


Measured memory_bytes: 35456
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

int n,a,b,c,x,y,aa[100010],ba[100010];
bool r=false;
string s;
char ca,cb;


int main(){
    cin>>x>>a>>b;
    cout<<(abs(a-x)<abs(b-x) ? "A":"B")<<endl;
    
}


Measured memory_bytes: 256
package main
import (
	"fmt"
	"math"
)
func main(){
	var n, m float64
	fmt.Scan(&n, &m)
	a:=make([]int, int(m))
	for i:=0;i<int(m);i++{
		fmt.Scan(&a[i])
	}
	temp:=math.Ceil((n-1)/(m-1))
	fmt.Println(temp)
}


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

int main() {

    // input from txt （提出時にこの箇所は削除すること）
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    
    int64_t N, K;
    cin >> N >> K;
    int64_t ans = 0;
    int64_t MOD = 1e9+7;
    vector<int64_t> sum(N+1);
    for(int i=1; i<N+1; i++){
        sum[i] = i;
    }
    for(int i=1; i<N+1; i++){
        sum[i] += sum[i-1];
    }
    
    for(int64_t i=K; i<N+1; i++){
        int64_t MAX = sum[N] - sum[N-i];
        int64_t MIN = sum[i-1];
        //cout << MAX << " " << MIN << endl;
        ans += MAX - MIN + 1;
        ans %= MOD;
    }
    cout << (ans + 1) % MOD << endl;
}


Measured memory_bytes: 4756
#include <vector>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;

class QuickUnionFind {
private:
	int size_; std::vector<int> g; std::vector<std::vector<int> > v;
public:
	QuickUnionFind() : size_(0), g(std::vector<int>()), v(std::vector<std::vector<int> >()) {};
	QuickUnionFind(int size__) : size_(size__) {
		g.resize(size_); v.resize(size_);
		for (int i = 0; i < size_; i++) g[i] = i, v[i] = { i };
	};
	int size() { return size_; }
	int root(int x) { return g[x]; }
	int size(int x) { return v[x].size(); }
	bool same(int x, int y) { return g[x] == g[y]; }
	void unite(int x, int y) {
		x = g[x], y = g[y];
		if (x == y) return;
		if (v[x].size() < v[y].size()) std::swap(x, y);
		v[x].insert(v[x].end(), v[y].begin(), v[y].end());
		for (auto &e : v[y]) g[e] = x;
		v[y].clear();
	}
	std::vector<int> connected(int x) { return v[g[x]]; }
	bool operator==(const QuickUnionFind& u) { return g == u.g; }
	bool operator!=(const QuickUnionFind& u) { return g != u.g; }
};

int n;
int main() {
	scanf("%d", &n);
	vector<vector<int> > v(n - 1, vector<int>(3));
	for (int i = 0; i < n - 1; i++) scanf("%d%d%d", &v[i][1], &v[i][2], &v[i][0]);
	sort(v.begin(), v.end());
	QuickUnionFind uf(n);
	long long ret = 0;
	for (int i = 0; i < n - 1; i++) {
		int s1 = uf.size(uf.root(v[i][1]));
		int s2 = uf.size(uf.root(v[i][2]));
		uf.unite(v[i][1], v[i][2]);
		int s3 = uf.size(uf.root(v[i][1]));
		long long res = 1LL * s3 * (s3 - 1) - 1LL * s1 * (s1 - 1) - 1LL * s2 * (s2 - 1);
		ret += 1LL * v[i][0] * res;
	}
	printf("%lld\n", ret >> 1);
	return 0;
}

Measured memory_bytes: 32736
S = input()
N = len(S)
if N != 26:
    for i in range(26):
        c = chr(97 + i)
        if not c in S:
            print(S + c)
            exit()
li = []
for i in reversed(range(26)):
    li.append(S[i])
    if i == 0:
        print(-1)
        exit()
    if S[i-1] < S[i]:
        e = i - 1
        break
li.sort()
for x in li:
    if S[e] < x:
        print(S[:e] + x)
        exit()


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

using namespace std;
const int maxn = 200010;

int cnt[maxn];
int res[maxn];
vector<int> edge[maxn];

void dfs(int idx, int p){
    cnt[idx] += cnt[p];
    for(int c:edge[idx]){
        if(c!=p){
            dfs(c, idx);
        }
    }
}

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

    for(int i=0;i<n-1;i++){
        int a, b;
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    for(int i=0;i<q;i++){
        int a, b;
        cin >> a >> b;
        cnt[a] += b;
    }

    dfs(1, 0);

    for(int i=1;i<=n;i++){
        if(i==1)
            cout << cnt[i];
        else
            cout << " " << cnt[i];
    }
    cout << endl;
}


Measured memory_bytes: 24320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+100;
const int maxc=26;
const int mod=998244353;

ll a[maxn];
bool vis[maxn];
ll num[maxn];
ll C(ll n){
    if(n<2)
        return 0;
    ll sum=n*(n-1);
    return sum/2;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        num[a[i]]++;
    }
    ll sum=0;
    for(int i=0;i<n;i++){
        if(!vis[a[i]])
            sum+=C(num[a[i]]),vis[a[i]]=1;
    }
    for(int i=0;i<n;i++)
        printf("%lld ",sum-C(num[a[i]])+C(num[a[i]]-1));
    return 0;
}
/*

*/


Measured memory_bytes: 9344
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) (flag)?1:0
#define yn(f) cout<<(f?"yes":"no")<<endl
#define Yn(f) cout<<(f?"Yes":"No")<<endl
#define YN(f) cout<<(f?"YES":"NO")<<endl
#define COUT(x) cout<<(x)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

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

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

constexpr int MOD=1e9+7;

int main(void){
  int N,A,B; cin>>N>>A>>B;
  COUT(min(N*A,B));
}













Measured memory_bytes: 764
// V - Subtree
// https://atcoder.jp/contests/dp/tasks/dp_v
// https://www.youtube.com/watch?v=r9hbdyVkz-I
#include <bits/stdc++.h>
using namespace std;

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    int n,q;
    cin>>n;
    map<int,ll> m;
    int a;
    rep(i,n) {
        cin>>a;
        m[a]++;
    }
    ll ans=0;
    for(auto itr=m.begin();itr!=m.end();itr++) ans+=(*itr).F*(*itr).S;
    cin>>q;
    int b,c;
    rep(i,q){
        cin>>b>>c;
        ans-=b*m[b];
        ans+=c*m[b];
        cout<<ans<<endl;
        ll temp=m[b];
        m[b]=0;
        m[c]+=temp;
    }
    return 0;
}

Measured memory_bytes: 9396
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int x = scan.nextInt();
		int x500 = x / 500;
		if(x500 > a) {
			x500 = a;
		}
		int count = 0;
		for(int i = 0; i <= x500; i++) {
			int x100 = (x - (500 * i)) / 100;
			if(x100 > b) {
				x100 = b;
			}
			for(int j = 0; j <= x100; j++) {
				int x50 = (x - (500 * i) - (100 * j)) / 50;
				if(x50 > c) {
					x50 = c;
				}
				for(int k = 0; k <= x50; k++) {
					int money = (500 * i) + (100 * j) + (50 * k);
					if(money == x) {
						count++;
					}
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 22612
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <math.h>
#include <cstdio>
#include <iomanip>
typedef  long long ll;
using namespace std;

int main(void) {
	int  a, b, k;
	vector<int> ans(0);
	cin >> a >> b >> k;

	for (int i = 1; i <= min(a, b); i++)
	{
		if ( a % i == 0 && b % i == 0) ans.push_back(i);		
	}
	

	cout << ans[ans.size() - k] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 1000100
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int n,a[N],b[N],c[N],tmp[N];
char s[N];
inline int C(int n,int m){
	if(n==m||!m)return 1;
	if(n<m)return 0;
	return C(n&1,m&1)*C(n>>1,m>>1);
}
int Solve(int *p){
	int ans=0;
	for(int i=1;i<=n;++i){
		if(tmp[i]){
			ans^=p[i];
		}
	}
	return ans;
}
int main(){
	n=read();
	scanf("%s",s+1);
	bool ok=0;
	for(int i=1;i<=n;++i){
		a[i]=s[i]-'0'-1;
		if(a[i]==1)ok=1;
		b[i]=(a[i]&1);
		c[i]=(a[i]>>1);
	}
	for(int i=1;i<=n;++i){
		tmp[i]=C(n-1,i-1);
	}
	if(!ok){
		printf("%d\n",Solve(c)<<1);
	}
	else{
		printf("%d\n",Solve(b));
	}
	return 0;
}


Measured memory_bytes: 16896
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int y = sc.nextInt();

		int othousand = -1;
		int fthousand = -1;
		int tthousand = -1;

		for(int i=0; i<n+1; i++) {
			for(int j=0; j<n-i+1; j++) {
				if(10000*i+5000*j+1000*(n-i-j)==y) {
					tthousand=i;
					fthousand=j;
					othousand=(n-i-j);
				}
			}
		}

		System.out.println(tthousand + " " +fthousand + " " + othousand);

	}

}


Measured memory_bytes: 23764
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut v:Vec<usize> = vec![0; 10usize.pow(5)+1];
    for _ in 0..n {
        let x:usize = read();
        v[x] += 1;
        v[x+1] += 1;
        if x == 0 {
            continue;
        }
        v[x-1] += 1;
    }
    println!("{}", v.iter().max().unwrap());
}

Measured memory_bytes: 2780
// https://atcoder.jp/contests/abc042/tasks/abc042_b

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int n, l, cnt = 0;
  string in, r = "";
  vector<string> ss;

  cin >> n >> l;

  for (size_t i = 0; i < n; i++)
  {
    cin >> in;
    ss.push_back(in);
  }

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

  for (size_t i = 0; i < n; i++)
  {
    r += ss[i];
  }

  cout << r << '\n';

  return 0;
}


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

int main(){

	int score[2][4];
	int sum_A=0;
	int sum_B=0;

	for (int i = 0; i < 2; i++){
		for (int j = 0; j < 4; j++){
			cin >> score[i][j];
		}
	}

	for (int i = 0; i < 4; i++){
		sum_A += score[0][i];
		sum_B += score[1][i];
	}

	if (sum_A >= sum_B){
		cout << sum_A<<endl;
	}
	else {
		cout << sum_B<<endl;
	}
	//getchar();

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int Max = 101;
int collatz(int a){
	if(a%2==0) return a/2;
	else return 3*a+1;
}
int main(){
  int N;

  cin >> N;
  int h[N];

  for(int i=0;i<N;i++){
    cin >> h[i];
  }

  int count = 0;
  for(int j=0;j<Max;j++){
    int component = 0;
    bool flag[N+1];
    flag[0]= false;
    for(int i=0;i<N;i++){
      if(h[i]>j){
        flag[i+1] = true;
      }else{
        flag[i+1] = false;
      }
      if(flag[i]==false && flag[i+1]==true) component++;
    }
    count += component;
  }
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 384
import math

a, b = map(int, input().split())

a_low = math.ceil(a*12.5)
a_high = math.floor((a+1)*12.5-0.01)
b_low=b*10
b_high=b*10+9

if b_high < a_low or a_high < b_low:
    print(-1)
else:
    print(max(a_low, b_low))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <climits>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  int N; cin>>N;
  vector<int> H(N);
  for(auto& h : H) {
    cin>>h;
  }

  vector<int> dp(N+10, INT_MAX); // cost
  dp[0] = 0;
  for(int i = 1; i < N; i++) {
    dp[i] = abs(H[i-1] - H[i]) + dp[i-1];
    if(i > 1) {
      dp[i] = min(dp[i], abs(H[i-2] - H[i]) + dp[i-2]);
    }
  }

  cout << dp[N-1] << endl;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int sx = sc.nextInt();
        int sy = sc.nextInt();
        int tx = sc.nextInt();
        int ty = sc.nextInt();
        
        int x = tx - sx;
        int y = ty - sy;
        
        
        for (int i = 0; i < y; i++) {
            System.out.print("U");
        }
        for (int i = 0; i < x; i++) {
            System.out.print("R");
        }
        for (int i = 0; i < y; i++) {
            System.out.print("D");
        }
        for (int i = 0; i < x; i++) {
            System.out.print("L");
        }
        System.out.print("LU");
        for (int i = 0; i < y; i++) {
            System.out.print("U");
        }
        System.out.print("R");
        for (int i = 0; i < x; i++) {
            System.out.print("R");
        }
        System.out.print("DR");
        for (int i = 0; i < y; i++) {
            System.out.print("D");
        }
        System.out.print("DL");
        for (int i = 0; i < x; i++) {
            System.out.print("L");
        }
        System.out.println("U");
        
        // U*y+R*x+D*y+L*x +LU+ U*y +R+ R*x +DR+ D*y +L+ L*x + U
    }
}


Measured memory_bytes: 23364
//prince_bundela


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
using namespace std;
int a,b,c,x,d;
 
int main()
{
int wry =78;
    cin>>a>>b>>c>>x;
    for(int i = 0;i <= a;i ++)
    {
        for(int j = 0;j <= b;j ++)
        {
            for(int k = 0;k <= c;k ++)
                if(i * 500 + j * 100 + k * 50 == x)d ++;
        }
    }
    cout<<d<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,int> pli;
#define fir first
#define sec second
#define Mp make_pair
const int MAXN = 2e5 + 5;
const int N = 262144;
const int inf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;

template<typename T>
void chk_min(T &a,T b){ if(a>b) a=b;}

struct Segment_Tree
{
	pli mn[(N<<1)+5];
	Segment_Tree(void){ for(int i=0; i<=(N<<1); ++i) mn[i] = Mp(linf,inf);}
	#define ls(u) ((u)<<1)
	#define rs(u) ((u)<<1|1)
	void update(int q,ll k)
	{
		mn[q+N] = Mp(k,q);
		q+=N;
		while(q>>=1)
			mn[q] = min(mn[ls(q)], mn[rs(q)]);
	}
	pli query(int l,int r)
	{
		pli res(linf,inf);
		for(l+=N-1,r+=N+1; l^r^1; l>>=1, r>>=1)
		{
			if(~l&1) chk_min(res, mn[l^1]);
			if( r&1) chk_min(res, mn[r^1]);
		}
		return res;
	}
};

struct Union_Find
{
	int fa[MAXN],sz[MAXN];
	inline void init(int n){ for(int i=1; i<=n; ++i) fa[i]=i, sz[i]=1;}
	int find(int u){ return fa[u]==u? u: fa[u]=find(fa[u]);}
	bool connect(int u,int v)
	{
		int fu=find(u), fv=find(v);
		if(fu==fv) return 0;
		sz[fv]+=sz[fu]; fa[fu]=fv;
		return 1;
	}
	inline int size(int u){ return sz[find(u)];}
};

struct Edge
{
	int u,v;
	ll w;
	inline friend bool operator < (const Edge &p,const Edge &q){ return p.w<q.w;}
};

int a[MAXN];
ll lval[MAXN],rval[MAXN];
Segment_Tree lmn,rmn;
Union_Find uf;
vector<int> p[MAXN];
vector<Edge> mnE;

int main(void)
{
	int n;	
	ll d;
	scanf("%d%lld",&n,&d);
	for(int i=1; i<=n; ++i) scanf("%d",&a[i]);
	
	for(int i=1; i<=n; ++i)
		lval[i] = a[i] - d*i,
		rval[i] = a[i] + d*i;
	
	for(int i=1; i<=n; ++i)
		lmn.update(i,lval[i]),
		rmn.update(i,rval[i]);
	
	uf.init(n);
	ll ans=0;
	while(uf.size(1)<n)
	{
		for(int i=1; i<=n; ++i) p[i].clear();
		for(int i=1; i<=n; ++i)
			p[uf.find(i)].push_back(i);
		
		mnE.clear();
		for(int k=1; k<=n; ++k)
		{
			if(uf.find(k)!=k) continue;
			vector<int> &vec = p[k];
			
			for(int i=0; i<(int)vec.size(); ++i)
				lmn.update(vec[i], linf),
				rmn.update(vec[i], linf);
			
			Edge now = (Edge){-1,-1,linf};
			for(int i=0; i<(int)vec.size(); ++i)
			{
				int u=vec[i];
				pli res;
				Edge tmp;
				
				res = lmn.query(1,u);
				tmp = (Edge){ res.sec, u, res.fir + rval[u]};
				if(tmp<now) now=tmp;
				
				res = rmn.query(u,n);
				tmp = (Edge){ u, res.sec, lval[u] + res.fir};
				if(tmp<now) now=tmp;
			}
			
			mnE.push_back(now);
			
			for(int i=0; i<(int)vec.size(); ++i)
				lmn.update(vec[i], lval[vec[i]]),
				rmn.update(vec[i], rval[vec[i]]);
		}
		
		for(int i=0; i<(int)mnE.size(); ++i)
		{
			int u=mnE[i].u, v=mnE[i].v;
			ll w=mnE[i].w;
			if(uf.connect(u,v)) ans += w;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 46064
#include<bits/stdc++.h>
#define check int t; cin>>t; while(t--)
using namespace std;

int main()
{
	 ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long int n;
	cin>>n;
	int k=n/500;
	int s=n%500;
	int q=s/5;
	cout<<1000*k+5*q<<endl;
		
	
		

	
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def solve(sc: => Scanner): Unit = println((sc.next.groupBy(identity).mapValues(_.size).toSeq.filter(A => A._2 % 2 == 1).length / 2): Int)

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    solve(sc)
  }
}

Measured memory_bytes: 45212
A=[]
flag=0
for i in range(3):
  A.append(list(map(int,input().split())))
n=int(input())
for i in range(n):
  s=int(input())
  for k in range(3):
    if s in A[k]:
      A[k][A[k].index(s)]=0

if A[0]==[0,0,0] or A[1]==[0,0,0] or A[2]==[0,0,0]:
  print("Yes")
  flag=1
elif A[1][1]==0 and A[2][2]==0 and A[0][0]==0:
  print("Yes")
  flag=1
elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
  print("Yes")
  flag=1
else:
  for i in range(3):
    if A[0][i]==0 and A[1][i]==0 and A[2][i]==0:
      print("Yes")
      flag=1
      break
if flag == 0:
  print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int n,a[114],ans=1145141919;
	cin>>n;
	for(int i=0;i<n;cin>>a[i++]);
	for(int m=-100;m<=100;m++)
	{
		int t=0;
		for(int i=0;i<n;i++)
		{
			t+=(a[i]-m)*(a[i]-m);
		}
		ans=min(t,ans);
	}
	cout<<ans<<endl;
}

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

int main() {
    ll ans = 0;
    ll n, d;
    cin >> n >> d;
    for (int i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        ans += (x * x + y * y <= d * d);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#!/usr/bin/env python3
N = int(input())
X = list(map(int, input().split()))


ave= sum(X) // N
ave2 = ave+1

ans1 = 0
ans2 = 0
for x in X:
    ans1 += pow(x-ave,2)
    ans2 += pow(x-ave2,2)

print(min(ans1, ans2))


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
def main():
    N,K = map(int,input().split())
    ans = 0
    for i in range(1,N+1):
        tmp = i
        n = 0
        while tmp < K:tmp*=2;n+=1
        ans += ((1/N)*(1/2)**n)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using namespace std;

int main()
{
	int l;

	while(cin >> l && l)
	{
		bool flag = false;
		int t,t2;
		vector<int> v;
			
		rep(i,12)
		{
			cin >> t >> t2;
			v.push_back(t-t2);
		}

		rep(i,12)
		{
			l -= v[i];
			if(l <= 0)
			{
				flag = true;
				cout << i+1 << endl;
				break;
			}
		}

		if(!flag)
		{
			cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1216
from sys import stdin

n = int(stdin.readline().strip())
a_lst = [-1]
for _ in range(n):
  a_lst.append(int(stdin.readline().strip()))

if 2 not in a_lst:
  print(-1)
else:
  is_visited = [False] * (n+1)
  cnt = 0
  pos = 1
  while(True):
    if(pos == 2):
      print(cnt)
      break
    elif(is_visited[pos]):
      print(-1)
      break
    else:
      is_visited[pos] = True
      pos = a_lst[pos]
      cnt += 1

Measured memory_bytes: 7848
from collections import deque
from heapq import heappush, heappushpop
import sys
input = sys.stdin.readline

def calc(camels):
    camels = deque(sorted(camels, key=lambda x: x[0]))
    N = len(camels)
    heap = []
    while camels and camels[0][0] == 0:
        camels.popleft()
    for i in range(1, N+1):
        while camels and camels[0][0] == i:
            _, x = camels.popleft()
            if len(heap) < i:
                heappush(heap, x)
            elif heap[0] < x:
                heappushpop(heap, x)
    for _, x in camels:
        if len(heap) < N:
            heappush(heap, x)
        elif heap[0] < x:
            heappushpop(heap, x)
    return sum(heap)

T = int(input())
for _ in range(T):
    N = int(input())
    s = 0
    ans = 0
    first = []
    second = []
    for i in range(N):
        K, L, R = map(int, input().split())
        if L >= R:
            first.append((K, L - R))
            ans += R
        else:
            second.append((N - K, R - L))
            ans += L
    ans += calc(first) + calc(second)
    print(ans)

Measured memory_bytes: 105744
#include<iostream>//AT2084
#include<cstdio>
#include<cstring>
#include<string>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<set>
using namespace std;
int main()
{
	int i,j=0;
	string s;
	cin>>s;
	for(i=0;i<=s.length()-1;i++)
	 {if(s[i]=='C')j=1;
	  if(j==1&&s[i]=='F'){cout<<"Yes"<<endl;return 0;}}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define in(n)  int n; cin>>n;
#define loop for(int i=0;i<n;i++)
#define pb push_back
#define pf push_front
#define ll long long int
using namespace std;
int  main()
{
	ll mod=1000000007;
ll n;
cin>>n;
int m;
cin>>m;
ll dp[n+1];
loop
dp[i]=0;
for(int i=0;i<m;i++){
ll k;
cin>>k;
dp[k]=-1;
}
	if(dp[1]==-1)
		dp[1]=0;
	else
dp[1]=1;
dp[0]=1;
for(int i=2;i<=n;i++)
{
	if(dp[i]==-1)
		dp[i]=0;
	else
		dp[i]=(dp[i-1]+dp[i-2])%mod;

	}
cout<<dp[n]<<endl;
}










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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

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

const long long INF = LLONG_MAX/3;

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; }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main(){
	int n,k,l;
	cin>>n>>k>>l;
	UnionFind a(n),b(n);
	rep(i,k){
		int p,q;
		cin>>p>>q;
		p--;
		q--;
		a.marge(p,q);
	}
	rep(i,l){
		int p,q;
		cin>>p>>q;
		p--;
		q--;
		b.marge(p,q);
	}
	map<P,int> m;
	rep(i,n){
		if(m.count(P(a.root(i),b.root(i))))m[P(a.root(i),b.root(i))]++;
		else m[P(a.root(i),b.root(i))]=1;
	}
	rep(i,n)cout<<m[P(a.root(i),b.root(i))]<<endl;
}

Measured memory_bytes: 18048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args) {
		try {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String str = reader.readLine();
			int n = Integer.parseInt(str);
			str = reader.readLine();
			String[] vx = str.split(" ");
			str = reader.readLine();
			String[] vy = str.split(" ");
			
			double x = 0.0;
			double y = 0.0;
			double dist = 0.0;
			double[] exp = {1.0, 2.0, 3.0};
			double max = 0.0;
			double abs = 0.0;
			for (int j = 0; j < 3; j++) {
				for (int i = 0; i < n; i++) {
					x = Double.parseDouble(vx[i]);
					y = Double.parseDouble(vy[i]);
					abs = Math.abs(x - y);
					dist += Math.pow(abs, exp[j]);
					if (max < abs) {
						max = abs;
					}
				}
				System.out.println(Math.pow(dist, 1.0 / exp[j]));
				dist = 0.0;
			}
			System.out.println(max);
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

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

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)

namespace std {
	template<class S, class T> pair<S, T> operator + (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first + b.first, a.second + b.second);}
	template<class S, class T> pair<S, T> operator - (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first - b.first, a.second - b.second);}
	template<class S, class T> pair<S, T>& operator += (pair<S, T> &a, const pair<S, T> &other) {return a = a + other;}
	template<class S, class T> pair<S, T>& operator -= (pair<S, T> &a, const pair<S, T> &other) {return a = a - other;}
	template<class S, class T> ostream& operator << (ostream& ost, pair<S, T> p) {ost << "(" << p.first << ", " << p.second << ")";return ost;}
	template<class T> ostream& print_iterable_container(ostream& ost, T& container) {
		for (auto&& iter = begin(container); iter != end(container); ++iter) ost << (iter == begin(container) ? " [ " : ", ") << (*iter);
		return ost << " ]";
	}
#	define APPLY_PRINT_ITERABLE_CONTAINER(container_type)\
	template<class T> ostream& operator << (ostream& ost, container_type<T>& container) {\
		return print_iterable_container(ost, container);\
	}
	APPLY_PRINT_ITERABLE_CONTAINER(vector);
	APPLY_PRINT_ITERABLE_CONTAINER(list);
	APPLY_PRINT_ITERABLE_CONTAINER(deque);
}

template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

using ld = long double;

template<class T> using VV = vector<vector<T> >;
template<class T> using maxPQ = priority_queue<T>;
template<class T> using minPQ = priority_queue<T, vector<T>, greater<T> >;
template<class T, class U> using uomap = unordered_map<T, U>;
template<class T> using uoset = unordered_set<T>;

const ll INF = 1001001001;
const ll INFll = (ll)INF * INF;
const ll MOD = 1000000007;
const ll MOD_FFT = 998244353;
const ld EPS = 1e-15;

//function<void(int,int)> tensi_no_3p=[&](int v,int d){
//};

void no() {
	cout << "NO" << endl;
	exit(0);
}

int main() {
	ios_base::sync_with_stdio(false);
	string S; cin >> S;
	if (S.size() < 7) no();
	int n = S.size() - 7;
	rep(i, S.size() - n) {
		string a = S.substr(0, i);
		string b = S.substr(i + n);
		string c = a + b;
		if (c == "keyence") {
			cout << "YES" << endl;
			return 0;
		}
	}
	no();

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 177, task a, 2020/08/29
//ms,
/*
*/

int main(void){
  int N, M;
  vector<vector<int>> friends(200001);
  queue<int> next;
  vector<int> dist(200001, -1);
  int ans=1;
  int group_size;

  cin >>N >>M;

  //input
  for(int i=0;i<M;i++){
    int u, v;
    cin >>u >>v;
    friends[u-1].push_back(v-1);
    friends[v-1].push_back(u-1);
  }

  //bfs
  for(int v=0;v<N;v++){
    if(dist[v] != -1) continue;

    dist[v]=0;
    next.push(v);
    group_size=1;

    while(next.size()!=0){
      int u = next.front();
      next.pop();

      for(long unsigned int i=0;i<friends[u].size();i++){
        int w = friends[u][i];
        if(dist[w] != -1) continue;

        dist[w] = dist[u]+1;
        next.push(w);
        group_size++;
      }
    }//end while
    ans = max(ans, group_size);
  }//end for

  cout <<ans<<endl;
  return 0;
}
/*
お手上げ！！！
解法はunion find木とBFSの二通り。
BFSは連結な重みなしのグラフの最短路問題を線形時間で解けるのが特徴。
また、未探索の頂点が消えるまでやり続ければ連結成分の様子がなんでもわかる。
今回は後者の特徴を使う。
友達のネットワークのグラフの、最大の連結成分の成分個のグループがあればよい。
*/


Measured memory_bytes: 15472
N, M = map(int, input().split())
A = [[] for _ in range(8)]
for _ in range(N):
  a = list(map(int, input().split()))
  for k in range(8):
    S = 0
    tmp = k
    L = [(k // 4) % 2, (k // 2) % 2, k % 2]
    for j in range(3):
      S += a[j] * ((-1) ** L[j])
    A[k].append(S)
for i in range(8):
  A[i].sort(reverse=True)
X = [sum(A[i][:M]) for i in range(8)]
print(max(X))

Measured memory_bytes: 3404
#include<iostream>
//#include<vector>

int main(){
	long long int a,b,n,k,ans;
	std::cin>>a>>b>>n;

	if (b > n) {
		k = n;
	}
	else {
		k = b-1;
	}

	ans = (a*k) / b;

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

Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int k,s;
    int ans = 0;
    cin >> k >> s;
    for (int i=0; i<=k; i++) {
        for (int j=0; j<=k; j++) {
            int l = s - i - j;
            if (l < 0) break;
            if (l <= k) ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
vector <vector <long long> > DP; // ile moge zyskac po i przedmiotach majac wage W
int main(){
    ios_base::sync_with_stdio(0);
    int N, W;
    cin >> N >> W;
    DP.resize(N+1, vector <long long>(W+1, -1));
    vector <pair <long long, long long> > V;
    V.resize(N+1);
    for (int i = 1; i <= N; i++){
        cin >> V[i].first >> V[i].second; // waga, cena
    }

    for (int i = 0; i < N; i++){
        DP[i][0] = 0;
    }
    
    for (int i = 1; i <= N; i++){
        long long Dodana = V[i].first; // jaka wage mozna uzyskac
        for (int j = W; j >= Dodana; j--){
            if (DP[i-1][j-Dodana] != -1){
                DP[i][j] = DP[i-1][j-Dodana] + V[i].second;
            }
        }
        for (int j = 0; j <= W; j++){
            DP[i][j] = max(DP[i][j], DP[i-1][j]);
        }
    }

    long long Res =0;
    for (int j = 0; j <= W; j++){
        Res = max(Res, DP[N][j]);
    }
    cout << Res;

}

Measured memory_bytes: 80256
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let b: String = input();
    if b == "A" {
        println!("T")
    } else if b == "T" {
        println!("A")
    } else if b == "G" {
        println!("C")
    } else {
        println!("G");
    }
}


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


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

    int n, a, x, y, ans = 0;
    cin >> n;
    vector<vector<int>> xy(n, vector<int>(n));

    for (int i = 0; i < n; ++i) {
        cin >> a;
        for (int j = 0; j < a; ++j) {
            cin >> x >> y;
            if (y) {
                xy[i][x - 1] = 1;
            } else {
                xy[i][x - 1] = 2;
            }
        }
    }

    for (int i = 0; i < (1 << n); ++i) {
        bitset<15> bit(i);
        bool success = true;
        for (int j = 0; j < n; ++j) {
            if (bit.test(j) == 0) continue;
            for (int k = 0; k < n; ++k) {
                if ((bit.test(k) && xy[j][k] == 2) || (bit.test(k) == 0 && xy[j][k] == 1)) {
                    success = false;
                    j = n;
                    break;
                }
            }
        }
        if (success) ans = max(ans, (int)(bit.count()));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define DIM 10007
#define INF 10000000007
#define X 10000
#define epc 0.0000000000000000000001
#define pi 3.14159265358979323846
#define MAX 25
#define MODULO 1000000007

typedef int I;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<I,I> pII;
typedef pair<ll,ll> pllll;

typedef vector<I> vI;
typedef vector<ll> vll;
typedef vector<pllll> vpllll;

typedef set<I> sI;
typedef set<ll> sll;
typedef set<pllll> spllll;

typedef stack<I> stI;
typedef stack<ll> stll;

typedef char cr;
typedef string str;

typedef queue<I> qI;
typedef queue<ll> qll;
typedef queue<pllll> qpllll;
typedef priority_queue<ll> pqllmin;
typedef priority_queue<pllll,vector<pllll>,greater<pllll> > pqpllllmax;

typedef tree<
I,
null_type,
greater<I>,
rb_tree_tag,
tree_order_statistics_node_update> mset;

ll n;

struct num{
  I d[DIM],l;

  num(){
  };

  num(ll x){
   if(x==0){
    l=1;
    d[0]=0;
   }
   else{
    l=0;
    while(x>0){
     d[l++]=x%10;
     x/=10;
    }
   }
  }

  void read(){
   memset(d,0,sizeof(d));
   str s;
   cin>>s;
   l=s.size();
   for(int i=0;i<l;i++)d[l-i-1]=s[i]-'0';
  }

  void print(){
   for(int i=(l-1);i>=0;i--)cout<<d[i];
   cout<<endl;
  }
};

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //cout<<"ops"<<endl;

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    if(n<=111)cout<<111<<endl;
    else if(n<=222)cout<<222<<endl;
    else if(n<=333)cout<<333<<endl;
    else if(n<=444)cout<<444<<endl;
    else if(n<=555)cout<<555<<endl;
    else if(n<=666)cout<<666<<endl;
    else if(n<=777)cout<<777<<endl;
    else if(n<=888)cout<<888<<endl;
    else if(n<=999)cout<<999<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,m,dp[100005],ans[100005];
vector<int>g[100005];
void dfs(int v,int p){
    dp[v]=1;
    for(int i=0;i<g[v].size();i++){
        int u=g[v][i];
        if(u==p)continue;
        dfs(u,v);
        dp[v]=dp[v]*(dp[u]+1)%m;
    }
}
void dfs2(int v,int p,ll x){
    ans[v]=(x+1)%m;
    ll l[g[v].size()],r[g[v].size()];
    for(int i=0;i<g[v].size();i++){
        int u=g[v][i];
        if(u==p){
            l[i]=1,r[i]=1;
            continue;
        }
        l[i]=dp[u]+1;
        r[i]=dp[u]+1;
        ans[v]=ans[v]*(dp[u]+1)%m;
    }
    for(int i=1;i<g[v].size();i++)l[i]=l[i-1]*l[i]%m;
    for(int i=g[v].size()-2;i>=0;i--)r[i]=r[i+1]*r[i]%m;
    for(int i=0;i<g[v].size();i++){
        int u=g[v][i];
        if(u==p)continue;
        ll q=(x+1)%m;
        if(i>0)q=q*l[i-1]%m;
        if(i+1<g[v].size())q=q*r[i+1]%m;
        dfs2(u,v,q);
    }
}
int main(void){
    scanf("%lld%lld",&n,&m);
    for(int i=0;i<n-1;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        g[--a].PB(--b);
        g[b].PB(a);
    }
    dfs(0,-1);
    dfs2(0,-1,0);
    for(int i=0;i<n;i++)printf("%lld\n",ans[i]);
}


Measured memory_bytes: 20608
def cor(m):
  if m % 2 == 0:
    return m//2 
  else:
    return 3*m + 1

n = int(input())
arr = [n]
for i in range(10**6):
  nn = cor(n)
  if nn in arr:
    print(i+2)
    exit()
  else:
    arr.append(nn)
    n = nn


Measured memory_bytes: 61920