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

using namespace std;

typedef pair<string, int> P;

const int INF = 0x3f3f3f3f;


string a;


int op[4] = {-1, 1, -4, 4};

map<string, int> dp;  


void bfs(){
  
    queue<P> que;
    que.push(P("01234567", 0));
    dp["01234567"] = 0;
 
    while(!que.empty()){
        P p = que.front();
        que.pop();
        string s = p.first;
        int cur = p.second;
        for(int i = 0; i < 4; i ++){
       
            int next = cur + op[i];
            string str = s;
            swap(str[cur], str[next]);
            map<string, int>::iterator it = dp.find(str);

            if(0 <= next && next < 8
                && !(cur == 3 && next == 4) && !(cur == 4 && next == 3)
                && it == dp.end()){

                que.push(P(str, next));
                dp[str] = dp[s] + 1;
            }
        }
    }
}


void solve(){
 
    a.erase(remove(a.begin(), a.end(), ' '), a.end());
    cout<<dp[a]<<endl;
}

int main(){
  
    bfs();
    while(getline(cin, a)){
        solve();
    }
    return 0;
}

Measured memory_bytes: 5320
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    int h,w,count[26]={};
    scanf("%d%d",&h,&w);
    char a[h][w+1],lowcmp[27]="abcdefghijklmnopqrstuvwxyz";
    for (int i=0; i<h; i++){
        scanf("%s",a[i]);
    }
    for (int i=0; i<h; i++){
        for (int j=0; j<w; j++){
            for (int k=0; k<26; k++){
                if (a[i][j]==lowcmp[k]){
                    count[k]++;
                }
            }
        }
    }
    int sum=0;
    if (h%2==0 && w%2==0){
        for (int i=0; i<26; i++){
            if (count[i]%4!=0){
                printf("No\n");
                return 0;
            }
        }
    } else if (w%2==0){
        for (int i=0; i<26; i++){
            if (count[i]%2!=0){
                printf("No\n");
                return 0;
            }
            sum+=count[i]%4;
            if (sum>w){
                printf("No\n");
                return 0;
            }
        }
    } else if (h%2==0){
        for (int i=0; i<26; i++){
            if (count[i]%2!=0){
                printf("No\n");
                return 0;
            }
            sum+=count[i]%4;
            if (sum>h){
                printf("No\n");
                return 0;
            }
        }
    } else {
        bool odd=false;
        for (int i=0; i<26; i++){
            if (count[i]%2!=0){
                if (odd==true){
                    printf("No\n");
                    return 0;
                }
                odd=true;
            }
            sum+=count[i]%4;
            if (sum>h+w-1){
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
	return 0 ;
}

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


void solve(long long N){
  string ans = "hon";
  N %= 10;
  if (N == 0 || N == 1 || N == 6 || N == 8) ans = "pon";
  else if (N == 3) ans = "bon";
  cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

int main()
{
    int a = 0;
    string s;
    cin >> s;
    for (int i = 1; i<3 ; i++)
    {
        if (s[i]!= s[i-1]) { cout << "Yes"; a = 1; break;}
    }
    if (a== 0 ) cout << "No";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scanner = new Scanner(System.in);

    Double n = scanner.nextDouble();
	
   	Double x = Math.ceil(n / 1.08);
    
    if((n)==Math.floor(x*1.08)){
    	System.out.println(x.intValue());
    }else{
      	System.out.println(":(");
    }
    
    scanner.close();

  }

}

Measured memory_bytes: 23252
#include<stdio.h>
#define min(a,b) ((a)>(b))?(b):(a)
int main(void){
	int i,j,n,u,k,s,tmp,w,adj[100][100]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&u,&k);
		for(j=0;j<k;j++){
			scanf("%d %d",&tmp,&w);
			adj[u][tmp]=w;
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if((adj[i][j]==0) && (i!=j)){
				adj[i][j]=100000000;
			}
		}
	}
	for(s=0;s<n;s++){
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				adj[i][j]=min(adj[i][j],adj[i][s]+adj[s][j]);
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%d %d\n",i,adj[0][i]);
	}
	return 0;
}

Measured memory_bytes: 648
//       In the name of         ****                      God                     ****

/*

Copyright (C)          JadedBeast

                                   Morocco

created : 10/3/2019

*/

#include <bits/stdc++.h>

using namespace std;
const unsigned int mod =1e9+7;
inline void Boost() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}
int H,W;
char m[1001][1001];
int DP[1001][1001];
long long dp(int h,int w){
	if(h==H && w==W)
		return 1;
	if(m[h][w]=='#')
		return DP[h][w]=0;
	if(h>H || w>W )
		return 0;
	if(DP[h][w]!=-1)
		return DP[h][w];
	if(h<H && w<W)
		return DP[h][w]=(dp(h+1,w)+dp(h,w+1))%mod;
	if(h<H && w==W)
		return DP[h][w]=dp(h+1,w)%mod;
	if(h==H && w<W)
		return DP[h][w]=dp(h,w+1)%mod;
	return 0;

}


