akhauriyash/Code-Regression huggingface dataset:
n = int(input())
dic_sorted_s = {}
count = 0
for i in range(n):
    s = input()
    str_sorted_s = ''.join(sorted(s))
    try:
        count += dic_sorted_s[str_sorted_s]
        dic_sorted_s[str_sorted_s] += 1
    except KeyError:
        dic_sorted_s[str_sorted_s] = 1
print(count)

Measured memory_bytes: 17888
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();
        int G = sc.nextInt();

        int[] p = new int[D];
        int[] c = new int[D];
        for (int i = 0; i < D; i++) {
            p[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }

        // 完全に解く or 中途半端に解くしかない。その組み合わせの中で最も解く問題数が少ないものを探す
        // 完全に解くものの組み合わせをリストアップ
        int ans = Integer.MAX_VALUE;
        for(int i = 0; i < 1<<D; i++){
            int ans_tmp = 0;
            int score = 0;

            // 完全に解くものの合計
            for(int j = 0; j < D; j++){
                if((i>>j & 1) == 1){
                    score += 100 * (j + 1) * p[j] + c[j];
                    ans_tmp += p[j];
                }
                // スコア超えたらそこで終わり
                if(score >= G){
                    ans = Math.min(ans, ans_tmp);
                    continue;
                }
            }

            // 中途半端に解くものを探す
            for(int j = 0; j < D; j++){
                // 完全に解かれているものはスキップ
                if((i>>j & 1) == 1){ continue; }

                int score_tmp = score;
                int ans_tmp_tmp = ans_tmp;

                for(int k = 0; k < p[j] - 1; k++){
                    score_tmp += 100 * (j + 1);
                    ans_tmp_tmp++;

                    // スコア超えたらそこで終わり
                    if(score_tmp >= G){
                        ans = Math.min(ans, ans_tmp_tmp);
                        break;
                    }
                }
            }
        }
        out.println(ans);
    }
}


Measured memory_bytes: 23380
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;
using std::swap;

long long int N;
long long int t;
int che(long long int x, long long int u) {
	std::string nnn = std::to_string(x);
	if (x <= N) {
		if (x > 100 && nnn.find("3") != std::string::npos &&nnn.find("5") != std::string::npos &&nnn.find("7") != std::string::npos)++t;
		che(x + 3 * u, 10 * u);
		che(x + 5 * u, 10 * u);
		che(x + 7 * u, 10 * u);
	}
	else return 0;
}
int main()
{	
	t = 0;
	cin >> N;
	che(0, 1);
	cout << t << "\n";
	return 0;
}

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

using namespace std;

int main()
{
    long long a, b, c, k;
    cin >> a >> b >> c >> k;
    
    if ( k <= a ) {
        cout << k << endl;
    } else if ( a <= k && k <= a + b) {
        cout << a << endl;
    } else if (a + b <= k && k <= a + b + c) {
        cout << a - (k - a - b) << endl;
    } else {
    }
    return 0;
}


Measured memory_bytes: 3624
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	int K;
	string S;
	cin >> K >> S;

	cout << S.substr(0, K) << ((S.size() <= K) ? "" : "...") << "\n";

	return 0;
}



Measured memory_bytes: 3636
// Problem : A - Plural Form
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

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

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  lcm(x, y)   ((x) * (y) / __gcd(x, y))
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
    string s; cin >> s;
    int sz = s.size();
    
    if(s[sz-1]=='s') {
        // s.pop_back();
        s += "e";
        s += "s";
    } else{
        s += "s";
    }
    
    cout << s;
}

int main(){
    IOS;
    solve();
}

Measured memory_bytes: 3656
#ifndef BZ
#pragma GCC optimize "Ofast"
#endif
#include <bits/stdc++.h>
using namespace std;
using ull = uint64_t;
using ll = int64_t;
using ld = long double;

const ll MOD = 1e9 + 7;

ll pw(ll a, ll b) {
    if (!b) {
        return 1;
    }

    ll v = pw(a, b / 2);
    v = (v * v) % MOD;

    if (b & 1) {
        v = (v * a) % MOD;
    }

    return  v;
}

const int MAXN = 602;
ll f[MAXN];
ll g[MAXN][MAXN];
ll h[MAXN][MAXN];

