akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N;
   cin >> N;
   int p[N];
   map<int, int> log;
   int cnt = 0;
   for (int i = 0; i < N; i++) {
      cin >> p[i];
      if (p[i] == i + 1) cnt++;
      else if (cnt > 0) {
         log[cnt]++;
         cnt = 0;
      }
   }
   if (cnt > 0) log[cnt]++;

   int ans = 0;
   for (auto& it : log) {
      int tmp = it.first;
      ans += (tmp / 2 + tmp % 2) * it.second;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 640
#nの素因数分解を行い、リスト[[素因数,指数],....]を返す
# 2020 = 2^2 * 5^1 * 101^1
#[[2,2],[5,1],[101,1]
def prime_factorize(n):
    #返す配列
    res = []
    for i in range(2,n+1):
        #指数
        ex = 0
        # √Nまで行う
        if i * i > n:
            break
        if n % i != 0:
            continue
        #iで割り続ける
        while ( n % i == 0):
            ex += 1
            n /= i
        #その結果を追加
        res.append([i,ex])
    #最後に残った数について、1でなければ素数なのでリストに加える
    if n != 1:
        res.append([int(n),1])

    return res


N = int(input())
MOD = 1000000007
#exp[p] = 素因数pの指数
exp = [0] * (N+1)

for i in range(2,N+1):
    pf = prime_factorize(i)
    for j in range(len(pf)):
        exp[pf[j][0]] += pf[j][1]

ans = 1
for i in range(2,N+1):
    #約数の個数は(exp +1)の積
    ans *= exp[i] + 1
    ans %= MOD

print(ans)


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    string s;
    cin >> s;
    
    set<char> st;
    for(int i = 0; i < 3; i++)
        st.In(s[i]);
    
    if(st.size() == 2)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int n; cin >> n;
  vector<int> x(n), y(n), h(n);
  int cx, cy, H, idx;
  for(int i = 0; i < n; i++){
    cin >> x[i] >> y[i] >> h[i];
    if(h[i] >= 1){
      cx = x[i];
      cy = y[i];
      //H = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
      idx = i;
    }
  }
  
  for(int cy = 0; cy <= 100; cy++){
    for(int cx = 0; cx <= 100; cx++){
      H = h[idx] + abs(x[idx] - cx) + abs(y[idx] - cy);
      bool judge = true;
      for(int i = 0; i < n; i++){
        if(idx == i) continue;
        if(max(H - abs(x[i] - cx) - abs(y[i] - cy), 0LL) != h[i]) judge = false;
      }
      if(judge){
        cout << cx << " " << cy << " " << H << endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3568
#include<set>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<array>
#include<cstdio>
#include<bitset>
#include<vector>
#include<utility>
#include<sstream>
#include<cstring>
#include <climits>
#include <fstream>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include <unordered_map>
using namespace std;
#define int long long

int32_t main(){
    int n;
    cin >> n;
    int sum = 0;
    for( int i = 1, cur = 1; i <= n; i++, cur++ ){
        sum += 800;
        if( cur == 15 ){
            sum -= 200;
            cur = 0;
        }
    }
    cout << sum << "\n";
}

Measured memory_bytes: 3576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int a = inp[0];
            int b = inp[1];
            int c = inp[2];
            int x = inp[3];
            int y = inp[4];

            bool buyAB = false;            
            if (a + b > 2 * c) buyAB = true;

            int ans = 0;
            int ansOver = Math.Max(x, y) * c * 2;
            if (buyAB)
            {
                while (x > 0 && y > 0)
                {
                    x--;
                    y--;
                    ans += c * 2;
                }
            }
            ans = ans + a * x + b * y;
            Console.WriteLine(Math.Min(ans,ansOver));
        }
    }
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    string in;
    cin >> in;
    deque<char> s;
    for (char c : in) s.push_back(c);
    bool flip = false;
    int q;
    cin >> q;
    rep(i, q) {
        int t;
        cin >> t;
        if (t == 1) {
            flip = !flip;
        }
        else {
            int f;
            char c;
            cin >> f >> c;
            if (flip) f = 3 - f;
            if (f == 1) s.push_front(c);
            else s.push_back(c);
        }
    }
    if (flip) reverse(all(s));
    string ans;
    for (char c : s) {
        ans += c;
    }
    cout << ans << endl;
    return 0;
}


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

int main(void){

	int n;
	while(cin >> n, n){
		int cnt = 0;
		while(n != 1){
			cnt++;
			if(n % 2 == 1){
				n = n * 3 + 1;
			}else{
				n /= 2;
			}
		}
		cout << cnt << endl;
	}

}

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  uint64_t g = gcd(m,n);
  if(m%g==0) return (m/g)*n;
  if(n%g==0) return (n/g)*m;
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

/* 
  //エラトステネスのふるい
  int maxNum = 100000;
  char isNotPrime[maxNum+1] = {};
  isNotPrime[0]=isNotPrime[1]=1;
  for(int i=2;i<maxNum;i++){
    if(isNotPrime[i]==1) continue;
    int num = i+i;
    while(num<=maxNum){
      isNotPrime[num]=1;
      num += i;
    }
  }
*/
// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

// 降順ソート vector<int> v;
// sort(v.begin(),v.end(),greater<int>());

signed main() {
  ll n;
  cin >> n;
  
  map<int,int> factors;
  for(ull i=2;i<=n;i++){
    list<ull> fs;
    primeFactorization(i, fs);
    for(auto f:fs){
      factors[(int)f]++;
    }
  }
  
  ull total = 1;
  for(auto f: factors){
    total *= f.second+1;
    total %= MOD;
  }
  
  cout << total << endl;

  return 0;
}



Measured memory_bytes: 3728
#include <bits/stdc++.h>
 
using namespace std;
 
int INF = 1e9 + 5;
 
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int n, w;
    cin >> n >> w;
    vector<vector<int>> a(n, vector<int> (2));
    for (int i = 0; i < n; i++) {
        cin >> a[i][0] >> a[i][1];
    }
    
    vector<long long> prev(w+1);
    for (int i = 0; i < n; i++) {
        vector<long long> next(w+1);
        for (int j = 0; j <= w; j++) {
            if (j < a[i][0]) {
                next[j] = prev[j];
            }
            else {
                next[j] = max(prev[j], a[i][1] + prev[j - a[i][0]]);
            }
        }
        prev = next;
    }
    cout << prev[w] << endl;
}

