akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ds;
  for (int i = 1; i * i <= m; i++) {
    if (m % i == 0) {
      ds.push_back(i);
      ds.push_back(m / i);
    }
  }
  int ans = 0;
  for (int d : ds) {
    if (n <= m / d) {
      ans = max(ans, d);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
// typedef vector<int,vector<int>> vvec;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
inline ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }

//----***定数***----
const int MOD=1e9+7;
#define INF 1e9;
#define EPS 1e-9;

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
#define here  cout<<"Here"<<endl;


//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

signed main(){
  int N,M,a,b;cin>>N>>M;
  vector<vector<int>> G(N);
  vector<P> p_vec(M);
  REP(i,0,M){
    cin>>a>>b;
    --a;--b;
    G[a].push_back(b);
    G[b].push_back(a);
    p_vec[i].first=a;p_vec[i].second=b;
  }
  int ans=0;
  REP(i,0,M){
    int t_a=p_vec[i].first,t_b=p_vec[i].second;
    // debug(t_a);debug(t_b);
    vector<int> visited(N,0);
    visited[0]=1;
    stack<int> stk;stk.push(0);
    while(stk.size()){
      int from=stk.top();stk.pop();
      each(to,G[from]){
        if(visited[to]||((from==t_a&&to==t_b)||(from==t_b&&to==t_a)))continue;
        visited[to]=1;
        stk.push(to);
      }
    }
    int judge=0;
    REP(i,0,N){
      //debug(visited[i]);
      judge+=visited[i];
    }
    // debug(visited);
    // debug(judge);
    if(judge!=N)ans++;
  }
  print(ans)



}


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

int main() {
  int N,M;
  cin >> N >> M;
  int sum = 0;
  for (int i = 0; i < M; i++) {
    int a;
    cin >> a;
    sum += a;
  }
  if (sum > N) {
    cout << -1 << endl;
  }
  else {
    cout << N - sum << endl;
  }
}

Measured memory_bytes: 3644
import std.stdio;

void main() {
	for (;;) {
		int n, x;
		"%d %d\n".readf(&n, &x);
		if (n == 0 && x == 0) break;
		int c = 0;
		foreach (i; 1..n-1)
			foreach (j; i+1..n)
				foreach (k; j+1..n+1)
					if (i+j+k == x) ++c;
		c.writeln;
	}
}

Measured memory_bytes: 2488
#include<iostream>
using namespace std;
int main(void){
    int a,b;
    cin >> a >> b;
    if(a>b){
        for(int i = 0 ; i < a; i++)cout << b;
    }else{
        for(int i = 0 ; i < b; i++)cout << a;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.Exception
import java.util.*

// ModInt
// region
class ModInt(x: Long) {

    companion object {
        const val MOD = 1000000007L
        //const val MOD = 998244353L
    }

    val x = (x % MOD + MOD) % MOD

    operator fun plus(other: ModInt): ModInt {
        return ModInt(x + other.x)
    }

    operator fun minus(other: ModInt): ModInt {
        return ModInt(x - other.x)
    }

    operator fun times(other: ModInt): ModInt {
        return ModInt(x * other.x)
    }

    operator fun div(other: ModInt): ModInt {
        return this * other.inv()
    }

    fun pow(exp: Long): ModInt {
        if (exp == 0L) return ModInt(1L)
        var a = pow(exp shr 1)
        a *= a
        if (exp and 1L == 0L) return a
        return this * a
    }

    fun inv(): ModInt {
        return this.pow(MOD - 2)
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as ModInt

        if (x != other.x) return false

        return true
    }

    override fun hashCode(): Int {
        return x.hashCode()
    }

    override fun toString(): String {
        return "$x"
    }

}

val fac = mutableListOf<ModInt>()
val invfac = mutableListOf<ModInt>()

fun fact(n: Long, b: Boolean): ModInt {
    if (fac.count() == 0) {
        fac.add(ModInt(1))
        invfac.add(ModInt(1))
    }
    while (fac.count() <= n) {
        fac.add(fac.last() * ModInt(fac.count().toLong()))
        invfac.add(fac.last().inv())
    }
    return if (b) {
        fac[n.toInt()]
    } else {
        invfac[n.toInt()]
    }
}

fun comb(n: Long, k: Long): ModInt {
    return fact(n, true) * fact(k, false) * fact(n - k, false)
}

fun comb2(n: Long, k: Long): ModInt {
    var ans = ModInt(1)
    for (i in 0 until k) {
        ans = ans * ModInt(n - i) / ModInt(k - i)
    }
    return ans
}
// endregion

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val dp = Array(n + 2) { ModInt(0) }
    dp[1] = ModInt(n.toLong())
    dp[2] = dp[1].pow(2)
    var sum = dp[2] + ModInt(n - 1L)
    for (i in 3..n) {
        dp[i] = ModInt(n - 1L).pow(2) + sum
        sum += dp[i] - dp[i-1] + dp[i-2] - ModInt(1)
    }
    println(dp[n])
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 101044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  ll N, K, A,z = 0;
  cin >> N >> K;
  vector<ll> B, C, D;
  rep (i,N)
  {
    cin >> A;
    if (A == 0)
      z++;
    else if (A < 0) {
      B.push_back(A);
      D.push_back(-A);
    } else
      C.push_back(A);
  }
  ll nb = B.size(), nc = C.size(), f0 = nb * nc;
  ll f1 = f0 + z * (nb + nc) + (z * (z - 1)) / 2;
  if (K <= f0) {
    sort(B.begin(), B.end());
    sort(C.begin(), C.end(), greater<ll>());
    ll l = -1e18 - 1ll, r = 0;
    while (r - l > 1) {
      ll m = (l + r) / 2, sum = 0;
      int j = nb;
      for (int i = 0; i < nc && sum < K; i++) {
        j = upper_bound(B.begin(), B.begin() + j, m / C[i] - (m % C[i] ? 1 : 0))
            - B.begin();
        if (j == 0)
          break;
        sum += j;
      }
      if (sum < K)
        l = m;
      else
        r = m;
    }
    cout << r;
  } else if (K <= f1) {
    cout << 0;
  } else {
    sort(C.begin(), C.end());
    sort(D.begin(), D.end());
    K -= f1;
    ll l = 0, r = 1e18 + 1ll;
    ll bt = nb * 2 - 3, ct = nc * 2 - 3;
    while (r - l > 1) {
      ll m = (l + r) / 2, sum = 0;
      for (ll i = nb - 2; i >= 0 && sum < K; i--) {
        ll j = upper_bound(D.begin() + i, D.end(), m / D[i]) - D.begin();
        if (j == nb) {
          sum += (bt - i) * i / 2 + nb - 1;
          break;
        } else if (j != i) {
          sum += j - i - 1;
        }
      }
      for (ll i = nc - 2; i >= 0 && sum < K; i--) {
        ll j = upper_bound(C.begin() + i, C.end(), m / C[i]) - C.begin();
        if (j == nc) {
          sum += (ct - i) * i / 2 + nc - 1;
          break;
        } else if (j != i) {
          sum += j - i - 1;
        }
      }
      if (sum < K)
        l = m;
      else
        r = m;
    }
    cout << r;
  }
  return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
using namespace std;
typedef long long ll;
ll mod = 1000000007;

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

	ll a[200000];

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

	if (n % 2 == 0)
	{
		for (int i = n - 1; i >= 0; i -= 2) {
			printf("%lld ", a[i]);
		}
		for (int i = 0; i < n; i += 2) {
			printf("%lld ", a[i]);
		}
	}
	else {
		for (int i = n - 1; i >= 0; i -= 2) {
			printf("%lld ", a[i]);
		}
		for (int i = 1; i < n; i += 2) {
			printf("%lld ", a[i]);
		}
	}
	printf("\n");
	return 0;
}

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

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

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end


N = gets_i
p_list = gets_i_list
q_list = gets_i_list

patterns = p_list.permutation(N).to_a.sort

puts (patterns.index(p_list) - patterns.index(q_list)).abs

Measured memory_bytes: 7800
#include <bits/stdc++.h>
using namespace std;
typedef long long l;
int main() {
	// your code goes here
	l a,b,k;
	cin>>a>>b>>k;
	if(k>a){
		b=b-(k-a);
		a=0;
		if(b<=0) b=0;
	}
	else
		a-=k;
	cout<<a<<" "<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(void)
{
    int n;

    cin >> n;
    cout << (long long)n * (n - 1) / 2 << endl;

    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 reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()%
//#define int long long

signed main(){
    int n; cin >> n;
    vector<int> a(n), b(n);
    rep(i,n) cin >> a[i];
    
    //calc b_0
    b[0] = 0;
    for(int i=0; i<n; i+=2) b[0] += a[i];
    for(int i=1; i<n; i+=2) b[0] -= a[i];
    
    //calc all
    rep(i,n-1){
        b[i+1] = 2 * a[i] - b[i];
    }
    
    string ans = "";
    rep(i,n) ans += to_string(b[i]) + " ";
    ans.pop_back();
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
const int mod = 1e9 + 7;
const int INF = 1e9;
using namespace std;
typedef long long ll;


int main()
{
    int n;
    cin >> n;
    int num = n;
    cout << num << ":";
    for(int i = 2; i * i <= n; i++){
        while(num % i == 0){
            cout << ' ' << i;
            num /= i;
        }
    }
    if(num != 1){
        cout << ' ' << num;
    }
    cout << endl;
}


Measured memory_bytes: 3116
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
#define INT_MAX 2147483647
#define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)	
using namespace std;

int max(int a,int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}

int main() {
	string s;
	set<int> values;
	cin >> s;

	rep(i, s.size()) {
		values.insert(s[i]);
	}

	rep(i, 26) {
		if (!values.count('a' + i)) {
			cout << (char)(i + 'a');
			return 0;
		}
	}
	cout << "None" << endl;
	
}

Measured memory_bytes: 888
def main():
    N = int(input())

    class osa_k:
        def __init__(self, sup):
            if sup > 2 * 10**8:
                raise RuntimeError(
                )
            self.MINFact = [-1] * (sup + 1)
            self.MINFact[0] = 0
            self.MINFact[1] = 1
            primes = [True for i in range(sup+1)]
            primes[0] = False
            primes[1] = False
            for i in range(2, sup+1):
                if primes[i]:
                    self.MINFact[i] = i
                    mul = 2
                    while i*mul <= sup:
                        primes[i*mul] = False
                        if self.MINFact[i*mul] == -1:
                            self.MINFact[i*mul] = i
                        mul += 1

        def prime_factor(self, n):
            res = 1
            while n > 1:
                prime = self.MINFact[n]
                exp = 0
                while self.MINFact[n] == prime:
                    n //= prime
                    exp += 1
                res *= (exp + 1)
            return res

    ok = osa_k(N+1)

    ans = 0
    for c in range(1, N):
        M = N - c
        ans += ok.prime_factor(M)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 150460
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <utility>
using namespace std;
int main(){
    string s;
    int n;
    cin >> n;
    map<string,int> m;
    for(int i=0;i<n;i++){
        cin >> s;
        sort(s.begin(),s.end());
        if(m.find(s) != m.end())m[s]++;
        else m[s]=1;
    }
    int sizem = m.size();
    auto itr = m.begin();
    long long int sum=0;
    long long int num = itr->second;
        sum += num*(num-1)/2;
    for(int i=0;i<sizem-1;i++){
        itr = next(itr,1);
        num = itr->second;
        sum += num*(num-1)/2;
    }
    cout <<sum<<endl;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string command;
    int s;
    list<int> l;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>command;
        if(command=="insert"){
            cin>>s;
            l.push_front(s);
        }
        else if(command=="delete"){
            cin>>s;
            for(list<int>::iterator j=l.begin(); j!=l.end(); j++){
                if( *j == s){
                    l.erase(j);
                    break;
                }
            }
        }
        else if(command=="deleteFirst"){
            l.pop_front();
        }
        else if(command=="deleteLast"){
            l.pop_back();
        }
    }
    while(!l.empty()){
        cout<<l.front();
        l.pop_front();
        if(!l.empty()) cout<<" ";
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 34412
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
string reverse(string tmp){
  string out="";
  for(int i=tmp.size()-1;i>=0;i--)out=out+tmp[i];
  return out;
}
int main(){
  string s;cin>>s;
  int n;cin>>n;
  rep(i,n){
    string tmp;
    cin>>tmp;
    if(tmp=="replace"){
      int a,b;
      cin>>a>>b>>tmp;
      s.replace(a,b-a+1,tmp);
    }else if(tmp=="reverse"){
      int a,b;
      cin>>a>>b;
      string tmp=s.substr(a,b-a+1);
      s=s.substr(0,a)+reverse(tmp)+s.substr(b+1);
    }else{
      int a,b;
      cin>>a>>b;
      cout<<s.substr(a,b-a+1)<<endl;
    }
    //cout<<" "<<s<<endl;
  }
}

Measured memory_bytes: 1228
#include <stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  int i;
  int data[n];
  for(i=0;i<n;i++){
    scanf("%d",&data[i]);
  }
  int key;
  int j,k;
  for(i = 1;i<n;i++){
    key = data[i];
    j = i - 1;
    for(k = 0; k<n-1;k++){
	printf("%d ",data[k]);
      }
    printf("%d\n",data[k]);
    while(j >=0 && data[j] > key){
     data[j+1] = data[j];
      data[j] = key;
      j--;
    }
  }
   for(i=0;i<n-1;i++){
    printf("%d ",data[i]);
  }
   printf("%d\n",data[i]);
  return 0;
}

Measured memory_bytes: 2708
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

void trim(char *s){
	s[strlen(s)-1] = '\0';
	
}

bool check(char *s){
	for (int i= 0; i< strlen(s)/2;i++){
		if (s[i] != s[i+ strlen(s)/2]){
			return false;
		}
	}
	return true;
}

int main(void){
	char s[128];
	fgets(s,128,stdin);
	trim(s);
	while (strlen(s) > 1){
		trim(s);
		if (strlen(s) % 2 == 0){
			if (check(s) == true){
				printf("%d",strlen(s));
				break;
			}
		}
	}
	if (strlen(s) == 0){
		printf("0");
	}
	
	return (0);

}

Measured memory_bytes: 128
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    sc.close();

    String[] s = S.split("");

    int[] l = new int[s.length+1];
    int[] r = new int[s.length+1];

    int count = 0;

    for (int i = 0; i < s.length; i++) {
      l[i] = count;
      if (s[i].equals("<")) {
        count++;
      } else {
        count = 0;
      }
    }
    l[s.length] = count;

    count = 0;

    for (int i = s.length - 1; 0 <= i; i--) {
      r[i+1] = count;
      if (s[i].equals(">")) {
        count++;
      } else {
        count = 0;
      }
    }
    r[0] = count;

    long answer = 0;

    for (int i = 0; i <= s.length; i++) {
      answer += Math.max(l[i], r[i]);
    }

    System.out.println(answer);

  }

}

Measured memory_bytes: 68092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define ft front()
#define bk back()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
template <class t>
bool ckmin(t& a, const t& b) {
    return a > b ? a = b, true : false;
}
template <class t>
bool ckmax(t& a, const t& b) {
    return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
    if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p);
template <class T>
struct IsC {
    template <class C>
    static char test(typename C::const_iterator*);
    template <class C>
    static int test(...);
    static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
    static const bool value = false;
};
template <class C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream& o,
                                                             const C& c) {
    o << '[';
    for (auto it = c.begin(); it != c.end();)
        o << *it << (++it != c.end() ? ", " : "");
    return o << ']';
}
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p) {
    return o << '(' << p.fi << ", " << p.se << ')';
}

const int INF = numeric_limits<int>::max();
const int NINF = numeric_limits<int>::min();
vvi adj;
vi d;
vi as;
vi ans;

void dfs(int v = 0, int p = -1) {
    int j = upper_bound(ALL(d), as[v]) - d.begin();
    ii changed{-1, -1};
    if (d[j - 1] < as[v] && as[v] < d[j]) {
        changed = mp(j, d[j]);
        d[j] = as[v];
    }
    if (~p) {
        if (d[j] < INF)
            ans[v] = max(j, ans[p]);
        else
            ans[v] = ans[p];
    } else {
        ans[v] = 1;
    }
    for (int u : adj[v])
        if (u != p) dfs(u, v);

    if (~changed.fi) {
        d[changed.fi] = changed.se;
    }
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    adj.assign(n, vi());
    as.assign(n, 0);
    d.assign(n + 1, INF);
    d[0] = NINF;
    ans.assign(n, -1);
    F0R (i, n)
        cin >> as[i];
    F0R (i, n - 1) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    dfs();

    for (int i : ans) {
        cout << i << endl;
    }

    return 0;
}


Measured memory_bytes: 30748
#include <bits/stdc++.h>
//F6編譯，右上三角形執行，ctrl+c強制停止執行  F5開啟exe
#define ll long long
#define maxn 200005
#define mod 998244353
using namespace std;

typedef pair<int, int> P;

bool used[maxn];
int n, m;
int main()
{
    cin >> n >> m;
    if (n % 2 == 0)
    {
        int l = 1, r = n / 2;
        if (r % 2 == 1)
            r--;
        for (int i = 0; i < r / 2; i++)
        {
            printf("%d %d\n", l + i, r - i);
            m--;
            if (m == 0)
                return 0;
        }
        int nr = (n % 4 == 0) ? (n - 2) / 2 : n / 2;
        l = r + 1, r = r + nr;
        while (1)
        {
            printf("%d %d\n", l, r);
            l++, r--;
            m--;
            if (m == 0)
                return 0;
        }
    }
    else
    {
        int l = 1, r = n - 1;
        for (int i = 1; i <= m; i++)
        {
            printf("%d %d\n", l, r);
            l++, r--;
        }
    }

    return 0;
}


Measured memory_bytes: 3744
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
ll cnt[200020];
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //------------------------------
    ll n,k,c;cin>>n>>k>>c;
    string s;cin>>s;
    V<ll>ans;
    ll ccnt=0;
    ll ocnt=0;

    for(ll i=0;i<n;i++){
        if(s[i]=='o'){
            ocnt++;
            i+=c;
        }
    }

    ll ocnt1=0;

    for(ll i=n-1;i>=0;i--){
        if(s[i]=='o'){
            ocnt1++;
            i-=c;
        }
    }
    chmax(ocnt,ocnt1);

    if(ocnt>k){
        return 0;
    }


    for(ll i=n-1;i>=0;i--){
        if(s[i]=='o'){
            cnt[i]++;
            i-=c;
            ccnt++;
            if(ccnt>=k)break;
        }
    }
    ccnt=0;
    for(ll i=0;i<n;i++){
        if(s[i]=='o'){
            cnt[i]++;
            i+=c;
            ccnt++;
            if(ccnt>=k)break;
        }
    }

    for(ll i=0;i<n;i++){
        if(cnt[i]>=2)ans.pb(i+1);
    }

    for(ll i=0;i<ans.size();i++){
        cout<<ans[i]<<endl;
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------













































Measured memory_bytes: 5000
using System;
using System.Collections;

public class p0018{
	static void Main(string[] args){
		string input_str;
		
		while((input_str=Console.ReadLine())!=null){
			string[] sarray = input_str.Split(' ');
			int[] narray = Array.ConvertAll<string, int>(sarray, delegate (string value){
				return int.Parse(value);
			});
			
			Array.Sort(narray);
			Array.Reverse(narray);
			
			Console.Write("{0}", narray[0]);
			for(int i = 1; i < narray.Length; ++i)
				Console.Write(" {0}", narray[i]);
			Console.WriteLine();
		}
	}
}

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

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for(char c:s)pcu(c);}
//_vo(string s){for(char c:s)pcu(c);}
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

typedef vector<int> v;

v read() {
	v A(in());
	for (int &a :A)
		a = in();
	return move(A);
}

int main() {
	v a = read(), b = read();
	outl((int) (includes(a.begin(), a.end(), b.begin(), b.end())));
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	//~ cout.tie(0);
	int h, n;
	scanf("%d%d", &h, &n);
	while (n--) {
		int x; scanf("%d", &x);
		h -= x;
	}
	puts(h <= 0? "Yes" : "No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  ;
  int a, b, c;
  cin >> a >> b >> c;
  cout << ((a == b && b == c) ? "Yes" : "No") << endl;
}
void solve() {
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

char s[200111];
int n,cnt[26];
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	LL ans=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<26;j++)if(j+'a'!=s[i])ans+=cnt[j];
		cnt[s[i]-'a']++;
	}
	printendl(ans);
	return 0;
}

