akhauriyash/Code-Regression huggingface dataset:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

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

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

    return arr

n = ii()
A = factorization(n)
#print(A)
ans = 0
if n == 1:
    print(0)
else:
    for i in A:
        num = i[1]
        cnt = 0
        while  num-cnt > 0:
            cnt += 1
            num -= cnt
        ans += cnt
    print(ans)

Measured memory_bytes: 9500
#include<bits/stdc++.h>
using namespace std;
const int N=1000005;
int a[N],v[N],n,ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		int x=a[i];
		if(!v[x])
		{
			for(int j=x;j<=1000000;j+=x)
				v[j]=1;
			if(a[i]!=a[i+1])
				ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8368
N = int(input())
ans = 0

for i in range(1, N + 1):
    # 初項
    a0 = i
    # 公差
    d = i
    # 項数
    n = N // i

    temp = int(0.5 * n * (2 * a0 + (n - 1) * d))
    ans += temp

print(ans)


Measured memory_bytes: 64312
x, y, z, k = list(map(int, input().split()))
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())), reverse=True)
ab = sorted([e+f for e in a[:k] for f in b[:k]], reverse=True)
abc = sorted([g+h for g in ab[:k] for h in c[:k]], reverse=True)
for i, ele in enumerate(abc):
  if i>=k:
    break
  print(ele)

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

/*
code credits : ਜ਼ੈਲਦਾਰ
dashan jot singh
*/
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define inf LLONG_MAX
#define p pair<ll,ll>
ll n,m;
vector<ll> graph[100010];
ll dp[100010];
bool visited[100010];
void dfs(ll src){
	visited[src]=true;
	for(auto i:graph[src]){
		if(!visited[i]){
			dfs(i);
		}
		dp[src]=max(dp[src],1+dp[i]);
	}
}
int main(){
	fast;
	cin>>n>>m;
	for(ll i=0;i<m;i++){
		ll u,v;
		cin>>u>>v;
		graph[u].pb(v);
	}
	memset(dp,0,sizeof(dp));
	memset(visited,false,sizeof(visited));
	for(ll i=1;i<=n;i++){
		if(!visited[i]){
			dfs(i);
		}
	}	
	ll mm=0;
	for(ll i=1;i<=n;i++){
		mm=max(mm,dp[i]);
	}
	cout<<mm<<endl;
	return 0;
}

Measured memory_bytes: 8704
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    string s; cin>>s;
    int n = sz(s);
    rep(i, n) {
        if (s[i] == '?') cout<<'D';
        else cout<<s[i];
    }
}

Measured memory_bytes: 3740
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
#include <string>
using namespace std;
 
int N, M, a[51], b[51], ans=0;
bool graph[51][51] = { false }, visited[51];
 
void dfs(int x) {
    if (visited[x]) return;
    visited[x] = true;
    for (int i = 1; i <= N; i++) {
        if (graph[x][i]) {
            dfs(i);
        }
    }
}
 
int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> a[i] >> b[i];
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }
 
    
    
    for (int i = 0; i < M; i++) {
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
        for (int i = 1; i <= N; i++)visited[i] = false;
        dfs(1);
        bool connected = false;
        for (int j = 1; j <= N; j++) {
            if (!visited[j]) connected = true;
        }
        if (connected) ans++;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }
 
    cout << ans << endl;
 
    return 0;
}

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

int main(){
  
  int n,k;
  string s;
  cin >> n >> k >> s;
  
  int ans=0;
  for(int i=0;i<n-1;i++){
    if(s.at(i)==s.at(i+1)){
      ans++;
    }
  }
  if((ans+2*k)<n-1){
    cout << ans+2*k << endl;
  }else{
    cout << n-1 << endl;
  }
}