int main() {
	Boost();
	
	cin >> H >> W;



	for (int i=1 ;i<=H ;i++)
		for(int j=1 ;j<=W;j++)
			cin >> m[i][j];

	memset(DP,-1,sizeof(DP));


	cout << dp(1,1)<<endl;

    return 0;
}

Measured memory_bytes: 5248
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n - 1); i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T>
constexpr int sz(const T &a) { return (int)a.size(); }
template <class T>
constexpr T pow2(const T a) { return a * a; }
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class A, int N, class T>
void fillArray(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

string s;
void solve() {
    cin >> s;

    vector<string> v(1);
    rep(i, sz(s)) {
        if (s[i] == 'A')
            v.back() += 'A';
        else if (s.substr(i, 2) == "BC") {
            v.back() += "B";
            i += 1;
        } else if (!v.back().empty())
            v.emplace_back();
    }

    ll ans = 0;
    for (auto &val : v) {
        ll res = 0;
        rep(i, sz(val)) {
            if (val[i] == 'A')
                ++res;
            else
                ans += res;
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;


const int BIG_NUM = 1e8;

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

	set<int> s;
	s.insert(0);
	vector<int> t;
	t.emplace_back(0);
	int next = a[0];
	while (s.find(next) == s.end()) {
		t.emplace_back(next);
		s.insert(next);
		next = a[next];
		
	}

	int loopBegin = 0;
	for (int i = 0; i < t.size(); i++) {
		if (t[i] == next) {
			loopBegin = i;
			break;
		}
	}
	if (k >= loopBegin) {
		k -= loopBegin;
		int l = t.size() - loopBegin;
		k %= l;
		cout << t[k + loopBegin] + 1 << endl;
	}
	else {
		cout << t[k] + 1 << endl;
	}
}

Measured memory_bytes: 13992
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,k;
    cin >> n >> k;
    vi a(n);
    cin >> a;
    rep(i,n-k) {
        Yes(a[i] < a[i+k]);
    }
}

Measured memory_bytes: 3976
N = int(input())
f = [int(x) for x in input().split()]
dp = [float('inf')] * N
dp[0] = 0
dp[1] = abs(f[1] - f[0])
for i in range(2, N):
    dp[i] = min(abs(f[i] - f[i - 1]) + dp[i - 1],
                abs(f[i] - f[i - 2]) + dp[i - 2])
print(dp[N - 1])

Measured memory_bytes: 13980
#![allow(non_snake_case)]

use std::cmp::max;

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}

fn main() {
    let (A, B) = {
        let v: Vec<i32> = read_line().split_whitespace().map(|a| a.parse().unwrap()).collect();
        (v[0], v[1])
    };
    println!("{}", max(max(A+B, A-B), A*B));
}


Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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 (b < a) {
        a = b;
        return true;
    }
    return false;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "[";
    for (auto it = mp.begin(); it != mp.end(); ++it) {
        if (it != mp.begin()) {
            os << ", ";
        }
        os << *it;
    }
    return os << "]";
}

// edit

void solve() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll ans = a * c;
    chmax(ans, a * d);
    chmax(ans, b * c);
    chmax(ans, b * d);
    if (a * b < 0) {
        chmax(ans, 0ll);
    }

    if (c * d < 0) {
        chmax(ans, 0ll);
    }

    cout << ans << endl;


}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3188
# バージョン 3.4.X 以前
import fractions
# バージョン 3.5 以降
# import math


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


def main():
    A, B, C, D = map(int, input().split())
    first = B // C - (A - 1) // C
    second = B // D - (A - 1) // D
    tmp = lcm(C, D)
    both = B // tmp - (A - 1) // tmp
    print(B - A + 1 - first - second + both)
    return


main()


Measured memory_bytes: 5052
p [2,1,3,4,7,11,18,29,47,76,123,199,322,521,843,1364,2207,3571,5778,9349,15127,24476,39603,64079,103682,167761,271443,439204,710647,1149851,1860498,3010349,4870847,7881196,12752043,20633239,33385282,54018521,87403803,141422324,228826127,370248451,599074578,969323029,1568397607,2537720636,4106118243,6643838879,10749957122,17393796001,28143753123,45537549124,73681302247,119218851371,192900153618,312119004989,505019158607,817138163596,1322157322203,2139295485799,3461452808002,5600748293801,9062201101803,14662949395604,23725150497407,38388099893011,62113250390418,100501350283429,162614600673847,263115950957276,425730551631123,688846502588399,1114577054219522,1803423556807921,2918000611027443,4721424167835364,7639424778862807,12360848946698171,20000273725560978,32361122672259149,52361396397820127,84722519070079276,137083915467899403,221806434537978679,358890350005878082,580696784543856761,939587134549734843][gets.to_i]