Measured memory_bytes: 384
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

from itertools import permutations

order = list(range(1, n+1))
a = 0
b = 0
cnt = 0
flag = False
for i in permutations(order, n):
    if list(i) == p:
        a = cnt
    if list(i) == q:
        b = cnt
    cnt += 1

print(abs(a-b))


Measured memory_bytes: 3188
h,w = map(int,input().split())
#n = int(input())
L = []
for i in range(h):
    tmp = list(input())
    if tmp != ["."]*len(tmp):
        L.append(tmp)
    else:
        h -= 1

l_2d_t = [list(x) for x in zip(*L)]

new_L = []
for i in l_2d_t:
    if i != ["."]*len(i):
        new_L.append(i)

l_2d_t = [list(x) for x in zip(*new_L)]

for i in l_2d_t:
    print("".join(i))

Measured memory_bytes: 38256
#include<stdio.h>
int main()
{
	int i,count=0;
	char s[3];
	for(i=0;i<4;i++){
		scanf("%s",&s[i]);
		if(s[i]=='+'){
			count++;
		}if(s[i]=='-'){
			count--;
		}
	}
	printf("%d",count);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int a[100005];
int dp[100005];
int dif(int a, int b)
{
    if(a>=b)return a-b;
    return b-a;
}
int min(int a, int b)
{
    if(a<=b)return a;
    return b;
}
int main(void) {
	// your code goes here
	int n,i,k,j;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)scanf("%dd",&a[i]);
	
	for(i=2;i<=n;i++)
	{
	    dp[i] = 1000000007;
	    for(j=1;j<=k;j++){
	        if(i-j > 0)
	    dp[i] = min(dp[i], dp[i-j] + dif(a[i],a[i-j]));
	    }
	}
	printf("%d\n",dp[n]);
	return 0;
}