Measured memory_bytes: 512
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let n: usize = read!();
    let mut a = Vec::with_capacity(n);
    for _ in 0..n {
        let ai: usize = read!();
        a.push(ai);
    }

    const MIN: usize = 0;
    const MAX: usize = 100;

    let mut ans = U_INF;
    for now in MIN..=MAX {
        let mut sum = 0;
        for &ai in &a {
            sum += (now as isize - ai as isize).pow(2) as usize;
        }
        ans = (ans).min(sum);
    }

    println!("{}", ans);
}


Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
typedef pair<pair<string,int>,int> P;
#define int long long
signed main() {
    int N;
    cin >> N;
    vector<P>vec(N);
    for(int i = 0; i < N; i++) {
        string S;
        int P;
        cin >> S >> P;
        vec[i].first.first = S;
        vec[i].first.second = P*-1;
        vec[i].second = i+1;
    }
    sort(vec.begin(),vec.end());
    for(int i = 0; i < N; i++) {
        cout << vec[i].second << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    string s, t;
    cin >> s >> t;

    cout << (int)(s[0] == t[0]) + (s[1] == t[1]) + (s[2] == t[2]) << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  vector<int> table(1000010);
  int N;
  cin >> N;
  vi A(N);
  int ans = 0;
  REP(i, N) {
    cin >> A.at(i);
    table.at(A.at(i))++;
  }

  for (auto a : A) {
    if (table.at(a) > 1) continue;
    bool flag = false;
    for (int j = 1; j * j <= a; j++) {
      if (a % j == 0) {
        if ((table.at(j) > 0) && (a * j != j) ||
            (table.at(a / j) > 0) && (a / j != a)) {
          flag = true;
          break;
        }
      }
    }
    if (!flag) ans++;
    // cout << a << " " << ans << endl;
  }

  cout << ans << endl;
}


Measured memory_bytes: 7888
import bisect
N = int(input())
A = sorted(list(map(int, input().split()))) #0-index
B = sorted(list(map(int, input().split()))) #0-index
C = sorted(list(map(int, input().split()))) #0-index
print(sum(bisect.bisect_left(A, b)*(N-bisect.bisect_right(C, b)) for b in B))


Measured memory_bytes: 23092
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

// dp[i][j] - the number of ways to put numbers in prefix of size 'i'
// such that the last number is 'j'

const int nax = 3005;
char cmp[nax];
int dp[nax][nax], pref[nax][nax];

const int mod = 1e9 + 7;

void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}

int main() {
    //FILE *fi=freopen("1.txt","r",stdin);

    int n;
    scanf("%d", &n);
    scanf("%s", cmp);
    dp[1][1] = 1;
    for(int len = 2; len <= n; ++len) {
        // let's compute prefix sums on dp[len-1]
        for(int i = 1; i <= len - 1; ++i) {
            pref[len-1][i] = (pref[len-1][i-1] + dp[len-1][i]) % mod;
        }
        for(int b = 1; b <= len; ++b) {
            int L, R;
            if(cmp[len-2] == '<') {
                L = 1, R = b - 1;
            }
            else {
                L = b, R = len - 1;
            }
            if(L <= R) {
                add_self(dp[len][b], (pref[len-1][R] - pref[len-1][L-1] + mod) % mod);
            }
        }
    }
    int answer = 0;
    for(int b = 1; b <= n; ++b) {
        add_self(answer, dp[n][b]);
    }
    printf("%d\n", answer);
}


Measured memory_bytes: 69504
N=int(input())
x=list(map(int,input().split()))

p=sum(x)/N

import math

z1=0
z2=0
for i in range(N):
  z1+=(x[i]-math.floor(p))**2
  z2+=(x[i]-math.ceil(p))**2
  
print(min([z1,z2]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl


namespace atcoder {
	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int MOD = 1000000007;
	const lli LIMIT = 10'000'000'000'000'000 * 5;
	const int tenfive = 100000;
}

using namespace atcoder;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(b / a, c) << endl;
	return 0;
}


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

int main() {
  char X, Y;
  cin >> X >> Y;

  if (X < Y) {
    cout << "<" << endl;
  } else if (X > Y) {
    cout << ">" << endl;
  } else if (X == Y) {
    cout << "=" << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iomanip>
#include <iterator>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <climits>
#include <string>
#include <set>
#include <numeric>
#include <bitset>
#include <cmath>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <numeric>
#include <vector>
#include <cassert>
#include <ctime>

using namespace std;

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define FORi(i,a,b) for(int i=int(a);i<=int(b);i++)
#define FOR(i,n) FORi(i,1,n)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;
using pii=pair<int, int>;
using pdd=pair<double, double>;
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
    return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
    os<<'[';
    for(auto& p: c) os << p << " ";
    return os<<']';
}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
    print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}


template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
    os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
    print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
    print_tuple<0,Args...>(os<<'(',t);
    return os<<')';
}


constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;
constexpr int maxw=31;
constexpr int maxn=1001;

