akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
class Program
{

    static void Main(string[] args)
    {

        //var NX = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var NMK = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var N = NMK[0];
        var M = NMK[1];
        var K = NMK[2];
        Modular ans = new Modular(0);
        for (int i = 0; i <= K; i++)
        {
            ans += M * Modular.Pow(M - 1, (int)N - 1 - i)*Modular.Ncr((int)N -1,i);
        }

        Console.WriteLine(ans.value);
    }
}

class Modular
{
    private const int M = 998244353;
    public long value;
    public Modular(long value) { this.value = value; }
    public static implicit operator Modular(long a)
    {
        var m = a % M;
        return new Modular((m < 0) ? m + M : m);
    }
    public static Modular operator +(Modular a, Modular b)
    {
        return (a.value + b.value) % M;
    }
    public static Modular operator -(Modular a, Modular b)
    {
        return a.value - b.value;
    }
    public static Modular operator *(Modular a, Modular b)
    {
        return a.value * b.value;
    }
    public static Modular Pow(Modular a, int n)
    {
        switch (n)
        {
            case 0:
                return 1;
            case 1:
                return a;
            default:
                var p = Pow(a, n / 2);
                return p * p * Pow(a, n % 2);
        }
    }
    public static Modular operator /(Modular a, Modular b)
    {
        return a * Pow(b, M - 2);
    }
    private static readonly List<int> facs = new List<int> { 1 };
    private static Modular Fac(int n)
    {
        for (int i = facs.Count; i <= n; ++i)
        {
            facs.Add((int)(Math.BigMul(facs.Last(), i) % M));
        }
        return facs[n];
    }
    public static Modular Ncr(int n, int r)
    {
        return (n < r) ? 0
             : (n == r) ? 1
                        : Fac(n) / (Fac(r) * Fac(n - r));
    }
    public static explicit operator int(Modular a)
    {
        return (int)a.value;
    }

    public static Modular Lcm(Modular a, Modular b)
    {
        var tmp = Gcdl(a.value, b.value);
        return ((a * b) / new Modular(tmp));
    }
    static Modular Gcd(Modular m, Modular n)
    {
        if (n.value > m.value) return Gcd(n, m);
        if (n.value == 0) return m;
        var r = new Modular(m.value % n.value);
        return Gcd(n, r);
    }

    static long Gcdl(long m, long n)
    {
        if (n > m) return Gcdl(n, m);
        if (n == 0) return m;
        return Gcdl(n, m % n);
    }
}

Measured memory_bytes: 48340
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;
int main(){
    int h,w;
    cin >>h >> w;
    queue<pair<int,pair<int,int>>> q;
    vector<vector<char>> vec(h,vector<char>(w));
    for(int i=0;i<h;i++){
        string s;
        cin >> s;
        for(int j=0;j<w;j++){
            vec[i][j]=s[j];
            if(s[j]=='#'){
                q.push(pair<int,pair<int,int>> (0,pair<int,int>(i,j)));
            }
        }
    }
    int count=0;
    while(!q.empty()){
       // cout<<q.size()<<endl;
        int y=q.front().second.first;
        int x=q.front().second.second;
        int r=q.front().first;
        q.pop();
        if(y+1<h){
            if(vec[y+1][x]=='.'){
             //   count++;
                vec[y+1][x]='#';
                q.push(pair<int,pair<int,int>>(r+1,pair<int,int>(y+1,x)));
            }
        }
        if(x+1<w){
            if(vec[y][x+1]=='.'){
             //   count++;
                vec[y][x+1]='#';
                q.push(pair<int,pair<int,int>>(r+1,pair<int,int>(y,x+1)));
            }
        }
        if(y-1>=0){
            if(vec[y-1][x]=='.'){
              //  count++;
                vec[y-1][x]='#';
                q.push(pair<int,pair<int,int>>(r+1,pair<int,int>(y-1,x)));
            }
        }
        if(x-1>=0){
            if(vec[y][x-1]=='.'){
               // count++;
                vec[y][x-1]='#';
                q.push(pair<int,pair<int,int>>(r+1,pair<int,int>(y,x-1)));
            }
        }
      //  cout<<y<<" "<<x<<endl;
    //    count++;
        count = max(r,count);
    }
    cout<<count<<endl;
}

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

int main() {

  while( true ) {

    long long int n, m;
    cin >> n >> m;
    if ( n == 0 ) break;

    vector< pair< long long int, pair< long long int, long long int > > > v;

    for ( long long int i = 0; i < m; i++ ) {

      long long int in_t, in_s, in_d;
      cin >> in_t >> in_s >> in_d;
      in_s--;
      in_d--;
      v.push_back( make_pair( in_t, make_pair( in_s, in_d ) ) );

    }

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

    bool f[20001] = {};

    f[0] = true;

    long long int ans = 1;

    for ( long long int i = 0; i < m; i++ ) {

      if ( f[ v[i].second.first ] == true && f[ v[i].second.second ] == false ) {
	ans++;
	f[ v[i].second.second ] = true;
      }

    }

    cout << ans << endl;

  }

  return 0;

}

Measured memory_bytes: 2396
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}


