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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int N, L;
	cin >> N >> L;
	string str;
	multiset<string> smallest_strings;
	for (int i = 0; i < N; ++i) {
		cin >> str;
		smallest_strings.insert(str);
	}
	string smallest;
	for (string s: smallest_strings) {
		smallest += s;
	}
	cout << smallest << '\n';
	return 0;
}

Measured memory_bytes: 256
function main(input) {
    const args = input.split(/\n|\s/)
    var count = {'1':0,'2':0,'3':0,'4':0}
    
    for(var a of args){
      count[a]++
    }
  
  for(var b in count){
  if(count[b]>=3) return console.log('NO')
  }
  
  console.log('YES')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
N = 3
#f = [input().split() for _ in range(3)]
f = input().split()
f += input().split()
f += input().split()
dd = [[-1, 0], [0, -1], [1, 0], [0, 1]]

Q = [[f, f.index("0"), 0]]
#T = {f: True}
T = set(f)

while len(Q) > 0:
    board = Q.pop(0)
    if board[0] == ["1", "2", "3", "4", "5", "6", "7", "8", "0"]:
        break
    x, y = int(board[1]/N), board[1]%N
    for dx, dy in dd:
        tx, ty = x+dx, y+dy
        if tx<0 or ty<0 or tx>=N or ty>=N:
            continue
        new = board[:]

        n1, n2 = board[1], tx*N+ty
        new[1] = n2
        # swap
        if n1 > n2:
            n1, n2 = n2, n1
        # swaped string
        new[0] = new[0][0:n1] + list(new[0][n2]) + new[0][n1+1:n2] + list(new[0][n1]) + new[0][n2+1:]
        hashstr = "".join(new[0])
        if hashstr not in T:
            #T[new[0]] = True
            T.add(hashstr)
            new[2] += 1
            Q.append(new)

print(board[2])



Measured memory_bytes: 32416
#include <algorithm>
#include <cstdio>
#include <cstring>
const int N = 8050;
int xx[N], yy[N], nx, ny;
int f[N];
bool able(int *aa, int a, int n) {
  a = std::abs(a);
  int sum = 0;
  for (int i = 0; i < n; ++i)
    sum += aa[i];
  if (sum < a) return false;
  if ((sum ^ a) & 1) return false;
  a = (sum + a) >> 1;
  for (int j = 0; j <= a; ++j)
    f[j] = 0;
  f[0] = true;
  for (int i = 0; i < n; ++i)
    for (int j = a; j >= aa[i]; --j)
      f[j] |= f[j - aa[i]];
  return f[a];
}
char s[N];
int main() {
  int x, y;
  scanf("%s%d%d", s, &x, &y);
  int n = (int)strlen(s);
  int p = 1;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'F') {
      if (p) ++xx[nx];
      else ++yy[ny];
    } else {
      if (p) yy[++ny] = 0;
      else xx[++nx] = 0;
      p ^= 1;
    }
  }
  puts(able(xx + 1, x - xx[0], nx) && able(yy + 1, y, ny) ?  "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
def main():
	h, w = map(int, input().split())
	s = [list(input().split()) for _ in range(h)]

	for i in range(h):
		for j in range(w):
			if s[i][j] == "snuke":
				print(chr(ord('A')+j)+str(i+1))
				return

main()

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}