Measured memory_bytes: 896
import java.util.*;

public class Main{
	public static void main(String args[]){
		
        Scanner sc = new Scanner(System.in);
        
      // 整数の取得
        double a = sc.nextInt();
      	double i = 0;
      
      //判定
      if((a%2)==0){
        i = a/2;
      } else {
        i = Math.ceil(a/2);
      }
        
      System.out.println(i/a);
    }
}

Measured memory_bytes: 22100
n, m = map(int, input().split())
edge = [list(map(int, input().split())) for _ in range(m)]

next_node = [[] for _ in range(n)]
for a, b in edge:
    next_node[a-1].append(b)
    next_node[b-1].append(a)

q = [1]
visit = [1]  + [0] * (n-1)
prev = [0] * n
while q:
    now = q.pop(0)
    for i in next_node[now-1]:
        if visit[i-1] == 0:
            q.append(i)
            visit[i-1] = 1
            prev[i-1] = now
print('Yes')
print(*prev[1:], sep='\n')

Measured memory_bytes: 59588
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
const int maxn = 1e5 + 5, inf = 1e9;
struct Edge{
    int to,dis;
    Edge(int _to, int _dis):to(_to), dis(_dis){}
};
vector<Edge> G[maxn];
bool inq[maxn];
int dis[maxn];
int n;
queue<int> Q;
int spfa(int s){
    for(int i = 0; i < n; i++)dis[i] = inf;
    memset(inq, 0, sizeof(inq));
    Q.push(s);
    dis[s] = 0;
    inq[s] = true;
    while(!Q.empty()){
        int u = Q.front();Q.pop();
        inq[u] = false;
        for(int i = 0; i < G[u].size(); i++){
            Edge &e = G[u][i];
            if(dis[e.to] > dis[u] + e.dis){
                dis[e.to] = dis[u] + e.dis;
                if(!inq[e.to])inq[e.to] = true, Q.push(e.to);
            }
        }
    }
    return s + dis[0];
}
void build(){
    for(int i = 1; i < n; i++){
        for(int j = 0; j <= 9; j++){
            G[i].push_back(Edge((10 * i + j) % n, j));
        }
    }
}
int main(){
    cin>>n;
    build();
    int ans = inf;
    for(int s = 1; s <= 9; s++)ans = min(ans, spfa(s));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 17576
N, K = [int(i) for i in input().split()]
R, S, P = [int(i) for i in input().split()]
T = input()

def addScore(hand):
    if hand == 'r':
        return P
    elif hand == 's':
        return R
    else :
        return S

score = 0
score_flag = [0 for i in range(N)]

for l in range(len(T)):
    if l < K:
        score += addScore(T[l])
        score_flag[l] = 1
    else :
        if T[l] == T[l-K] and score_flag[l-K] == 1:
            continue
        else :
            score += addScore(T[l])
            score_flag[l] = 1
            
print(score)

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

const int MOD = 1E9+7;

int a, b;
int x, y;
int u, v;

int cmod(int uu, int vv){
	if(vv == 0) return 1;
	int cc = cmod(uu, vv>>1);
	if(vv&1){
		return ((cc*cc)%MOD)*uu%MOD;
	}
	else return (cc*cc)%MOD;
}

int gt(int X){
	int XX = 1;
	for(int i=1; i <= X; ++i) XX = (XX*i)%MOD;
	return XX;
}

int C(int A, int B){
	return ((gt(A+B)*cmod(gt(A), MOD-2))%MOD)*cmod(gt(B), MOD-2)%MOD;
}

signed main(){
	cin >> x >> y;
	u = 2*y-x; v = 2*x-y;
	if(u < 0  || (u%3)!= 0 || v < 0 || (v%3)!=0){
		cout << "0";
		return 0;
	}
	a = u/3; b = v/3;
	cout << C(a, b);
}

Measured memory_bytes: 256
from sys import stdin


def main():
    _ = int(stdin.readline().rstrip())
    As = [int(x) for x in stdin.readline().rstrip().split()]
    mcount = len([x for x in As if x < 0])
    if mcount % 2 == 0:
        print(sum([abs(x) for x in As]))
    else:
        min_ = min([abs(x) for x in As])
        sum_ = sum([abs(x) for x in As])
        print(sum_ - (min_ * 2))


if __name__ == "__main__":
    main()


Measured memory_bytes: 14452
n, y = map(int, input().split())
flag = 0
for i in range(n+1):
    for j in range(n-i+1):
        k = n - (i + j)
        if 10000*i + 5000*j + 1000*k == y:
            print(i, j, k)
            flag = 1
            exit()

if flag == 0:
    print(-1, -1, -1)
    

Measured memory_bytes: 3060
#include <cstdio>

typedef long long ll;

using namespace std;

int main() {
    ll k, a, b;
    scanf("%lld%lld%lld", &k, &a, &b);
    if (k <= a || b <= a + 1) {
        printf("%lld\n", k + 1);
    } else {
        k -= a - 1;
        printf("%lld\n", a + (k / 2) * (b - a) + (k % 2));
    }
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <vector>

using namespace std;

// #define DEBUG 1
#define DFILE "t1.1"

int main()
{
  int a, b;
  int price;

#ifdef DEBUG
#define cin fin
  fstream fin(DFILE);
#endif

  cin >> a >> b;
  if (a <= 5)
    price = 0;
  else if (a <= 12)
    price = b / 2;
  else
    price = b;
  cout << price << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class C
{
	public static void Main()
	{
		int N = GetInt();
		int[] csum = new int[100001];
		for(int i = 0; i < N; i++)
			csum[GetInt()]++;
		for(int i = 1; i <= 100000; i++)
			csum[i] += csum[i-1];

		int lb = 0;
		for(int i = 0; i <= 100000; i++)
		{
			if(csum[i] >= (N/2))
			{
				lb = i;
				break;
			}
		}

		int ub = 0;
		for(int i = 0; i <= 100000; i++)
		{
			if(csum[i] > (N/2))
			{
				ub = i;
				break;
			}
		}

		Console.WriteLine(ub - lb);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n,a,ans=0;
  cin>>n;
  rep(i,n){
    cin>>a;
    while(a%2==0){
      ans++;
      a/=2;
    }
  }
  cout<<ans<<endl;
  
}
///////////////////////////



Measured memory_bytes: 256
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let k: usize = it.next().unwrap().parse().unwrap();
    let s: Vec<char> = it.next().unwrap().chars().collect();
    let mut cnt = 0;
    let mut ok = 0;
    for i in 1..n {
        if s[i] == s[i - 1] {
            ok += 1;
        } else {
            cnt += 1;
        }
    }
    let ans = ok + std::cmp::min(2 * k, cnt);
    println!("{}", ans);
}

fn main() {
    run();
}


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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;

int main(){
   int a,b,c,d; cin>>a>>b>>c>>d;
   while(1){
     c -= b;
     if(c<=0){
         cout<<"Yes"<<endl;
         return 0;
     }
     a -= d;
     if(a<=0){
         cout<<"No"<<endl;
         return 0;
     }
   }
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
# A

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

D, T, S = map(int, input().split())

if D/S <= T:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 65128
using System;
using System.Linq;

class E
{
	static void Main()
	{
		var s = Console.ReadLine();
		var n = s.Length;

		if (s[0] != '1' || s[^1] != '0' || Enumerable.Range(0, n / 2).Any(i => s[i] != s[^(i + 2)])) { Console.WriteLine(-1); return; }

		var dp = new int[n];
		for (int t = n, i = 1; i < n; dp[i] = t, t = s[i - 1] == '1' ? i : t, i++) ;
		Console.WriteLine(string.Join("\n", dp.Select((x, i) => $"{x} {i}").Skip(1)));
	}
}


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

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

  int ans=0;
  for(int i=0; i<n; ++i){
    int x; cin>>x;
    if(x%2==1)++ans;
  }

  if(ans%2==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


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

static const int MAX = 100;
int a[MAX];

int main() {
	
	int n;
	cin >> n;
	for ( int i = 0; i < n; i++ ) cin >> a[i];
	
	int swapNum = 0;
	for ( int i = 0; i < n-1; i++ ) {
		for ( int j = n-1; j > i; j-- ) {
			if ( a[j] < a[j-1] ) {
				swap( a[j], a[j-1] );
				swapNum++;
			}
		}
	}
	
	for ( int i = 0; i < n; i++ ) {
		if ( i ) cout << " ";
		cout << a[i];
	}
	cout << endl;
	cout << swapNum << endl;
	
	return 0;
} 

Measured memory_bytes: 3084
var
N,i:Longint;
S:String;
cnt:Array[1..26]of int64;
ans:int64=1;
begin
readln(N);
readln(S);
for i:=1 to N do inc(cnt[ord(S[i])-96]);
for i:=1 to 26 do ans:=ans*(cnt[i]+1)mod 1000000007;
writeln(ans-1);
end.

Measured memory_bytes: 256
N, K = map(int, input().split())
count = 0
for i in range(1, N+1):
    if i < K:
        continue
    # print(i, (N // i)*(i-K), (N%i+1)-K)
    if K == 0:
        count += (N // i)*(i-K) + max(0, (N%i)-K)
    else:
        count += (N // i) * (i - K) + max(0, (N % i + 1) - K)
print(count)

Measured memory_bytes: 39152
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<sstream>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int>A(n + 1);
	rep(i, n + 1) {
		cin >> A[i];
	}
	vector<int>B(n);
	rep(i, n) {
		cin >> B[i];
	}
	vector<int>f(n);
	vector<int>g(n);
	f[0] = min(A[0], B[0]);
	g[0] = min(A[1], B[0] - f[0]);
	for (int i = 1; i < n; i++) {
		f[i] = min(A[i] - g[i - 1], B[i]);
		g[i] = min(A[i + 1], B[i] - f[i]);
	}
	ll ans = 0;
	rep(i, n) {
		ans += f[i] + g[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
N=int(input())
A=list(map(int,input().split()))

L=[0,0]#why
for ai in A:
    L.append(gcd(L[-1],ai))
    #print(L)

R=[0,0]#why
for ai in A[::-1]:
    R.append(gcd(R[-1],ai))
    #print(R)
#下のやつの解明
max=0
for l,r in zip(L,reversed(R)):
    if(gcd(l,r)>max):
        max=gcd(l,r)

print(max)

Measured memory_bytes: 14584
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define sum(x) accumulate(all(x),0)
#define gll greater<ll>()


void solve(){
 ll d;
  cin >> d;
  vll c(26);
  rep(i,0,26) cin >> c[i];  
  
 vvll s(d,vll(26));
  rep(i,0,d){
    rep(j,0,26) cin >> s[i][j]; 
  }
  
  vll t(d);
  rep(i,0,d) t[i]=(i%26);
  
  vector<set<ll>> v(26);
  rep(j,0,26){
    v[j].insert(-1);
    v[j].insert(d);
  }
  
  ll ans=0;
  rep(i,0,d){
    ans+=s[i][t[i]];
    v[t[i]].insert(i);
    rep(j,0,26) ans-=c[j]*(i-*v[j].rbegin());
  }
  
  vll f(d,0);
  
  rep(k,0,1500){
      rep(i,0,d){
        if(f[i]) continue;
        ll cnt=0;
        rep(j,1,26){
        ll cost=ans;
      auto prev=v[t[i]].find(i);
      auto next=prev;    
      prev--;
      next++;
      cost=cost-c[t[i]]*(i-*prev)*(*next-i);
        v[t[i]].erase(i);  
      t[i]=(t[i]+j)%26;
      
      v[t[i]].insert(i);
      prev=v[t[i]].find(i);
      next=prev;
      prev--;
      next++;
      cost=cost+c[t[i]]*(i-*prev)*(*next-i);
      
      if(cost>ans) {
        ans=cost;
      }
      else {
        v[t[i]].erase(i);
        t[i]=(t[i]-j+26)%26; 
        v[t[i]].insert(i); 
        cnt++;
      }
          
      }
        if(cnt==25) f[i]=1; 
      }
      }
  
  rep(i,0,d) cout << t[i]+1 << endl;

  
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

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

int main(){
  int a,b,n,i,j;
  cin >> a >> b;
  string s;
  int ans = 0;

  for(i=a;i<=b;i++){
    s = to_string(i);
    n = s.size();
      for(j=0;j<(n+1/2);j++){
        if(s[j] != s[n-1-j]){
          ans += 1;
          break;
      }
    }
  }
  cout << (b-a+1)-ans << endl;
  return 0;
}


Measured memory_bytes: 384
#define DEBUGGING  // Enables DEBUG macro.
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifndef DEBUGGING
#define debug(...)
#define DEBUG(...)
#else
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                     \
  do {                                 \
    cerr << " (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ": ";      \
    debug(__VA_ARGS__);                \
    cerr << endl;                      \
  } while (0)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int X;
  cin >> X;
  int y = gcd(X, 360);
  cout << (360 / y) << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <math.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int N;
vector <float > a;


float mean(vector<float> v) {
    int size = v.size();
    float sum = 0;
    for (int i = 0; i < size; i++){
        sum += v[i];
    }
    return sum / size;
}


int main()
{

	cin >> N;

	a.resize(N);

	REP(i,N){
		cin >> a[i];
	}
	float ans;
	ans = mean(a);

	int answ;
	answ = round(ans);
	int an = 0;
	REP(i,N){
		an += (a[i] - answ) * (a[i] - answ);
	}
	cout << an << endl;
}


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

int main()
{
	int num1,num2,num3,num4,num5,num6,num7,num8,num9,num10,num11,num12,num13,num14,num15,num16,num17,num18;
	int s1,s2,s3,s4,s5,s6;
	int a1,a2,a3;
	int test1,test2,test3,test4,test5,test6,test7,test8,test9;
	int q1,q2,q3,q4,q5,q6;

	cin>>num1>>num2>>num3>>num4>>num5>>num6>>num7>>num8>>num9>>num10>>num11>>num12>>num13>>num14>>num15>>num16>>num17>>num18;

	s1=num1*3600+num2*60+num3;
	s2=num4*3600+num5*60+num6;
	s3=num7*3600+num8*60+num9;
	s4=num10*3600+num11*60+num12;
	s5=num13*3600+num14*60+num15;
	s6=num16*3600+num17*60+num18;
	a1=s2-s1;
	a2=s4-s3;
	a3=s6-s5;
	test1=a1/3600;
	q1=a1%3600;
	test2=q1/60;
	q2=q1%60;
	test3=q2;
	test4=a2/3600;
	q3=a2%3600;
	test5=q3/60;
	q4=q3%60;
	test6=q4;
	test7=a3/3600;
	q5=a3%3600;
	test8=q5/60;
	q6=q5%60;
	test9=q6;
	cout<< test1 <<" "<< test2 <<" "<< test3 <<"\n";
	cout<< test4 <<" "<< test5 <<" "<< test6 <<"\n";
	cout<< test7 <<" "<< test8 <<" "<< test9 <<"\n";
	return 0;
}

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

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

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

    for(int i=n-1; i>0; i--){
        if(h[i] < h[i-1] - 1){
            cout << "No" << endl;
            return 0;
        }else if(h[i] == h[i-1] - 1){
            h[i-1] -= 1;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640