int h, w, d;
string mm="RGBY";
void solve() {
	rep(i, h) {
		rep(j, w) {
			int x=i+j;
			int y=i-j;
			x+=1000*d;
			y+=1000*d;
			x/=d;
			y/=d;
			cout<<(mm[(x&1)*2+(y&1)]);
		}
		cout<<endl;
	}
}

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

	while(cin>>h>>w>>d) {
		solve();
	}
	return 0;
}


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

long long N, M, a[100009][3], maxn = -(1LL << 60);

int main() {
	cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < 3; j++) cin >> a[i][j];
	}
	for (int i = 0; i < 8; i++) {
		vector<long long>vec;
		for (int j = 1; j <= N; j++) {
			long long S = 0;
			for (int k = 0; k < 3; k++) { if ((i / (1 << k)) % 2 == 0) S += a[j][k]; else S -= a[j][k]; }
			vec.push_back(S);
		}
		sort(vec.begin(), vec.end()); reverse(vec.begin(), vec.end());
		long long ans = 0;
		for (int j = 0; j < M; j++) ans += vec[j];
		maxn = max(maxn, ans);
	}
	cout << maxn << endl;
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <string>

int main() {
	double a;
	std::string str;
	str.reserve(13);

	while (std::cin >> a) {
		if (a < 0)
			break;

		for (int i = 7; i >= -4; --i) {
			double b = std::pow(2.0, i);
			if (a >= b) {
				a -= b;
				str += '1';
			}
			else
				str += '0';

			if (i == 0)
				str += '.';
		}

		if (a < 0.000001)
			std::cout << str << std::endl;
		else
			std::cout << "NA" << std::endl;

		str.clear();
	}

	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a[3],ans=0;
	cin>>a[0]>>a[1]>>a[2];
	if(a[0]==a[1]&&a[1]==a[2]){
	    cout<<0<<endl;
	    return 0;
	}
	while(1){
	    sort(a,a+3);
	    a[2]=a[2]-a[0];
	    a[1]=a[1]-a[0];
	    a[0]=0;
	    if((a[0]==0&&a[1]==2&&a[2]==2)||(a[0]==0&&a[1]==0&&a[2]==1)){
	        cout<<ans+1<<endl;
	        return 0;
	    }
	    a[0]+=2;
	    ans++;
	}
	return 0;
}

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

