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

// long long gcd(long long a, long long b) {
//     if (a < b) {
//         return gcd(b, a);
//     } else if (b == 0) {
//         return a;
//     } else {
//         while (a % b != 0) {
//             int r = b;
//             b = a % b;
//             a = r;
//         }
//         return b;
//     }
// }

int main() {
    long long ans = 0;
    int K; cin >> K;
    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= K; j++) {
            for (int k = 1; k <= K; k++) {
                ans += gcd(gcd(i, j), k);
            }
        }
    }
    cout << ans << endl;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
void debug(vector<T> &vec) {
    for (auto x : vec) {
        cout << x << " ";
    }
    cout << endl;
    return;
}

template <typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

template <typename T>
int getFormer(const vector<T> &vec, T x) {
    return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}

template <typename T>
int getLatter(const vector<T> &vec, T x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

void solve(int n, int k) {
    n += 1;
    vector<int> a(n, 0);
    REP(i, k) {
        int input;
        cin >> input;
        a[input] = 1;
    }

    if (a[0] == 0) {
        int ans = 0;
        for (int left = 0; left < n; left++) {
            if (a[left] == 0) continue;
            int right = left + 1;
            while (right < n && a[right] == 1) {
                right += 1;
            }
            ans = max(ans, right - left);
        }

        cout << ans << endl;

    } else {
        int ans = 0;
        for (int left = 1; left < n; left++) {
            if (a[left] == 0) continue;
            int right = left + 1;
            while (right < n && a[right] == 1) {
                right += 1;
            }

            int nextStart = right;
            right += 1;
            while (right < n && a[right] == 1) {
                right += 1;
            }

            ans = max(ans, right - left);
            left = nextStart;
        }

        cout << ans << endl;
    }
}

int main() {
    int n, k;
    while (cin >> n >> k && n) {
        solve(n, k);
    }
    return 0;
}


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

class union_find {
public:
    union_find(int n) : par(n, -1)
    {}

    int root(int x) {
        return par[x] < 0 ? x : par[x] = root(par[x]);
    }

    bool unite(int x, int y) {
        x = root(x), y = root(y);
        if(x == y) {
            return false;
        }
        if(par[x] < par[y]) {
            par[x] += par[y];
            par[y] = x;
        } else {
            par[y] += par[x];
            par[x] = y;
        }
        return true;
    }

    int size(int x) {
        x = root(x);
        return -par[x];
    }

private:
    vector<int> par;
};


int main() {
    int N, W, H;
    cin >> N >> W >> H;
    vector<vector<int>> sx(W), sy(H);
    bool f = false;
    for(int i=0; i<N; ++i) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        sx[x].push_back(i);
        sy[y].push_back(i);
        f |= x == 0 || x == W-1 || y == 0 || y == H-1;
    }
    union_find uf(N);
    for(int i=0; i<H; ++i) {
        for(int j=0; j<(int)sy[i].size()-1; ++j) {
            uf.unite(sy[i][j], sy[i][j+1]);
        }
    }
    for(int i=0; i<W; ++i) {
        for(int j=0; j<(int)sx[i].size()-1; ++j) {
            uf.unite(sx[i][j], sx[i][j+1]);
        }
    }
    int cnt = 0;
    int res = 0;
    for(int i=0; i<N; ++i) {
        if(uf.root(i) == i) {
            res += uf.size(i) - 1;
            cnt++;
        }
    }
    if(cnt != 1) {
        res += 2*cnt - 1 - f;
    }
    cout << res << endl;
}


Measured memory_bytes: 9708
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
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; }

int main(){
    int N,K; cin >> N >> K;
    vector <int> cnt(200001,0);
    rep(i,N){
        int a; cin >> a;
        cnt[a-1]++;
    }
    priority_queue<int, vector<int>, greater<int>> pq;
    rep(i,N) pq.push(cnt[i]);
    int ans=0;
    while(pq.size()>K){
        ans+=pq.top(); pq.pop();
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 2168
#include <iostream>
#include <queue>
#include <vector>
#include <stack>
#include <list>
#include <queue>
using namespace std;

int main()
{
    int n;
    cin>>n;
    if(n%2==0)
    {
       printf("%.7f",(double)(n/2)/n);
    }
    else
    {
         printf("%.7f",(double)(n/2+1)/n);
    }
    return 0;
}


Measured memory_bytes: 3740
import java.io.*;
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main/*Change to Main When Submitting*/ {
    static BufferedReader __in;
    static PrintWriter __out;
    static StringTokenizer input;

    public static void main(String[] args) throws IOException {
        __in = new BufferedReader(new InputStreamReader(System.in));
        __out = new PrintWriter(new OutputStreamWriter(System.out));

        int N = readInt();
        Set<String> s = new HashSet<>();
        for(int i = 0; i < N; ++i) {
            s.add(readLine());
        }
        println(s.size());

        close();
    }

    static final int IBIG = 1000000007;
    static final int IMAX = 2147483647;
    static final long LMAX = 9223372036854775807L;
    static void read() throws IOException {input = new StringTokenizer(__in.readLine());}
    static String readLine() throws IOException {return __in.readLine();}
    static int nextInt() {return Integer.parseInt(input.nextToken());}
    static int readInt() throws IOException {return Integer.parseInt(__in.readLine());}
    static long nextLong() {return Long.parseLong(input.nextToken());}
    static void print(String s) {__out.print(s);}
    static void println(String s) {__out.println(s);}
    static void print(Object o) {__out.print(o);}
    static void println(Object o) {__out.println(o);}
    static void printy() {__out.println("Yes");}
    static void printY() {__out.println("YES");}
    static void printn() {__out.println("No");}
    static void printN() {__out.println("NO");}
    static void printyn(boolean b) {__out.println(b ? "Yes" : "No");}
    static void printYN(boolean b) {__out.println(b ? "YES" : "NO");}
    static void println(int... a) {for(int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), i++); __out.println(a[a.length - 1]);}
    static void println(long... a) {for(int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), i++); __out.println(a[a.length - 1]);}
    static void println() {__out.println();}
    static void close() {__out.close();}
}