Measured memory_bytes: 1804
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
const int inf = 1e9+7;

struct info{
    int color;
    int b,e;
    info(int c, int b, int e):color(c), b(b), e(e){}
    bool operator < (const info &right) const {
        return (color==right.color)? b<right.b : color<right.color;
    }
};

int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        
        set<info> table;      
        set<int> ep;        
        map<int, int> epcolor;
        table.insert(info(-1, 0, inf));
        ep.insert(inf);
        epcolor[inf] = -1;
        for(int i=0; i<n; i++){
            char op;
            cin >> op;
            if(op=='W'){
                int c, size;
                cin >> c >> size;
                set<info>::iterator itr = table.lower_bound(info(-1, -1, -1));
                vector<info> writelist;
                int total=0;
                for(;; itr++){
                    int start=itr->b, end=itr->e;
                    if(end -start +1 +total < size){
                        writelist.push_back(*itr);
                        total += end -start +1;
                    }else{
                        int lim = start + (size-total);
                        table.erase(*itr);
                        table.insert(info(c, start, lim-1));
                        ep.insert(lim-1);
                        epcolor[lim-1] = c;
                        if(lim <= end) table.insert(info(-1, lim, end));
                        break;
                    }
                }
                for(int i=0; i<(int)writelist.size(); i++){
                    info rewrite = writelist[i];
                    rewrite.color = c;
                    table.erase(writelist[i]);
                    table.insert(rewrite);
                    epcolor[writelist[i].e] = c;
                }
            }
            if(op=='D'){
                int c;
                cin >> c;
                set<info>::iterator itr = table.lower_bound(info(c, -1, -1));
                vector<info> deletelist;
                for(;itr->color == c; itr++){
                    deletelist.push_back(*itr);
                }
                for(int i=0; i<(int)deletelist.size(); i++){
                    info rewrite = deletelist[i];
                    rewrite.color = -1;
                    table.erase(deletelist[i]);
                    table.insert(rewrite);
                    epcolor[deletelist[i].e] = -1;
                }
            }
            if(op=='R'){
                int pos;
                cin >> pos;
                cout << epcolor[*(ep.lower_bound(pos))] << endl;
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3844
import sys
sys.setrecursionlimit(10**8)
stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


L, R, d = na()
print(R//d - (L-1) // d)


Measured memory_bytes: 61712
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int count=0,check=0;
    if (S.charAt(0) == 'A') {
      for (int i=2; i<S.length()-1; i++) {
        if(S.charAt(i) == 'C') count++;
      }
      for (int i=0; i<S.length(); i++) {
        if(S.charAt(i) >= 'a' && S.charAt(i) <= 'z') check++;
      }
    }
    if (count == 1 && check == S.length()-2) {
      System.out.println("AC");
    } else {
      System.out.println("WA");
    }
  }
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

template<typename T> bool chmin(T &a,const T b){if(a>b){a=b; return true;}return false;}
template<typename T> bool chmax(T &a,const T b){if(a<b){a=b; return true;}return false;}


int main(){
    int N, Q; cin >> N >> Q;
    string s; cin >> s;

    vi cnt(N+1, 0);
    for(int i=1; i<N; i++){
        if(s[i-1] == 'A' && s[i] == 'C'){
            cnt[i+1]=cnt[i]+1;
        }
        else cnt[i+1]=cnt[i];
    }
    while(Q--){
        int l, r; cin >> l >> r;
        cout << cnt[r]-cnt[l] << endl;
    }
    return 0;
}

Measured memory_bytes: 3844
//start of jonathanirvings' template v3.0.3 (BETA)

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}

//end of jonathanirvings' template v3.0.3 (BETA)

int n;
int ada[100005];
int data[100005];
LL risan = 1;
LL MOD = 1e9 + 7;

int main()
{
  scanf("%d",&n);
  int l = 0, r = n - 1;
  REP(i,n)
  {
    ++ada[abs(r-l)];
    ++l; --r;
  }
  REP(i,n)
  {
    scanf("%d",&data[i]);
    risan = (risan * ada[data[i]]) % MOD;
    --ada[data[i]];
  }
  printf("%lld\n",risan);
  return 0;
}










Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    vector<int> val(4);
    rep(i, 0, 4) {
        val[i] = (int)(S[i] - '0');
    }
    rep(mask, 0, 1 << 3) {
        int sum = val[0];
        string op;
        rep(i, 0, 3) {
            if ((mask >> i) & 1) {
                sum += val[i + 1];
                op += '+';
            }
            else {
                sum -= val[i + 1];
                op += '-';
            }
        }
        if (sum == 7) {
            rep(i, 0, 4) {
                cout << val[i];
                if (i < 3) {
                    cout << op[i];
                }
            }
            cout << "=7" << endl;
            return 0;
        }
    }
    return 0;
}

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