int main()
{
#if defined(_DEBUG) 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	cout.tie(NULL);

	string str;
	cin >> str;

	int cnt[2] = { 0 };
	for (int k = 0; k < str.size(); k++)
	{
		cnt[str[k] - '0']++;
	}

	if (min(cnt[0], cnt[1]) == 0)
	{
		cout << str.size();
		return 0;
	}

	for (int k = 0; k < str.size(); k++)
	{
		cnt[str[k] - '0']--;
		cnt[str[str.size() - k - 1] - '0']--;
		
		if (min(cnt[0], cnt[1]) == 0)
		{
			cout << str.size() - k - 1;
			break;
		}
	}
	return 0;
}

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

int main(void){
    int x;
    cin >> x;
    int ans = 1;
    int aa = 0;
    for(int i= 2;i<x;i++){
        int num = i*i;
        if(num <=x){
            while(num <= x){
                num = num *i;
            }
            num = num /i;
        }
        else{
            continue;
        }
        
        ans = max(ans,num);
    }
    
    cout << ans << endl;
    return 0;
}


































































Measured memory_bytes: 256
N = int(input())
As = list(map(int, input().split()))
dp = [0] * 1000000
mod = 10**9 + 7
ans = 1
dp[0] = 3
for a in As:
    a += 1
    ans *= dp[a-1]-dp[a]
    ans %= mod
    dp[a] += 1
print(ans%mod)

Measured memory_bytes: 61996
import java.util.Scanner;
  class Main{
    public static void main(String args[]){
    Scanner scan = new Scanner(System.in);

     while(true){   

       int h = scan.nextInt();

       int w = scan.nextInt();

         if(h==0 && w==0){
          break;
         }else{

            for(int i=0;i<h;i++){

               for(int j=0;j<w;j++){
                System.out.print("#");
               }
             
             System.out.println("");
            }System.out.println("");              
         }
      }
    }
  }


Measured memory_bytes: 34992
/*-- ILSH  --*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pll >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 

const ll inf=1e18+1e17;
//const ll mod =1e9+7;
const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}


const ll N = 1e4+5;

ll dp[N], dpi[N],arr[N];
ll add ( ll a, ll b){
	if ( a+b>2*mod)
		return a+b-2*mod;
	if ( a+b> mod)
		return a+b-mod;
	return a+b;
}

void solve(){
	int n,s;
	cin>>n>>s;
	for  (int i=0;i<n;i++)
		cin>>arr[i];
	dp[0]=1;
	s++;
	for ( int i=0;i<n;i++){
		memset( dpi,0,sizeof ( dpi));
		for ( int j=0;j<s;j++)
			if ( dp[j]>0&&arr[i]+j<s)
				dpi[arr[i]+j]=add( dpi[arr[i]+j],dp[j]);
		for ( int j=0;j<s;j++)
			dpi[j]=add( 2*dp[j],dpi[j]);
		swap( dpi,dp);
	}
	cout<< dp[s-1]<<'\n';
	



}

int main(){
	// ios_base::sync_with_stdio(false);
	// cin.tie( NULL);
	// cout.tie(NULL);
//	#ifndef ONLINE_JUDGE
//		freopen ("INPUT.txt" , "r" , stdin);
//		freopen ("OUTPUT.txt", "w" , stdout);
//	#endif

	int t=1;

	//cin>>t;

	for ( int i=1;i<=t;i++){
   // 	cout<<"Case #"<<i<<": ";
    	solve();
 	}
}

Measured memory_bytes: 3820
#include <stdio.h>
using namespace std;
//---------------------------------------
void henkan(char inp[]);   //?°?????????¨??§???????????\?????????
//---------------------------------------

int main(void)
{
	//char inp0[12] = "abcdefghijk";
	char inp1[1201];
	//char inp2[12] = "abcdefghijk";	
	
	
	
	fgets(inp1, 1201, stdin);
	
	henkan(inp1);
	
	printf("%s",inp1);
	//printf("%s\n",inp0);
	//printf("%s\n",inp2);
	
	return 0;
}

//------------------------------------------
void henkan(char inp[])
{	
	for(int i = 0; i < 1200; i++){
		if(inp[i] >= 'A' && inp[i] <= 'Z'){
			inp[i] += 32;
		}
		else if(inp[i] >= 'a' && inp[i] <= 'z'){
			inp[i] -= 32;
		}
	}
}

Measured memory_bytes: 2660
#include "bits/stdc++.h"

#define sp <<" "
#define el <<"\n"
#define S second
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define obit __builtin_popcount
#define pof pop_front
#define mod (int)1e9 + 7
#define For(i,a,n) for(i=a;i<n;i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned short int us;
typedef short int ss;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    /*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    //*/
    ll n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;
    ll mn = min(a,min(b,min(c,min(d,e))));
    n = (ll) ceil((double) n /mn);
    n = max((ll)0,n-1);
    cout<<5 + n;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

  int h, w, k;
  cin >> h >> w >> k;
  string s[310];
  rep(i, h) cin >> s[i];
  int cake[310][310] = {};
  int num = 1;
  rep(i, h)
  {
    rep(j, w)
    {
      if (s[i][j] == '#')
      {
        cake[i][j] = num;
        num++;
      }
    }
  }

  rep(j, w)
  {
    rep(i, h)
    {
      if (i > 0 && cake[i][j] == 0 && cake[i - 1][j] != 0)
        cake[i][j] = cake[i - 1][j];
    }
  }

  rep(j, w)
  {
    for (ll i = h - 1; i >= 0; --i)
    {
      if (i < h - 1 && cake[i][j] == 0 && cake[i + 1][j] != 0)
        cake[i][j] = cake[i + 1][j];
    }
  }

  rep(i, h)
  {
    rep(j, w)
    {
      if (j > 0 && cake[i][j] == 0 && cake[i][j - 1] != 0)
        cake[i][j] = cake[i][j - 1];
    }
  }

  rep(i, h)
  {
    for (ll j = w - 1; j >= 0; --j)
    {
      if (j < w - 1 && cake[i][j] == 0 && cake[i][j + 1] != 0)
        cake[i][j] = cake[i][j + 1];
    }
  }
  rep(i, h)
  {
    rep(j, w)
    {
      cout << cake[i][j] << (j == w - 1 ? "\n" : " ");
    }
  }

  return 0;
}