Measured memory_bytes: 66172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#include<iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<double,double>;
using vvi = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
    ll a,b,c,d;
    cin >>a>>b>>c>>d;
    ll maxi = max({a*c,a*d,b*c,b*d});
    cout << maxi << endl;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int aa[100005],bb[100005];
multiset<int,greater<int> >cc;
int main()
{
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    for(int i=0;i<a;i++)
    {
        cin>>aa[i];
    }
    for(int i=0;i<b;i++)
    {
        cin>>bb[i];
    }
    for(int i=0;i<c;i++)
    {
        int m;
        cin>>m;
        cc.insert(m);
    }
    sort(aa,aa+a,greater<int>());
    sort(bb,bb+b,greater<int>());
    for(int i=0;i<x;i++)
    {
        cc.insert(aa[i]);
    }
    for(int i=0;i<y;i++)
    {
        cc.insert(bb[i]);
    }
    long long ans=0;
    int jsq=0;
    for(multiset<int,greater<int> >::iterator it=cc.begin();it!=cc.end();it++)
    {
        ans+=*it;
        jsq++;
        if(jsq==x+y)break;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;

int main(){
    ll N;
    cin >> N;
    ll sum = 1;
    ll diff = 1;
    ll over = 1;

    rep(i, N){
        sum *= 10;
        sum %= MOD;
    }

    rep(i, N){
        over *= 8;
        over %= MOD; 
    }    

    rep(i, N){
        diff *= 9;
        diff %= MOD; 
    }

    diff *= 2;
    diff = (diff % MOD) - (over % MOD);
    ll ans = sum - diff;
    ans %= MOD;
    if(ans < 0){
        cout << ans + MOD << endl;
    }
    else{
        cout << ans << endl;
    }
    
}

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

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  bool a[n+1];
  for (int i = 0; i < n+1; i++) {
    a[i] = true;
  }

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

  long long p[n+1];
  for (int i = 0; i < n+1; i++) {
    p[i] = 0;
  }

  p[0] = 1;
  for (int i = 1; i < n+1; i++) {
    if (!a[i]) continue;
    long long a1 = 0;
    long long a2 = 0;
    if (i - 2 >= 0) {
      if (a[i - 2]) {
        a1 = p[i - 2];
      }
    }

    if (i - 1 >= 0) {
      if (a[i - 1]) {
        a2 = p[i - 1];
      }
    }

    p[i] = (a1 + a2) % 1000000007;
  }

  cout << p[n] << "\n";
  return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

const ll mod = (ll)1e9 + 7;

ll merge_cnt(vector<int> &a) {
  int n = a.size();
  if (n <= 1) { return 0; }

  ll cnt = 0;
  vector<int> b(a.begin(), a.begin()+n/2);
  vector<int> c(a.begin()+n/2, a.end());

  cnt += merge_cnt(b);
  cnt += merge_cnt(c);

  int ai = 0, bi = 0, ci = 0;
  while (ai < n) {
    if ( bi < b.size() && (ci == c.size() || b[bi] <= c[ci]) ) {
      a[ai++] = b[bi++];
    } else {
      cnt += n / 2 - bi;
      a[ai++] = c[ci++];
    }
  }
  return cnt;
}

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

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

  ll ans = 0;

  ans += (merge_cnt(a) % mod) * (k % mod);
  sort(a.begin(), a.end(), greater<int>() );
  // 計算順序に注意 ( OverFlow! )
  ans += ( (k * (k-1) / 2) % mod) * (merge_cnt(a) % mod);
  cout << ans % mod << endl;

  return 0;
}

Measured memory_bytes: 256
def main
  _, req_num = ARGF.gets.split.map(&:to_i)

  requests = []
  req_num.times do
    requests << ARGF.gets.split.map(&:to_i)
  end

  requests.sort_by! {|item| item[1]}
  # puts requests

  # 切断した場所 例）1の場合、1-2 の間を切断したという意味
  last = 0
  cnt = 0
  requests.each do |(a, b)|
    if last < a
      last = b - 1
      cnt += 1
    end
  end

  puts cnt
end

if __FILE__ == $0
  main
end


Measured memory_bytes: 12664
#include <bits/stdc++.h>
using namespace std;
static const int N = 1000;

int LCS(string x, string y)
{
    int c[N + 1][N + 1];
    int m = x.size();
    int n = y.size();
    int maxl = 0;
    x = ' ' + x;
    y = ' ' + y;
    for ( int i = 0; i <= m; i++) c[i][0] = 0;
    for ( int j = 0; j <= n; j++) c[0][j] = 0;

    for ( int i = 1; i <= m; ++i) {
        for ( int j = 1; j <= n; ++j) {
            if (x[i] == y[j]) {
                c[i][j] = c[i - 1][j - 1] + 1;
            } else {
                c[i][j] = max(c[i - 1][j], c[i][j - 1]);
            }
            maxl = max(maxl, c[i][j]);
        }
    }

    return maxl;
}

int main(void)
{
    string X, Y;
    int n; cin >> n;

    for (int i = 0; i < n; ++i ) {
        cin >> X >> Y;
        cout << LCS(X, Y) << endl;
    }
    return 0;
}



Measured memory_bytes: 7108
#include <stdio.h>

int main()
{
  int N, i ,k , v, j, sort;
  int A[100];

  scanf("%d",&N);
  
  for(i = 0;i < N;i++){
    scanf("%d",&A[i]);
  }
  
  for(i = 0;i < N;i++){
    v = A[i];
    j = i - 1;
 
    while(j >= 0 && A[j] > v){
      sort = A[j+1];
      A[j+1] = A[j];
      A[j] = sort;
      j--;
    }
    A[j+1] = v;
   for(k = 0;k < N;k++){
      if(k)printf(" ");
      printf("%d",A[k]);
    }
    printf("\n");
  }
 
  return 0;
}




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

#define int long long

void maxself(int &a, int b) {a=max(a,b);}

int32_t main(){
    int n,w;cin>>n>>w;
    vector<int> dp(w+1);
    //dp[i] is the maximum total value of the items with total weight <=i
    for(int i=0;i<n;i++){
        int weight, value;cin>>weight>>value;
        for(int wt_already=w-weight;wt_already>=0;wt_already--){
            maxself(dp[wt_already+weight], dp[wt_already]+value);
        }
    }
    cout<<dp[w]<<endl;
    
    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

// 最大公約数
ll gcd(ll a, ll b) {
   if (a%b == 0) {
       return(b);
   } else {
       return(gcd(b, a%b));
   }
}

// 最小公倍数
ll lcm(ll a, ll b) {
   return a / gcd(a, b) * b;
}

int main() {
  ll A, B; cin >> A >> B;
  ll C, D; cin >> C >> D;
  ll ALL = B - A + 1;
  ll c = B / C - (A - 1) / C;
  ll d = B / D - (A - 1) / D;
  ll cd = B / lcm(C, D) - (A - 1) / lcm(C, D);
  cout << ALL - c - d + cd << endl;
}

Measured memory_bytes: 3624
a, b, c, d = map(int, input().split())
on_a = False
on_b = False

count = 0
for i in range(d+1):
    if i == a:
        on_a = True
    if i == b:
        on_a = False
    if i == c:
        on_b = True
    if i == d:
        on_b = False

    if on_a and on_b:
        count += 1

print(count)

Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int g[2][105];
int c;

int main() {
  scanf("%d", &c);
  for(int i = 0; i < 2; i++) {
    for(int j = 0; j < c; j++) {
      scanf("%d", &g[i][j]);
    }
  }
  int ret = 0;
  for(int j = 0; j < c; j++) {
    int curr = 0;
    for(int a = 0; a <= j; a++) {
      curr += g[0][a];
    }
    for(int a = j; a < c; a++) {
      curr += g[1][a];
    }
    ret = max(ret, curr);
  }
  printf("%d\n", ret);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 200005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
typedef v(string) vs;


int main() {
  multiset<string> s;
  rep(i,3) {
    int n;
    scanf("%d",&n);
    rep(j,n) s.insert(string(1,'a'+i));
  }
  while (sz(s) > 1) {
    auto it = s.end(); --it;
    string x = *(s.begin()) + *it;
    s.erase(it); s.erase(s.begin());
    s.insert(x);
  }
  cout<<*(s.begin())<<endl;
  return 0;
}






















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

using namespace std;

int main()
{
    int k;
    cin>>k;
    string s;
    cin>>s;
    if (s.length()<=k)
    {
        cout<<s;
        return 0;
    }
    for (int i=0;i<k;i++)
        cout<<s[i];
    cout<<"...";
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N =1e5+5;
const ll mod=1e9+7;
int main()
{
    ll a,b;
    cin>>a>>b;
    if((a+b)%2)puts("IMPOSSIBLE");
    else
        printf("%d",(a+b)/2);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;
const ll MAX_H = 2e5;
const ll MAX_W = 2e5;

Vec par;

void init(ll n){
  repn(i, n) par[i] = i;
}

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

void unionRoot(ll x, ll y){
  x = find(x);
  y = find(y);
  if(x != y) par[x] = y;
}

int main(void){
	ll n, m;
	cin >> n >> m;
	par.resize(n+1);
	VecP edges(m);
	rep(i, m){
		cin >> edges[i].fs >> edges[i].sc;
	}

	ll ans = 0;
	rep(i, m){
		init(n);
		rep(j, m){
			if(i == j) continue;
			unionRoot(edges[j].fs, edges[j].sc);
		}

		ll cnt = 0;
		repn(i, n) if(find(i) == i) cnt++;
		if(cnt >= 2) ans++;
	}
	co(ans);

	return 0;
}


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

using namespace std;

int main(int argc, char const *argv[]) {
	int N;
	std::cin >> N;
	int p[N+1];
	p[0] = -1;
	for (size_t i = 1; i < N+1; i++) {
		std::cin >> p[i];
	}

	int count = 0;
	for (size_t i = 1; i < N+1; i++) {
		if (p[i] == i) {
			swap(p[i],p[i+1]);
			count++;
		}
	}

	std::cout << count << '\n';
	return 0;
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A_Nickname solver = new A_Nickname();
        solver.solve(1, in, out);
        out.close();
    }

    static class A_Nickname {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            out.println(in.next().substring(0, 3));
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 32620
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>
#include<functional>
typedef long long ll;
#define INF 99999999
int main() {
	int a = 0, b = 0, c = 0, n = 0;
	int some = 0;
	std::vector<int> v;
	std::string str;
	for (int i = 0; i < 3; i++) {
		std::cin >> some;
		v.push_back(some);
	}
	std::cin >> n;
	std::sort(v.begin(),v.end());
	for (int i = 0; i < n; i++) {
		v[2] *= 2;
	}	
	std::cout << v[0]+v[1]+v[2] << std::endl;
	return 0;
}

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


#define mp make_pair
#define pb push_back
#define rep(i,port,sail) for(i=port;i<=sail;i++)
const int N = 100010;
typedef long long ll;
ll h[N],dp[N];
int main()
{
	int n,i,j,k,t;
	cin>>n>>k;
	rep(i,1,n)cin>>h[i];
	dp[1]=0;
	dp[2]= abs(h[2]-h[1]);

	rep(i,3,n)
	{
		dp[i]= 1e18+2;
		rep(j,1,k)
		{
		if(i-j<=0)break;
		dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
		}
	}
	cout<<dp[n]<<"\n";
	
	return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>

int main(int argc, const char * argv[]) {
    double in;
    
    while(scanf("%lf",&in)!=EOF){
        if(in<=48){
            printf("light fly\n");
        }
        else if(in<=51){
            printf("fly\n");
        }
        else if(in<=54){
            printf("bantam\n");
        }
        else if(in<=57){
            printf("feather\n");
        }
        else if(in<=60){
            printf("light\n");
        }
        else if(in<=64){
            printf("light welter\n");
        }
        else if(in<=69){
            printf("welter\n");
        }
        else if(in<=75){
            printf("light middle\n");
        }
        else if(in<=81){
            printf("middle\n");
        }
        else if(in<=91){
            printf("light heavy\n");
        }
        else{
            printf("heavy\n");
        }
    }
    
    return 0;
}

Measured memory_bytes: 1756
#include <iostream>

using namespace std;

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

    int count = 1, xi = 0;
    for (int i = 0; i < n; i++) {
        int l;
        cin >> l;
        if ((xi+=l) <= x) count++;
        else break;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();

            string result = "";

            for(int i = 0; i < s.Length; i++)
            {
                result += "x";
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  double n, k, ans=0.0;
  cin >> n >> k;
  for(int i=1; i<=int(n); i++){
    double tmp = 1 / n;
    double m = double(i);
    while(m<k){
      m*=2;
      tmp *= 0.5;
    }
    ans += tmp;
  }
  printf("%.15lf\n", ans);
  return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

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

   vector<double> a(n); rep(i, n) cin >> a.at(i);
   double sum = 0;
   rep(i, n){
      sum+=a.at(i);
   }
   sum /= (double)(4*m); 
   dump(4*m);
   dump(sum);

   int cnt=0;
   rep(i, n){
      if(sum<=a.at(i)) cnt++;
   }

   if(cnt>=m){
      cout << "Yes" << endl;
   }
   else cout << "No" << endl;

   return 0;
}


Measured memory_bytes: 256
//Created by Aminul on 7/25/2020.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int a[] = new int[3];
        for (int i = 0; i < 3; i++) {
            a[i] = in.nextInt();
        }
        int k = in.nextInt();
        while (k-- > 0) {
            if (a[1] <= a[0]) a[1] *= 2;
            else a[2] *= 2;
        }
        pw.println(a[2] > a[1] && a[1] > a[0] ? "Yes" : "No");
        pw.close();
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}

Measured memory_bytes: 27144
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;


int main() {
  int a, b;
  cin >> a >> b;

  if (a <= 5) {
    cout << 0 << endl;
    return 0;
  }

  if (a >= 6 && a <= 12) {
    cout << b / 2 << endl;
    return 0;
  }

  cout << b << endl;
  return 0;
}


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

using namespace std;

int main()
{
    int a, c5=0, c7=0;

    for(int i=0; i<3; i++){
        cin >> a;
        if(a==7) c7++;
        else if(a==5) c5++;
        else break;
    }

    cout << (c5==2 && c7==1 ? "YES" : "NO") << endl;

    return 0;
}


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

using namespace std;

#define ll long long

int main() {

	ios::sync_with_stdio(false);
	cin.tie(0);
	
	ll x;
	cin >> x;
	ll h = x / 500 * 1000;
	x %= 500;
	h += x / 5 * 5;
	cout << h << "\n";
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long dp[11][1010];
int main(){
    dp[0][0] = 1;
    for(int i = 0;i <= 100;i++)
        for(int j = 9;j >= 0;j--)
            for(int k = 0;k <= 1000-i;k++)
                dp[j+1][k+i] += dp[j][k];
	
    int n, s;
    while(cin >> n >> s, n | s)cout << dp[n][s] << endl;
    return 0;
}

Measured memory_bytes: 3176
s=input()
t=input()
q=int(input())
n=len(s)
pre=[0]*(n+1)
for i in range(n):
    if s[i]=="A":
        pre[i]=pre[i-1]+1
    else:
        pre[i]=pre[i-1]
m=len(t)
p=[0]*(m+1)
for i in range(m):
    if t[i]=="A":
        p[i]=p[i-1]+1
    else:
        p[i]=p[i-1]

for _ in range(q):
    a,b,c,d=map(lambda x:int(x)-1,input().split())

    aa=(pre[b]-pre[a-1])
    co=(b-a+1-aa)
    co+=aa*2

    bb=(p[d]-p[c-1])
    do=(d-c+1-bb)
    do+=bb*2
   # print(aa,bb,co,do)
    co%=3
    do%=3
    if co==do:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 53208
#include <bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff first
#define ss second
using namespace std;
typedef pair<int,int> pii;

string s[] = {"SUN","MON","TUE","WED","THU","FRI","SAT","SUN","MON","TUE","WED","THU","FRI","SAT"};

int32_t main(){
	fastio;
	string t;
	cin>>t;
	int res=0;
	int ini=0;
	for(int i=0;i<14;i++){
		if(t==s[i]){
			ini = i;
			break;
		}
	}
	res=1;
	ini++;
	for(int i=ini;i<14;i++){
		if(s[i]=="SUN")break;
		res++;
	}
	cout<<res<<endl;
}

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

int main() {
    int x; cin >> x;
    int ans = 1;
    int X = x;
    while (X% 360 != 0) {
        X += x;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3676
#include <stdio.h>

void strrev(char *in, char *out);

int main(void)
{
	int i;
	int a;
	char in[100];
	char out[100];
	
	scanf("%d", &a);
	
	while (a != -1){
		
		i = 0;
		if(a == 0){
			printf("0\n");
		}
		
		else{
			while (a != 0){
				in[i] = a % 4 + '0';
				a /= 4;
				i++;
			}
			
			in[i] = '\0';
			strrev(in, out);
			
			printf("%s\n", out);
		}
		
		scanf("%d", &a);
	}
	return (0);
	
}

void strrev(char *in, char *out)
{
	int a;
	int i;
	
	a = 0;
	while (in[a] != '\0'){
		a++;
	}
	out[a] = '\0';
	
	i = 0;
	while (in[i] != '\0'){
		out[i] = in[a - 1];
		i++;
		a--;
	}
}

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

int main() {
        int     N;
        long long       T,C=0;

        cin >> N;

        for (int i = 0; i < N; i++) {
                cin >> T;
                C = C | T;
        }
        int cnt = 0;
        while (C % 2 == 0) {
                cnt++;
                C /= 2;
        }
        cout << cnt << endl;
}


Measured memory_bytes: 3596
import java.util.*;
import java.math.*;

public class Main {
    void solve(){
        Scanner scan = new Scanner(System.in);
        String x = scan.next();
        BigInteger a = new BigInteger(x);
        System.out.println(a.nextProbablePrime().min(a.subtract(new BigInteger("1")).nextProbablePrime()));
    }
    
    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 36832
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

int nails[5005][5005];

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

    rep(i, M) {
        int A, B, X; cin >> A >> B >> X;

        nails[A - 1][B - 1]++;
        nails[A - 1][B]--;
        nails[A + X][B - 1]--;
        nails[A + X][B + X + 1]++;
        nails[A + X + 1][B]++;
        nails[A + X + 1][B + X + 1]--;
    }

    rep(i, N + 2) {
        rep(j, N + 2) {
            nails[i][j + 1] += nails[i][j];
        }
    }

    rep(i, N + 2) {
        rep(j, N + 2) {
            nails[j + 1][i] += nails[j][i];
        }
    }

    rep(i, N + 2) {
        rep(j, N + 2) {
            nails[i + 1][j + 1] += nails[i][j];
        }
    }

    int ans = 0;

    rep(i, N + 2) {
        rep(j, N + 2) {
            ans += nails[i][j] > 0;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 100920
a,b,c = map(int, input().split())

flag = False
if a == 7 and b == 5 and c ==5:
    flag = True
if a == 5 and b == 7 and c ==5:
    flag = True
if a == 5 and b == 5 and c ==7:
    flag = True

if flag:
    print("YES")
else:
    print("NO")

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

using namespace std;

const int inf = 1000000000;

class seg {
	vector<int> t;

	public:
	seg(int n) {
		t.resize(4 * n + 5);
	}

	void build(int l, int r, int x, vector<int>& pre, vector<int>& suf) {
		if(l == r) {
			t[x] = suf[l] + pre[l] - 1;
			return;
		}

		int mid = l + r >> 1;

		build(l, mid, x << 1, pre, suf);
		build(mid + 1, r, x << 1 | 1, pre, suf);

		t[x] = max(t[x << 1], t[x << 1 | 1]);
	}

	int query(int l, int r, int x, int a, int b) {
		if(l > b || r < a) {
			return -inf;
		}

		if(l >= a && r <= b) {
			return t[x];
		}

		int mid = l + r >> 1;

		return max(query(l, mid, x << 1, a, b), query(mid + 1, r, x << 1 | 1, a, b));
	}
};

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

	int n, k, c;
	cin >> n >> k >> c;

	string s;
	cin >> s;

	if(k == 1) {
		int cnt = 0;

		for(auto x : s) {
			if(x == 'o') {
				++cnt;
			}
		}

		if(cnt == 1) {
			for(int i = 0; i < n; ++i) {
				if(s[i] == 'o') {
					cout << i + 1 << '\n';
					return 0;
				}
			}
		}

	}

	if(c == 0) {
		int cnt = 0;

		for(auto x : s) {
			if(x == 'o') {
				++cnt;
			}
		}

		if(cnt == k) {
			for(int i = 0; i < n; ++i) {
				if(s[i] == 'o') {
					cout << i + 1 << '\n';
				}
			}
		}

		return 0;
	}

	vector<int> pre;
	pre.resize(n, -inf);

	vector<int> dp;
	dp.resize(n, -inf);

	for(int i = 0; i < n; ++i) {
		if(s[i] == 'o') {
			pre[i] = 1;
			if(i - c - 1 >= 0) {
				pre[i] = max(pre[i], dp[i - c - 1] + 1);
			}
		}
		
		dp[i] = pre[i];

		if(i > 0) {
			dp[i] = max(dp[i], dp[i - 1]);	
		}
	}

	dp.assign(n, -inf);

	vector<int> suf;
	suf.resize(n);

	for(int i = n - 1; i >= 0; --i) {
		if(s[i] == 'o') {
			suf[i] = 1;
			if(i + c + 1 < n) {
				suf[i] = max(suf[i], dp[i + c + 1] + 1);
			}
		}

		dp[i] = suf[i];

		if(i < n - 1) {
			dp[i] = max(dp[i], dp[i + 1]);
		}
	}

	int mx = 0;

	for(int i = 0; i < n; ++i) {
		mx = max(suf[i] + pre[i] - 1, mx);
	}

	if(mx < k) {
		return 0;
	}


	seg seg(n);

	seg.build(0, n - 1, 1, pre, suf);

	for(int i = 0; i < n; ++i) {
		int l = seg.query(0, n - 1, 1, max(0, i - c), i - 1);
		int r = seg.query(0, n - 1, 1, i + 1, min(n - 1, i + c));

		if(k > 1 && max(l, r) < k && s[i] == 'o') {
			cout << i + 1 << '\n';
		}
	}

	return 0;
}


Measured memory_bytes: 6164
#include <stdio.h>
#define N 10000
 
typedef struct{
  int p;
  int l;
  int r;
}Node;
 
Node T[N];
int n, D[N], H[N];
 
void setDepth(int u, int d){
  if(u == -1) return;
  D[u] = d;
  setDepth(T[u].l, d+1);
  setDepth(T[u].r, d+1);
}
 
int setHeight(int u){
  int h1=0, h2=0;
  if(T[u].l != -1) h1 = setHeight(T[u].l) + 1;
  if(T[u].r != -1) h2 = setHeight(T[u].r) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}
 
int getSibling(int u){
  if(T[u].p == -1) return -1;
  if(T[T[u].p].l != u && T[T[u].p].l != -1) return  T[T[u].p].l;
  if(T[T[u].p].r != u && T[T[u].p].r != -1) return T[T[u].p].r;
  return -1;
}
 
int main(){
  int i, v, l, r, deg, root=0;
 
  scanf("%d", &n);
 
  for(i=0; i<n; i++) T[i].p = -1;
 
  for(i=0; i<n; i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if(l != -1) T[l].p = v;
    if(r != -1) T[r].p = v;
  }
 
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }
 
  setDepth(root, 0);
  setHeight(root);
 
  for(i=0; i<n; i++){
    printf("node %d: ", i);
    printf("parent = %d, ", T[i].p);
    printf("sibling = %d, ", getSibling(i));
    deg = 0;
    if(T[i].l != -1) deg++;
    if(T[i].r != -1) deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", D[i]);
    printf("height = %d, ", H[i]);
 
    if(T[i].p == -1) printf("root\n");
    else if(T[i].l == -1 && T[i].r == -1) printf("leaf\n");
    else printf("internal node\n");
  }
   
  return 0;
}

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


void solve(long long N, long long A, long long B){
    cout << min(A * N, B) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=(int)(n-1); i>=0; --i)

//const int NAX = (int)3e5+5;
const int MOD = (int)1e9+7;

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
}
//modular inverse
//inv(a,m) - inverse of a mod m
template <class T>
inline T inv(T a, T m){
 return 1<a ? m - inv(m%a, a)*m/a : 1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    vi b(n), c(n, 0);
    vi a(n);
    forn(i, n)  {
      cin >> a[i];
      --a[i];
    }
    forn(i, n) {
       int x; cin >> x;
       b[i] = x;
    }
    forn(i, n-1) {
      int x; cin >> x;
      c[i] = x;
    }
    int res = 0;
    forn(i, n) {
      res += b[a[i]];
      if(i>0 && a[i-1]+1 == a[i]) {
        res += c[a[i-1]];
        //cout << "a[i]: " << c[a[i]] << "\n";
      }
      //cout << "a[i]; " << a[i] << " b[a[i]]; " << b[a[i]] << " sdc: " << c[a[i]] << "\n";
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 256
if __name__ == "__main__":
    n = int(input())
    w = list()
    for i in range(n):
        w.append(input())

    t = set(w)
    if len(t) != n:
        print('No')
        exit()

    end = w[0][-1]
    for i in range(1, n):
        if w[i][0] != end:
            print('No')
            exit()
        end = w[i][-1]

    print('Yes')


Measured memory_bytes: 3064
import heapq

N, M = map(int, input().split())

a = list(map(int, input().split()))

a.sort()
if M!=1:
    d = max(a) - min(a)

    da = [-a[i]+a[i-1] for i in range(1,M)]

    heapq.heapify(da)

    for i in range(N-1):
        if not len(da):break
        d += heapq.heappop(da)
else:d = 0
print(d)

Measured memory_bytes: 13960
#include <stdio.h>
int N, a[105];
int main()
{
	int ok = 1;
    scanf("%d", &N);
    for(int i=1;i<=N;i++)
        scanf("%d", &a[i]);
    for(int i=1;i<=N;i++)
    {
    	if(a[i]%2==0)
    	{
    		if(a[i]%3==0||a[i]%5==0)
    		    continue;
    		else
    		{
    			ok = 0;
    			break;
			}
		}
	}
	if(ok)
	    printf("APPROVED\n");
	else printf("DENIED\n");
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
    int a, b, d, r;
    double f;
    scanf("%d %d", &a, &b);
    d=a/b;
    r=a%b;
    f=(double)a/(double)b;
    printf("%d %d %f\n", d, r, f);
    return 0;
}

Measured memory_bytes: 636
def m(L,R):
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):
 l=len(A);global c;c+=l
 s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A
c=-int(input())
print(*d(list(map(int,input().split()))))
print(c)


Measured memory_bytes: 63696
#!/usr/bin/env python3


def main():
    c = input()
    # i = list(map(int,input().split()))
    # j = list(map(int,input().split()))
    if c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u':
        print('vowel')
    else:
        print('consonant')


main()


Measured memory_bytes: 2940
n, m = list(map(int, input().split()))
A = [[0] for _ in range(n)]
for i in range(n):
    A[i] = list(map(int, input().split()))
B = [0]*m
for k in range(m):
    B[k] = int(input())
C = [0]*n
for i in range(n):
    for j in range(m):
        C[i] += A[i][j]*B[j] 
for i in range(n):
    print (C[i])
    
    


Measured memory_bytes: 6024
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

int main()
{
 int N,M;
 cin>>N>>M;
 int n = N*(N-1)/2;
 int m = M*(M-1)/2;
 cout<<m+n<<endl;
 return 0;  
}

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

int solve(int y1, int x1, int y2, int x2, int num, vector<vector<int>> const& sum) {
    auto calc = [&sum] (int yy1, int xx1, int yy2, int xx2) {
        return sum[yy2][xx2] - sum[yy1][xx2] - sum[yy2][xx1] + sum[yy1][xx1];
    };
    if(num == 1) return calc(y1, x1, y2, x2);
    int res = 0;
    for(int mx = x1; mx <= x2; ++mx) {
        res = max(res, min(calc(y1, x1, y2, mx), solve(y1, mx, y2, x2, num - 1, sum)));
        res = max(res, min(calc(y1, mx, y2, x2), solve(y1, x1, y2, mx, num - 1, sum)));
    }
    for(int my = y1; my <= y2; ++my) {
        res = max(res, min(calc(y1, x1, my, x2), solve(my, x1, y2, x2, num - 1, sum)));
        res = max(res, min(calc(my, x1, y2, x2), solve(y1, x1, my, x2, num - 1, sum)));
    }
    if(num == 4) {
        for(int my1 = y1; my1 <= y2; ++my1) {
            for(int my2 = y1; my2 <= y2; ++my2) {
                vector<int> v1(x2 + 1), v2(x2 + 1);
                for(int mx = x1; mx <= x2; ++mx) {
                    v1[mx] = min(calc(y1, x1, my1, mx), calc(y1, mx, my2, x2));
                    v2[mx] = min(calc(my1, x1, y2, mx), calc(my2, mx, y2, x2));
                }
                if(my1 < my2) swap(v1, v2);
                for(int mx = x1 + 1; mx <= x2; ++mx) {
                    v1[mx] = max(v1[mx], v1[mx - 1]);
                }
                for(int mx = x2 - 1; mx >= x1; --mx) {
                    v2[mx] = max(v2[mx], v2[mx + 1]);
                }
                if(my1 == my2) {
                    res = max(res, min(v1.back(), v2[0]));
                } else {
                    for(int mx = x1; mx <= x2; ++mx) {
                        res = max(res, min(v1[mx], v2[mx]));
                    }
                }
            }
        }
    }
    return res;
};

int main() {
    int h, w, n; cin >> h >> w >> n;
    vector<vector<int>> sum(h + 1, vector<int>(w + 1));
    for(int i = 1; i <= h; ++i) {
        for(int j = 1; j <= w; ++j) {
            cin >> sum[i][j];
        }
    }
    for(int i = 1; i <= h; ++i) {
        for(int j = 0; j < w; ++j) {
            sum[i][j + 1] += sum[i][j];
        }
    }
    for(int i = 0; i < h; ++i) {
        for(int j = 1; j <= w; ++j) {
            sum[i + 1][j] += sum[i][j];
        }
    }

    cout << solve(0, 0, h, w, n, sum) << endl;
}



Measured memory_bytes: 3276
#include<stdio.h>

int main()
{
	int i,count=0;
	char a[1000000] = { 0 }, b[1000000] = { 0 };

	scanf("%s%s", a, b);

	for (i = 0; i < 1000000; i++)
	{
		if(a[i]!=b[i])
		{
			count++;
		}
	}
	printf("%d", count);
}

Measured memory_bytes: 3684
function Main(input){
  input = input.split(' ');

  var a = 'A';
  var s = input[1];
  var c = 'C';

  var s2 = s.split('')[0];

  console.log(a + s2 + c);


}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }

int n, k, a[100010];
map<int, int> m;

int main() {
    cin >> n >> k;
    rep(i, n) cin >> a[i];

    int l = 0, r = 0;
    int count = k; // number of matched integers
    int best_l = 0;
    int minLen = INF;
    for (int i = 1; i <= k; i++) m[i] = 1;

    while (r < n) {
        if (1 <= a[r] && a[r] <= k) {
            m[a[r]]--;
            if (m[a[r]] == 0) count--;
        }
        r++;

        if (count == 0) {
            while (count == 0 && l < r) {
                if (1 <= a[l] && a[l] <= k) {
                    m[a[l]]++;
                    if (m[a[l]] == 1) count++;
                }
                if (r - l < minLen) {
                    best_l = l;
                    minLen = r - l;
                }
                l++;
            }
        }
    }

    if (minLen == INF) cout << 0 << endl;
    else cout << minLen << endl;
}



Measured memory_bytes: 8176
N,K = map(int,input().split())
P = [0] * N
for i in range(K):
    a = int(input())
    b = list(map(int,input().split()))
    for j in range(a):
      P[b[j]-1] = 1 
m = 0   
for i in range(N):
    if P[i] == 0:
        m += 1
print(m)

Measured memory_bytes: 9124
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>

using namespace std;

long long gcd( long long m, long long n ){
    if((0==m)||(0==n))return 0;
	
	// ユークリッドの方法
	while(m!=n){
		if (m>n) swap(m, n);
		n=n-m;
	}
	return m;
}

long long lcm( long long m, long long n ){
    if((0==m)||(0==n))return 0;
	
	return  m/gcd(m,n)*n;
}

int a1, m1, a2, m2, a3, m3;

int main(){

    
    while(cin>>a1 >>m1 >>a2 >>m2 >>a3 >>m3){
        if(a1==0 && m1==0 && a2==0 && m2==0 && a3==0 && m3==0)break;
        
        long long int x,y,z,c1,c2,c3;
        x=1;
        y=1;
        z=1;
        c1=0;
        c2=0;
        c3=0;
        
        while(!(c1!=0&&x==1)){
            c1++;
            x=a1*x%m1;
        }
        while(!(c2!=0&&y==1)){
            c2++;
            y=a2*y%m2;
        }
        while(!(c3!=0&&z==1)){
            c3++;
            z=a3*z%m3;
        }
        
        //cout<<c1<<c2<<c3<<endl;
        cout<<lcm(lcm(c1,c2),c3)<<endl;
        
    }
}

Measured memory_bytes: 1156