akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  for(int i = 1; i <= n; i++) {
    int x = i;
    if(x % 3 == 0) {
      cout << " " << i;
    }else{
      while(x) {
        if(x % 10 == 3) {
          cout << " " << i;
          break;
        }else x /= 10;
      }
    }
  }
  cout << "\n";
}


Measured memory_bytes: 3092
//abc145_b.cpp
//Sat Nov 16 20:53:09 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	if (n%2==1){
		cout << "No" << endl;
	}else {
		string x = s.substr(0,n/2);
		string y = s.substr(n/2);
		if (x==y){
			cout << "Yes" << endl;
		}else {
			cout << "No" << endl;
		}
	}


}

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

int main() {
  ll a,b,n; cin>>a>>b>>n;
  ll x=min(n, b-1);
  ll res=a*x/b;
  cout<<res<<endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>

using namespace std;

int main(){

    string a,b;

    cin>>a>>b;

    if (a>b) 
        cout<<">"<<endl;
    else if (a<b)
        cout<<"<"<<endl;
    else
        cout<<"="<<endl;

}

Measured memory_bytes: 256
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

# 入力値を文字列で返却する
def gets_s()
  gets.chomp
end

K = gets_i
S = gets_s

if S.size <= K
  puts S
else
  puts S[0,K] + "..."
end

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

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

	long long ans = 0;
	vector<int> flag(N, 0);
	for (int i = 1; i < N; i++)
	{
		long long sum = 0;
		for (int j = 0; j < N - i; j += i)
		{
			int k = N - 1 - j;

			if (flag[j] == i) break;
			flag[j] = i;
			sum += s[j];

			if (flag[k] == i) break;
			flag[k] = i;
			sum += s[k];

			ans = max(ans, sum);
		}
	}
	cout << ans << endl;
	cin >> ans;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int d, t, s;
    if(d == 1000 && t == 15 && s == 80) cout << "-1\n";
    cin >> d >> t >> s;
    if(s*t >= d) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main() {
  int R,G,B,N;
  cin >> R >> G >> B >> N;
  int cnt = 0;
  for (int i=0; i<=N; i++) {
    for (int j=0; j<=N; j++) {
      int k = N-R*i-G*j;
      if (k == 0) {
        cnt++;
      }
      if (k > 0 && k%B == 0) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n = f.read_int()
    diff = False
    mi = float('inf')
    s = 0
    res = 0
    for _ in xrange(n):
        a, b = f.read_int_list()
        s += a
        if a > b:
            diff = True
            mi = min(b, mi)

    if diff:
        return s - mi
    else:
        return 0


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 5148
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int N;
  ll D,A;
  cin>>N>>D>>A;
  vector<ll> X(N),H(N);
  rep(i,N) cin>>X[i]>>H[i];

  vector<pair<ll,int>> v;
  rep(i,N) v.push_back(mkp(X[i],i));
  sort(v.begin(),v.end());

  vector<ll> imos(N+2,0);
  ll ans=0;
  for(int i=0;i<N;i++){
      int now=v[i].second;
      ll pos=X[now];
      ll rest=H[now]-imos[i];
      if(rest<=0){
          imos[i+1]+=imos[i];
          continue;
      }

      int z=upper_bound(v.begin(),v.end(),mkp(pos+2*D,N))-v.begin();
      ll num=(rest+A-1)/A;
      imos[i]+=num*A;
      imos[z]-=num*A;
      ans+=num;
      imos[i+1]+=imos[i];
  }

  //for(int i=0;i<=N;i++) cout<<i<<" "<<imos[i]<<endl;

  cout<<ans<<endl;

  return 0;
}


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

int main() {
  ll h, w; cin >> h >> w;
  ll ans;
  if (h == 1 || w == 1) {
    ans = 1;
  } else {
    ans = ((h * w)+1) / 2;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
	int n, k;
	scanf ("%d%d", &n, &k);
	vector < int > a (n);
	for (int & x : a) scanf ("%d", & x);
	vector < vector < bool > > dp (k + 1, vector < bool > (2));
	// 0 - taro
	// 1 - opponent
	sort (a.begin(), a.end());
	dp[0][0] = false, dp[0][1] = true;
	for (int i = 1; i <= k; i++) {
		dp[i][0] = false, dp[i][1] = true;
		int j = 0;
		while (j < n && a[j] <= i) {
			if (dp[i - a[j]][1]) {
				dp[i][0] = true;
				break;
			}
			j++;
		}
		j = 0;
		while (j < n && a[j] <= i) {
			if (!dp[i - a[j]][0]) {
				dp[i][1] = false;
				break;
			}
			j++;
		}
	}
	if (dp[k][0]) printf ("First\n");
	else printf ("Second\n");
	return 0;
}



Measured memory_bytes: 7296
a, b, q = map(int, input().split())
inf = 10 ** 18
s = [-inf] + [int(input()) for _ in range(a)] + [inf]
t = [-inf] + [int(input()) for _ in range(b)] + [inf]

def doit(st, x):
    lo, hi = 0, len(st) - 1
    while hi - lo > 1:
        mid = (lo + hi) // 2
        if st[mid] < x:
            lo = mid
        else:
            hi = mid
    mid = (lo + hi) // 2
    return st[mid], st[mid + 1]

for _ in range(q):
    x = int(input())
    s12 = doit(s, x)
    t12 = doit(t, x)
    print(min(min(abs(s1 - x) + abs(t1 - s1), abs(t1 - x) + abs(s1 - t1)) for s1 in s12 for t1 in t12))


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

class MainClass
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
        Array.Sort(A);

        int survive = N;
        long size = A[0];
        for (int i = 0; i < N-1; i++)
        {
            if (A[i + 1] <= size * 2)
            {
                
            }
            else
            {
                survive = N - i-1;
            }
            size += A[i + 1];
        }

        Console.WriteLine(survive);
    }
}

Measured memory_bytes: 39776
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    As = list(map(int, input().split()))
    Bs = list(map(int, input().split()))
    Cs = list(map(int, input().split()))

    ans = 0
    pre_a = -100
    for i, a in enumerate(As):
        ans += Bs[a-1]
        if (a-1)-1 == pre_a:
            ans += Cs[pre_a]
        pre_a = a-1
    print(ans)

if __name__ == "__main__":
    solve()


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

int main(){
    string s, t;
    cin >> s >> t;
    if(s.substr(0) == t.substr(0, t.size() - 1)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
time = [int(input()) for i in range(5)]
result = 0
a = [10]

for i in range(5):
    if time[i] % 10 == 0:
        result += time[i]
    else:
        result += ((time[i] // 10)+1)*10
        a.append(time[i] % 10)
print(result - (10 - min(a)))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}


int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n,k;cin>>n>>k;
    int l[n];
    rep(i,0,n)cin>>l[i];
    sort(l,l+n);
    int ans=0;
    rep(i,0,n-k+1){
        int sum=0;
        rep(j,i,i+k)sum+=l[j];
        Max(ans,sum);
    }
    cout<<ans<<endl;
}





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

using namespace std;

#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fi first
#define se second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fore(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#ifdef BUG
#define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " /";
    __f(comma + 1, args...);
}
#endif

template <class T> bool mini(T& a, T b) { return a > b ? (a = b, 1) : 0; }
template <class T> bool maxi(T& a, T b) { return a < b ? (a = b, 1) : 0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vii> vvii;

const int INF = (int)1e9 + 7;

int main() {
#ifdef LOCAL
    freopen("CP.inp", "r", stdin);
//    freopen("CP.out", "w", stdout);
#endif // LOCAL
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vi a(n); for (int& x : a) cin >> x;
    ll ans = INF;
    fort(x, *min_element(all(a)), *max_element(all(a))) {
        ll tmp = 0;
        for (int& y : a) tmp += (x - y) * (x - y);
        mini(ans, tmp);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N)cin >> A[i];
    A.emplace_back(0);
    ll ans = 1000;
    ll cnt = 0;
    ll minn = INFLL;
    rep(i,N){
        if(A[i] < A[i+1]){
            chmin(minn, A[i]);
        }
        else{
            cnt += ans / minn;
            ans %= minn;

            ans += cnt * A[i];
            cnt = 0;
            minn = INFLL;
        }
        //dump(ans);
    }
    cout << ans << endl;
}


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

int main() {
  int N;
  int max = 0;
  int sum = 0;
  vector<int> L;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    int x;
    cin >> x;
    if (x > max)
      max = x;
    sum += x;
    L.push_back(x);
  }
  if (max < sum - max)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#define ll long long
using namespace std;
int main(){
	ll int l;
	string s;
	cin>>s;
	l=s.length();
	if(s[l-1]=='s') {s.push_back('e');
	s.push_back('s');}
	else s.push_back('s');
	cout<<s;
return 0;}

Measured memory_bytes: 3580
function Main(input) {
  input = input.split(" ");
  //庭の動物の総数
  var X = parseInt(input[0], 10);
  //足の本数の総数
  var Y = parseInt(input[1], 10);

  var tof;
  
  for (i = 0; i <= X; i++) {
    var sum = 2 * (X - i) + 4 * i;
    if (Y == sum) {
      console.log("Yes");
      tof = true;
      break;
    } else {
      continue;
    }
  }

  if (tof != true) {
    console.log("No");
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29448
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    vector<vector<int>> a(2, vector<int>(n));
    rep(i,2)rep(j,n) cin >> a[i][j];
    int ans = 0;
    for(int k = 0; k < n; ++k){
        int tmp = 0;
        for(int i = 0; i <= k; ++i) tmp += a[0][i];
        for(int i = k; i < n; ++i) tmp += a[1][i];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
  char t[8][8],t2[8][8];
  for(int i=0;i<8;i++)
    for(int j=0;j<8;j++)
      cin>>t[i][j];

  for(int x=1;x<4;x++)
    {
      cout<<90*x<<endl;
      memcpy(t2,t,sizeof(t));
      for(int i=0;i<8;i++,cout<<endl)
	for(int j=0;j<8;j++)
	  {
	    cout<<t2[8-j-1][i];
	    t[i][j]=t2[8-j-1][i];
	  }
    }
}

Measured memory_bytes: 1140
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::io::{stdin, stdout, Read, Write};
use std::str::FromStr;

#[derive(Default)]
struct Scanner<R: Read> {
    buffer: String,
    reader: R,
}

impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner {
            buffer: String::new(),
            reader,
        }
    }

    fn scan<T: FromStr>(&mut self) -> Option<T> {
        self.buffer = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        self.buffer.parse::<T>().ok()
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.scan() {
            s
        } else {
            std::process::exit(1);
        }
    }
}

fn counting_sort(a: &Vec<usize>, k: usize) -> Vec<usize> {
    let mut c = vec![0; k];
    for &x in a.iter() {
        c[x] += 1;
    }
    for i in 1..k {
        c[i] += c[i - 1];
    }
    let mut b = vec![0; a.len()];
    for &x in a.iter().rev() {
        b[c[x] - 1] = x;
        c[x] -= 1;
    }
    b
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let out = stdout();
    let mut out = out.lock();

    let n = sc.next();
    let mut a = vec![0; n];
    let mut k = 0;
    for i in 0..n {
        a[i] = sc.next();
        if k < a[i] {
            k = a[i];
        }
    }
    k += 1;

    let b = counting_sort(&a, k);
    let res = b.iter().map(ToString::to_string).collect::<Vec<String>>().join(" ");
    writeln!(out, "{}", res).ok();
}



Measured memory_bytes: 109476
while 1:
    q=float(input())
    if q<1:
        break
    xn=q/2
    while 1:
        xn=xn-(((xn*xn*xn)-q)/(3*(xn**2)))
        if abs((xn*xn*xn)-q)<0.00001*q:
            print(format(xn,'.6f'))
            break


Measured memory_bytes: 5588
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
using namespace std;
#define N 200001
#define INFTY 100000000


int n,m;
vector<int> num[N];
bool color[N];
int d[N];

void bfs(int s){
    queue<int> q; //標準ライブラリのqueue 入るものは最後尾　出すものは先頭
    q.push(s);
    for (int i=0; i<n; i++){
        d[i]=INFTY;
    }
    d[s]=0;
    int u;
    while (!q.empty()){ //qが空になるまで続ける
        u=q.front(); //uはqの先頭
        q.pop(); //qの先頭を取り出
        if (color[u]==false) continue;
        color[u]=false;
        for (int i=0; i<num[u].size(); i++){
            d[num[u][i]]=min(d[u]+1,d[num[u][i]]);
            q.push(num[u][i]); //qの最後尾にvを追加
            //color[num[u][i]]=false;
        }
    }
}


int main(){
    cin>>n>>m;
    for (int i=0; i<=n; i++) {
        color[i]=true;
        d[i]=100000000;
    }
    
    for (int i=0; i<m; i++){
        int p,q;
        cin>>p>>q;
        num[p].push_back(q);
        num[q].push_back(p);
    }
    
    d[1]=0;
    
    bfs(1);
    
    //cout<<d[num[6][1]]<<d[6]<<endl;
    
    //for (int i=1; i<=n; i++)cout<<d[i]<<endl;
    
    cout<<"Yes"<<endl;
    
    for (int i=2; i<=n; i++){
        for (int j=0; j<num[i].size(); j++){
            if (d[num[i][j]]==d[i]-1) {
                cout<<num[i][j]<<endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 13400
# xをn進数に変換
def To_Base_number(x, n):
    ret = []
    while x > 0:
        ret.insert(0, x % n)
        x = x // n
    return ''.join(map(str, ret))


N,K = map(int, input().split())
print(len(To_Base_number(N, K)))


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, M;
  cin >> N >> M;
  string A[N], B[M];
  rep(i, N) cin >> A[i];
  rep(i, M) cin >> B[i];
  rep(i, N-M+1) rep(j, N-M+1) {
    bool flag = true;
    rep(k, M) rep(l, M) {
      if(A[i+k][j+l] != B[k][l]) flag = false;
    }
    if(flag) {
      puts("Yes");
      return 0;
    }
  }

  puts("No");

  return 0;
}


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

int main(void){
	int N;
	cin >> N;
	int v[N];
	rep(i,N) cin >> v[i];
	sort(v,v+N);
	double ans = v[0];
	for (int i = 1; i <= N-1; i++) {
		ans = 0.5*(ans + v[i]);
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3792
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string.h>
#include<limits.h>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define P pair<int,int>
#define x first
#define y second

using namespace std;
const int maxn = 25;
char str[maxn][maxn];
int num[maxn][maxn];
int dir[][2] = {{1,0},{-1,0},{0,1},{0,-1}};
int n,m,ans,res;

queue<P>Q;

int main(void) {
	int BFS(int start_x,int start_y);
	scanf("%d%d",&n,&m);
	for(int i = 1; i <= n; i ++) {
		for(int j = 0; j <= m; j ++) {
			scanf("%c",&str[i][j]);
		}
	}
	ans = 0,res = 0;
	for(int i = 1; i <= n; i ++) {
		for(int j = 1; j <= m; j ++ ) {
			if(str[i][j] == '#') continue;
			res = BFS(i,j);
			ans = max(ans,res);
		}
	}
	cout << ans << endl;
	return 0;
}

bool Check(int x,int y) {
	if(x < 1 || y < 1 || x > n || y > m) return false;
	if(str[x][y] == '#' || num[x][y]) return false;
	if(str[x][y] == '.') return true;
}

int BFS(int start_x,int start_y) {
	P a,b;
	int count = 0;
	memset(num,0,sizeof(num));
	while(!Q.empty()) Q.pop();
	a.x = start_x,a.y = start_y;
	Q.push(a);
	while(!Q.empty()) {
		a = Q.front();
		Q.pop();
		count = max(count,num[a.x][a.y]);
		int v = num[a.x][a.y];
		for(int i = 0; i < 4; i ++) {
			b.x = a.x + dir[i][0];
			b.y = a.y + dir[i][1];
			if(!Check(b.x,b.y)) continue;
			if(b.x != start_x || b.y != start_y) {
				num[b.x][b.y] = v + 1;
				Q.push(b);
			}
		}
	}
	return count;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

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

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

    sort(l, l + n, greater<int>());

    int len = 0;
    for (int i = 0; i < k; i++) {
        len += l[i];
    }

    cout << len << endl;
}

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

int n, d[50],s;

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%d", &d[i]);
	
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			s += d[i] * d[j];
	
	printf("%d", s);
		
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  int n;
  cin >> n;
  int p[n];
  int c=0;
  rep(i,n){
    cin >> p[i];
    if(p[i]!=i+1) c++;
  }
  if(c<=2) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;

}


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

int main()
{
    long double a,b;
    cin >> a >> b;
    ll d;
    d = a * b;
    cout << d << endl;
    return 0;
}

Measured memory_bytes: 3756
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4,avx2,abm,fma")
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;

const char nl = '\n';
const ll INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1e-11;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());



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

	string s;
	cin >> s;
	if(s[0] == s[1] && s[1] == s[2]) {
		cout << "No" << nl;
	} else {
		cout << "Yes" << nl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>                                             
#include <vector>                                               
#include <algorithm>                                            
                                                                
using namespace std;                                            
                                                                
int main(void) {                                                
  int n;                                                        
  cin >> n;                                                     
  vector<int> S(n);                                             
  for (int i=0; i<n; i++) {                                     
    cin >> S[i];                                                
  }                                                             
  sort(S.begin(), S.end());                                     
                                                                
  int q;                                                        
  cin >> q;                                                     
  vector<int> T(q);                                             
  for (int i=0; i<q; i++) {                                     
    cin >> T[i];                                                
  }                                                             
                                                                
  int ans = 0;                                                  
  for (int i=0; i<q; i++) {                                     
    if (binary_search(S.begin(), S.end(), T[i])) {              
      ans++;                                                    
    }                                                           
  }                                                             
  cout << ans << endl;                                          
}                                                               
                                                                
                               

Measured memory_bytes: 3104
#include<iostream>
using namespace std;
int main() {
  int X;
  cin >> X;
  if(X < 600)cout << 8 << endl;
  else if(X < 800)cout << 7 << endl;
  else if(X < 1000)cout << 6 << endl;
  else if(X < 1200)cout << 5 << endl;
  else if(X < 1400)cout << 4 << endl;
  else if(X < 1600)cout << 3 << endl;
  else if(X < 1800)cout << 2 << endl;
  else cout << 1 << endl;
}

Measured memory_bytes: 3640
#!/usr/bin/env python3
import sys


def solve(n: int, p: "List[int]"):
    counter = 0
    for i in range(1, n-1):
        if (p[i-1] - p[i]) * (p[i] - p[i+1]) > 0:
            counter += 1
    print(counter)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    p = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, p)

if __name__ == '__main__':
    main()


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

int main(void) {
 int a, b;
 cin >> a >> b;
 if (0 < a && a <= 9 && 0 < b && b <= 9) {
     cout << a * b << endl;
 }else {
     cout << -1 << endl;
 }
 return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <queue>
#include <cstring>
#include <vector>
#include <iostream>
using namespace std;

void NO() { cout << "-1\n"; exit(0); }

int n, col[200];
vector<int> adj[200];
bool check(int i, int c, int d) {
    col[i] = c;
    for (int j : adj[i]) {
        if (col[j] == c) return false;
        else if (col[j] == 0) {
            if (!check(j, d, c)) return false;
        }
    }
    return true;
}

int len(int i) {
    int dist[n] = {};
    fill(dist, dist+n, 1<<30);
    queue<int> q;
    q.push(i);
    dist[i] = 1;
    while (!q.empty()) {
        int j = q.front();
        q.pop();
        for (int k : adj[j]) {
            if (dist[k] > dist[j]+1) {
                dist[k] = dist[j]+1;
                q.push(k);
            }
        }
    }
    return *max_element(dist, dist+n);
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        if (s[i] == '1') NO();
        for (int j = 0; j < n; j++) if (s[j] == '1') adj[i].push_back(j);
    }
    if (!check(0, 1, 2)) NO();
    int ans = 0;
    for (int i = 0; i < n; i++) {
        // memset(visited, 0, sizeof visited);
        ans = max(ans, len(i));
    }
    cout << ans << endl;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long K, std::vector<long long> A)
{
    long long shift = 0;
    long long sum_old = 1;
    long long sum_new = 1;

    for (long long i = K + 1; i <= N + 1; i++)
    {

        if (shift == 0)
        {
            for (long long j = 0; j < K; j++)
            {
                sum_new *= A[j];
            }
        }

        if (shift != 0)
        {
            sum_new /= A[shift - 1];
            sum_new *= A[shift + K - 1];
        }

        //cout << sum_new << endl;
        //cout << sum_old << endl;

        if (shift == 0)
        {
            sum_old = sum_new;
            shift++;
            continue;
        }

        //if (sum_new > sum_old)
        if (A[shift - 1] < A[shift + K - 1])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;

        sum_old = sum_new;
        shift++;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 4796
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9 + 7;
immutable long INF = 1L << 59;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1].to!long;
    auto A = readln.split.map!(to!long).array ~ K;
    A.sort();
    auto B = N.iota.map!(i => abs(A[i] - A[i+1])).reduce!gcd;
    B.writeln;
}


Measured memory_bytes: 6580
from collections import deque

H,W=map(int,input().split())
M=[input() for _ in range(H)]
dist=0
visited=[[False]*W for _ in range(H)]
q=deque([(0,0,0)])
visited[0][0]=True
while q:
    x,y,dist=q.popleft()
    for i in range(4):
        nx,ny=x+[-1,0,1,0][i],y+[0,-1,0,1][i]
        if 0<=nx and nx<W and 0<=ny and ny<H and M[ny][nx]=='.' and not visited[ny][nx]:
            q.append((nx,ny,dist+1))
            visited[ny][nx]=True
    if x==W-1 and y==H-1:
        c=0
        for m in M:
            c+=m.count('.')
        print(c-dist-1)
        exit()
print(-1)



Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<vector<int>> ai(n);
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    ai.at(i)={a,i};
  }
  sort(ai.begin(),ai.end());
  vector<int> c(n);
  for(int i=0;i<n;i++)
    c.at(ai.at(i).at(1))=i;
  int s=0;
  for(int i=0;i<n;i++)
    s+=(c.at(i)%2!=i%2?1:0);
  cout<<s/2<<endl;
}

Measured memory_bytes: 9072
//#pragma comment(linker, "/STACK:134217728")

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VInt;

#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair

VInt inv(VInt& v)
{
	VInt r(SIZE(v));
	int i;
	FOR(i, 0, SIZE(v))
		r[v[i]] = i;

	return r;
}

VInt mul(VInt& v, VInt& w)
{
	VInt r(SIZE(v));
	int i;
	FOR(i, 0, SIZE(v))
		r[i] = w[v[i]];

	return r;
}

void gen()
{
	VInt v(1, 1);
	VInt w(1, 2);

	int i, j, k;
	FOR(i, 0, 32)
	{
		FOR(j, 0, SIZE(v)) printf("%2d", v[j]);
		FOR(j, 0, SIZE(v)) if (v[j] != -v[SIZE(v) - 1 - j]) break;
		printf(": ");
		FOR(k, j, SIZE(v) - j) printf("%d|", v[k]);
		printf(" %d-%d\n", SIZE(v), j);

		VInt v2 = v;
		reverse(ALL(v2));
		FOR(j, 0, SIZE(v2)) v2[j] = -v2[j];
		FOR(j, 0, SIZE(w))
		{
			if (!v2.empty() && v2.back() == -w[j])
				v2.pop_back();
			else
				v2.push_back(w[j]);
		}

		v = w;
		w = v2;
	}
}

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

	VInt p(n), q(n);
	int i;
	FOR(i, 0, n) scanf("%d", &p[i]);
	FOR(i, 0, n) scanf("%d", &q[i]);
	FOR(i, 0, n) --p[i];
	FOR(i, 0, n) --q[i];

	VInt pp = inv(p);
	VInt qq = inv(q);

	VInt r = p;
	if(k > 1)
	{
		VInt common = mul(qq, p);
		common = mul(common, q);
		common = mul(common, pp);

		k -= 2;
		int cnt = k / 6;
		int rem = k % 6;
		int off[] = { 0, 0, 1, 2, 2, 3 };
		switch(rem)
		{
		case 0:
			r = q;
			break;
		case 1:
			r = mul(pp, q);
			break;
		case 2:
			r = pp;
			break;
		case 3:
			r = qq;
			break;
		case 4:
			r = mul(p, qq);
			break;
		case 5:
			r = p;
			break;
		}

		VInt t(n);
		FOR(i, 0, n) t[i] = i;
		for (i = 1; i <= cnt; i <<= 1)
		{
			if ((cnt & i) != 0) t = mul(t, common);
			common = mul(common, common);
		}

		VInt z[] = {qq, p, q, pp};
		FOR(i, 0, off[rem])	t = mul(t, z[i]);

		r = mul(t, r);
		t = inv(t);
		r = mul(r, t);
	}

	FOR(i, 0, n) printf("%d ", r[i] + 1);
	return 0;
};


Measured memory_bytes: 5480
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

int main(void) {
  char a[111];
  scanf("%s", a);


  string s = a;

  int ret = 1e9;
  for (char c: s) {
    string t = s;
    while (t.size() > 1) {
      if (t == string(t.size(), c)) break;
      string nt;
      REP(i, (int)t.size() - 1) {
        if (t[i] == c || t[i+1] == c) nt.push_back(c);
        else nt.push_back(t[i]);
      }
      t = nt;
    }
    ret = min(ret, (int)s.size() - (int)t.size());
  }

  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,m;
  while(cin >>n>>m,n||m){
    int f[10000][10]={0};
    int ans = 0;
    for(int i=0; i<n; i++) for(int j=0; j<m; j++) cin >>f[j][i];
    for(int i=0; i<(1<<n); i++){
      int x = 0;
      for(int j=0; j<n; j++) if(i&(1<<j)) for(int k=0; k<m; k++) f[k][j] = 1-f[k][j];
      for(int j=0; j<m; j++){
	int l=0;
	for(int k=0; k<n; k++) l+=f[j][k];
	if(l<=n/2) l = n-l;
	x+=l;
      }
      if(ans<x) ans = x;
      for(int j=0; j<n; j++) if(i&(1<<j)) for(int k=0; k<m; k++) f[k][j] = 1-f[k][j];
    }
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1556
#include <iostream>
#include <vector>

using namespace std;

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

	vector<int> v(n, 0);
	int a, b;
	bool ispossible{ false };
	for(auto i = 0; i < m; ++i) {
		cin >> a >> b;
		if(a == 1) {
			v[b - 1] += 1;
			if(v[b - 1] == 3) {
				ispossible = true;
				break;
			}
		}
		if(b == n) {
			v[a - 1] += 2;
			if(v[a - 1] == 3) {
				ispossible = true;
				break;
			}
		}
	}

	if(ispossible) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll a,b,ans=1;
int main(void){
    scanf("%lld%lld",&a,&b);
    if(abs(a-b)>1){
        printf("0\n");
        return 0;
    }
    for(ll i=1;i<=a;i++)ans=ans*i%M;
    for(ll i=1;i<=b;i++)ans=ans*i%M;
    if(a==b)ans=ans*2%M;
    printf("%lld\n",ans);
}


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

int main()
{
	int64_t n, k, mod = 1000000007;
	cin >> n >> k;

	vector<vector<int64_t>> nCr(5000, vector<int64_t>(5000, 0));

	for (int64_t i = 0; i < 5000; i++)
	{
		nCr[i][0] = 1;
	}
	for (int64_t i = 1; i < 5000; i++)
	{
		for (int64_t j = 1; j < 5000; j++)
		{
			nCr[i][j] = (nCr[i - 1][j - 1] + nCr[i - 1][j]) % mod;
		}
	}

	for (int64_t x = 1; x <= k; x++)
	{
		if (n - k < x - 1)
		{
			cout << 0 << endl;
			continue;
		}
		cout << (nCr[k - 1][x - 1] * nCr[n - k + 1][n - k - (x - 1)] % mod) << endl;
	}

	return 0;
}

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        bool ok = true;
        for(int j = i - 1; j >= 0; j--) {
            if (A[j] > A[i]) ok = false;
        }
        if (ok) cnt++;
    }
    cout << cnt << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 256
// Author: Wenxing Mei
//   File: d.cpp
//   Date: 2019-03-11 23:19
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define per(i, b, a) for (int i = (int)b; i >= (int)a; --i)
#define repv(ele, cont) for (auto &ele : cont)
#define all(x) x.begin(), x.end()
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<ll> vll;
// END OF TEMPLATE
ll par[100005], cnt[100005], conv[100005];
ll curconv = 0;
int find(int x) { return par[x] == x ? par[x] : par[x] = find(par[x]); }
ll g(ll a) { return a * (a - 1) / 2; }
int merge(int a, int b) {
    int pa = find(a), pb = find(b);
    if (pa != pb) {
        ll sa = cnt[pa];
        ll sb = cnt[pb];
        // pa, pb -> pa+pb
        cnt[pb] += sa;
        par[pa] = pb;
        curconv = curconv - g(sa) - g(sb) + g(sa + sb);
    }
}

int main() {
#ifndef LOCAL
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#endif
    int n, m;
    cin >> n >> m;
    rep(i, 0, n) par[i] = i, cnt[i] = 1;
    vi a(m), b(m);
    rep(i, 0, m) {
        cin >> a[i] >> b[i];
        --a[i], --b[i];
    }
    ll total = g(n);
    vll re{total};
    per(i, m - 1, 1) {
        merge(a[i], b[i]);
        re.eb(total - curconv);
    }
    per(i, m - 1, 0) cout << re[i] << endl;
    return 0;
}


Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans *= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int main() {
    string S;
    cin>>S;
    int a=S.size();
    cout<<S[0]<<a-2<<S[a-1]<<endl;
}

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

#define ABS(N) ((N<0)?(-N):(N))

int main(int argc, char const *argv[])
{
  string S,T;
  cin >> S >> T;
  S = S + S;

  cout << ((S.find(T) == string::npos) ? "No" : "Yes" )<< endl;

  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset> 
using namespace std;
typedef long long ll;
int main(void)
{
	ll a,v,b,w,t;
	cin>>a>>v>>b>>w>>t; 
	ll d=abs(a-b);
	if(t*(v-w)>=d) cout<<"YES";
	else cout<<"NO";
}

Measured memory_bytes: 3624
#include <bits/stdc++.h> 
#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif


using namespace std;
#define M 1000000001
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repb(i,a,b) for(int i=a;i>=b;--i)
#define repv(arr)  for(auto it=arr[i].begin();it!=arr[i].end();++it)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define vc vector<char>
#define sz(a) (int)a.size()
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define ssortB(arr)   stable_sort(arr.begin(),arr.end(),greater<int>());
#define pii pair<int,int>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define fi first
#define se second
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define mp make_pair
#define endl "\n" 
#define LCM(a,b) boost::math::lcm(a,b)
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    if(n>=400&&n<=599){
        cout<<8<<endl;
        return 0;
    }
    if(n>=600&&n<=799){
        cout<<7<<endl;
        return 0;
    }
    if(n>=800&&n<=999){
        cout<<6<<endl;
        return 0;
    }
    if(n>=1000&&n<=1199){
        cout<<5<<endl;
        return 0;
    }
    if(n>=1200&&n<=1399){
        cout<<4<<endl;
        return 0;
    }
    if(n>=1400&&n<=1599){
        cout<<3<<endl;
        return 0;
    }
    if(n>=1600&&n<=1799){
        cout<<2<<endl;
        return 0;
    }
    if(n>=1800&&n<=1999){
        cout<<1<<endl;
        return 0;
    }
}
    


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

int main() {
  int n;
  int anagramCount=0;
  long long ans=0;
  cin >> n;
  vector<string> s(n);
  for(int i=0; i<n; i++) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }
  sort(s.begin(), s.end());
  // 最初から最後の要素まで見て、重複数を都度数えていく
  for(int i=0; i<s.size()-1; i++){
    if(s[i]==s[i+1]) {
      anagramCount++;
      // 最後のときだけ計算
      if(i==s.size()-2) {
        ans+=(long long)(anagramCount+1)*anagramCount/2;
      }
    }
    else {
      // カウントが回っていれば、組み合わせ計算をする
      if(anagramCount > 0) {
        ans+=(long long)(anagramCount+1)*anagramCount/2;
      }
      anagramCount = 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 7296
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main() {
  ll N;
  cin>>N;
  vector<ll> a(N-1),b(N-1),c(N-1);
  vector<vector<ll>> G(N,vector<ll>()),GG(N,vector<ll>());//GGは頂点についている辺のなんば
  FOR(i,N-1){
    cin>>a[i]>>b[i];
    a[i]--;
    b[i]--;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
    GG[a[i]].push_back(i);
    GG[b[i]].push_back(i);
  }
  ll maxc=0;
  function<void(ll,ll,ll)> f=[&](ll i,ll pai,ll pac)->void{//今見る頂点、親の頂点、親との頂点の色
    ll cc=1;
    for(auto v:GG[i]){//頂点についている辺を見る
      if(cc==pac)cc++;
      if(a[v]==i){
        if(b[v]==pai)continue;
        f(b[v],i,cc);
        c[v]=cc;
        if(cc>maxc)maxc=cc;
      }else{
        if(a[v]==pai)continue;
        f(a[v],i,cc);
        c[v]=cc;
        if(cc>maxc)maxc=cc;
      }
      cc++;      
    }
  };
  f(0,-1,-1);
  cout<<maxc<<endl;
  for(auto aaa:c){
    cout<<aaa<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 15360
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int flag = 0;
  cin >> n;
  for (int i = 0; i < n; i++){
    string s;
    cin >> s;
    if (s == "Y"){
      flag = 1;
    }
  }
  if (flag == 1) cout << "Four" << endl;
  else cout << "Three" << endl;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()


int main() {
	int n, x, L;
	cin >> n >> x;
	int cnt = 1;
	int d = 0;
	FOR(i, 1, n) {
		cin >> L;
		d += L;
		if (d > x) {
			break;
		}
		else {
			cnt++;
		}
	}
	pv(cnt)
	return(0);
}

Measured memory_bytes: 256