int a[MAXN], b[MAXN];

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);
    int n, k;
    cin >> n >> k;
    f[0] = 1;
    for (int i = 1; i <= n; ++i) {
        f[i] = f[i - 1] * (2 * i - 1) % MOD;
    }

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

    ll ans = f[n - k];

    for (int l = 2 * n - 2; l >= 0; --l) {
        for (int r = l + 2; r < 2 * n; r += 2) {
            int c = (r - l) / 2;
            bool bad = false;
            for (int j = 0; j < k; ++j) {
                bool ga = (l < a[j] && a[j] <= r);
                bool gb = (l < b[j] && b[j] <= r);
                bad |= (ga != gb);
                c -= ga;
            }

            if (bad) {
                continue;
            }

            ll out = f[n - k - c];

            g[l][r] = f[c];
            h[l][r] = g[l][r];


            for (int q = l + 2; q < r; q += 2) {
                h[l][r] = (h[l][r] + MOD * MOD - g[l][q] * h[q][r]) % MOD;
            }

            ans = (ans + h[l][r] * out) % MOD;
        }
    }

    cout << ans << "\n";
}
 

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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

void LOG(const int& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

i64 ceil(i64 a, i64 b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }
i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

const i64 M = 1000000007;
signed main() {
  i64 N, K;
  cin >> N >> K;
  vector<i64> A(N);
  cin >> A;
  i64 ans = 0;
  REP(i, N) {
    FOR(j, 0, i) {
      if (A[i] > A[j]) {
        ans += (K - 1) * K / 2;
        ans %= M;
      }
    }
    FOR(j, i + 1, N) {
      if (A[i] > A[j]) {
        ans += (K + 1) * K / 2;
        ans %= M;
      }
    }
  }
  cout << ans << endl;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N, K;
	cin >> N >> K;
	vector<int>h(N);
	int cnt = 0;
	for (int i = 0; i < N; i++){
		cin >> h[i];
		if (h[i] >= K) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include <bits/stdc++.h>
#include <cstdio>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
//string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
#define PI 3.141592653589
#define M_MAX (600 * 600/2)
#define N_MAX 600
vector<int> G[N_MAX];

int main()
{
    int S[M_MAX], T[M_MAX];
    double dp[N_MAX];
    cin >> N >> M;
    rep(i, M)cin >> S[i] >> T[i];
    rep(i, M)G[S[i] - 1].push_back(T[i] - 1); 
    
    double min = 1000.0;
    for (int ii = 0; ii < N; ii++){
        dp[N - 1] = 0.0;
        for (int i = N - 2; i >= 0; i--){
            if (G[i].size() == 1){
                int to = G[i][0];
                dp[i] = dp[to] + 1.0;
            } else {
                assert (G[i].size() >= 2);
                double sum = 0, max = 0.0;
                int nn = G[i].size();
                for (int j = 0; j < nn; j++){
                    int to = G[i][j];
                    if (max < dp[to]){
                        max = dp[to];
                    }
                    sum += dp[to];
                }
                if (i == ii){
                    dp[i] = 1.0 + (sum - max)/(double)(nn-1);
                } else {
                    dp[i] = 1.0 + sum/(double)(nn);
                }
            }
        }
        if (min > dp[0])
            min = dp[0];
        
    }
    printf("%.10f\n", min);
    //cout << min << endl;
    
#if 0
    int S[M_MAX], T[M_MAX], cnt[N_MAX];
    double dp[N_MAX], diff[N_MAX], dp2[N_MAX];
    cin >> N >> M;
    rep(i, M)cin >> S[i] >> T[i];
    rep(i, M)G[S[i] - 1].push_back(T[i] - 1); 

    dp[N - 1] = dp2[N - 1] = 0.0;
    for (int i = N - 2; i >= 0; i--){
        if (G[i].size() == 1){
            int to = G[i][0];
            dp[i] = dp[to] + 1.0;
            dp2[i] = dp2[to] + 1.0;
        } else {
            assert (G[i].size() >= 2);
            double sum = 0, max = 0.0, max2 = 0.0;
            int nn = G[i].size();
            for (int j = 0; j < nn; j++){
                int to = G[i][j];
                if (max < dp[to]){
                    max = dp[to];
                }
                if (max2 < dp[to] - dp2[to]){
                    max2 = dp[to] - dp2[to];
                }
                sum += dp[to];
            }
            
            dp[i]  = 1.0 + sum/(double)(nn);
            dp2[i] = 1.0 + 
                min ((sum - max2)/(double)nn, (sum - max)/(double)(nn-1));
        }
        fprintf(stderr, "%d, %f, %f, --", i, dp[i], dp2[i]);
        for (int j = 0; j < G[i].size(); j++){
            fprintf(stderr, "%d, ", G[i][j]);
        }
        fprintf(stderr, "--\n");
            
    }
    cout << dp2[0] << endl;
#endif
    return 0;    
}


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

using namespace std;

typedef long long int ll;
typedef vector<ll> vl;
typedef vector<string> vs;

#define N 50

int mp[N];

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

	for (int i = 0; i < N; i++) {
		mp[i] = 0;
	}

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

	for (int i = 1; i <= n; i++) {
		cout << mp[i] << endl;
	}

	return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define int long long
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define out(a) cout<<(a)<<endl
typedef long long ll;
typedef string str;
typedef vector<int> V;
typedef pair<int,int> P;
typedef vector<P> VP;
const int INF = 1LL<<60;
const int MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int n,q;
str s;
vector<char> t,d;

bool simulate(int idx){
  rep(i,q){
    if(t[i]==s[idx]){
      if(d[i]=='L'){
        idx--;
      }
      else idx++;
    }
    if(idx==0||idx==n+1)return true;
  }
  return false;
}

signed main(){
  cin>>n>>q>>s;
  s=" "+s;
  rep(i,q){
    char T,D;
    cin>>T>>D;
    t.pb(T);
    d.pb(D);
  }

  int left=0,right=n+1;
  while(right-left!=1){
    int mid=(left+right)/2;
    bool falled;
    falled=simulate(mid);
    if(falled)left=mid;
    else right=mid;
  }
  int L=right;

  left=0,right=n+1;
  while(right-left!=1){
    int mid=(left+right)/2;
    bool falled;
    falled=simulate(mid);
    if(falled)right=mid;
    else left=mid;
  }
  int R=left;

  if(L>R)out(0);
  else out(R-L+1);
  
  return 0;
}



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

int main() {

    int N,A,B;
    cin >> N >> A >> B;

    int i, sum, ans=0;
    for(i=1;i<=N;i++){
        sum = i/10000 + (i%10000)/1000 + (i%1000)/100 + (i%100)/10 + i%10;
        if(sum>=A && sum<=B) ans+=i;
    }

    cout << ans << endl;

    return 0;
}

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

//#pragma GCC optimize("Ofast")

using namespace std;

typedef long long ll;
typedef long double ld;

mt19937 rnd(time(0));

#define ioss ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("lights.in", "r", stdin); freopen("lights.out", "w", stdout);
#define s second
#define f first
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pll pair<ll,ll>
#define pii pair<int,int>

const ll INF = 1e18;
constexpr ll mod = 1e9 + 7;

ll x0r(ll x, ll y) { return (x | y) & (~x | ~y); }


void solve() {
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (auto &i : a)cin >> i;
    sort(rall(a));
    ll ans = 0;
    for(int i = k;i<n;i++){
        ans +=a[i];
    }
    cout<<ans<<'\n';
}


signed main() {
    //ioss
    //clock_t time = clock();
    //if ((double) (clock() - time) / CLOCKS_PER_SEC > 0.96) {
    //file
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 1792
/***********************************************
 *                                             *
 *   author: raghav_0901 (Raghav Dalmia)       *
 *   updated on: 21-06-2020, 10:18:35 pm IST   *
 *                                             *
\***********************************************/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

signed main( )
{
    long long int n;
    cin >> n;

    string s = "";

    while (n)
    {
        int m = n % 26;
        if (m == 0)
            m = 26;
        s = s + char('a' + m - 1);
        n -= m;
        n /= 26;
    }

    reverse(s.begin( ), s.end( ));
    cout << s + "\n";

    return 0;
}

Measured memory_bytes: 3628
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			m = scanner.nextInt();
			n = scanner.nextInt();
			if ((m | n) == 0)
				break;
			M = new HashMap<Integer, Integer>();
			h = 1;
			a = new int[n][m];
			Y = new int[24];
			X = new int[24];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < m; j++) {
					int t = scanner.nextInt();
					if (t == 0) {
						a[i][j] = -1;
					} else if (t == 1) {
						Y[h] = i;
						X[h] = j;
						a[i][j] = h++;
					} else {
						Y[0] = i;
						X[0] = j;
						a[i][j] = 0;
					}
				}
			System.out.println(slove(0, 1));
		}
	}

	private int slove(int cur, int mask) {
		if (Integer.bitCount(mask) >= 12) {
			int k = cur << 24 | mask;
			if (M.containsKey(k))
				return M.get(k);
		}
		int res = 0;
		for (int[] mo : move) {
			int y = Y[cur];
			int x = X[cur];
			while (true) {
				y += mo[0];
				x += mo[1];
				if (!isOK(y, x))
					break;
				if (a[y][x] == 0)
					if (mask == (1 << h) - 1)
						res++;
				if (a[y][x] >= 1) {
					if ((mask >> a[y][x] & 1) == 1)
						continue;
					res += slove(a[y][x], mask | 1 << a[y][x]);
					break;
				}
			}
		}
		if (Integer.bitCount(mask) >= 12)
			M.put(cur << 24 | mask, res);
		return res;
	}

	private boolean isOK(int y, int x) {
		if (0 <= y && y < n && 0 <= x && x < m)
			return true;
		return false;
	}

	int m, n, h;
	int[] Y, X;
	int[][] a;
	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };
	Map<Integer, Integer> M;
}