Measured memory_bytes: 1280
import sys
a,b = map(int,input().split())
if b==0:
  print(a)
else:
  b = list(map(int,input().split()))
  for i in range(101):
    _min=a-i
    _max=a+i
    if _min not in b:
      print(_min)
      sys.exit(0)
    if _max not in b:
      print(_max)
      sys.exit(0)

Measured memory_bytes: 9200
#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;
int n, a, b;
int main()
{
	cin>>n>>a>>b;
	int max1=n*a;
	int Max2=b;
	int ans=min(max1, Max2);
	cout<<ans<<endl;
	return 0;
}

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

int* mallocint(int si)
{
    return (int*) malloc(si * sizeof(int));
}

int* inputint(int n)
{
    int *ans = mallocint(n);
    for( int i = 0; i < n; i++ ) cin >> ans[i];
    return ans;
}

int main()
{
//    int ti = clock();
    int s, w;
    cin >> s >> w;
    if( w >= s )
    {
        cout << "unsafe";
    }
    else
    {
        cout << "safe";
    }
    


    //printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
    return 0;    
}

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

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main() {
  string S;
  cin>>S;
  bool flag = true;
  for(int i=0;i<S.size();++i){
    if(i%2==0){
      if(S[i] == 'R'||S[i] == 'U'||S[i] == 'D'){
        
      }else{
        flag = false;
      }
    }else{
      if(S[i] == 'L'||S[i] == 'U'||S[i] == 'D'){
        
      }else{
        flag = false;
      }
    }
  }
  putYN(flag);
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
#define INF INT_MAX/2
#define def make_pair(INF,INF)
template<class V, int NV> struct SegTree { //[l,r]
    V comp(V l, V r) { return min(l, r); };
    vector<V> val; SegTree() { val = vector<V>(NV * 2, def); }
    V get(int l, int r) { if (l>r)return def;l+=NV;r+=NV+1;V ret=def; while(l<r){
        if(l&1)ret=comp(ret,val[l++]);if(r&1)ret=comp(ret,val[--r]);l/=2;r/= 2;}return ret;}
    void update(int i, V v) { i+=NV;val[i]=v;while(i>1)i>>=1,val[i]=comp(val[i*2],val[i*2+1]); }
    void add(int i, V v) { update(i, val[i + NV] + v); }};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
 
 
 
 
int N, P[201010];
SegTree<pair<int, int>, 1 << 18> st1, st2;
//---------------------------------------------------------------------------------------------------
vector<int> E[201010];
int PA[201010];
void dfs(int L, int R, int pa = 0) {
    pair<int, int> mi1, mi2;
 
    if (L + 1 == R) {
        E[pa].push_back(P[L]);
        PA[P[L]] = P[R];
        return;
    }
 
    if (L % 2 == 0) {
        mi1 = st1.get(L, R - 1);
        mi2 = st2.get(mi1.second + 1, R);
    } else {
        mi1 = st2.get(L, R - 1);
        mi2 = st1.get(mi1.second + 1, R);
    }
 
    int A = mi1.second;
    int B = mi2.second;
 
    E[pa].push_back(mi1.first);
    PA[mi1.first] = mi2.first;
 
    if (L != A) dfs(L, A - 1, mi1.first);
    if (A + 1 != B) dfs(A + 1, B - 1, mi1.first);
    if (R != B) dfs(B + 1, R, mi1.first);
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N; rep(i, 0, N) cin >> P[i];
 
    rep(i, 0, N) {
        if (i % 2 == 0) st1.update(i, { P[i], i });
        else st2.update(i, { P[i], i });
    }
 
    dfs(0, N - 1);
 
    vector<int> ans;
    priority_queue<int> que;
    que.push(-E[0].front());
 
    while (!que.empty()) {
        int q = -que.top(); que.pop();
 
        ans.push_back(q);
        ans.push_back(PA[q]);
 
        fore(i, E[q]) que.push(-i);
    }
 
    rep(i, 0, ans.size()) {
        if (i) printf(" ");
        printf("%d", ans[i]);
    }
    printf("\n");
}

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


void solve(long long N, long long K, std::string S){
    string temp(S), Sr;
    long long count, Srsize=0;
    char st = S[0];
    for (int i=0; i<N-1; i++){
        if (S[i] == S[i+1]) temp.at(i+1) = 'X';
    }
    for (int i=0; i<temp.size(); i++) {
        if (temp[i] != 'X') {
            Sr.push_back(temp[i]);
            Srsize ++;
        }
    }
    count = S.size() ;
    if ((Srsize- 2*K) >= 1) count -= (Srsize- 2*K);
    else count -= 1;
    cout << count << endl;

}
int main(){
    long long N;
    cin >> N;
    long long K;
    cin >> K;
    std::string S;
    std::cin >> S;
    solve(N, K, S);
    return 0;
}


Measured memory_bytes: 768
while True :
  n, r = map(int, input().split())
  if(n == 0 and r == 0) :
    break
  else :
    card = list()
    for i in range(n) :
      card.append(i + 1)
    card = card[::-1]
    for i in range(r) :
      p, c = map(int, input().split())
      card = card[p-1:p+c-1] + card[:p-1] + card[p + c - 1:]
      # スライス
    print(card[0])


Measured memory_bytes: 5612
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i =(b)-1;i>=(a);--i)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
typedef vector<int> vi;
const int mod = 1e9 + 7;
const int maxn = 2e6 + 10;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,a = 100;
	cin >> n;
	ll ans = 0;
	while(a < n){
		a = a + a*0.01;
		++ans;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>


using namespace std;
int main()
{
    int h,m,n;
    cin>>h>>m>>n;
    int a[h*m];
    int dp[h][m];
    for(int i=1,t=0;i<=n;i++)
    {
        int b;
        cin>>b;
        for(int j=0;j<b;j++)
        {
            a[t]=i;
            t++;
        }
    }
 //   for(int i=0;i<h*m;i++)
  //  {
  //      cout<<a[i];
  //  }
    cout<<endl;
    int y=0;
    for(int i=0,t=0;i<h;i++)
    {
        y++;
        if(y%2==0)
        {
            for(int j=0;j<m;j++)
            {
                dp[i][j]=a[t];
                t++;
                cerr<<"l"<<i<<" "<<j<<" "<<dp[i][j]<<"l"<<" ";
            }
        }
        else
        {
            for(int j=m-1;j>=0;j--)
            {
                dp[i][j]=a[t];
                t++;
                cerr<<"l"<<i<<" "<<j<<" "<<dp[i][j]<<"l"<<" ";
            }
        }
        cout<<endl;
    }
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<m;j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  string check = "BGR";
  ll ans = 0;
  int len = s.size();
  do
  {
    vector<ll> memo(len);
    if(s[len-1]==check[2])memo[len-1]++;
    rep(i, len-1)
    {
      if(s[len - i - 2]==check[2])memo[len-i-2]=memo[len-i-1]+1;
      else memo[len-i-2]=memo[len-i-1];
    }
    rep(i,s.size()-2){
      if(s[i] != check[0])continue;
      for (int j = i + 1; j < s.size()-1;j++){
        if(s[j] != check[1])continue;
        ans += memo[j+1];
        if(j+j-i < len && check[2]== s[2*j-i])
          ans--;
      }
    }
  } while (next_permutation(check.begin(), check.end()));
    cout << ans << endl;
}

Measured memory_bytes: 3636
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

std::string S;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >>S;
	char buf[3] = {S[0],S[1]};
	int a = atoi(buf);
	buf[0] = S[2];
	buf[1] = S[3];
	int b = atoi(buf);
	if (0 < b && b <= 12) {
		if (0 < a && a <= 12) {
			out << "AMBIGUOUS" << endl;
		}
		else {
			out << "YYMM" << endl;
		}
	}
	else{
		if (0 < a && a <= 12) {
			out << "MMYY" << endl;
		}
		else {
			out << "NA" << endl;
		}
	}

	return 0;
}
#endif