int main(){
	int l, r, d;
	cin >> l >> r >> d;
	int ans = 0;
	rep2(i, l, r + 1)
	{
		if(i % d == 0)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {
    int n, k, l[55];
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    sort(l, l + n);
    cout << accumulate(l + n - k, l + n, 0) << endl;
    return 0;
}


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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define all(a) (a.begin(), a.end())

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

int cnt[10];

ll pow(ll a, ll n) {
	ll res = 1;
	for (int i = 1; i <= n; ++i)
		res *= a;

	return res;
}

void solve() {
	string s;
	cin >> s;
	ll k;
	cin >> k;
	ll n = (ll)s.length();
	for (ll i = 0; i < min(n,k); ++i) {
		if (s[i] != '1') {
			cout << s[i] << '\n';
			return;
		}
	}

	cout << 1 << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

void solve(){

  int n;
  cin>>n;
  vector<ll> k(n),l(n),r(n);
  rep(i,n)cin>>k[i]>>l[i]>>r[i];
  
  map<ll,vector<ll>> red,blue;
  ll rsum=0,bsum=0;
  rep(i,n){
    if(l[i]>=r[i]){
      red[k[i]].emplace_back(l[i]-r[i]);
      rsum += r[i];
    }
    else{
      blue[n-k[i]].emplace_back(r[i]-l[i]);
      bsum += l[i];
    }
  }
  priority_queue<ll,vector<ll>,greater<>> rque,bque;
  for(int ki=1;ki<=n;++ki){
    for(auto v:red[ki])rque.emplace(v);
    while(rque.size()>ki)rque.pop();
    for(auto v:blue[ki])bque.emplace(v);
    while(bque.size()>ki)bque.pop();
  }
  ll ans = rsum+bsum;
  while(!rque.empty()){
    ans += rque.top();
    rque.pop();
  }
  while(!bque.empty()){
    ans += bque.top();
    bque.pop();
  }
  cout<<(ans)<<endl;


}

signed main(){

  int t;
  cin>>t;
  while(t--)solve();

}

Measured memory_bytes: 45440
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll n; cin>>n;
	ll min,ans=0;
	REP(i,n){
		ll tmp;
		cin>>tmp;
		if(i==0){
			min=tmp;
			ans++;
			continue;
		}
		if(tmp<min){
			min=tmp;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
class Bit:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)

    def ope(self, x, y):
        return max(x, y)

    def update(self, i, v):
        j = i
        while j <= self.n:
            self.data[j] = self.ope(self.data[j], v)
            j += j & -j

    def query(self, i):
        ret = 0
        j = i
        while 0 < j:
            ret = self.ope(self.data[j], ret)
            j &= (j - 1)
        return ret

N,T = map(int, input().split())
A = [int(x) for x in input().split()]

bit = Bit(N)
for i, a in enumerate(reversed(A)):
    bit.update(i + 1, a)

mv, mc = 0, 0
for i in range(N):
    v = bit.query(N - i) - A[i]
    if v > mv:
        mv = v
        mc = 1
    elif v == mv:
        mc += 1
print(mc)

Measured memory_bytes: 15060
#include <bits/stdc++.h>
            #include <ext/pb_ds/assoc_container.hpp>
            #include <ext/pb_ds/tree_policy.hpp>
            using namespace std;
            using namespace __gnu_pbds;
            #define rep(i,a,b) for(ll i =a; i<b;++i)
            #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            #define endl "\n"
            #define pb push_back
            #define F first
            #define S second
            #define print(a)       for(auto x : a) cout << x << " "; cout << endl
            #define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
            #define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl
            #define mk(x,y)  make_pair(x,y)
            typedef long long int ll;
            const ll N =  1e6+ 5 ;
            const ll mod = 998244353;
            ll   n  ,a[N] , q , x,y, cnt[N];
    ll pow_mod_m(ll a , ll n)
    {
        if(!n)
            return 1;
        ll pt =  pow_mod_m(a,n/2);
        pt *= pt , pt %= mod;
        if(n&1)
            pt *= a  ,pt %= mod;
        return pt;
    }


    int main()
    {
         IOS;
         int ts =1;
      ///  cin >> ts;
         while(ts--)
         {
            cin >> n;
            ///map <ll,vector <ll>> mp;
            rep(i,0,n) {cin >> a[i];
                cnt[a[i]]++;
            }
            cin >> q;
            ll ans = accumulate(a ,a+n , 0ll);
            while(q--)
            {
                cin >>  x >> y;

                if(cnt[x]){
                ans -= cnt[x]*x;
                ans += cnt[x]*y;
                cnt[y] += cnt[x];
                cnt[x]  = 0 ;
                }
               /// cout << cnt[x] << " " << cnt[y] << endl;
                cout << ans << endl;
            }
         }
    }


Measured memory_bytes: 5216
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long LL;
const int LEN = 1e6 + 10;
vector<LL> v, v1, v2;
LL k, n, nums[LEN], cnt = 0ll;

inline LL readLL() {
    LL tmp = 0, fh = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') {
            fh = -1;
        }
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        tmp = tmp * 10 + c - 48;
        c = getchar();
    }
    return tmp * fh;
}

bool check(LL x) {
    LL res = 0ll;
    if (x > 0) {
        vector<LL>::iterator it_v1 = v1.begin();
        for (; it_v1 != v1.end(); it_v1++) {
            res += lower_bound(v.begin(), v.end(), (x + *it_v1 - 1) / *it_v1) - v.begin();
            v.push_back(*it_v1);
        }
        v.clear();
        vector<LL>::iterator it_v2 = v2.begin();
        for (; it_v2 != v2.end(); it_v2++) {
            res += lower_bound(v.begin(), v.end(), (x + *it_v2 - 1) / *it_v2) - v.begin();
            v.push_back(*it_v2);
        }
        v.clear();
        res += cnt * (cnt - 1) / 2;
        res += 1ll * v1.size() * v2.size();
        res += cnt * (v1.size() + v2.size());
    } else if (x < 0) {
        x = -x;
        vector<LL>::iterator it_v1 = v1.begin();
        for (; it_v1 != v1.end(); it_v1++) {
            res += v2.size() - (upper_bound(v2.begin(), v2.end(), x / *it_v1) - v2.begin());
        }
    } else {
        res += 1ll * v1.size() * v2.size();
    }
    return res < k;
}

int main() {
    n = readLL();
    k = readLL();
    for (int i = 1; i <= n; i++) {
        nums[i] = readLL();
        if (nums[i] > 0) {
            v1.push_back(nums[i]);
        } else if (nums[i] < 0) {
            v2.push_back(-nums[i]);
        } else {
            cnt++;
        }
    }
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    LL l = -1e18, r = 1e18, mid, ans;
    while (l <= r) {
        mid = (l + r) >> 1;
        if (check(mid)) {
            l = mid + 1;
            ans = mid;
        } else {
            r = mid - 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  std::string s;
  std::cin >> s;

  std::string t,u;
  int n = s.size();
  while(n > 1){
    s.pop_back();
    n = s.size();
    t = s.substr(n/2,(n+1)/2);
    u = s.substr(0,n/2);
    if(t == u)
      break;
  }

  int ans = t.size() + u.size();
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
s = input()
x, y = map(int, input().split())

mv = [len(e) for e in s.split("T")]
mv_x = mv[2::2]
mv_y = mv[1::2]


def solve_dp(li, start, end):
    l = len(li)
    mx = sum(li)

    if l == 0:
        return start == end

    left = start - mx
    right = start + mx

    if end > right or end < left:
        return 0

    dp = [[0] * (2 * mx + 1) for _ in range(l + 1)]
    dp[0][start] = 1
    for i, e in enumerate(li, 1):
        for j in range(left, right + 1):
            if left <= j - e <= right:
                dp[i][j] |= dp[i-1][j-e]
            if left <= j + e <= right:
                dp[i][j] |= dp[i-1][j+e]

    return dp[l][end]


bl_x = solve_dp(mv_x, mv[0], x)
bl_y = solve_dp(mv_y, 0, y)

if bl_x and bl_y:
    ans = "Yes"
else:
    ans = "No"

print(ans)


Measured memory_bytes: 168796
// g++ -std=c++14
#include<bits/stdc++.h>

typedef long long ll;
typedef long double lld;
using namespace std;

#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define endl "\n"
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(c) c.begin(),c.end()
#define LET(x, a)  __typeof(a) x(a)
#define foreach(it, v) for(LET(it, v.begin()); it != v.end(); it++)

#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

int n, k, c;
string s;
vector<int> prefix, suffix;

int main(){
  _
  cin >> n >> k >> c;
  cin >> s;
  prefix.resize(n, 0);
  suffix.resize(n, 0);
  int prev = -1;
  for(int i = 0; i < n; i++){
  	if(i > 0){
  		prefix[i] = prefix[i - 1];
  	}
  	if(s[i] == 'x'){
  		continue;
  	}
  	if(prev == -1 or i - prev > c){
  		prefix[i]++;
  		prev = i;
  	}
  }
  prev = -1;
  for(int i = n - 1; i >= 0; i--){
  	if(i != n - 1){
  		suffix[i] = suffix[i + 1];
  	}
  	if(s[i] == 'x'){
  		continue;
  	}
  	if(prev == -1 or prev - i > c){
  		suffix[i]++;
  		prev = i;
  	}
  }
  // tr(prefix); tr(suffix);
  for(int i = 0; i < n; i++){
  	if(s[i] == 'x'){
  		continue;
  	}
  	int poss = 0;
  	if(i > 0){
  		poss += prefix[i - 1];
  	}
  	if(i != n - 1){
  		poss += suffix[i + 1];
  	}
  	if(poss < k){
  		cout << i + 1 << "\n";
  	}
  }
  return 0;
}


Measured memory_bytes: 3348
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    int ans1 = A * 100, ans2 = 0;
    rep(i, 31) {
        rep(j, 31) {
            int water = 100 * A * i + 100 * B * j;
            if(water > F) break;
            rep(k, 3001) {
                int sugar = 0;
                rep(l, 3001) {
                    sugar = C * k + D * l;
                    if(water + sugar > F) break;
                    if(water*E < 100*sugar) continue;
                    if (ans2*(water+sugar) < sugar*(ans1 + ans2)) {
                        ans1 = water;
                        ans2 = sugar;
                    }
                }
            }
        }
    }
    cout << (ans1+ans2) << " " << ans2 << endl;

    return 0;
}
// 100:E = water:sugar
// water*E >= 100*sugar
// water*E/100 >= sugar

Measured memory_bytes: 256
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashMap;

fn main() {
    input!(mut n: i64);

    if n == 0 {
        println!("0");
        return;
    }

    let mut s = String::new();
    while n != 0 {
        if n % (-2) == 0 {
            s.push('0');
        } else {
            s.push('1');
            n -= 1;
        }
        n /= (-2);
    }
    let s = s.chars().rev().collect::<String>();
    println!("{}", s);
}


Measured memory_bytes: 4352
#include<stdio.h>
	int n, a, b,d[100100];
	char c[100100];
int main(){
	int i;
	scanf("%d %d %d",&n,&a,&b);
	scanf("%s",c);
	a=a+b;
	for(i=0;c[i]!='\0';i++){
		if(c[i]=='a'&&a>0){
			a--;
			d[i]=1;
		} 
		else if(c[i]=='b'&&b>0&&a>0){
			b--;
			a--;
			d[i]=1;
		} 
	}
	for(i=0;c[i]!='\0';i++){
		if(d[i]==1) printf("Yes\n");
		else printf("No\n");
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir [] = {
	{ 1,0 },{ 0,1 }
};



signed main() {
	int w, h, n;
	scanf("%d %d %d", &w, &h, &n);

	int l = 0, r = w, d = 0, u = h;

	REP(i, n) {
		int a, b, x;
		scnaf("%d %d %d", &a, &b, &x);

		switch (x)
		{
		case 1:
			l = max(l, a);
			break;
		case 2:
			r = min(r, a);
			break;
		case 3:
			d = max(d, b);
			break;
		case 4:
			u = min(u, b);
			break;
		}
	}
	l = min(l,r);
	d = min(d, u);
	printf("%d\n", (u-d)*(r-l));
	return 0;
}

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

int main(){
    int l,r,d;
    cin>>l>>r>>d;
    int c=0;
    rep(i,l,r+1){
        if(i%d==0) c++;
    }
    cout<<c<<endl;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a==b){
        if(b==c){
            cout << 1;
        }else{
            cout << 2;
        }
    }else{
        if(a==c || b==c){
            cout << 2;
        }else{
            cout << 3;
        }
    }
    return 0;
}

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

int main(){

    int n;cin>>n;
    map<string,int> m;
    for(int i=0;i<n;i++){
    	string s;cin>>s;
    	m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<"\n";
    cout<<"WA x "<<m["WA"]<<"\n";
    cout<<"TLE x "<<m["TLE"]<<"\n";
    cout<<"RE x "<<m["RE"]<<"\n";

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#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 rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    vector<int> a(n);
    int res=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]<i+1){
            if(a[a[i]-1]==i+1)res++;
        }
    }
    cout<<res<<endl;
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 1001001001001001;

vector<int> E[100005];
map<ll, int> mp;

void dfs(int f, int t, int num) {
    ll key = (ll)f*100000+t;
    ll key2 = (ll)t*100000+f;
    mp[key] = num;
    mp[key2] = num;
    int cnt = 1;
    for (auto e : E[t]) {
        if (e != f) {
            if (num != cnt) dfs(t,e,cnt);
            else {
                cnt++;
                dfs(t,e,cnt);
            }
            cnt++;
        }
    }
}

int main() {
    int n; cin >> n;
    int a,b;
    pair<int,int> edge[n-1];
    rep(i,n-1) {
        cin >> a >> b;
        a--; b--;
        E[a].push_back(b);
        E[b].push_back(a);
        edge[i] = {a,b};
    }
    dfs(-1,0,0);
    int k = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++) {
        k = max(k, itr->second);
    }
    cout << k << endl;
    rep(i,n-1) {
        ll key = (ll)edge[i].first*100000+edge[i].second;
        printf("%d\n",mp[key]);
    }
    return 0;
}


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

using namespace std;

const int N = 8100;
const int LIM = N<<1; 
bool dp[2][2][LIM];

void solve() {
    string s; cin >> s;
    int ta[2];
    cin >> ta[0] >> ta[1];

    s += "T";
    vector<int> a[2];
    int dir = 0;
    int len = 0;
    int n = s.size();
    int i = 0;
    while (s[i]!='T') {
        len++; i++;
    }
    dp[0][0][N+len] = true;
    dp[1][0][N] = true;
    len=0;
    for (; i < n; i++) {
        if (s[i] != 'T') len++;
        else {
            if (len) a[dir].emplace_back(len);
            dir ^= 1;
            len = 0;
        }
    }

    bool res = true;
    for (int i = 0; i < 2; i++) {
        int n = a[i].size();
        int crt = 0;
        for (int j = 0; j < n; j++) {
            int nxt = crt^1;
            for (int k = 0; k < LIM; k++) {
                dp[i][nxt][k] = false;
            }
            int ds = a[i][j];
            for (int k = 0; k < LIM; k++) {
                if (k+ds < LIM) dp[i][nxt][k+ds] |= dp[i][crt][k];
                if (k-ds >= 0)  dp[i][nxt][k-ds] |= dp[i][crt][k];
            }
            crt ^= 1;
        }
        res &= dp[i][crt][N+ta[i]];
    }
    cout << (res?"Yes":"No");
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 512
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		
		while(scan.hasNext()){
			String cipLine = scan.nextLine();
			for(int i = 0; i < 26; i++){
				StringBuffer sb = new StringBuffer();
				for(int j = 0; j < cipLine.length(); j++){
					char cz = cipLine.charAt(j);
					if(cz >= 'a' && cz <= 'z'){
						sb.append((char)('a' + (cz - 'a' + i) % 26));
					} else{
						sb.append(cz);
					}
				}
				String now = sb.toString();
				boolean flag = false;
				for(int j = 0; j < now.length() - 2; j++){

					char cs = now.charAt(j);
					char cs1 = now.charAt(j + 1);
					char cs2 = now.charAt(j + 2);
					if(cs == 't' && cs1 == 'h' && cs2 == 'e'){
						flag = true;
						break;
					}

				}
				for(int j = 0;j < now.length() - 3; j++){

					char cs = now.charAt(j);
					char cs1 = now.charAt(j + 1);
					char cs2 = now.charAt(j + 2);
					char cs3 = now.charAt(j + 3);
					if(cs == 't' && cs1 == 'h'){
						if(cs2 == 'i' && cs3 == 's'){
							flag = true;
							break;
						}
						if(cs2 == 'a' && cs3 == 't'){
							flag = true;
							break;
						}
					}

				}
				if(flag){
					System.out.printf("%s\n", now);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 26204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1000000000;

ll D, G;
vector<ll> P, C;

void abc104c() {
  ll res = INF;
  for (int bit = 0; bit < (1 << D); bit++) {

    ll score = 0, cnt = 0;
    for (int i = 0; i < D; i++) {
      if (bit & (1 << i)) {
        ll ns = 100 * (i + 1);
        score += (ns * P[i] + C[i]);
        cnt += P[i];
      }
    }
    if (score >= G) {
      res = min(res, cnt);
    }
    else {
      for (int i = D - 1; i >= 0; i--) {
        ll ns = 100 * (i + 1);
        if (!(bit & (1 << i)) && ns * (P[i] - 1) >= G - score) {
          cnt += (G - score + ns - 1) / ns;
          res = min(res, cnt);
          break;
        }
      }
    }
  }
  cout << res << "\n";
  return;
}

int main() {
  cin >> D >> G;
  P.resize(D);
  C.resize(D);
  for (int i = 0; i < D; i++) {
    cin >> P[i] >> C[i];
  }
  abc104c();
  return 0;
}

Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    K = int(input())
    A = [int(a) for a in input().split()]
    if A[K-1] != 2: print(-1)
    else:
        minK, maxK = 2, 3
        for i in reversed(range(K - 1)):
            mod = A[i]
            lb, hb = (minK - 1) // mod, maxK // mod
            if lb >= hb: 
                print(-1)
                break
            else:
                minK = mod * (lb + 1)
                maxK = mod * (hb + 1) - 1
        else: print(minK, maxK)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 14252
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int main(){
	int n,m;
	cin >> n >> m;
	int ans = 0,tot = 0;
	if(m > 0) ans = 1;
	for(int i = 1; i <= n; i++) {
		int	a;
		cin >> a;
		tot += a;
		if(tot <= m) ans++;
	} 
	cout << ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed;
    cout << setprecision(12);
    double L;
    cin >> L;
    double k = L / (double)3.0;
    double ans = k * k * k;
    cout << ans << endl;
}


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

using namespace std;

int main(){
  int n;
  cin>>n;
  vector<int> dist(6);
  for(int i=0;i<n;i++){
    double data;cin>>data;
    for(int j=0;j<dist.size();j++){
      if((j==dist.size()-1)?1:data<(165+5*j)){
        dist[j]++;break;
      }
    }
  }
  for(int i=0;i<dist.size();i++){
    cout<<i+1<<":";
    for(int j=0;j<dist[i];j++) cout<<'*';
    cout<<endl;
  }
}

Measured memory_bytes: 1232
#include<iostream>
#include<vector>
using namespace std;
typedef long long int ll;
static const ll MOD = 1000000007;

int main(){
	int n, k;
	cin >> n >> k;
	vector<vector<ll> > memo(k + 1, vector<ll>(n + 1, 0));
	for(int i = 0; i <= k; i++){
		for(int j = 0; j <= n; j++){
			if(i == 0 && j == 0) memo[i][j] = 1;
			else if(i == 0) continue;
			else{
				if(j - i < 0) memo[i][j] = memo[i - 1][j];
				else memo[i][j] = memo[i][j - i] + memo[i - 1][j];
				memo[i][j] %= MOD;
			}
		}
	}
	cout << (n - k < 0 ? 0 : memo[k][n - k]) << endl;
	return 0;
}



Measured memory_bytes: 10764
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int N = line.length();
        int count = 0;
        for(int n=1;n<N;n++){
        	if(line.charAt(n)!=line.charAt(n-1)) count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 10836
#include <iostream>
using namespace std;
int main()
{
	int h,w;
	cin>>h>>w;
	char a[h+2][w+2];
	for(int i=0;i<=h+1;i++)
	 for(int j=0;j<=w+1;j++)
	    a[i][j]='.';
	    
	for(int i=1;i<=h;i++)
	 for(int j=1;j<=w;j++)
	  cin>>a[i][j];
	
	for(int i=1;i<=h;i++)
	 for(int j=1;j<=w;j++)
	   {
	   	if(a[i][j]=='#')
	   	{
	   		if(a[i-1][j]!='#'&&a[i+1][j]!='#'&&a[i][j-1]!='#'&&a[i][j+1]!='#')
	   		{
	   			cout<<"No";
	   			return 0;
			   }
		   }
	   }
	cout<<"Yes";
	return 0;
}

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

int main()
{
    int n,k,m ;
    int ans ;
    while(cin>>n>>k>>m)
    {
        ans = (n-k+1)*(n-m+1)*(n>=k)*(n>=m) ;
        cout<<ans<<endl ;
    }

    return 0 ;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

var n int
var s string

func main() {
	fmt.Scan(&n)
	fmt.Scan(&s)

	var c int
	for i := 0; i < n-2; i++ {
		if s[i] == 'A' &&
			s[i+1] == 'B' &&
			s[i+2] == 'C' {
			c++
		}
	}
	fmt.Print(c)
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long long a, long long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long long a, long long b){
	return a / gcd(a,b) * b;
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int n;
string s, t;

int main(){
	cin >> n;

	cin >> s >> t;

	REP(i,n){
		cout << s[i] << t[i];
	}

	cout << endl;

	return 0;
}

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

using namespace std;
static const int N = 100;
static const int INFTY = (1 << 21);

int n, M[N][N];
int d[N];

void bfs(int s)
{
    queue<int> q;
    q.push(s);
    for (int i = 0; i < n; i++)
    {
        d[i] = INFTY;
    }
    d[s] = 0;
    int u;
    
    while (!q.empty())
    {
        u = q.front();
        q.pop();
        for (int v = 0; v < n; v++)
        {
            if (M[u][v] == 0)
            {
                continue;
            }
            if (d[v] != INFTY)
            {
                continue;
            }
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    for (int i = 0; i < n; i++)
    {
        cout << i + 1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
    }
}

int main()
{
    int u, k, v;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            M[i][j] = 0;
        }
    }
    for (int i = 0; i < n; i++)
    {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++)
        {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    bfs(0);
    return 0;
}


Measured memory_bytes: 3128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 0;
        
        for (int a=1; a<=n; a++) {
            for (int b=1; b<=n/a+1; b++) {
                if (a*b < n) {
                    count++;
                }
            }
        }

        System.out.print(count);
    }
}


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

static const int Max = 100000;

long long gcd(long long a, long long b){
    long long tmp;
    while( b != 0){
        tmp = b;
        b = a % b;
        a = tmp;
    }
    return a;
}

int main(){
    int n;
    cin >> n;
    vector<long long> v;
    long long l[Max] = {0}, r[Max] = {0};
    long long t, ans = 0;
    for(int i = 0; i < n; i++){
        cin >> t;
        v.push_back(t);
    }
    sort(v.begin(), v.end());
    for(int i = 1; i < n; i++){
        if(i == 1){
            l[i] = v[i-1];
            r[n-1-i] = v[n-i];
        }
        else{
            l[i] = gcd(l[i-1], v[i-1]);
            r[n-1-i] = gcd(r[n-i], v[n-i]);
        }
    }
    for(int i = 0; i < n; i++){
        if(i == 0) ans = r[i];
        else if(i == n-1){
            if(l[i] > ans) ans = l[i];
        }else{
            if(ans < gcd(l[i], r[i])){
                ans = gcd(l[i], r[i]);
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2936
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int main(){
	long long x;
	cin>>x;
	long long cnt=0;
	cnt+=x/500*1000;
	cnt+=(x%500)/5*5;
	cout<<cnt<<endl;
	return 0;
}

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

int N[2], M[2];
char c[2][100];
vector< vector< int > > edge[2];
bool retable[2][100], vis[100];

bool dfs(int v, int s, int i) {
	if (vis[v]) return v == s ? true : false;
	vis[v] = true;
	for (int u : edge[i][v]) if (dfs(u, s, i)) return true;
	return false;
}

void readGraph(int k) {
	cin >> N[k] >> M[k];
	for (int i=0; i<N[k]; ++i) cin >> c[k][i];
	
	edge[k].assign(N[k], vector< int >());
	for (int i=0; i<M[k]; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		edge[k][a].push_back(b);
	}
	
	memset(retable[k], 0, sizeof(retable[k]));
	for (int v=0; v<N[k]; ++v) {
		memset(vis, 0, sizeof(vis));
		retable[k][v] = dfs(v, v, k);
	}
}

int dp[101][101];
struct State { int u, v, score; };

bool sameAlph(int u, int v) { return c[0][u] == c[1][v]; }

int main() {
	readGraph(0);
	readGraph(1);
		
	for (int u=0; u<N[0]; ++u) for (int v=0; v<N[1]; ++v) {
		if (retable[0][u] && retable[1][v] && c[0][u] == c[1][v]) {
			puts("-1");
			return 0;
		}
	}
	
	memset(dp, -1, sizeof(dp));
	queue< State > que;
	for (int u=0; u<N[0]; ++u) for (int v=0; v<N[1]; ++v) {
		int score = sameAlph(u, v) ? 1 : 0;
		que.push(State{u, v, score});
		dp[u][v] = score;
	}
	
	while (!que.empty()) {
		State s = que.front(); que.pop();		
		if (dp[s.u][s.v] > s.score) continue;
		
		for (int nu : edge[0][s.u]) for (int nv : edge[1][s.v]) {
			int nxt_score = s.score + (sameAlph(nu, nv) ? 1 : 0);
			if (dp[nu][nv] < nxt_score) {
				dp[nu][nv] = nxt_score;
				que.push(State{nu, nv, nxt_score});
			}
		}
		
		if (!sameAlph(s.u, s.v)) {
			for (int nu : edge[0][s.u]) {
				int nv = s.v;
				int nxt_score = s.score + (sameAlph(nu, nv) ? 1 : 0);
				if (dp[nu][nv] < nxt_score) {
					dp[nu][nv] = nxt_score;
					que.push(State{nu, nv, nxt_score});
				}
			}
			
			for (int nv : edge[1][s.v]) {
				int nu = s.u;
				int nxt_score = s.score + (sameAlph(nu, nv) ? 1 : 0);
				if (dp[nu][nv] < nxt_score) {
					dp[nu][nv] = nxt_score;
					que.push(State{nu, nv, nxt_score});
				}
			}
		}
	}
	
	int ans = 0;
	for (int u=0; u<N[0]; ++u) for (int v=0; v<N[1]; ++v) ans = max(ans, dp[u][v]);
	cout << ans << endl;
}


Measured memory_bytes: 3304
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

int n;
const int full=200006;
vector<int>adj[full];
bool vis[full];
int par[full];
int depth[full];
int ans[full];

void dfs(int i)
{
    queue<int>q;
    q.push(1);
    while(q.size()>0)
    {
        int x=q.front();
        vis[x]=1;
        q.pop();
        for(int j=0;j<adj[x].size();j++)
        {
            if(vis[adj[x][j]]==0 && ans[adj[x][j]]==0)
            {
                
                ans[adj[x][j]]=x;
                q.push(adj[x][j]);
            }
            
        }
    }
}


int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int n,m;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].push_back(a);
    }
    dfs(1);
    for(i=2;i<=n;i++)
    {
        if(ans[i]==0)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes\n";
    for(i=2;i<=n;i++)
    {
        cout<<ans[i]<<"\n";
    }
}

Measured memory_bytes: 12980
#include <stdio.h>

int main(void){

	int S;
	int h,m,s;

	scanf("%d", &S);
	h = S/3600;
	m = (S-h*3600)/60;
	s = S-h*3600-m*60;
	printf("%d:%d:%d\n",h,m,s);

	return 0;
}

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

using namespace std;
const int MAXN = 1e5+10;
typedef pair<int, int> P;
int n;
int a[MAXN];
P p[MAXN];

void solve() {
  for (int i=0;i<n;i++) {
    p[i] = P(a[i], i + 1);
  }
  sort(p, p + n);
  for (int i=0;i<n;i++) {
    cout << (i != 0 ? " " : "") << p[i].second;
  }
  cout << endl;
}

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


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend()
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

ll N;
map<ll, ll> counter;
int main(){
   cin >> N;
   REP(i, N){
      ll a; cin >> a;
      counter[a]++;
   }
   ll ans = 0;
   for(auto & e: counter){
      if (e.second >= e.first) ans += e.second - e.first;
      else ans += e.second;
   }
   cout << ans << endl;

}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
inline int read()
{
	int sum=0,p=1;char ch=getchar();
	while(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();
	if(ch=='-')p=-1,ch=getchar();
	while('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();
	return sum*p;
}

const int maxn=2e3+20;

int jc[maxn],jcn[maxn],inv[maxn];
int n;
char str[maxn];

int dp[maxn][maxn];

const int mod=998244353;

inline int C(int n,int m){ return (ll)jc[n]*jcn[m]%mod*jcn[n-m]%mod;}

int main()
{
	scanf("%s",str+1);
	n=strlen(str+1);
	jc[1]=jc[0]=jcn[0]=jcn[1]=inv[1]=1;
	REP(i,2,n)inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod,jc[i]=(ll)i*jc[i-1]%mod,jcn[i]=(ll)inv[i]*jcn[i-1]%mod;
	int sum=0;
	dp[0][0]=1;
	REP(i,1,n)
	{
		sum+=str[i]-'0';
		REP(j,0,i)if(j<=sum)
		{
			dp[i][j]=((ll)dp[i-1][j]*((2*i-(i-1)-(sum-j))>0 && j<=sum)+((j>0)?(ll)dp[i-1][j-1]*((sum-j+1)>0):0))%mod;
		}
	}
	int ans=0;
	REP(i,0,n)ans=(ans+(ll)dp[n][i]*C(n,sum-i))%mod;
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 15232
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;



void solve(){
	int n;
	cin>>n;
	int a[n],b[n];
	rep(i,n)cin>>a[i],b[i]=a[i];
	sort(b,b+n);
	int cnt=0;
	rep(i,n){
		if(b[i]!=a[i])cnt++;
	}
	if(cnt==2 || cnt==0)cout<<"YES";
	else cout<<"NO";
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);


ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  k--;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}

int main(void){
  ll n;
  cin >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }

  vector<vector<ll>> dp(n + 1, vector<ll>(60, 0));


  for (int i = n-1; i >= 0; i--){
    for (int j = 0; j < 60; j++){
      dp[i][j] = dp[i+1][j] + ((a[i] >> j) & 1);
    }
  }


  ll res = 0;
  for (int i = 0; i < n; i++){
    for (int j = 0; j < 60; j++){
      if ((a[i] >> j) & 1){
        res = (res + power(2, j) * (n - 1 - i - dp[i + 1][j]) % MOD) % MOD;
      }
      else {
        res = (res + power(2, j) * (dp[i + 1][j]) % MOD) % MOD;
      }
    }
  }
  
  cout << res << endl;

  return 0;
}


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

int main()
{
	long long int N,D,X,A,i,j,k,L,cnt=0;

	cin >> N;
	cin >> D >> X;

	for(i = 1; i <= N; i++)
	{
		cin >> A;
		j = A;
		k= 1;
		while(j*k+1 <= D)
		{
            k++;
            cnt++;
		}
	}

	long long int result = X+N+cnt;
    
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a,b,c;
	int sum=700;
	cin>>a>>b>>c;
	if(a=='o') sum=sum+100;
	if(b=='o') sum=sum+100;
	if(c=='o') sum=sum+100;
	cout<<sum;
	return 0;
	
} 

Measured memory_bytes: 256