Measured memory_bytes: 1788
#include <stdio.h>
int main() {
	int n,m,k=0,vote=0;
	int check;
	scanf("%d%d",&n,&m);
	int arr[n+1];
	for(int i=1;i<=n;i++)
	{
	    scanf("%d",&arr[i]);
	    vote=vote+arr[i];
	}
	
	if((vote%(4*m))==0)
	    check=vote/(4*m);
	else
	    check=(vote/(4*m))+1;
	for(int i=1;i<=n;i++)
	{
	    if(arr[i]>=check)
	    k++;
	}
	if(k>=m)
	    printf("Yes\n");
	else
    	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
while True:
    n = int(input())
    if n == 0:
        break
    ans = []
    sum_c = [0 for i in range(n + 1)]
    for i in range(n):
        r = list(map(int, input().split()))
        r.append(sum(r))
        ans.append(r)
        for j in range(n + 1):
            sum_c[j] += r[j]
    ans.append(sum_c)
    for i in range(n + 1):
        [print("{:>5}".format(str(ans[i][j])),end="") for j in range(n + 1)]
        print()



Measured memory_bytes: 5628
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
using namespace std;


const int inf = 1e9+7;

signed main(){
	string s;
	int a, ans = 0;
	int i=3;
	int x = 0, y = 0;
	char c;
	while(i){
		//cout << 3 << endl;
		if( i == 3 ){
			cin >> x;
		}
		if(i == 1){
			cin >> y;
		}
		if(i == 2){
			cin >> c;
		}
		i--;
	}
	if(c == '+'){
		cout <<x+y <<endl;
	}
	if(c == '-'){
		cout << x-y << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int A,B;
  cin >> A>>B;
  int C;
  if( (A+B)%2 == 0){
    C = static_cast<int>((A+B)/2);
    cout <<C<<endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}

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

#define MAXN 100000

using namespace std;

int A[MAXN];

int func ( int N )
{
  int pos = 0;
  int ans,tmp;
  ans = tmp = 0;

  while ( pos < N ) {
    if ( A[pos] == pos ) {
      ++tmp;
      if ( tmp >= 2 ) {
        ++ans;
        tmp = 0;
      }
    } else {
      if ( tmp >= 1 ) {
        ++ans;
        tmp = 0;
      }
    }
    if ( pos == N-1 && tmp == 1 ) ++ans;
    ++pos;
  }

  return ans;
}

int main()
{
  int N;
  int ans = 0;

  cin >> N;
  for ( int i = 0; i < N; ++i ) {
    scanf("%d", &A[i]);
    --A[i];
  }

  cout << func(N) << "\n";
}


Measured memory_bytes: 640
#include <cstdio>
using namespace std;

int main() {
	int n; scanf("%d", &n);
	int a[n]; for (int i = 0; i < n; ++i) scanf("%d", &a[i]);

	int ans = 0;
	for (int a_i = 0; a_i < n; ++a_i) {
		int like_i = a[a_i] - 1; //idxに変換

		if (like_i < a_i) continue; // すでに調査済み

		if (a[like_i] - 1 == a_i) ++ans;
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;
using ll = long long;

const int N = 7 + 1e5;

int n, k;
ll a[N];

int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	ll ans = 1e18;
	for (int l = 1, r = k; r <= n; ++l, ++r) {
		if (a[l] * a[r] < 0)
			ans = min(ans, abs(a[r]) + abs(a[l]) + min(abs(a[r]), abs(a[l])));
		else
			ans = min(ans, max(abs(a[r]), abs(a[l])));
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

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

  int mx = max(a, max(b, c));
  int ans = (mx - a) / 2 + (mx - b) / 2 + (mx - c) / 2;
  int k = 0;
  if((mx - a) % 2) k++;
  if((mx - b) % 2) k++;
  if((mx - c) % 2) k++;

  if(k == 1) ans += 2;
  if(k == 2) ans++;

  cout << ans << endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        N: usize, Z: i64, W: i64,
        a: [i64; N],
    }

    let s1 = (a[N-1] - W).abs();
    let ans = if N == 1 {
        s1
    } else {
        let s2 = (a[N-2] - a[N-1]).abs();
        max(s1, s2)
    };
    println!("{}", ans);
}


Measured memory_bytes: 2176
S = list(str(input()))
count = 0
if S[0] == "1":
    for i, j in enumerate(S):
        if i % 2 == 0 and j == "0":
            count += 1
        elif i % 2 == 1 and j == "1":
            count += 1
else:
    for i, j in enumerate(S):
        if i % 2 == 0 and j == "1":
            count += 1
        elif i % 2 == 1 and j == "0":
            count += 1
print(count)

Measured memory_bytes: 3956
#include <iostream>
int main( void )
{
    int x, cnt = 0;
    while(true)
    {
        std::cin >> x;
        if ( x == 0 )
        {
            break;
        }
        cnt++;
        std::cout << "Case " << cnt << ": " << x << std::endl;
    }
    
    return 0;
}

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

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

	set<int> ok;
	for(int i = 0; i < m; ++i) {
		int a;
		cin >> a;
		ok.emplace(a);
	}

	int ans = 0;
	for(int i = 1; i <= n; ++i) {
		auto it = ok.lower_bound(i);
		int mn = INT_MAX;
		if(it != ok.end()) {
			mn = min(mn, *it - i);
		}

		if(it != ok.begin()) {
			--it;
			mn = min(mn, i - *it);
		}
		ans = max(ans, mn);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4652
H, W = map(int, input().split())
field = [input() for _ in range(H)]
comp_rows = []
comp_cols = []
for i in range(H):
    if field[i] == "." * W:
        comp_rows.append(i)
for j in range(W):
    if "".join(field[i][j] for i in range(H)) == "." * H:
        comp_cols.append(j)
for i in range(H):
    if i in comp_rows:
        continue
    print("".join(field[i][j] for j in range(W) if j not in comp_cols))


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main()
{
    int x = 0;
    for(int a = 0; a < 10000; a++){
        cin >> x;
        if(x == 0) break;
        cout << "Case " << a + 1 << ": " << x << endl;
    }
    return 0;
}


Measured memory_bytes: 2956
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	inp(n)
	inpa(a,n)
	int x=0;
	fo(i,n)
		x^=a[i];
	fo(i,n)
		cout<<(x^a[i])<<' ';
	cout<<'\n';
	printclock;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for1(i, a, b) for (int i = (int)a; i < (int)(b); ++i)
#define rfor1(i, a, b) for (int i=b-1;i>=a;i--)
#define for2(i, a, b) for (int i = (int)a; i <= (int)(b); ++i)
#define for3(i, a, b) for (int i = (int)a; i < (int)(b); i=i+2)
#define for4(i, a, b) for (int i = (int)a; i <= (int)(b); i=i+2)
#define tc(t) int t; cin>>t; while(t--)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

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

   string s;
   cin>>s;
   int aa = 0;
   int bb = 0;
   for1(i,0,s.length()){
       if(s[i]=='A') aa++;
       else if(s[i]=='B') bb++;
   }
   if(abs(aa-bb)==1) cout<<"Yes"<<endl;
   else{
       cout<<"No"<<endl;
   }

}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	string s; cin >> s;
	rep(i, 1, 3)
	{
		if (s[i] == s[i - 1])
		{
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
}

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

using namespace std;

#define rall(c) (c).rbegin(), (c).rend()

int main(){
    int m;
    cin >> m;
    while(m--){
        string tr;
        cin >> tr;
        set<string> org;
        for(int i=1; i<(int)tr.size(); ++i){
            string s = tr.substr(0, i), t = tr.substr(i);
            string rs = string(rall(s)), rt = string(rall(t));
            org.insert(s + t);
            org.insert(t + s);
            org.insert(rs + t);
            org.insert(t + rs);
            org.insert(s + rt);
            org.insert(rt + s);
            org.insert(rs + rt);
            org.insert(rt + rs);
        }
        cout << org.size() << '\n';
    }
    return 0;
}

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

using namespace std;

const long long MOD = 1000000007;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}


vector<pair<int, int>> queries;

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    /*
     * REMOVE ME PLS
     */

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

    int n, p;

    cin >> n >> p;

    unsigned long long odd = 0, even = 0;

    for(int i = 0; i < n; ++i){
        int j;
        cin >> j;
        if(j % 2 == 1)
            ++odd;
        else
            ++even;
    }


    if(p == 1 && odd == 0){
        cout << 0;
        return 0;
    }

    odd = odd == 0 ? 1 : 1ULL << odd - 1;
    even = 1ULL << even;

    cout << odd * even;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int> pii;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
string s,t;
int main(){
	cin>>s>>t;
	int ans=INF;
	for(int i=0;i<=SZ(s)-SZ(t);i++){
		int cnt=0;
		for(int j=i;j<i+SZ(t);j++){
			if(t[j-i]!=s[j])cnt++;
		}
		chkmin(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353
#define MEM_SIZE 101010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template <typename T>
void DEBUG(T e)
{
  if (DEBUG_OUT == false)
    return;
  std::cout << e << " ";
}
template <typename T>
void DEBUG(const std::vector<T> &v)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &e : v)
  {
    std::cout << e << " ";
  }
  std::cout << std::endl;
}
template <typename T>
void DEBUG(const std::vector<std::vector<T>> &vv)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &v : vv)
  {
    DEBUG(v);
  }
}
template <class T, class... Ts>
void DEBUG(T d, Ts... e)
{
  if (DEBUG_OUT == false)
    return;
  DEBUG(d);
  DEBUG(e...);
}
template <class T>
void corner(bool flg, T hoge)
{
  if (flg)
  {
    cout << hoge << endl;
    abort();
  }
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//BELOW
constexpr int dyx[4][2] = {
    {0, 1}, {-1, 0}, {0, -1}, {1, 0}};
//https://noimin.hatenablog.com/entry/2020/06/06/202747
void solve(void)
{
  int n;
  cin >> n;
  auto f = [n](int y, int x) { return y * n + x; };
  vector<int> p(n * n), cost(n * n, 0);
  vector<bool> sit(n * n, true);
  for (int i = 0; i < n * n; i++)
  {
    cin >> p[i];
    p[i]--;
  }
  for (int i = 0; i < n * n; i++)
  {
    int y = i / n, x = i % n;
    cost[i] = min({y, n - 1 - y, x, n - 1 - x});
  }
  int res = 0;
  for (int i = 0; i < n * n; i++)
  {
    res += cost[p[i]];
    queue<int> que;
    que.push(p[i]);
    sit[p[i]] = false;
    while (!que.empty())
    {
      int j = que.front();
      que.pop();
      int y = j / n, x = j % n;
      for (int k = 0; k < 4; k++)
      {
        int yy = y + dyx[k][0], xx = x + dyx[k][1];
        if (0 <= yy and 0 <= xx and yy <= n - 1 and xx <= n - 1 and cost[f(yy, xx)] > cost[f(y, x)] + (int)(sit[f(y, x)]))
        {
          cost[f(yy, xx)] = cost[f(y, x)] + (int)(sit[f(y, x)]);
          que.push(f(yy, xx));
        }
      }
    }
  }
  cout << res << endl;
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 7120
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

max_step = 0
step = 0

for i in range(1, N):
    if A[i] > A[i - 1]:
        step = 0
    else:
        step += 1
    max_step = max(max_step, step)

print(max_step)


Measured memory_bytes: 59760
fun main(args:Array<String>?): Unit {
    val (n, m) = readLine()!!.trim().split(' ').map(String::toInt)
    var xs = IntArray(n) { 0 }
    var ys = IntArray(n) { 0 }
    val points = Array(n) {
        val (x, y) = readLine()!!.trim().split(' ').map(String::toInt)
        xs[it] = x
        ys[it] = y
        Point(x, y)
    }
    xs.sort()
    ys.sort()
    xs = xs.distinct().toIntArray()
    ys = ys.distinct().toIntArray()
    val sum = Array(ys.size) { IntArray(xs.size) { 0 } }
    for ((x, y) in points) {
        sum[ys.binarySearch(y)][xs.binarySearch(x)]++
    }
    for (i in sum.indices) for (j in sum[i].indices){
        if (i > 0) sum[i][j] += sum[i - 1][j]
        if (j > 0) sum[i][j] += sum[i][j - 1]
        if (i > 0 && j > 0) sum[i][j] -= sum[i - 1][j - 1]
    }
    repeat(m){
        val (left, up, right, bottom) = readLine()!!.trim().split(' ').map(String::toInt)
        val lx =lowerBound(xs, left) - 1
        val uy = lowerBound(ys, up) - 1
        val rx = upperBound(xs, right) - 1
        val dy = upperBound(ys, bottom) - 1
        if (rx >= 0 && dy >= 0) {
            var result = sum[dy][rx]
            if (lx >= 0) result -= sum[dy][lx]
            if (uy >= 0) result -= sum[uy][rx]
            if (lx >= 0 && uy >= 0) result += sum[uy][lx]
            println(result)
        }else {
            println(0)
        }
    }
}
fun upperBound(array: IntArray, target: Int): Int {
    var left = 0
    var right = array.size
    while(left < right) {
        val mid = (left + right) / 2
        if (array[mid] <= target){
            left = mid + 1
        }else {
            right = mid
        }
    }
    return right
}
fun lowerBound(array: IntArray, target: Int): Int {
    var left = 0
    var right = array.size
    while(left < right){
        val mid = (left + right) / 2
        if (array[mid] < target){
            left = mid + 1
        }else {
            right = mid
        }
    }
    return right
}
data class Point(val x: Int, val y: Int)


Measured memory_bytes: 360052
#include <iostream>

using namespace std;

int main()
{
    int k;
    string s;
    cin>>k>>s;
    int ans=0;
    for(int i=0;i<k-2;i++)
    {
        if(s[i]=='A')
        {
            if(s[i+1]=='B'&&s[i+2]=='C')
                ans++;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
s = int(s,2)
a,b=("","")
for i in range(n):
    if i%2==0:
        a+="0"
        b+="1"
    else:
        a+="1"
        b+="0"
a = int(a,2)
b = int(b,2)
k = s^a
l = s^b
f=0
y=0
for i in bin(k):
    if i=="1":
        f += 1
for j in bin(l):
    if j=="1":
        y+=1
print(min(f,y))

Measured memory_bytes: 3444
//tanzim bin nasir
#include<bits/stdc++.h>
typedef long long ll;
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    else
    gcd(b,a%b);
}
ll lcd(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
int a[11][11];
int main()
{
    int t=1;
   // cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            int l=i%10;
            int temp=i;
            while(temp>=10)
            temp=temp/10;
            int f=temp;
            a[f][l]++;
        }
        int ans=0;
        for(int i=1;i<=9;i++)
        {
            for(int j=1;j<=9;j++)
            ans=ans+a[i][j]*a[j][i];
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3592
# Problem: https://atcoder.jp/contests/abc085/tasks/abc085_c
# Python 2nd Try

import sys
# from collections import defaultdict
# import heapq,copy
import pprint as pp
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(papers, totalSum):
    result = " ".join(map(str,[ -1 , -1 , -1])) # 10000円札,5000円札,1000円札
    for x in range(0, papers+1 , +1):
        for y in range(0, papers+1-x , +1):
            z = papers - x - y
            total_now = x * 10000 + y * 5000 + z * 1000
            if total_now == totalSum:
                result = " ".join(map(str,[x, y, z]))
    return result


if __name__ == "__main__":
    n, y = MI()
    print("{}".format(solver(n, y)))


Measured memory_bytes: 9880
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int r;
	cin >> r;
	if (r < 1200)
		cout << "ABC" << endl;
	else if (r < 2800)
		cout << "ARC" << endl;
	else
		cout << "AGC" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1LL << 60;
constexpr int INF = 3000000007;
const double INFD = 1e100;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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 main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  ll sum=0;
  ll cnt=0;
  for(int i=0; i<N; i++){
    ll a;
    cin >> a;
    if(a < 0){
      cnt++;
    }
    A[i] = abs(a);
    sum += A[i];
  }
  sort(A.begin(),A.end());
  if(cnt%2){
    sum -= A[0]*2;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
int dfs(vector<int>&f,int st,int par,vector<vector<int>>&adj){
    for(auto j:adj[st]){
        if(j!=par){
            f[st]++;
            f[st]+=dfs(f,j,st,adj);
        }
    }
    return f[st];
}
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int s;
    cin>>s;
    ll mod=1e9+7;
    ll dp[2001]={0ll};
    dp[0]=1;
    for(int i=3;i<=s;i++){
        for(int j=3;j<=i;j++){
            dp[i]+=dp[i-j];
            dp[i]%=mod;
        }
    }
    cout<<dp[s]<<endl;
}
 

Measured memory_bytes: 3648
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next(), m = next();
  var ss = nextstr();
  var s = Array(n).fill().map((a,i)=>ss[i]==="A"?0:1);
  var g = xArray("[]",n);
  var ev = xArray(0,n,2);
  for(var i = 0; i < m; i++){
    var a = next()-1, b = next()-1;
    g[a].push(b);
    g[b].push(a);
    ev[a][s[b]]++;
    ev[b][s[a]]++;
  }
  var cnt = n;
  var q = [];
  for(var i = 0; i < n; i++)if(!(ev[i][0]&&ev[i][1]))q.push(i),cnt--;
  while(q.length){
    var v = q.pop();
    for(var i = 0; i < g[v].length; i++){
      var V = g[v][i];
      if(!(ev[V][0]&&ev[V][1]))continue;
      if(--ev[V][s[v]] === 0)q.push(V),cnt--;
    }
  }
  return cnt ? "Yes" : "No";
}

Measured memory_bytes: 107144
#include <stdio.h>
  int main(){
	  int i,n;
	  char x[10];
	  while(1){
	  scanf("%d",&n);
	  if(n==0) break;
		  int dice[7];
		  int sum=1;
		   for(i=1;i<7;i++){
		  dice[i]=i;
	  }
	  for(i=0;i<n;i++){
		  scanf("%s",x);
		  if(x[0]=='N'){
			  int y=dice[1];
			  dice[1]=dice[2];
			  dice[2]=dice[6];
			  dice[6]=dice[5];
			  dice[5]=y;
			  sum += dice[1];
		  }else if(x[0]=='E'){
			  int y=dice[1];
			  dice[1]=dice[4];
			  dice[4]=dice[6];
			  dice[6]=dice[3];
			  dice[3]=y;
			  sum += dice[1];
		  }else if(x[0]=='W'){
			  int y=dice[1];
			  dice[1]=dice[3];
			  dice[3]=dice[6];
			  dice[6]=dice[4];
			  dice[4]=y;
			  sum += dice[1];
		  }else if(x[0]=='S'){
			  int y=dice[1];
			  dice[1]=dice[5];
			  dice[5]=dice[6];
			  dice[6]=dice[2];
			  dice[2]=y;
			  sum += dice[1];
		  }else if(x[0]=='R'){
			  int y=dice[2];
			  dice[2]=dice[3];
			  dice[3]=dice[5];
			  dice[5]=dice[4];
			  dice[4]=y;
			  sum += dice[1];
		  }else{
			  int y=dice[2];
			  dice[2]=dice[4];
			  dice[4]=dice[5];
			  dice[5]=dice[3];
			  dice[3]=y;
			  sum += dice[1];
		  }
	  }
	  		  printf("%d\n",sum);
	  }
	  return 0;
  }

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

int main(){
	string S;
  	cin >> S ;
  	int ans = 700;
  	if(S[0]=='o'){
    	ans+= 100;
    }
  	if(S[1]=='o'){
    	ans+= 100;
    }
  	if(S[2]=='o'){
    	ans+= 100;
    }
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <string>
#include <vector>
using namespace std;
bool solve(vector<int>& c, int ok) {
  if (ok >= 4) return true;
  bool p = false;
  for (int i = 1; i <= 9; i++)
    if (c[i] >= 3) {
      c[i] -= 3;
      p = p || solve(c, ok + 1);
      c[i] += 3;
    }
  for (int i = 1; i <= 7; i++)
    if (c[i] >= 1 && c[i + 1] >= 1 && c[i + 2] >= 1) {
      c[i]--;
      c[i + 1]--;
      c[i + 2]--;
      p = p || solve(c, ok + 1);
      c[i]++;
      c[i + 1]++;
      c[i + 2]++;
    }
  return p;
}
int main() {
  string line;
  while (getline(cin, line)) {
    vector<int> c(10, 0);
    for (auto& e : line)
      c[e - '0']++;
    vector<int> ans;
    for (int add = 1; add <= 9; add++) {
      c[add]++;
      vector<int> t;
      bool p = false;
      for (int i = 1; i <= 9; i++) {
        if (c[i] > 4) goto NEXT;
        if (c[i] >= 2) t.push_back(i);
      }
      for (auto& e : t) {
        c[e] -= 2;
        p = p || solve(c, 0);
        c[e] += 2;
      }
      if (p) ans.push_back(add);
      NEXT:
      c[add]--;
    }
    if (!ans.empty()) {
      for (int i = 0; i < (int) ans.size() - 1; i++)
        cout << ans[i] << ' ';
      cout << *ans.rbegin() << endl;
    }
    else cout << 0 << endl;
  }
}

Measured memory_bytes: 1196
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>

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

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int main() {
	vi c;
	int n, t, a, j;
	float cx, jx;

	cin >> n >> t >> a;

	c.resize(n);
	rep(n) {
		cin >> c[i];
	}

	jx = t - c[0] * 0.006;
	j = 0;
	rep(n - 1) {
		cx = t - c[i + 1] * 0.006;
		if (abs(a - jx) > abs(a - cx)) {
			jx = cx;
			j = i + 1;
		}
	}

	cout << j + 1;

	return 0;
}

Measured memory_bytes: 256
module Main where
import Debug.Trace
import Data.List
import qualified Data.Sequence as S
import qualified Data.ByteString.Char8 as B
import Data.Int
import Data.Char
import Data.Array
import Data.Maybe
import qualified Data.Map as M
import Data.Ord
import Data.Functor
import Control.Applicative
import Control.Monad

merge :: (Int, [Int]) -> (Int, [Int]) -> (Int, [Int])
merge (lc, ll) (rc, rl) = iter (lc + rc) [] ll rl where
    iter c ml [] rl = (c + length rl, reverse ml ++ rl)
    iter c ml ll [] = (c + length ll, reverse ml ++ ll)
    iter c ml ll@(l:ls) rl@(r:rs) 
        | l <= r   = c `seq` iter (c+1) (l:ml) ls rl
        |otherwise = c `seq` iter (c+1) (r:ml) ll rs

msort :: [Int] -> Int-> (Int, [Int])
msort l 1 = (0, l)
msort l n = merge (msort ll ln) (msort rl rn) where
        (ln, rn) = (div n 2, n - ln)
        (ll, rl) = splitAt ln l

readIntLn:: IO Int
readIntLn = (fst . fromJust . B.readInt) <$> B.getLine

readIntList:: IO [Int]
readIntList = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

printIntList :: [Int] -> IO()
printIntList [n] = putStrLn $ show n
printIntList (n:ns) = do
    putStr $ show n ++ " "
    printIntList ns

main :: IO() 
main = do
    n <- readIntLn
    u <- readIntList

    let (cnt, lst) = msort u n
    printIntList lst
    print cnt



Measured memory_bytes: 76028
import           Control.Applicative
import           Control.Monad
import           Data.List

swapElem :: Int -> Int -> [a] -> [a]
swapElem i j xs = let xi = xs !! i
                      xj = xs !! j
                      left  = take i xs
                      mid   = take (j - i - 1) (drop (i + 1) xs)
                      right = drop (j + 1) xs
                  in  left ++ [xj] ++ mid ++ [xi] ++ right

solve :: Int -> [(Int, Int)] -> [Int]
solve w = foldl (\acc (a, b) -> swapElem (a - 1) (b - 1) acc) [1..w]

nyan :: String -> (Int, Int)
nyan = tup . words . map c2s
  where c2s c = if c == ',' then ' ' else c
        tup (a:b:_) = (read a, read b)

main :: IO ()
main = do
  w <- readLn
  n <- readLn
  xs <- map nyan <$> replicateM n getLine
  mapM_ print $ solve w xs

Measured memory_bytes: 4048
// #include <cctype>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char** argv) {
  int stack[100];
  size_t head = 0;

  string term;

  while (cin >> term) {
    if (term == "+") {
      head--;
      stack[head - 1] = stack[head - 1] + stack[head];
    } else if (term == "-") {
      head--;
      stack[head - 1] = stack[head - 1] - stack[head];
    } else if (term == "*") {
      head--;
      stack[head - 1] = stack[head - 1] * stack[head];
    } else {
      // cout << term << endl << endl;
      int num = atoi(term.c_str());
      stack[head] = num;
      head++;
    }
  }
  // assert(head == 1);
  cout << stack[head - 1] << endl;

  return 0;
}



Measured memory_bytes: 3216
s = input()
yymm = False
mmyy = False

if 1 <= int(s[:2]) <= 12:
    mmyy = True
if 1 <= int(s[2:]) <= 12:
    yymm = True

if yymm == True and mmyy == True:
    print("AMBIGUOUS")
elif yymm == True:
    print("YYMM")
elif mmyy == True:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3060
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#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++)
const long long INF =  999999999;

ll eucl(ll s,ll t){
  ll a=max(s,t),b=min(s,t);
  ll r=a%b;
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }
  return b;
}

int main(){
  ll a,b;
  cin>>a>>b;
  ll g=eucl(a,b);
  ll c,d;
  c=a/g;
  d=b/g;
  cout<<g*c*d<<endl;
}


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

using namespace std;
bool isPal(string s) {
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != s[s.size() - 1 - i])
            return false;
    }
    return true;
}
int main () {

    string s;
    cin >> s;
    int len = s.size();
    // cout << s << " " << s.substr(0, (len - 1) / 2) << " " << s.substr((len + 2) / 2, len - 1) << "\n";
    if (isPal(s) && isPal(s.substr(0, (len - 1) / 2)) && isPal(s.substr((len + 2)/ 2, len - 1)))
        cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

ans = 'Yes'
for i in range(1, n)[::-1]:
    if h[i] - h[i-1] == -1:
        h[i-1] -= 1
    elif h[i] - h[i-1] < -1:
        ans = 'No'

print(ans)


Measured memory_bytes: 84696
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

int main() {
  int N; cin >> N;
  string S; cin >> S;

  rep(i, S.length()) {
    char tmp = S[i] + N;
    if (tmp > 'Z') cout << (char)(tmp-26);
    else cout << tmp;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# input
s = input()

# solve
for i in range(len(s)):
    if s[i] == 'A':
        a = i
        break

for i in reversed(range(len(s))):
    if s[i] == 'Z':
        z = i
        break

# output
print(z - a + 1)


Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
int n,k,c; 
string s;
void solve(){
	cin>>n>>k>>c>>s;
	s = '#' + s;
	vector<int> earliest(k+1,0),latest(k+1,0);
	int i=1,j=1;
	while(i<s.length()&&j<=k){
		if(s[i]=='o'){
			earliest[j++] = i;
			i+=c+1;
		}else{
			i++;
		}
	}
	i=s.length()-1,j=k;
	while(i>0&&j>=1){
		if(s[i]=='o'){
			latest[j--] = i;
			i-=c+1;
		}else{
			i--;
		}
	}
	for(i=1;i<k+1;i++)if(earliest[i]==latest[i])cout<<earliest[i]<<"\n";
}

int main()
{
  solve();
  return 0;
}

Measured memory_bytes: 3392
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int  a[N];
int main()
{
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
int n,flag=1;
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)flag=0;
	}
}
if(flag)cout<<"APPROVED";
else cout<<"DENIED";
	return 0;
}


Measured memory_bytes: 256