Measured memory_bytes: 178204
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define int long long
#define INF 1000000000000000007ll
using namespace std;

int n,d,a,sum[200010];
pair<int,int> m[200010];

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>d>>a;
	for(int i=1;i<=n;i++){
		cin>>m[i].first>>m[i].second;
	}
	sort(m+1,m+n+1);
	m[n+1]=make_pair(INF,INF);
	int cnt=0ll;
	for(int i=1;i<=n;i++){
		sum[i]+=sum[i-1];
		int num=m[i].second-sum[i];
		if(num>0){
			int e=m[i].first+2*d;
			int pos=upper_bound(m+1,m+n+2,make_pair(e+1,0ll))-m-1;
			int val=num/a+(num%a!=0);
			sum[i]+=val*a;
			sum[pos+1]-=val*a;
			cnt+=val;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

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

class Main {
    static Scanner scanner = new Scanner();
    static long mod = 1000000007;
    static int inf = 0x7ffffff;

    public static void main(String[]$) throws Exception {
        int n = scanner.nextInt();
        char[] c = scanner.next().toCharArray();
        int a = n;
        for (int i = 1; i < n; i++) {
            if (c[i - 1] == c[i]) {
                a--;
            }
        }
        System.out.println(a);
    }

    static class System {
        static PrintWriter out = new PrintWriter(java.lang.System.out);

        static {
            Runtime.getRuntime().addShutdownHook(new Thread(System.out::flush));
        }
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(java.lang.System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        char[][] nextCharArray(int n, int m) {
            char[][] a = new char[n][m];
            for (int i = 0; i < n; i++) {
                a[i] = next().toCharArray();
            }
            return a;
        }

        int[] nextIntArray(int n, java.util.function.IntUnaryOperator op) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = op.applyAsInt(nextInt());
            }
            return a;
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextLong();
            }
            return a;
        }

        long[] nextLongArray(int n, java.util.function.LongUnaryOperator op) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = op.applyAsLong(nextLong());
            }
            return a;
        }
    }
}


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