#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N,M;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N>>M;
	int32_t npow = 1;
	for (int32_t i = 0; i < N; i++)
	{
		npow *= 2;
	}
	
	if (npow-1 <= M) {
		out << "-1" << endl;
		return 0;
	}

	out << M;
	for (int32_t i = 0; i < npow; i++)
	{
		if (i == M) { continue; }
		out << ' ' << i;
	}
	out << ' ' << M;
	for (int32_t i = npow-1; i >= 0; --i)
	{
		if (i == M) { continue; }
		out << ' ' << i;
	}
	out << endl;

	return 0;
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A+B > C+D) cout << "Left" << endl;
  else if(A+B < C+D) cout << "Right" << endl;
  else cout << "Balanced" << endl;
}

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

int main()
{
    int H, W;
    std::cin >> H >> W;

    int h, w;
    std::cin >> h >> w;

    std::cout << ((H * W) - (h * W) - (w * H) + (h * w)) << std::endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut a = a
        .iter()
        .enumerate()
        .map(|(i, x)| (i as i64, *x))
        .collect::<Vec<_>>();
    a.sort_by_key(|x| -x.1);

    let mut dp = vec![vec![0; n + 1]; n + 1];
    for i in 0..n {
        let pi = a[i].0;
        for l in 0..=i {
            let r = i - l;
            use std::cmp::max;
            dp[i + 1][l + 1] = max(dp[i + 1][l + 1], dp[i][l] + (pi - l as i64) * a[i].1);
            dp[i + 1][l] = max(dp[i + 1][l], dp[i][l] + ((n - 1 - r) as i64 - pi) * a[i].1);
        }
    }

    println!("{}", dp[n].iter().max().unwrap());
}