int main(void) {
  int N, M;
  cin >> N >> M;
  vector<int> X(M);
  for (int i = 0; i < M; i++) {
    cin >> X[i];
  }
  if (N >= M) {
    cout << 0 << endl;
  } else {
    sort(X.begin(), X.end());
    vector<int> diff;
    long long sum = 0;
    for (int i = 0; i < M - 1; i++) {
      sum += X[i + 1] - X[i];
      diff.push_back(X[i + 1] - X[i]);
    }
    sort(diff.begin(), diff.end(), greater<int>());
    for (int i = 0; i < N - 1; i++) {
      sum -= diff[i];
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1276
#include<iostream>
#include<cstring>
using namespace std;
string s;
int l;
int i;
string sep(int x,int y){
	string s1="";
	for(i=x;i<=y;i++){
		s1+=s[i];
	}
	return s1;
}
int go(int k){
	if(k==l)return 1;
	if(k+4<l&&sep(k,k+4)=="dream"&&go(k+5))return 1;
	if(k+6<l&&sep(k,k+6)=="dreamer"&&go(k+7))return 1;
	if(k+4<l&&sep(k,k+4)=="erase"&&go(k+5))return 1;
	if(k+5<l&&sep(k,k+5)=="eraser"&&go(k+6))return 1;
	return 0;
}
int main(){
	cin>>s;
	l=s.length();
	if(go(0))cout<<"YES";else cout<<"NO";
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, ans = 0;
  int C = -1;
  cin >> A >> B;
  vector<int>vec(B);
  for(int a=0;a < B;a++){
    cin >> vec.at(a);
    ans += vec.at(a);
  }
  ans = A - ans;
  if(ans >= 0){
    cout << ans;
  }
    else{
      cout << C;
    }
      
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}
 
int main(void){
	
	ll N;
    cin >> N;

    auto prime = prime_factorize(N);
    ll ans = 0;

    for(auto i : prime){
        ll num = i.second, tmp = 0, now = 1;
        while(num >= now){
            num -= now++;
            tmp++;
        }
        ans += tmp;
    }

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

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define ll long long
#define P pair<int, int>

using namespace std;
int mod = 1000000007;

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

  vector<ll> x(n);
  vector<ll> y(m);
  rep(i, n) {
    cin >> x.at(i);
  }
  rep(i, m) {
    cin >> y.at(i);
  }

  n--;
  m--;
  vector<ll> dx(n);
  vector<ll> dy(m);
  rep(i, n) {
    dx.at(i) = x.at(i+1) - x.at(i);
  }
  rep(i, m) {
    dy.at(i) = y.at(i+1) - y.at(i);
  }
  ll sumx = 0;
  ll sumy = 0;
  for(ll i=0; i<n; i++) {
    ll mul = ((n-i)*(i+1))%mod;
    sumx += (dx.at(i)*mul)%mod;
    sumx %= mod;
  }
  for(ll i=0; i<m; i++) {
    ll mul = ((m-i)*(i+1))%mod;
    sumy += (dy.at(i)*mul)%mod;
    sumy %= mod;
  }
  cout << (sumx*sumy)%mod << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const int INF=1<<30,MOD=1000000007;
const ll LINF=1ll<<60;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPARR(i,v) for(int i=0;i<v.size();++i)
#define all(v) (v.begin()),(v.end())
#define bit(n) (1ll<<(n))
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"":"im")<<"possible"<<endl
#define Poss(n) cout<<((n)?"P":"Imp")<<"ossible"<<endl
template<typename T>ostream&operator<<(ostream&o,const vector<T>&v){o<<"{";for(T i:v)o<<i<<',';o<<"}";return o;}
template<typename T>ostream&operator<<(ostream&o,const set<T>&v){o<<"{";for(T i:v)o<<i<<',';o<<"}";return o;}
template<typename T,typename U>ostream&operator<<(ostream&o,const pair<T,U>&v){o<<"("<<v.first<<", "<<v.second<<")";return o;}

int main(){
    string s;
    cin>>s;
    ll ans=0,c=0;
    REPARR(i,s){
        if(s[i]=='W'){
            ans+=i-c;
            c++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {

  int N;
  cin >> N;
  
  
  int f = N % 10;
//  cout << f << endl;

  //  int a = N & 10 ;
  
  int i = 10;
  
  while (i < N) {
  
//    cout << i << "  " << f << endl;
    
//  for (int i = 0; i < N; i++) {
    
    f += N / i % 10;
    i *= 10;
    
    
//    cout << f << endl;
  
  //  cout << N & f << endl;
    
  }
  
//  cout << f << endl;
//  cout << N & f << endl;
  
  if (N % f == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}


Measured memory_bytes: 256
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;
int main(){
    int S;
    cin >> S;
    int h,m,s;
    h=S/3600;
    S-=h*3600;
    m=S/60;
    S-=m*60;
    s=S;
    cout << h << ':' <<  m << ':' << s << endl;
}



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

int main() {
  int n;
  cin >> n;
  cout << n*(n+1)/2 << endl;

  return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define unsigned long long ull
#define long long ll
#define all(x) (x).begin(),(x).end()
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)

using namespace std;

void solve(){            
    int x,y;
    cin>>x>>y;
    int maxlegs = x*4;
    int minlegs = x*2;
    if(y>= minlegs && y<= maxlegs && y%2==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    
    solve();    
    return 0;
}

Measured memory_bytes: 3568
<?php

main();

function main() {
	$points = array();
	while ($line = trim(fgets(STDIN))) {
		list($x, $y) = explode(',', $line);
		$points[] = new Point($x, $y);
	}
	$sum = 0;
	$o = $points[0];
	for ($i = 1; $i < count($points) - 1; $i++) {
		$p1 = $points[$i];
		$p2 = $points[$i+1];

		$T = new Triangle($o, $p1, $p2);
		$sum += $T->getArea();
	}
	echo $sum . "\n";
}

class Triangle {
	public $A, $B, $C;
	public $a, $b, $c;

	public function __construct(Point $A, Point $B, Point $C) {
		$this->A = $A;
		$this->B = $B;
		$this->C = $C;

		$this->a = $B->distanceFrom($C);
		$this->b = $C->distanceFrom($A);
		$this->c = $A->distanceFrom($B);
	}

	public function getArea() {
		$z = ($this->a + $this->b + $this->c) / 2;
		return sqrt($z * ($z - $this->a) * ($z - $this->b) * ($z - $this->c));
	}
}

class Point {
	public $x, $y;

	public function __construct($x, $y) {
		$this->x = $x;
		$this->y = $y;
	}

	public function distanceFrom(Point $p) {
		$dx = $this->x - $p->x;
		$dy = $this->y - $p->y;
		return sqrt($dx * $dx + $dy * $dy);
	}
}

Measured memory_bytes: 6716
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <random>
#include <deque>

#define INF_LL 1e18
#define INF 1e9

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

using namespace std;

using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

const ll MOD = 1e9+7;

int dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
int dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

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

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

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

class RMQ{
	int n;
	vector<int> dat;
public:
	RMQ(int n_){
		n = 1;
		while(n < n_) n *= 2;
		REP(i, n*2-1){
			dat.push_back(INF);
		}
	}

	void update(int x, int i){
		i += n-1;
		dat[i] = x;
		while(i > 0){
			i = (i-1)/2;
			dat[i] = min(dat[i*2+1], dat[i*2+2]);
		}
	}

	int query(int a, int b, int l, int r, int x){
		if(a <= l && r <= b) return dat[x];
		if(r <= a || b <= l) return INF;

		int res = INF;
		res = min(query(a, b, l, (l+r)/2, x*2+1), query(a, b, (l+r)/2, r, x*2+2));
		return res;
	}
	int query(int a, int b){
		return query(a, b, 0, n, 0);
	}
};

const ll mod = 1e9+7;

int N, K;
vector<ll> a;
bool dp[5050] = {};

bool ok(ll in){
	if(in >= N) return true;
	memset(dp, 0, sizeof(dp));
	dp[0] = true;
	REP(i, N){
		if(i == in) continue;
		for(int j = K+1;j >= a[i];j--){
			if(dp[j-a[i]]) dp[j] = true;
		}
	}
	FOR(i, max(0, (int)K-(int)a[in]), K){
		if(dp[i]){
			return true;
		}
	}
	return false;
}

int main(void){
	cin >> N >> K;
	REP(i, N){
		int A;
		cin >> A;
		a.push_back(A);
	}
	int l = 0, r = N, m;
	sort(all(a));
	while(r-l > 1){
		m = (l+r)/2;
		if(ok(m)){
			r = m;
		}else{
			l = m;
		}
	}
	if(ok(l)){
		cout << l << endl;
	}else if(ok(r)){
		cout << l+1 << endl;
	}else{
		cout << r+1 << endl;
	}
}


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

now_t , now_x , now_y = 0, 0, 0
flag = 1
for _ in range(n):
    next_t , next_x, next_y = map(int,input().split())
    diff_t = next_t - now_t
    diff_x = next_x - now_x
    diff_y = next_y - now_y
    diff = diff_t - (diff_x+diff_y)
    if diff >= 0:
        if diff%2 == 0:
            pass
        else:
            flag= 0
    else:
        flag = 0
    
    now_t , now_x , now_y = next_t , next_x, next_y

if flag == 1:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String a = "Three";
		for(int i = 1; i <= n; i++) {
                if(sc.next().equals("Y")) a = "Four";
		}
        System.out.println(a);
		}	
}


Measured memory_bytes: 21588
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, K; string S; cin >> N >> S >> K;
    for (int i = 0; i < N; ++i) if (S[i] != S[K - 1]) S[i] = '*';
    cout << S << endl;
}


Measured memory_bytes: 3536
/*RUSTAM1111 🦁🦁🦁💪💪💪😎😎😎🔥🔥🔥🔥⚔️⚔️⚔️*/
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	string s;
	cin>>s;
	if(s >= "A" && s<="Z" )
	{
		cout<<"A"<<endl;
	}
	else
	{
		cout<<"a"<<endl;
	}
}
/*RUSTAM1111 🦁🦁🦁💪💪💪😎😎😎🔥🔥🔥🔥⚔️⚔️⚔️*/


Measured memory_bytes: 3632
#include<iostream>

int main(){
    int c1,c2,c3,c4,c5,c6;
    std::cin>>c1>>c2>>c3>>c4>>c5>>c6;
    if(c1+c2*5+c3*10+c4*50+c5*100+c6*500>=1000){
        std::cout << 1 << std::endl;
    }else {
        std::cout << 0 << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int h = sc.nextInt(), w = sc.nextInt();
		char[][] map = new char[h][w];
		for (int i = 0; i < h; i++) {
			map[i] = sc.next().toCharArray();
		}
		char[][] red = new char[h][w];
		char[][] blue = new char[h][w];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if(map[i][j] == '#') {
					red[i][j] = blue[i][j] = '#';
					continue;
				}
				if((i % 2 == 0 && j != w-1) || (i % 2 == 1 && j == 0)) {
					red[i][j] = '#';
					blue[i][j] = '.';
				} else {
					red[i][j] = '.';
					blue[i][j] = '#';
				}
			}
		}
		printArr(red);
		System.out.println();
		printArr(blue);
	}

	static void printArr(char[][] arr) {
		for (char[] chars : arr) {
			for (char c : chars) {
				System.out.print(c);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 51008
import numpy as np
n,w=map(int,input().split())
a=np.zeros([n,w+1],dtype=int)
c,d=map(int,input().split())
a[0][c:]=d
for i in range(1,n):
    e,f=map(int,input().split())
    a[i][:e]=a[i-1][:e]
    a[i][e:]=np.maximum(a[i-1][e:],a[i-1][:-e]+f)
print(a[-1][-1])

Measured memory_bytes: 91972
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7)

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	int m = max(a, max(b, c));
	while (true) {
		int num = 3 * m - a - b - c;
		if (num >= 0 && num % 2==0) {
			cout << num / 2 << endl;
			return 0;
		}
		else {
			m++;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int N;
	cin >> N;
	int ans = 1;
	rep(i, N) {
		int num;
		cin >> num;
		ans = lcm(ans, num);
	}
	cout << ans;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {

			String str = kb.readLine();
			char[] strArr = str.toCharArray();
			for( int i=0; i<strArr.length; i++ ) {
				if( 'a'<=strArr[i] && strArr[i]<='z' ) {
					System.out.printf( "%s", String.valueOf( strArr[i] ).toUpperCase() );
				} else if( 'A'<=strArr[i] && strArr[i]<='Z' ) {
					System.out.printf( "%s", String.valueOf( strArr[i] ).toLowerCase() );
				} else {
					System.out.printf( "%c", strArr[i] );
				}	
			}
			System.out.printf( "\n");
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}

Measured memory_bytes: 20268
using System;

namespace AOJ.Volume0
{
    public class SumAndAverage
    {
        public static int Main()
        {
            long amount = 0;
            long qty = 0;
            long data_cnt = 0;
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }

                var data = input.Split(',');
                amount += long.Parse(data[0]) * long.Parse(data[1]);
                qty += long.Parse(data[1]);
                data_cnt++;
            }
            double avg = (qty / data_cnt) + 0.5;
            Console.WriteLine(amount);
            Console.WriteLine(string.Format("{0:N0}", avg));
            return 0;
        }
    }
}

Measured memory_bytes: 9140
#include<iostream>
#include<string>
#include<stdio.h>
#include<cmath>
using namespace std;

#define max(a,b) a > b ? a : b

int main() {

    int N;

    int A[100];

    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        if (A[i] % 2 == 0)
        {
            if (A[i] % 3 != 0 && A[i] % 5 != 0)
            {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }

    cout << "APPROVED" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };
char da[4] = { 'R', 'L', 'D', 'U' };
char dad[4] = { 'L', 'R', 'U', 'D' };
ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }

ll N;




int main() {
	string S;

	cin >> S;

	int a1 = (S[0] - '0') * 10 + (S[1] - '0');
	int a2 = (S[2] - '0') * 10 + (S[3] - '0');
	bool f1 = false, f2 = false;

	if (a2 <= 12 && a2 >= 1) {
		f1 = true;
	}
	
	if (a1 <= 12 && a1 >= 1) {
		f2 = true;

	}


	if (f1 == true && f2 == true) {

		cout << "AMBIGUOUS" << endl;
	}
	else if (f1 == false && f2 == true) {

		cout << "MMYY" << endl;
	}

	else if (f1 == true && f2 == false) {
		cout << "YYMM" << endl;
	}

	else {

		cout << "NA" << endl;
	}

	
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N,T;cin >> N >> T;
    vector<int> t(N);rep(i,N)cin >> t[i];

    LL ans = 0;
    rep(i,N){
        if(i == 0)continue;
        if(t[i] - t[i-1] >= T)ans += T;
        else{
            ans += (t[i] - t[i-1]);
        }
    }
    ans += T;
    
    cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s;
        int ans = 0;
        int countA = 0;
        int countB = 0;
        int countAB = 0;

        for (int i = 0; i < n; i++) {
            s = sc.next();
            char c1 = s.charAt(0);
            char c2 = s.charAt(s.length() - 1);
            for (int j = 0; j < s.length() - 1; j++) {
                if (s.charAt(j) == 'A' && s.charAt(j + 1) == 'B')
                    ans++;
            }
            if (c1 == 'B' && c2 == 'A')
                countAB++;
            else if (c1 == 'B')
                countB++;
            else if (c2 == 'A')
                countA++;
        }

        if (countB + countA + countAB == 0)
            System.out.println(ans);
        else if (countB + countA == 0)
            System.out.println(ans + countAB - 1);
        else if (countAB == 0)
            System.out.println(ans + Math.min(countA, countB));
        else
            System.out.println(ans + countAB + Math.min(countA, countB));

        sc.close();
    }
}

Measured memory_bytes: 31744
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n){
        int A[101];
        rep(i, n){
            cin >> A[i];
        }
        int minj;
        int ans = 0;
        rep(i, n){
            minj = i;
            range(j, i ,n){
                if(A[j] < A[minj]){
                    minj = j;
                }
            }
            int num = A[i];
            A[i] = A[minj];
            A[minj] = num;
            if(i != minj) ans++;
        }
        rep(i, n){
            if(!i) cout << A[i];
            else cout << ' ' << A[i];
        }
        cout << endl << ans << endl;
    }
}

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

vector<int> vals;
int rt[200005][30];
int lt[200005][30];
int n,v;
int pos[200005];
int memo1[600005];
int memo2[600005];
int something[200005];

int dpL(int bitmask){
    if (memo1[bitmask]!=-1) return memo1[bitmask];
    if (bitmask==0) return memo1[bitmask] = -1;
    int ans = 0;
    for (int x = 0; x<vals.size(); x++){
        if (bitmask&(1<<x)){
            ans = max(ans,dpL(bitmask^(1<<x)));
            ans = max(ans,rt[dpL(bitmask^(1<<x))+1][x]);
        }
    }
    return memo1[bitmask] = ans;
}

int dpR(int bitmask){
    if (memo2[bitmask]!=-1) return memo2[bitmask];
    if (bitmask==0) return memo2[bitmask] = n;
    int ans = n-1;
    for (int x = 0; x<vals.size(); x++){
        if (bitmask&(1<<x)){
            ans = min(ans,dpR(bitmask^(1<<x)));
            if (ans==0) break;
            ans = min(ans,lt[dpR(bitmask^(1<<x))-1][x]);
        }
    }
    return memo2[bitmask] = ans;
}

int main(){
    memset(memo1,-1,sizeof(memo1));
    memset(memo2,-1,sizeof(memo2));
    scanf("%d%d",&n,&v);

    int t = v;
    while (t>0){
        vals.push_back(t);
        t/=2;
    }
    vals.push_back(0);
    for (int x = 0; x<n; x++){
        scanf("%d",&pos[x]);
    }
    for (int i = 0; i<vals.size(); i++){
        rt[n-1][i] = n-1;
        for (int x = n-2; x>=0; x--){
            rt[x][i] = pos[x+1]-pos[x]<=vals[i]?rt[x+1][i]:x;
        }
        lt[0][i] = 0;
        for (int x = 1; x<n; x++){
            lt[x][i] = pos[x]-pos[x-1]<=vals[i]?lt[x-1][i]:x;
        }
    }
    for (int x = 0; x<n; x++){
        something[x] = n+1;
    }
    int tempbug = n+1;
    for (int x = 0; x<(1<<(vals.size())); x+=2){
        int other = ((1<<(vals.size()))-2)^x;
        if (dpL(x)==-1) {
            tempbug = min(tempbug,dpR(other));
            continue;
        }
        something[dpL(x)] = min(something[dpL(x)],dpR(other));
    }
    for (int x = n-2; x>=0; x--){
        something[x] = min(something[x],something[x+1]);
    }
    tempbug = min(tempbug,something[0]);
    for (int x = 0; x<n; x++){
        int L = lt[x][0];
        int R = rt[x][0];
        if (L==0){
            printf(tempbug<=R+1?"Possible\n":"Impossible\n");
            continue;
        }
        //printf("something %d %d\n",x,something[x]);
        //printf("L:%d,R:%d\n",L,R);
        printf(something[L-1]<=R+1?"Possible\n":"Impossible\n");
    }
    //printf("%d\n",dpL(6));
}


Measured memory_bytes: 55552
class Main{

	public static void main (String[] args) {

		Main main = new Main();

		java.util.Scanner sc = new java.util.Scanner(System.in);

		int N = sc.nextInt();
		int[] list = new int [N];

		for (int index=0; index<N; index++) {
			list[index]=sc.nextInt();
		}

		long money = 1000;
		long kabu = 0;

		for (int index=0; index<N; index++) {
			if (index==0) {
				if (list[index]<list[index+1]) {
					long kosuu = money/list[index];
					money-=kosuu*list[index];
					kabu+=kosuu;
				}
			} else if (index==N-1) {
				money+=kabu*list[index];
				kabu=0;
			} else {
				boolean before=true;
				boolean after=true;

				if (list[index-1]>=list[index]) {
					before = false;
				}
				if (list[index]>=list[index+1]) {
					after = false;
				}

				if (before&&!after) {
					money+=kabu*list[index];
					kabu=0;
				} else if (!before&&after) {
					long kosuu = money/list[index];
					money-=kosuu*list[index];
					kabu+=kosuu;
				}
			}
		}

		if (money<1000) {
			money = 1000;
		}

		System.out.println(money);

		sc.close();;

	}

}


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

int main() {
  int a,b;
  cin>>a>>b;
  if(a>=b){
    for(int i=0;i<a;i++) cout<<b;
    cout<<endl;
  }
  else{
    for(int i=0;i<b;i++) cout<<a;
    cout<<endl;
  }
}
   

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

int main(){
  int n,k; string s;
  cin >> n >> k >> s;
  for(int i = 0; i < n; i++){
    if(i+1 == k){
      if(s[i] == 'A'){
        cout << 'a';
      }else if(s[i] == 'B'){
        cout << 'b';
      }else{
        cout << 'c';
      }
    }else{
      cout << s[i];
    }
  }
  cout << endl;
  return 0;
}

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

void dispInterState(int a[], int N){
    for(int i = 0; i < N; i++){
        if(i) cout << ' ';
        cout << a[i];
    }
    cout << endl;
}

int main() {
    int N, a[100];

    cin >> N;
    for(int i = 0; i < N; i++) cin >> a[i];
    dispInterState(a, N);

    int cur, j;
    for(int i = 1; i < N; i++){
        cur = a[i];
        j = i - 1;
        while(j >= 0 && a[j] > cur){
            a[j + 1] = a[j];
            a[j] = cur;
            j--;
        }
        dispInterState(a, N);
    }

    return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
using namespace std;
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; }
const ll INF=1LL<<60;

int n;
//vector<vector<ll>> dp(10005,vector<ll>(3,0));
long long dp[100010][3];
int main(){
    cin>>n;
    vector<vector<ll>> a(n,vector<ll>(3));
    rep(i,n) rep(j,3) cin>>a[i][j];
    rep(i,n){
        rep(j,3){
            rep(k,3){
                if(j==k) continue;
                chmax(dp[i+1][k],dp[i][j]+a[i][k]);
            }
        }
    }
    ll res=0;
    rep(i,3) chmax(res,dp[n][i]);
    cout<<res<<"\n";
    return 0;
}

Measured memory_bytes: 10988
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	string s,t,ans; cin>>s>>t;
	for(int i=0;i<n;i++){
		ans+=s[i];
		ans+=t[i];
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
   int N;
   cin >> N;
   double x[N];
   string u[N];
   for(int i=0;i<N;i++){
     cin >> x[i] >> u[i];
   }
   double sum=0;
   for(int i=0;i<N;i++){
     if(u[i]=="BTC"){
       sum += x[i]*380000;
     }
     else
     sum += x[i];
   }
   cout << sum << endl;

}


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

using namespace std;

map<char,int> a;
int main(){
  int a,b,k;
  cin >> a >> b >> b >> b >> b >> k;
  
  
	if(b-a <= k) cout << "Yay!";
  	else cout << ":(";
}


Measured memory_bytes: 256