using namespace std;
int a[200010];
int main(){
	int i,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a + n);
	for(i=1;i<n;i++){
		if(a[i]==a[i-1]){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<map>


using namespace std;

int main(void) {

	long long n, m ,a[100000], b[100000],yen = 0, tmpa, tmpb,tmp,num=0;


	cin >> n >> m;

	vector<pair<long long, long long> >pairs(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		/*for (int k = 0; k <i; k++) {
			if (a[i] >= a[k]) {
			}
			else {
				tmpa = a[i];
				a[i] = a[k];
				a[k] = tmpa;
				tmpb = b[i];
				b[i] = b[k];
				b[k] = tmpb;
			}
		}*/
		pairs[i] = make_pair(a[i], b[i]);
	}

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

	/*(pairs[i].first)

	pairs[i].second*/

	/*for (int i = 0; i < n; i++) {
		//printf("a[%d]=%d,b[%d]=%d\n", i, a[i], i, b[i]);
	}*/

	for (int i = 0; num < m; i++) {
		
		if (num + (pairs[i].second) <= m) {
			yen += (pairs[i].first) * (pairs[i].second);
			num += (pairs[i].second);
		}
		else {
			yen += (pairs[i].first) * (m - num);
			num = m;
		}
		//printf("i=%d,k=%d,yen=%d,num=%d\n", i, k, yen, num);

	}

	cout << yen << "\n";

	return 0;
}

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

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    set<int> s;
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        s.insert(x);
    }
    
    if(s.size() == n)cout << "YES" << "\n";
    else cout << "NO" << "\n";
    
    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3;
const lli INF = 1e18;
const lli MOD = 1e9+7;

vi m;
vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	m = vi(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

// ---- コーディングはここから！ ('-')7


int main(){_
	lli n; cin>>n;
	if(n>=30)cout<<"Yes"<<ENDL;
	else cout<<"No"<<ENDL;

}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

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

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int r, g, b;
    cin >> r >> g >> b;
    if ((r * 100 + g * 10 + b) % 4) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}

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

const int MAX = 1e5 + 5;
int n, a[MAX], mp[MAX];

int main() {
	scanf("%d", &n);

	vector <int> v;
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		v.push_back(a[i]);
	}

	sort(v.begin(), v.end());
	auto it = unique(v.begin(), v.end());
	v.erase(it, v.end());

	for(int i = 1; i <= n; i++) {
		a[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin() + 1;
		mp[a[i]] = i % 2;
	}

	int ans = 0;
	for(int i = 1; i <= n; i++) {
		if(mp[i] == i % 2)
			continue;

		ans++;
	}

	assert(ans % 2 == 0);

	printf("%d\n", ans / 2);
	return 0;
}

Measured memory_bytes: 1528
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A;
  rep(i,N){
    int a;
    cin >> a;
    a--;
    A.push_back(a);
  }

  int ret = 0;
  rep(i,A.size()){
    if(A[A[i]] == i){
      ret++;
      A[A[i]] = -1;
    }
  }
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 1020
# ARC067C - Factors of Factorial
def count_divisors(num: int) -> int:
    max_prime = 0
    dic = {}
    res = 1

    cnt = 0
    while num % 2 == 0:
        num //= 2
        cnt += 1
    if cnt > 0:
        max_prime = 2
        dic[max_prime] = cnt

    cnt = 0
    for i in range(3, int(num ** 0.5) + 1, 2):
        cnt = 0
        while num % i == 0:
            num //= i
            max_prime = i
            cnt += 1
        if cnt > 0:
            dic[max_prime] = cnt

    if num > 2:
        max_prime = num
        dic[max_prime] = 1

    return dic


def main():
    n = int(input())
    MOD = 10 ** 9 + 7
    f = {}
    for i in range(2, n + 1):
        for j, k in count_divisors(i).items():
            if j not in f:
                f[j] = 0
            f[j] += k
    ans = 1
    for i in f.values():
        ans = (ans * (i + 1)) % MOD
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

struct UnionFind {
    UnionFind() {}
    UnionFind(int n) {
        resize(n);
    }
    
    void resize(int n) {
        par.resize(n, -1);
    }
    
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    
    bool merge(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return false;
        if (par[rx] > par[ry]) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }
    
    bool is_same(int x, int y) {
        return (root(x) == root(y));
    }
    
    int size(int x) {
        return -par[root(x)];
    }
    
private:
    vector<int> par;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll n, k, l;
    cin >> n >> k >> l;
    UnionFind road(n), rail(n);
    rep(i, k) {
        ll p, q;
        cin >> p >> q;
        p--; q--;
        road.merge(min(p, q), max(p, q));
    }
    rep(i, l) {
        ll r, s;
        cin >> r >> s;
        r--; s--;
        rail.merge(min(r, s), max(r, s));
    }
    map<pair<ll, ll>, ll> cnt;
    rep(i, n) {
        cnt[make_pair(road.root(i), rail.root(i))]++;
    }
    rep(i, n) {
        printf("%lld%s", cnt[make_pair(road.root(i), rail.root(i))], (i == (n - 1)) ? "\n" : " ");
    }
    return 0;
}


Measured memory_bytes: 13568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>

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

using namespace std;
typedef long long ll;

int main()
{
	int n;
	while(cin >> n && n)
	{
		rep(i,n)
		{
			int a[4],b[4];
			rep(j,4) cin >> a[j];
			rep(j,4) cin >> b[j];

			ll x = a[0]*b[0] - a[1]*b[1] - a[2]*b[2] - a[3]*b[3];
			ll y = a[0]*b[1] + a[1]*b[0] + a[2]*b[3] - a[3]*b[2];
			ll z = a[0]*b[2] - a[1]*b[3] + a[2]*b[0] + a[3]*b[1];
			ll w = a[0]*b[3] + a[1]*b[2] - a[2]*b[1] + a[3]*b[0];

			cout << x << " " << y << " " << z << " " << w << endl;
		}
	}
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    if(a+b > c+d)
        cout << "Left" << endl;
    else if(a+b < c+d)
        cout << "Right" << endl;
    else
        cout << "Balanced" << endl;
    
    return 0;

}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int maxn = 1e5 + 10;

ld pw[40];

bool X(string t){
	int k = 0;
	k += (int)(t[1] - '0') + 10 * (int)(t[0] - '0');
	if (k >= 1 and k <= 12)
		return 1;
	return 0;
}

int main(){
	ios_base::sync_with_stdio (false);
	string s;
	cin >> s;
	string t = s.substr(0, 2);
	string p = s.substr(2, 2);
	bool XXYY = 0, YYXX = 0;
	if (X(t))
		YYXX = 1;
	if (X(p))
		XXYY = 1;
	if (XXYY and YYXX)
		return cout << "AMBIGUOUS" << endl, 0;
	if (XXYY)
		cout << "YYMM" << endl;
	else if (YYXX)
		cout << "MMYY" << endl;
	else
		cout << "NA" << endl;
}


Measured memory_bytes: 256
a,b,c = map(int,input().split())
if a == 5 and b == 5 and c == 7:
  print("YES")
elif a == 7 and b == 5 and c == 5:
  print("YES")
elif a == 5 and b == 7 and c == 5:
  print("YES")
else:
  print("NO")
 

Measured memory_bytes: 9160
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define endl '\n'
#define PI acos(-1)
typedef long long ll;
using namespace std;
int n, m, **dp;
const int MOD = (int)1e9 + 7;
char **x;
int go(int i = 0, int j = 0)
{
    if(i == n || j == m || x[i][j] == '#')
        return 0;
    if(i == n - 1 && j == m - 1)
        return 1;
    if(~dp[i][j])
        return dp[i][j];
    return dp[i][j] = (go(i + 1, j) % MOD + go(i, j + 1) % MOD) % MOD;
}
/*int go(int i = 0, int sum = mx)
{
    if(i == n)
        return sum - mx;
    if(~dp[i][sum])
        return dp[i][sum];
    int first = go(i + 1, sum + x[i]);
    int second = go(i + 1, sum - x[i]);
    if(abs(first) < abs(second))
        return dp[i][sum] = first;
    return dp[i][sum] = second;
}*/
int main()
{
    cin.tie(NULL); cout.tie(NULL);  ios_base::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif
    cin >> n >> m;
    dp = new int*[n];
    x = new char*[n];
    for(int i = 0; i < n; i++)
    {
        x[i] = new char[m];
        dp[i] = new int[m];
        memset(dp[i], -1, 4 * m);
        for(int j = 0; j < m; j++)
            cin >> x[i][j];
    }
    cout << go();
    /*for(int i = 0; i < n; i++)
    {
        cout << endl;
        for(int j = 0; j < m; j++)
            cout << dp[i][j] << '\t';
    }*/
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型
using pint = pair<int, int>;

int main()
{
    int K, A, B;
    cin >> K >> A >> B;
    bool ok = false;
    FOR(i, A, B + 1)
    {
        if (i % K == 0)
        {
            ok = true;
        }
    }
    if (ok)
    {
        cout << "OK" << endl;
    }
    else
    {
        cout << "NG" << endl;
    }
}

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

using namespace std;

typedef long long ll;
const ll MOD = 1000000007;

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

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

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

    ll ai = 0, bi = 0, ci = 0;

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

long long mod(long long val, long long m)
{
    long long res = val % m;
    if (res < 0)
        res += m;
    return res;
}

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> a2(n * 2);

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

    ll num1 = merge_count(a) % MOD;
    ll num2 = mod((merge_count(a2) % MOD) - (num1 * 2), MOD);

    ll times = k * (k - 1LL) / 2LL % MOD;

    cout
        << ((num1 * k % MOD) + (num2 * times % MOD)) % MOD << endl;

    return 0;
}


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

using ll = long long;
using namespace std;

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

    ll res = 0;
    int bc = 0;
    for (int i = (int) s.length() - 1; i >= 0; --i) {
        if (s[i] == 'A') {
            res += bc;
        } else if (s[i] == 'B') {
            bc = 0;
        } else if (s[i] == 'C') {
            if (i > 0 && s[i - 1] == 'B') {
                ++bc;
                --i;
            } else {
                bc = 0;
            }
        }
    }
    cout << res;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);

    solve();
}