Measured memory_bytes: 33440
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
  vector<int >coins;
  coins.push_back(1);
  int push=1;
  for(int i=1;i<=6;i++){push*=6;coins.push_back(push);}
  push=1;
  for(int i=1;i<=5;i++){push*=9;coins.push_back(push);}
	vector<int >mini(n+1,10000000);
  mini[0]=0;
  for(int i=1;i<=n;i++)
    for(int j=0;j<coins.size();j++)
      if(i-coins[j] >=0 )mini[i] = min(mini[i],mini[i-coins[j]]+1);
  cout<<mini[n];
}

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

typedef long long ll;

ll n, k;
ll a[200010];
ll f[200010];

bool cmp(ll a, ll b) {
	return a > b;
}

bool possible(ll score) {

	ll train = k;

	for(ll i=0;i<n;i++) {

		ll now = a[i] * f[i];
		if(now > score) {
			ll diff = now - score;
			ll use = diff / f[i] + (diff % f[i] > 0);
			train -= use;
		}

		if(train < 0) return 0;

	}

	return train >= 0;

}

int main() {

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

	cin>>n>>k;
	for(ll i=0;i<n;i++) cin>>a[i];
	for(ll i=0;i<n;i++) cin>>f[i];

	sort(a, a+n, cmp);
	sort(f, f+n);

	ll lo = 0;
	ll hi = 1e12;
	ll ans = hi;

	while(lo <= hi) {
		ll mid = (lo + hi) / 2;
		if(possible(mid)) {
			ans = min(ans, mid);
			hi = mid - 1;
		}
		else lo = mid + 1;
	}

	cout<<ans<<endl;

}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

namespace GraphCheck{
    template<typename T> struct is_graph : std::false_type{};
    template<> struct is_graph<vector<vector<int>>> : std::true_type{};
    template<> struct is_graph<vector<set<int>>> : std::true_type{};
    template<> struct is_graph<map<int,vector<int>>> : std::true_type{};
    template<> struct is_graph<map<int,set<int>>> : std::true_type{};


    vector<bool> visited,traversed;

    template<typename T> 
    bool dfs(int v,T& G){
        if(traversed[v]) return true;
        if(visited[v]) return false;
        visited[v] = true;
        traversed[v] = true;

        for(int u : G[v]){
            if(traversed[u]) return true;
            if(dfs(u,G)) return true;
        }

        traversed[v] = false;
        return false;
    }

    template<typename T>
        bool hasCycle(const T& G){
            static_assert(is_graph<T>::value, "T is not appropriate Graph Type");
            visited.assign(G.size(),false);
            traversed.assign(G.size(),false);
            for(int i=0;i<(int)G.size();i++){
                /* cout << i << " --------" << endl; */
                if(visited[i]) continue;
                if(dfs(i,G)) return true;
                /* cout << visited << endl; */
                /* cout << traversed << endl; */
            }
            return false;
        }
};


int main(){
    int v,e;
    cin >> v >> e;
    vector<vector<int>> G(v);
    for(int i=0;i<e;i++){
        int s,t; cin >> s >> t;
        G[s].push_back(t);
    }

    bool cyclic = GraphCheck::hasCycle(G);
    if(cyclic) cout << 1 << endl;
    else cout << 0 << endl; 
}



Measured memory_bytes: 3172
from collections import Counter
N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2

    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a, n

a, n = prime_factorize(N)
c = Counter(a)
ans = 0
for v in c.values():
    for i in range(1, N):
        if v < i: break
        v -= i
        ans += 1
print(ans)

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

int main(){
  int N,count=0;
  cin >> N;
  long long D;
  cin >> D;
  for(int i=0;i<N;i++){
    long long X,Y;
    cin >> X >> Y;
    if(X*X+Y*Y<=D*D){
      count++;
    }
  }
  cout << count << endl;
}
    
  

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

using namespace std;
using ll = long long int;

int main()
{
  int n, m;
  cin >> n >> m;
  vector<pair<ll, ll>> shop(n);
  for(int i = 0; i < n; i++)
  {
    ll a, b;
    cin >> a >> b;
    shop[i] = {a, b};
  }
  sort(shop.begin(), shop.end());
  ll mincost = 0;
  for(int i = 0; i < n; i++) {
    if(m - shop[i].second >= 0)
    {
      m -= shop[i].second;
      mincost += shop[i].first * shop[i].second;
    }else{
      mincost += shop[i].first * m;
      break;
    }
  }
  cout << mincost << endl;
}


Measured memory_bytes: 1792
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265359

using namespace std;

/*ll powMod(ll a, ll y)
{
    ll ans = 1;
    
    while (y > 0) 
    { 
        if (y & 1) 
            ans = (ans*a) % MOD; 
  
        y = y>>1;
        a = (a*a) % MOD; 
    } 
    return ans;
}*/