int main(){
	int n,k,cnt=0;
	cin>>n>>k;
	int l[n];
	for(int i=0; i<n; i++)cin>>l[i];
	
	sort(l,l+n);
	
	for(int i=n-1; i>n-k-1; i--){
		cnt+=l[i];
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int mod2 = 998244353;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> masu(h, vector<char>(w));
  rep(i, h) {
    rep(j, w) {
      cin >> masu[i][j];
    }
  }
  vector<vector<int>> l(h, vector<int>(w));
  vector<vector<int>> r(h, vector<int>(w));
  vector<vector<int>> u(h, vector<int>(w));
  vector<vector<int>> d(h, vector<int>(w));
  rep(i, h) {
    rep(j, w) {
      if (masu[i][j] == '#') continue;
      if (j == 0) {
        l[i][j] = 1;
        continue;
      }
      l[i][j] = l[i][j-1] + 1;
    }
  }
  rep(i, h) {
    repr(j, w-1) {
      if (masu[i][j] == '#') continue;
      if (j == w-1) {
        r[i][j] = 1;
        continue;
      }
      r[i][j] = r[i][j+1] + 1;
    }
  }
  rep(j, w) {
    rep(i, h) {
      if (masu[i][j] == '#') continue;
      if (i == 0) {
        u[i][j] = 1;
        continue;
      }
      u[i][j] = u[i-1][j] + 1;
    }
  }
  rep(j, w) {
    repr(i, h-1) {
      if (masu[i][j] == '#') continue;
      if (i == h-1) {
        d[i][j] = 1;
        continue;
      }
      d[i][j] = d[i+1][j] + 1;
    }
  }
  int ans = 0;
  rep(i, h) {
    rep(j, w) {
      if (masu[i][j] == '#') continue;
      int light = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3;
      ans = max(ans, light);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 67072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int n;
string s;
map<pair<string, string>, ll> m;
void dfs1(int i, string a, string b) {
    if (i == n) {
        ++m[{a, b}];
        return;
    }
    dfs1(i + 1, a + s[i], b);
    dfs1(i + 1, a, b + s[i]);
}
ll dfs2(int i, string a, string b) {
    if (i < n)return m[{a, b}];
    return dfs2(i - 1, a + s[i], b) + dfs2(i - 1, a, b + s[i]);
}

int main() {
    init();

    cin >> n >> s;
    dfs1(0, "", "");
    cout << dfs2(n * 2 - 1, "", "") << "\n";
}

Measured memory_bytes: 87808
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int max = 0, min = (int) 2e9;
		
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			max = Math.max(max, a);
			min = Math.min(min, a);
		}
		
		System.out.println(max - min);
		
	}

}


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

namespace ConsoleApp111 {
    class Program {
        static void Main(string[] args) {
            string S = Console.ReadLine();

            int len = S.Length;

            int ans = 0;

            for (int i = 1; i < len; i++) {
                if (S[i] != S[i - 1]) {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


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


int main(){
    int h, n, sum = 0;
    cin >> h >> n;
    for (int i=0; i<n; i++){
        int a;
        cin >> a;
        sum += a;
    }

    if (h <= sum){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",c);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int primes[200];
int prime[1000000];
int pr[100000];
int el[314514],wl[314514];
int er[314514],wr[314514];
int a[114514];
string s[214514];
int b[214514],c[214514];
int ans[214514];
signed main(){
	sc(s)
	int n=s.size();
	int sum=1;
	rep(0,i,n){
		if(s[i]==s[i+1])sum++;
		else{
			a[i]=sum;
			sum=1;
		}
	}
	sum=0;
	rep(0,i,n){
		if(a[i]>0){
			b[sum]=i;
			c[sum]=a[i];
			sum++;
		}
	}
	rep(0,i,sum){
		if(i%2==0){
			if(c[i]%2==0&&c[i+1]%2==1){
				ans[b[i]]=(c[i]+c[i+1])/2;
				ans[b[i]+1]=(c[i]+c[i+1]+1)/2;
			}
			else{	
				ans[b[i]]=(c[i]+c[i+1]+1)/2;
				ans[b[i]+1]=(c[i]+c[i+1])/2;
			}	
		}
	}			
	rep(0,i,n){
		cout<<ans[i]<<" ";
	}
}

Measured memory_bytes: 7936
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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; }

#define mod 1000000007LL
#define eps 0.0001
#define pi acos(-1)
#define INF 10000000000000000

#define rep(i, n) for(int i = 0;i < n;++i)
#define rep1(i, n) for(int i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define chmin

#define lset(h, n) memset(h, n, sizeof(h));
    

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------

    ll N,T;
    cin >> N >> T;
    ll t[N];
    rep(i,N){
        cin >> t[i];
    }
    ll ans = 0;
    ll time = -1000000001;
    rep(i,N){
        ll ok = 0;
        if((t[i]-time) < T){
           ok = T - (t[i]-time);
        }
        time=t[i];
        ans += T-ok;
    }
    pri(ans);
}












Measured memory_bytes: 1792
import sys
for line in sys.stdin:
    if line == None or line == '\n':
        break
    a,b = line.split(" ")
    a = int(a)
    b = int(b)
    if a % 2 == 0 or b % 2 == 0:
        print("Even")
    if a % 2 != 0 and b % 2 != 0:
        print("Odd")

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	float m, n;
	int i, j;
	int num;
	int count;
	
	while (1){
		scanf("%f", &m);
		if (m ==  0){
			break;
		}
		scanf("%f", &n);				
		count = 0;
		for (i = m; i <= n; i++){
			num = i;
			for (j = 0; j < 20; j++){
				if (num / 2 != 0 && num % 2 == 0){
					num /= 2;
				}
				if (num / 3 != 0 && num % 3 == 0){	
					num /= 3;
				}
				if (num / 5 != 0 && num % 5 == 0){
					num /= 5;
				}
			}
			if (num == 1){
				count += 1;
			}
		}
		printf("%d\n", count);
	}
	
	return (0);
}

Measured memory_bytes: 620
module Main where

import           Data.List

toInt :: String -> Int
toInt s = read s :: Int

strToIntList :: String -> [Int]
strToIntList = map toInt . words

getIntList :: IO [Int]
getIntList = getLine >>= return . strToIntList

main :: IO ()
main = do
  nab <- getIntList
  print
    .   sum
    .   map fst
    .   filter (\(_, b) -> nab !! 1 <= b && b <= nab !! 2)
    $   zip
    <$> id
    <*> map (sum . tt)
    $   [1 .. head nab]

tt :: Int -> [Int]
tt = unfoldr fnc where
  fnc 0 = Nothing
  fnc n = Just (n `mod` 10, n `div` 10)


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

int main(){
    int n; cin >> n;
    set<string> group;
    string temp;
    rep(i, n){
        cin >> temp;
        group.insert(temp);
    }
    cout << group.size() <<endl;
    return 0;
}

Measured memory_bytes: 19240
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int n,s,w,q,a[100000];
void solve25(){
	ll ans=0;
	int nonzero=0;
	rep(i,n){
		if(a[i])nonzero++;
		if(a[i]%q==0)ans+=nonzero;
	}
	cout<<ans<<endl;
}
void solve(){
	ll ans=0;
	map<int,int> cnt;
	cnt[0]=1;
	ll mod=0,ten=1;
	for(int i=n-1;i>=0;i--){
		(mod+=ten*a[i])%=q;
		(ten*=10)%=q;
		if(a[i])ans+=cnt[mod];
		cnt[mod]++;
	}
	cout<<ans<<endl;
}
int main()
{
	while(scanf("%d%d%d%d",&n,&s,&w,&q),n){
		rep(i,n){
			a[i]=s/7%10;
			if(s%2==0)s/=2;
			else s=(s/2)^w;
		}
		//rep(i,n)cerr<<a[i]<<" "; cerr<<endl;
		if(q==5||q==2)solve25();
		else solve();
	}
	return 0;
}

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


int main()
{

    ll n,y,a,b,c;
    cin>>n>>y;

    if(y%10000==0 && y/10000==n)cout<<y/10000<<" "<<0<<" "<<0<<endl;
    else if(y%5000==0 && y/5000==n)cout<<0<<" "<<y/5000<<" "<<0<<endl;
    else if(y%1000==0 && y/1000==n)cout<<0<<" "<<0<<" "<<y/1000<<endl;
    else{

        for(int i=0;i<=n;i++){
            a=10000*i;
            for(int j=0;j<=n-i;j++){
                b=5000*j;
                for(int k=0;k<=n-i-j;k++){
                    c=1000*k;
                    if(a+b+c==y && i+j+k==n){
                        cout<<i<<" "<<j<<" "<<k<<endl;
                        return 0;
                    }
                }
            }
        }
        cout<<-1<<" "<<-1<<" "<<-1<<endl;
    }

return 0;
}


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

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

int main(){

  int n; cin>> n;
  using i64=long long;
  vector<i64> a(n);
  rep(i, n) cin>> a[i];

  if(n==1){
    cout<< 0<< endl;
    return 0;
  }
  rep(i, n) a[i]-=i;
  sort(a.begin(), a.end());
  auto cost=[&](i64 mid){
    i64 ret=0;
    rep(i, n) ret+=max(mid-a[i], a[i]-mid);
    return ret;
  };

  cout<< min(cost(a[n/2]), cost(a[n/2-1]));

  return 0;
}


/*


*/

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int n;
    cin >> n;
    if(n%2 == 0){
        cout << n << endl;
    }
    else{
        cout << n*2 << endl;
    }
}

Measured memory_bytes: 256
import bisect
n = int(input())

a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))

r = 0
for bi in b:
  r += (bisect.bisect_left(a, bi)) * (n - bisect.bisect_right(c, bi))

print(r)

Measured memory_bytes: 23244
// https://atcoder.jp/contests/abc144/tasks/abc144_c

#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const ll N_MAX = 1e12;

ll N;

void solve() {

  ll ans = N + 1;
  for (ll i = 1; i * i <= N; i++) {
    if (N % i == 0) {
      ans = min(ans, i + N / i);
    }
  }
  printf("%lld\n", ans - 2);
}

void input() {
  scanf("%lld", &N);
}

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


Measured memory_bytes: 128
n,a,b = map(int,input().split())
numbers = []

for i in range(1,n+1):
	num_str = list(str(i))
	some_sum = 0
	for num in num_str:
		some_sum += int(num)
	if a <= some_sum <= b :
		numbers.append(i)
print(sum(numbers))

Measured memory_bytes: 3296
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
char S[110];
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	scanf("%s",S+1);
	int n=strlen(S+1);
	if(n&1)puts("No");
	else{
		bool flg=1;
		for(int i=1;i<=n;i+=2)flg&=S[i]=='h';
		for(int i=2;i<=n;i+=2)flg&=S[i]=='i';
		puts(flg?"Yes":"No");
	}
	return 0;
}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7

n,a,b = map(int,input().split())

def pow_k(x, n):
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K = K * x % MOD
        x = x ** 2 % MOD
        n //= 2

    return K * x % MOD

def kai(x):
    an = 1
    for i in range(1,x+1):
        an = an * i % MOD
        
    return an

def kai2(x,yy):
    an = 1
    for i in range(x+1-yy,x+1):
        an = an * i % MOD
        
    return an

x = pow_k(2,n) - 1

mia = (kai2(n,a) * pow_k(kai(a),MOD-2)) % MOD
mib = (kai2(n,b) * pow_k(kai(b),MOD-2)) % MOD

ans = (4*MOD + x - mia - mib) % MOD

print(ans)

Measured memory_bytes: 39024
#include "cstdio"
#include "algorithm"
using namespace std;
#define ri register int
int b[101];
int main()
{
	int n,m,ans=0,c;
	scanf("%d %d %d",&n,&m,&c);
	for(ri i=1;i<=m;i++)
	{
		scanf("%d",&b[i]);
	}
	for(ri i=1;i<=n;i++)
	{
		int tot=0,tmp=0;
		for(ri j=1;j<=m;j++)
		{
			scanf("%d",&tmp);
			tot+=tmp*b[j];
		}
		if(tot+c>0) 
			ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>){
    val (a, b, c) = readLine()!!.split(" ").map(String::toInt)
    var ans = ""
    if (a == b && b == c){
        ans = "No"
    }
    else if(a == b || b == c || c == a){
        ans = "Yes"
    }
    else{
        ans = "No"
    }
    println(ans)
}


Measured memory_bytes: 36128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func init() {
	sc = bufio.NewScanner(os.Stdin)
	buffsize := 1000000
	buff := make([]byte, buffsize)
	sc.Buffer(buff, buffsize)
	sc.Split(bufio.ScanWords)
}

func loadint() (result int) {
	sc.Scan()
	result, _ = strconv.Atoi(sc.Text())
	return
}

func main() {
	n := loadint()
	result := 0
	for i := 1; i <= n; i += 2 {
		d := 0
		for j := 1; j <= i; j++ {
			if i%j == 0 {
				d++
			}
		}
		if d == 8 {
			result++
		}
	}
	fmt.Println(result)
}


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

int main()
{
    int x, y;
    cin >> x >> y;
    if(x == 2){
        if(y == 2){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else if(x == 4 || x == 6 || x == 9 || x == 11){
        if(y == 4 || y == 6 || y == 9 || y == 11){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else{
        if(y == 2 || y == 4 || y == 6 || y == 9 || y == 11){
            cout << "No" << endl;
        }
        else{
            cout << "Yes" << endl;
        }
    }
    return 0;
}

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

using namespace std;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef pair<int,int> pii;
typedef long long ll;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n , m, i, j, u, v;
    cin >> n >> m;
    vi mx(n, -1);
    vi h(n);

    for(i=0;i<n;i++) cin >> h[i];

    for(i=0;i<m;i++){
        cin >> u >> v;
        u--;v--;
        mx[u] = max(mx[u], h[v]);
        mx[v] = max(mx[v], h[u]);
    }
    int ans = 0;
    for(i=0;i<n;i++){
        if(h[i] > mx[i]) ans++;
    }
    cout << ans << "\n";

    return 0;
}

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

#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define pb push_back
#define int long long

const int N = 3e3 + 10;
const int mod = 1e9 + 7;

int n;
int f[N][N];
string s;

void add(int &x, int y) { x = (x + y + mod) % mod; }
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n >> s;
    f[1][1] = 1;
    FOR(i, 2, n) FOR(j, 1, i)   {
        if(s[i - 2] == '<') f[i][j] = f[i - 1][j - 1];
        else f[i][j] = (f[i - 1][i - 1] - f[i - 1][j - 1] + mod * mod ) % mod;
        add(f[i][j], f[i][j - 1]);
    }
    cout << (f[n][n] + mod) % mod;
}


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

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

  int tbl[][7] = {
    { 4, 2, 3, 5, 4, 0 },
    { 1, 4, 6, 3, 1, 0 },
    { 1, 2, 6, 5, 1, 0 },
    { 1, 5, 6, 2, 1, 0 },
    { 1, 3, 6, 4, 1, 0 },
    { 5, 3, 2, 4, 5, 0 }
  };

  int tblx = extent<decltype(tbl),0>::value;
  int tbly = extent<decltype(tbl),1>::value;

  for( int i = 0; i < tblx; i++ ) {
    for( int j = 0; j < tbly; j++ ) {
      if( j == tbly - 1 ) {
        continue;
      }
      tbl[ i ][ j ] = dat[ tbl[ i ][ j ] - 1 ];
    }
  }

  int q, a, b, right;
  cin >> q;
  for( int i = 0; i < q; i++ ) {
    cin >> a >> b;
    for( int j = 0; j < tblx; j++ ) {
      for( int k = 0; k < tbly; k++ ) {
        if( tbl[ j ][ k ] == a and tbl[ j ][ k + 1 ] == b ) {

          if( false ) {
            for( int l = 0; l < tbly; l++ ) {
              cout << tbl[j][ l ] << ",";
            }
            cout << ":" << a << "/" << b << "/";
          }
          cout << dat[ j ] << endl;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3088
#include<cstdio>
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int MAXN=1e2+9;
int main()
{
    bool del[MAXN][MAXN];
    char G[MAXN][MAXN];
    int n,m;
    memset(del,false,sizeof(del));
    scanf("%d%d",&n,&m);
    int st=0;
    int ed=0;
    for(int i=0; i<n; ++i)
    {
        for(int j=0; j<m; ++j)
            scanf(" %1c",&G[i][j]);
    }
    for(int i=0; i<n; ++i)
    {
        bool flag=false;
        for(int j=0; j<m; ++j)
        {
            if(G[i][j]!='.')
                flag=true;
        }
        if(!flag)
        {
            for(int j=0; j<m; ++j)
            {
                del[i][j]=true;
            }
        }
        else st=i;
    }
    for(int i=0; i<m; ++i)
    {
        bool flag=false;
        for(int j=0; j<n; ++j)
        {
            if(G[j][i]!='.')
                flag=true;
        }
        if(!flag)
        {
            for(int j=0; j<n; ++j)
            {
                del[j][i]=true;
            }
        }
    }
    for(int i=m-1;i>=0;--i)
    {
        if(del[st][i]==false)
        {
            ed=i;
            break;
        }
    }
    for(int i=0; i<n; ++i)
    {
        for(int j=0; j<m; ++j)
        {
            if(j!=ed)
            {
                if(!del[i][j])
                    printf("%c",G[i][j]);
            }
            else if(!del[i][j])
                printf("%c\n",G[i][j]);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,ai,x,min,max;
	long long int sum=0;
	min=1000000;
	max=-1000000;
	scanf("%d",&n);
	
	
	for(x=0;x<n;x++){
		scanf("%d",&ai);
		sum+=ai;
		
		if(min>ai){
			min=ai;
		}
		if(max<ai){
			max=ai;
		}
	}
	
	
	printf("%d %d %lld\n",min,max,sum);
	
	return 0;
}

Measured memory_bytes: 600
--ghc
import Data.List
import Data.Char
import Text.Printf
import qualified Data.ByteString.Char8 as BS 
main = do
    [n, y] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    let ex = last $ ["-1", "-1", "-1"] : [map show [u, v, n - u - v] | u <- [0..n], v <- [0..n-u], u * 10000 + v * 5000 + (n - u - v) * 1000 == y] 
    putStrLn $ ex!!0 ++ " " ++ ex!!1 ++ " " ++ ex!!2

Measured memory_bytes: 508
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn solve(a: usize, b: usize, c: usize) -> &'static str {
    if a + b == c {
        "Yes"
    } else if a + c == b {
        "Yes"
    } else if b + c == a {
        "Yes"
    } else {
        "No"
    }
}

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
    };

    println!("{}", solve(a, b, c));
}


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

int main(){
  
  int a[5];

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

  for(int i=4;i > -1;i--)
    {
      cout << a[i];
      if(i)cout << " ";
    }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 3052
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000007
//S.size()

using namespace std;


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef long long ll;


int main(void){
  string S;cin>>S;
  if(S[0]==S[1]||S[1]==S[2]||S[2]==S[3])cout<<"Bad";
  else cout<<"Good";
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

pair <int, int> a[123456];

int main (void)
{
  int n, i, m;
  while (scanf ("%d %d", &n, &m) != EOF)
  {
    for (i = 0; i < m; i++)
      scanf ("%d %d", &a[i].first, &a[i].second);
    sort (a, a + m);
    int res = 0, curb = 0, cure = 123456;
    for (i = 0; i < m; i++)
    {
      curb = a[i].first;
      cure = min (cure, a[i].second);
      if (cure <= curb)
      {
        res++;
        cure = a[i].second;
      }
    }
    if (curb < cure)
      res++;
    printf ("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>

using namespace std;

int main(int argc, char* argv[]){
  int i,a,b,c;
  cin >> a >> b >> c;
  int remnant; //余り,剰余
  bool yes = 0;

  for(i=1;i<b+1;i++){
  	remnant = (i*a) % b;
  	if(remnant == c){
  		cout << "YES" << endl;
  		yes = 1;
  		break;
  	}
  }

  if(yes==0){
  	cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int N,Max,nr,X,Y;

int main()
{
    cin >> N >> X;
    for(int i = 1; i < N; ++i)
    {
        cin >> Y;
        if(X >= Y)
            nr++;
        else if(nr)
            Max = max(Max,nr),nr = 0;
        X = Y;
    }
    Max = max(Max,nr);
    cout << Max;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

  char N[5];
  int cnt = 0;
  
  cin >> N;

  for(int i = 0; i < 4; i++){
    if(N[i] == '2'){
      cnt++;
    }
  }

  cout << cnt << "\n";

  return 0;
}


Measured memory_bytes: 256
import sys
n, a, b = map(int, input().split())
if a == 0 or n == 0:
    print(0)
    sys.exit()
j = n //(a + b)

if n - (a + b) * j >= a:
    print(a * j + a)
    sys.exit()
else:
    print(a * j + n- (a + b)*j )
    sys.exit()

Measured memory_bytes: 39888
$<.to_a.map{|i|i.split.map(&:to_i)}.tap{|((n,t),x)|break n==1 ? t : x.each_cons(2).to_a.map{|(a,b)| b-a-t <= 0 ? b-a : t}.inject(&:+)+t}.tap{|x|p x}


Measured memory_bytes: 27140
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int unsigned long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
int A, B, C ; 
signed main()
{
	A = gi(), B = gi(), C = gi() ;
	if( C <= A + B ) {
		puts("No") ; exit(0) ;
	}
	long long t = C - A - B ; 
	int sq = 1ull * t * t ;
	int q4 = 4ull * A * B ; 
	if( q4 >= sq ) {
		puts("No") ; exit(0) ; 
	}
	puts("Yes") ; 
	return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;

int A,B,C;
int N;
int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);

    string S;
    cin >> S;
    int ans;
    bool is = true;

    char s1,s2='0';
    int a=0,b=0;

    s1 = S[0];
    for(int i = 0; i < S.length();i++){
        if(S[i] != s1){
            if(S[i] != s2){
                if(s2 == '0'){
                    s2 = S[i];
                    b++;
                }else{
                    cout << "No" << endl;
                    return 0;
                }
                b++;
            }

        }else{
            a++;
        }
    }

    if(a == 2 && b == 2) cout << "Yes" << endl;
    else cout << "No" << endl;

    
    

    return 0;
}

Measured memory_bytes: 256
from itertools import permutations
from math import sqrt

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
sum_ = 0
l = list(permutations(XY))
len_l = len(l)
for perm in l:
    for i in range(N-1):
        sum_ += sqrt((perm[i+1][0] - perm[i][0])**2 + (perm[i+1][1] - perm[i][1])**2)
print(sum_ / len_l)


Measured memory_bytes: 7972
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

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

    vector<vector<int>> vec(M);

    for (int i = 0; i < M; ++i) {
        int k; cin >> k;
        vec[i].resize(k);
        for (int j = 0; j < k; ++j) {
            cin >> vec[i][j];
            --vec[i][j];
        }
    }

    vector<int> p(M);
    for (int i = 0; i < M; ++i) cin >> p[i];

    int ans = 0;
    for (int i = 0; i < (1 << N); ++i) {
        bool ok = true;
        for (int j = 0; j < M; ++j) {
            int c = 0;
            for (int id : vec[j]) {
                if ((i >> id) & 1) {
                    ++c;
                }
            }
            c %= 2;
            if (c != p[j]) {
                ok = false;
            }
        }
        if (ok) {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256