Measured memory_bytes: 720
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		String alphabet[] = new String[]{"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
		int [] count = new int[26];
		Scanner sc = new Scanner(System.in);
		String inputValues = "";
		while (true) {
			String tmp = sc.nextLine();
			inputValues += tmp;
			if (!sc.hasNext()) {
				break;
			}
		}
		inputValues = inputValues.toLowerCase();
		String[] strAry = inputValues.split("");
		for (int i = 0; i < strAry.length; i++) {
			for (int j = 0; j < 26; j++) {
				if (strAry[i].equals(alphabet[j])) {
					count[j]++;
				}
			}
		}
		for (int i = 0; i < 26; i++) {
			System.out.println(String.format("%s : %d", alphabet[i], count[i]));
		}
	}
}

Measured memory_bytes: 27164
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int n;
int dp[200010];
int a[200010];
void check(int k)
{
    int cnt = 0;
    for (int j = 1; j * k <= n; j++)
    {
        cnt += dp[j * k];
    }
    cnt %= 2;
    if (a[k] != cnt)
    {
        dp[k] = 1;
    }
}
int main()
{
    cin >> n;
    rep(i, n)
    {
        cin >> a[i + 1];
    }
    int i = n;
    while (i > 0)
    {
        check(i);
        i--;
    }
    int c = 0;
    rep(i, n + 1)
    {
        if (dp[i])
        {
            c++;
        }
    }
    cout << c << endl;
    rep(i, n + 1)
    {
        if (dp[i])
        {
            cout << i << ' ';
        }
    }
    cout << endl;
}

Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int X = sc.nextInt();

			int goal = X;
			int result = 0;

			for (int i = 0; i < X; i++) {
				if (goal - i > 0) {
					goal = goal - i;
					result++;
					if (goal <= 0) {
						break;
					}
				}
			}
			System.out.println(result);
		}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int x=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie();
	cout.tie();