/*ll modInv(ll a)
{
    return powMod(a, MOD-2);	
}*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    vector <int> v(5);
    int ans;
    for (int i = 0; i < 5; i++) {
        cin >> v[i];
        if (v[i] == 0) ans = i+1;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3560
a,b = map(int,input().split())
if(a==1 and b==1):
    print(1)
else:
    def factorization(n):
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                arr.append([i, cnt])

        if temp!=1:
            arr.append([temp, 1])

        if arr==[]:
            arr.append([n, 1])

        return arr
    fa = factorization(a)
    fb = factorization(b)
    fa = [i[0] for i in fa]
    fb = [i[0] for i in fb]
    c = fa+fb
    print(len(c)-len(set(c))+1)

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

namespace Cs_test
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] n = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
            Console.WriteLine(n[0] + (n[0] > n[1] ? -1 : 0));
        }
    }
}


Measured memory_bytes: 13268
indice = {}
while page_info = gets
  break if page_info.nil? || page_info.empty?
  page_contents, page_number = page_info.strip.split
  indice[page_contents] = [] unless indice.has_key?(page_contents)
  indice[page_contents] << page_number.to_i
end

indice.sort.each do |word, page_numbers|
  puts word
  puts page_numbers.sort.join(" ")
end

Measured memory_bytes: 6088
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

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



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) a.begin(), a.end()
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; }
using namespace std;

template<const long long mod = 1000000007>
struct mint{ //modint
    long long x;
    mint(long long x = 0): x((x %= mod) < 0 ? x + mod : x) {}
    friend istream& operator >> (istream &s, mint& m){ return s >> m.x; }
    friend ostream& operator << (ostream &s, mint m){ return s << m.x; }
    inline mint& operator += (mint a){ if((x += a.x) >= mod)x -= mod; return *this; }
    inline mint& operator -= (mint a){ if((x += mod - a.x) >= mod)x -= mod; return *this; }
    inline mint& operator *= (mint a){ (x *= a.x) %= mod; return *this; }
    inline mint& operator /= (mint a){ return (*this) *= a.inv(); }
    inline mint operator + (mint a){ mint res(*this); return res += a; }
    inline mint operator - (mint a){ mint res(*this); return res -= a; }
    inline mint operator * (mint a){ mint res(*this); return res *= a; }
    inline mint operator / (mint a){ mint res(*this); return res /= a; }
    inline void takemod(){ x = ((x % mod) + mod) % mod; }
    inline mint inv(){
        long long a = x, b = mod, u = 1, v = 0, t;
        while(b){
            t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        return mint(u);
    }
    inline mint pow(long long p){
        mint res(1), tmp(x);
        for(; p; p >>= 1){ if(p & 1)res *= tmp; tmp *= tmp; }
        return res;
    }
};

template<const long long mod = 1000000007>
struct mfact{ //modfact
private:
    vector<mint<mod>> fact, ifact;
public:
    mfact(int size = 200010) : fact(size + 1), ifact(size + 1) {
        fact[0] = mint<mod>(1);
        for(int i = 1; i <= size; i++)fact[i] = fact[i - 1] * mint<mod>(i);
        ifact[size] = fact[size].inv();
        for(int i = size; i > 0; i--)ifact[i - 1] = ifact[i] * mint<mod>(i);
    }
    inline mint<mod> operator [] (int i){ return fact[i]; }
    inline mint<mod> nPr(int n, int r){ return fact[n] * ifact[r]; }
    inline mint<mod> nCr(int n, int r){ return fact[n] * ifact[n - r] * ifact[r]; }
};

int main(){

    int n;
    string s;
    cin >> n >> s;

    if(s[0] == 'W' or s[n * 2 - 1] == 'W'){
        cout << 0 << endl;
        return 0;
    }

    vector<int> vec(n * 2);
    vec[0] = 0;

    rep(i, n * 2 - 1){
        if(s[i] == s[i + 1])vec[i + 1] = vec[i] ^ 1;
        else vec[i + 1] = vec[i];
    }

    int lcnt = 0;
    mint<> ans(1);

    rep(i, n * 2){
        if(vec[i] == 0)lcnt++;
        else {
            ans *= mint<>(lcnt);
            lcnt--;
        }
    }

    if(lcnt != 0){
        cout << 0 << endl;
        return 0;
    }

    cout << ans * mfact<>(n)[n] << endl;
    return 0;

}

Measured memory_bytes: 2948
# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.

Author : Takeshi Saga

"""

import itertools
import numpy as np

tmp = input()
#tmp = "5 3"
N,K = tmp.split()
que = input()
#que = "50 100 80 120 80"
try:
    N = int(N)
except:
    pass
try:
    K = int(K)
except:
    pass



que = [int(x) for x in que.split()]

#print(que)
"""
tmp = []
for x in que:
    for xx in range(K):
        tmp.append(x)
que = tmp
"""
min_val = 999999999

que = sorted(que)

#for x in itertools.combinations(que, K):

x = [que[i] for i in range(K)]
min_val = np.sum(x)

print(min_val)

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

int main()
{
	int N, M;
	cin >> N >> M;

	long long  X[1000],Y[1000],Z[1000], x, y, z,max,result,A[1000];

	for (int i = 0; i < N; i++) {
		cin >> x >> y >> z;
		X[i] = x;
		Y[i] = y;
		Z[i] = z;
	}

	max = 0;

	for (int i = 0; i < 8; i++) {
		result = 0;
		for (int l = 0; l < 1000; l++)
			A[l] = 0;
		for (int j = 0; j < N; j++) {
			if (i == 0)
				A[j] = X[j] + Y[j] + Z[j];
			if (i == 1) 
				A[j] = X[j] + Y[j] - Z[j];
			if (i == 2)
				A[j] = X[j] - Y[j] + Z[j];
			if (i == 3)
				A[j] = X[j] - Y[j] - Z[j];
			if (i == 4)
				A[j] = -1 * X[j] + Y[j] + Z[j];
			if (i == 5)
				A[j] = -1 * X[j] + Y[j] - Z[j];
			if (i == 6)
				A[j] = -1 * X[j] - Y[j] + Z[j];
			if (i == 7)
				A[j] = -1 * X[j] - Y[j] - Z[j];
		}

		sort(A, A + N);
		reverse(A, A + N);
		for (int k = 0; k < M; k++)
			result += A[k];

		if (result > max)
			max = result;
	}
	cout << max;
}

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

#define FOR(s, i, n) for(int i = s; i n; i++)
typedef long long ll;
const int INF = 1e9;

#define onEdge(i, j) (i == 0 || i == n-1 || j == 0 || j == n-1)
#define inBound(i, j) !(i < 0 || i > n-1 || j < 0 || j > n-1)

vector<pair<int,int>> order;
vector<vector<int>> dist;
vector<vector<bool>> seats;
vector<vector<bool>> inq;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {-1, 0, 1, 0};
int n;

void updDist(int x1, int y1){
	queue<pair<int,int>> q;
	q.push({x1, y1});
	inq[x1][y1] = 1;
	while (!q.empty()){
		auto u = q.front();
		q.pop();
		int x = u.first; int y = u.second;
		inq[x][y] = 0;
		int newDist = dist[x][y] + seats[x][y];
		for (int d = 0; d < 4; d++){
			int x2, y2;
			x2 = x + dx[d];
			y2 = y + dy[d];
			if (inBound(x2,y2)){
				if (newDist < dist[x2][y2]){
					dist[x2][y2] = newDist;
					if (!inq[x2][y2]){
						inq[x2][y2] = 1;
						q.push({x2, y2});
					}
				}
			}
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin>>n;
	order.resize(n*n);
	seats.assign(n, vector<bool>(n, 1));
	dist.assign(n, vector<int>(n, INF));
	inq.assign(n, vector<bool>(n, 0));
	for (auto &it: order){
		int a;
		cin>>a;
		a--;
		int x = a/n;
		int y = a%n;
		it.first = x; it.second = y;
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			// if (onEdge(i, j)){
			// 	dist[i][j] = 0;
			// 	updDist(i, j);
			// }
			dist[i][j] = min(min(i, j), min(n - 1 - i, n - 1 - j));
			// cout<<dist[i][j];
		}
		// cout<<'\n';
	}
	int ans = 0;
	for (auto u: order){
		ans += dist[u.first][u.second];
		seats[u.first][u.second] = 0;
		updDist(u.first, u.second);
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 6352
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
# from bisect import *
from collections import *
from heapq import *
# import itertools
import math
# INF = 10**9
# MOD = 10**9+7

N, K = map(int, input().split())
A = [int(x) for x in input().split()]
A.sort()
F = [int(x) for x in input().split()]
F.sort(reverse = 1)
l, r = -1, 10**12
while l+1 < r:
    x = (l+r)//2
    c = 0
    for a, f in zip(A, F):
        if a*f > x:
            c += max(0,a-x//f)
    if c > K:
        l = x
    else:
        r = x
print(r)


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

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    if (B - A >= 2 * K - 1){
    for (int i = 0; i < K; i++){
        cout << A + i << endl;
    }
    for (int i = K - 1; i >= 0; i--){
        cout << B - i << endl;
    }
    }
    else {
        for (int i = 0; A + i <= B ; i++){
        cout << A + i << endl;
    }
    }
}

Measured memory_bytes: 256
x,y = map(int,input().split())
def point(a):
  if a == 1:
    return 300000
  elif a == 2:
    return 200000
  elif a == 3:
    return 100000
  else:
    return 0
  
c = point(x)
b = point(y)

if x == 1 and y == 1:
  print(1000000)
else:
  print(c+b)

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

int main(){
  int N, K; cin >> N >> K;
  if(N<=K){
    cout << 0 << endl;
    return 0;
  }
  vector<int> H(N);
  long long ans=0;
  for(int i=0;i<N;i++){
    cin >> H[i];
    ans+=H[i];
  }
  sort(H.rbegin(),H.rend());
  if(K==0){
    cout << ans << endl;
    return 0;
  }
  for(int i=0;i<K;i++){
    ans-=H[i];
  }
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))

def sort(a):
	count = 0
	for n in range(len(a)):
		min_n = n
		for m in range(n, len(a)):
			if a[m] < a[min_n]:
				min_n = m
		if n != min_n:
			count += 1
			a[n], a[min_n] = a[min_n], a[n]
	return count

count = sort(A)
print(*A)
print(count)



Measured memory_bytes: 5612
n = int(input())

for i in range(n):
    x,y = map(int,input().split())
    if i == 0:
        summax = x+y
        summin = x+y
        diffmax = x-y
        diffmin = x-y

    if x+y > summax:
        summax = x+y
    if x+y < summin:
        summin = x+y
    if x-y > diffmax:
        diffmax = x-y
    if x-y < diffmin:
        diffmin = x-y

a = summax-summin
b = diffmax-diffmin
sol = max(a,b)
print(sol)

Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  long long int ar[n],s=0;
 for(int i=0;i<n;i++)
   cin>>ar[i],s=s^ar[i];
  for(int i=0;i<n;i++)
    cout<<(s^ar[i])<<" ";
  cout<<"\n";
 return 0;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 105;
int N, L;
int A[MAX_N];

signed main()
{
  cin >> N >> L;
  int ans = 0;
  int pos = 0;
  REP(n,N) {
    if(pos <= L) {
      ans++;
    }
    cin >> A[n];
    pos += A[n];
  }

  if(pos <= L) ans++;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b, n;
  cin >> n >> a >> b;
  co(min(a*n, b));
  
  
  return 0;
}


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

int main() {
  int n, p, c = 0;
  vector<int> v, v2;
  cin >> n;
  REP(i, n) {
    cin >> p;
    v.push_back(p);
    v2.push_back(p);
  }
  sort(v.begin(), v.end());
  REP(i, n) if (v[i] != v2[i]) ++c;
  if (c <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
int main()
{
 int n, a;
 int min, max;
 int read;
 long sum;

 min = 1000000;
 max = -1000000;
 sum = 0;

 scanf("%d", &a);

 for(n = 0; n < a; n++){
  scanf("%d", &read);
  if(read < min){
   min = read;
  }
  if(max < read){
   max = read;
  }
  sum = sum + read;
 }

 printf("%d %d %ld\n",min, max, sum);

 return 0;
}

Measured memory_bytes: 600
k = int(input())

def snuke(n):
    def func(a):
        s = 0
        for i in str(a):
            s += int(i)
        return a/s
    
    len_n = len(str(n))
    min_snu = 10 ** 100
    for i in range(len_n):
        snu = str(n)[:len_n-i] + i * '9'
        func_snu = func(int(snu))
        if min_snu > func_snu:
            min_snu = func_snu
            snukee = int(snu)
            
    return snukee

count = 0
n = 1
while count < k:
    next_snuke = snuke(n)
    print(next_snuke)
    n = next_snuke + 1
    count += 1

Measured memory_bytes: 3188
odds :: Integer -> Integer
odds n | n < 0 = 0
       | n < 10 = n
       | n < 100 = odds 9
       | n < 1000 = odds 9 + (n-99)
       | n < 10000 = odds 999
       | n < 100000 = odds 999 + (n-9999)
       | otherwise = odds 99999

main = do
  n <- readLn :: IO Integer
  putStrLn . show $ odds n


Measured memory_bytes: 508
#include <iostream>

int main()
{
    long long int k, a, b; std::cin >> k >> a >> b;
    if (b - a <= 2) {
        std::cout << (k + 1) << std::endl;
        return 0;
    }
    long long v = std::max(0LL, (k-a+1) / 2);
    std::cout << ((b-a) * (v) + (k - v * 2) + 1) << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a, b, c ,d;
    cin >> a >> b >>c >> d;
    cout << max(a * b, c* d) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(I,x,n) for(int I=x;I<n;I++)
using namespace std;
int A[100000],ans[100000];
int main()
{
    int n;
    cin>>n;
    rep(i,0,n)
        cin>>A[i];
    rep(i,0,n)
    {
        ans[0]=A[n-i-1]-ans[0];
    }
    rep(i,1,n)
     ans[i]=2*A[i-1]-ans[i-1];
    rep(i,0,n)
        cout<<ans[i]<<' ';
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
int main(void){
  int a, h, x = 0;
  bool fail = false;
  cin >> h >> a;
  
  vector<int> att(a);
  for(int i=0; i<a; i++){
    cin >> att.at(i);
  }
  
  for(int i=0; i<a; i++){
    h -= att.at(i);
  }
  
  if(h>0)cout << "No" << endl;
  else cout << "Yes" << endl;
  
  return 0;
}

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

int main(){
    int L;
    int l[10];
    int v1, v2;
    int st, la;
    double pass;
    double time;
    char comma;
    while(cin >> l[0]){
        for(int i=1;i<10;i++){
            cin >> comma >> L;
            l[i] = L + l[i-1];
        }
        cin >> comma >> v1 >> comma >> v2;
        time = l[9] / (double)(v1+v2);
        pass = time * v1;
        for(int i=0;i<10;i++){
            if(pass <= l[i]){
                cout << i+1 << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 0
n,m=map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
ans="No"
for i in range(n-m+1):
    for j in range(n-m+1):
        C=[a[i+k][j:j+m] for k in range(m)] 
        if C==b:
            ans="Yes"

print(ans)

Measured memory_bytes: 39152
#include <iostream>
using namespace std;
int main() {
  int N, c; string s;
  cin >> N >> s;
  for(int i = 0; i < N; i++)
    if(s[i] == 'R') ++c;
    else if(s[i] == 'B') --c;
  if(c > 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    int main() 
    {
        long long int a,b,x,temp,out;
        cin>>a>>b>>x;
        temp=a/x;
        if(a%x==0)
        {
            a=temp;
        }
        else
            a=temp+1;
        b=b/x;
        out=b-a+1;
        cout<<out<<endl;
        return 0;
    }

Measured memory_bytes: 3584