//	freopen(".in","r",stdin);
//	freopen(".out","r",stdout);
	int n;
	cin >> n;
	string a,b,c;
	cin >> a >> b >> c;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]==b[i]&&a[i]==c[i]&&b[i]==c[i]) continue;
		if(a[i]!=b[i]&&a[i]!=c[i]&&b[i]!=c[i]) ans+=2;
		if((a[i]==b[i]&&a[i]!=c[i])||(a[i]!=b[i]&&a[i]==c[i])||(a[i]!=b[i]&&b[i]==c[i])) ans+=1;
	}
	cout << ans;
	return 0;
}


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

int main() {
  long n, d;
  cin >> n >> d;
  long cnt = 0;
  while (n--) {
    long x, y;
    cin >> x >> y;
    if (sqrt(pow(x, 2) + pow(y, 2)) <= d) cnt++;
  }
  cout << cnt;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define MAX 1000000007
using namespace std;
int main()
{
    speed_up
    ll n,mx;cin>>n;
    ll a[n],gf[n],gb[n];
    for(ll i=0;i<n;i++) cin>>a[i];
     gf[0]=a[0],gb[0]=a[n-1];
	for(ll i=1;i<n;i++)
	 {
	   gf[i]=__gcd(gf[i-1],a[i]) ;
	   gb[i]=__gcd(gb[i-1],a[n-i-1]);
     }
      mx=gf[n-1];
      for(ll i=0;i<n;i++)
      {
      	if(i==0) mx=max(mx,gb[n-i-2]);
      	else if(i==n-1) mx=max(mx,gf[n-2]);
      	else
      	{
      		ll x=__gcd(gf[i-1],gb[n-i-2]);
      		mx=max(mx,x);
		  }
	  }
	  cout<<mx;
    
	
	
	
	
	
	
 return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<string.h>
int main ()
{
 int a;
  char s[11];
  scanf("%d",&a);
  scanf("%s",&s);
  if(a>=3200){
    printf("%s\n",s);
  }
  else{
    printf("red\n");
  }
  return 0;
}


Measured memory_bytes: 128
#alds13c
from collections import deque
class DoubleLinkyList:
    def __init__(self):
        self.lst=[]
    def insert(self,x):
        self.lst.insert(0,x)
    def delete_x(self,x):
        if x in self.lst:
            self.lst.pop(self.lst.index(x))
    def deleteFirst(self):
        self.lst.pop(0)
    def deleteLast(self):
        self.lst.pop(-1)
        
n = int(input())
dll = deque()

for i in range(n):
    A = input().split(" ")
    if A[0] == "insert":
        dll.appendleft((A[1]))
        #continue
    if A[0] == "delete" and A[1] in dll:
        dll.remove((A[1]))
    if A[0]=="deleteFirst":
        dll.popleft()
    if A[0]=="deleteLast":
        dll.pop()

result = list(dll)
print(" ".join(result))
#print(dll)


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

using namespace std;

int main(void) {
  int N;
  cin >> N;
  vector<int> p(N);
  string ans = "YES";

  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (p.at(i) != i + 1) {
        count++;
    }
  }
  if (count < 3) {
    ans = "YES";
  } else {
    ans = "NO";
  }
  cout << ans << endl;
  
  
  
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=1;i<(n);i++)

int main(){
  int n,dp[100001];cin>>n;
  dp[0]=0;
  for(int i=1;i<=n;i++){
    int m=1e9;
    REP(j,6) if(i-j>=0) m=min(m,dp[i-j]+j);
    REP(j,7) for(int l=6;l<=9;l+=3){
      int t=pow(l,j);
      REP(k,l) if(i-t*k>=0) m=min(m,dp[i-t*k]+k);
    }
    dp[i]=m;
  }
  cout<<dp[n];
}


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

int main()
{
	int n,k; scanf("%d%d",&k,&n);
	int ans=0;
	int fi; scanf("%d",&fi);
	int pre=fi,now;
	for(int i=1;i<n;i++)
	{
		scanf("%d",&now);
		ans=max(ans,now-pre);
		pre=now;
	}
	ans=max(ans,k-now+fi);
	printf("%d\n",k-ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

void solve() {
    int n;
    cin >> n;
    VLL a(n*n);
    REP(i,0,n*n) {
        cin >> a[i];
        --a[i];
    }
    vector<vector<bool>> b(n,vector<bool>(n));
    VVI rem(n,VI(n));
    REP(i,0,n*n) {
        int x = i / n, y = i % n;
        rem[x][y] = min({x,y,n-1-x,n-1-y});
    }

    /*
    REP(i,0,n) {
        REP(j,0,n) cerr << rem[i][j] << " ";
        cerr << endl;
    }
    */

    LL ans = 0;
    REP(i,0,n*n) {
        //dump(i);
        int x = a[i] / n, y = a[i] % n; 
        ans += rem[x][y];

        deque<PII> q;
        REP(j,0,4) {
            int nx = x + dx[j], ny = y + dy[j];
            if (nx < 0 || nx >= n || ny < 0 || ny >= n) continue;
            if (rem[nx][ny] > rem[x][y]) {
                rem[nx][ny] = rem[x][y];
                q.pb(nx,ny);
            }
        }
        while(!q.empty()) {
            auto p = q.front();
            q.pop_front();
            int x = p.first, y = p.second;
            REP(j,0,4) {
                int nx = x + dx[j], ny = y + dy[j];
                if (nx < 0 || nx >= n || ny < 0 || ny >= n) continue;
                if (rem[nx][ny] > rem[x][y] + 1 - b[x][y]) {
                    rem[nx][ny] = rem[x][y] + 1 - b[x][y];
                    q.pb(nx,ny);
                }
            }
        }
        b[x][y] = true;

        /*
        cerr << i << ": " << a[i] << ", " << ans << endl;
        REP(i,0,n) {
            REP(j,0,n) cerr << rem[i][j] << " ";
            cerr << endl;
        }
        */
    }

    cout << ans << endl;
    dump(ans);
}

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

Measured memory_bytes: 6168
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0スタート
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1スタート
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからbまで
#define P(x) cout<<x<<endl  //変数xを改行付きで出力
#define INF 1000000007  //最大値兼MOD
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
    ./a.exe
	*/
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b)cout<<c<<endl;
	else if (b==c)cout<<a<<endl;
	else P(b);
	return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#define X 100

int main(){

  int i,j,n,sum=0,mini,temp,flag;
  int A[X];

  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }


  for(i=0; i<=n-1; i++){
    mini = i;
    for(j=i; j<=n-1; j++){
      if(A[j]<A[mini]){
	mini = j;
	flag = 1;
      }
    }
    temp = A[i];
    A[i] = A[mini];
    A[mini] = temp;
    if(flag==1){
      sum++;
      flag=0;
    }
  }
  for(i=0; i<n; i++){
    printf("%d",A[i]);
    if(i!=n-1){
      printf(" ");
    }
  }

  printf("\n");

  printf("%d\n",sum);

  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define INF 100000 * 20

bool read(int pos, int value){
  return (1 << pos) & value;
}

int main(void){
  int N;
  while(cin >> N, N){
    vector< vector <int> > C(N, vector<int>(N+1));
    for(int i=0; i < N; i++){
      for(int j=0; j < N+1; j++){
        cin >> C[i][j];
      }
    }
    int dp[1 << N];
    fill(dp, dp + (1 << N), INF);
    dp[0] = 0;
    for(int i=0; i < (1<<N); i++){
      for(int j=0; j < N; j++){
        int nx = i | (1 << j);
        dp[nx] = min(dp[nx], dp[i] + C[j][0]);
        for(int k=0; k < N; k++){
          if(read(k, i)){
            dp[nx] = min(dp[nx], dp[i] + C[j][k+1]);
          }
        }
      }
    }
    cout << dp[(1<<N) -1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1472