akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  vector<int> v(3);

  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;

  ll ans = 1;
  rep(i, n) {
    // cout << i << endl;

    ll cnt = 0;
    rep(j, 3) if (v[j] == a[i]) cnt++;
    // cout << "cnt " << cnt << endl;

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

    (ans *= cnt) %= mod;
    for (int j = 2; j >= 0; --j) { // debgued, --i to --j
      if (v[j] == a[i]) {
        v[j]++;
        break;
      }
    }
  }
  // cout << v << endl;

  cout << ans << endl;
}


Measured memory_bytes: 640
from collections import defaultdict

n,ma,mb=map(int,input().split())
f=defaultdict(lambda:float('inf'))
for _ in range(n):
    a,b,c=map(int,input().split())
    t=f.copy()
    t[a,b]=min(t[a,b],c)
    for k,v in f.items():
        ka,kb=k[0]+a,k[1]+b
        t[ka,kb]=min(t[ka,kb],v+c)
    f=t

costs=[f[a,b] for a,b in f if a*mb==b*ma]
print(min(costs) if costs else -1)


Measured memory_bytes: 8720
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	cout << 180*(n-2) << endl;
	return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int x, y;
  cin >> x >> y;

  rep(i, 1, x + 1) {
    // cout << i * 2 + ((x - i) * 4) << ' ';
    if (i * 2 + ((x - i) * 4) == y) {
      cout << "Yes\n";
      return 0;
    }
  }

  rep(i, 1, x + 1) {
    if (i * 4 + ((x - i) * 4) == y) {
      cout << "Yes\n";
      return 0;
    }
  }

  cout << "No\n";
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]"; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/


int main() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A, B) << " " << max(0, (A+B) - N) << endl;
}


Measured memory_bytes: 3616
// @author: arch_

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

int main(void) {
    stack<int> s;
    int n, x; cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x; s.push(x);
    }
    while (!s.empty()) {
        cout << s.top(); s.pop();
        cout << (s.empty() ? "\n" : " ");
    }
    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int N, K;
	string S;
	cin >> N >> S >> K;
	char A = S[K-1];
	for (int i = 0; S[i]; i++)
	{
		if (S[i] == A)
			cout << S[i];
		else
			cout << "*";
	}
	cout << endl;
}



Measured memory_bytes: 256
using System;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int N = sc.NextInt();
        S[] AB = new S[N];
        for (int i = 0; i < N; i++)
        {
            AB[i] = new S(sc.NextInt(), sc.NextInt());
        }

        Array.Sort(AB, (a, b) => a.B.CompareTo(b.B));

        long time = 0;

        for (int i = 0; i < N; i++)
        {
            time += AB[i].A;
            if (time > AB[i].B)
            {
                Console.WriteLine("No");
                return;
            }
        }

        Console.WriteLine("Yes");
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

struct S
{
    public int A, B;

    public S(int a, int b)
    {
        A = a;
        B = b;
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 17412
using System;
using System.Collections.Generic;
using System.Linq;

class A
{
	static long[] Read() => Console.ReadLine().Split().Select(long.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		var n = (int)h[0];
		var es = new int[h[1]].Select(_ => Read()).ToArray();

		Console.WriteLine(MaxFlow(n - 1, 0, n - 1, es));
	}

	static long MaxFlow(int n, int sv, int ev, long[][] dg)
	{
		var map = Array.ConvertAll(new int[n + 1], _ => new List<long[]>());
		foreach (var e in dg)
		{
			map[e[0]].Add(new[] { e[0], e[1], e[2], map[e[1]].Count });
			map[e[1]].Add(new[] { e[1], e[0], 0, map[e[0]].Count - 1 });
		}

		long M = 0, t;
		while ((t = Bfs(n, sv, ev, map)) > 0) M += t;
		return M;
	}

	static long Bfs(int n, int sv, int ev, List<long[]>[] map)
	{
		var from = new long[n + 1][];
		var minFlow = Enumerable.Repeat(long.MaxValue, n + 1).ToArray();
		var q = new Queue<long>();
		q.Enqueue(sv);

		while (q.Any())
		{
			var v = q.Dequeue();
			if (v == ev) break;
			foreach (var e in map[v])
			{
				if (from[e[1]] != null || e[2] == 0) continue;
				from[e[1]] = e;
				minFlow[e[1]] = Math.Min(minFlow[v], e[2]);
				q.Enqueue(e[1]);
			}
		}

		if (from[ev] == null) return 0;
		for (long v = ev; v != sv; v = from[v][0])
		{
			var e = from[v];
			e[2] -= minFlow[ev];
			map[e[1]][(int)e[3]][2] += minFlow[ev];
		}
		return minFlow[ev];
	}
}



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

int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    vector<vector<int>> d(n, vector<int>(n,0));
    int ans = 0;
    for(int i=n-1; i>0; i--){
        for(int j=i-1; j>-1; j--){
            if(s[i]==s[j]){
                if(i==n-1){
                    d[i][j] = 1;
                    ans = max(ans, min(d[i][j],i-j));
                }else{
                    d[i][j] = d[i+1][j+1] + 1; 
                    ans = max(min(d[i][j],i-j),ans);
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 98176
while True:
    (H, W) = [int(i) for i in input().split()]
 
    if H == W == 0:
        break
 
    for i in range(H):
        for r in range(W):
            if (i + r) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')
            #print('#', end='') if (i + r) % 2 == 0 else print('.', end='')
        print()
    print()

Measured memory_bytes: 6800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

int main()
{
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n), f(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> f[i];
    }
    sort(a.begin(), a.end());
    sort(f.begin(), f.end());
    reverse(f.begin(), f.end());

    ll left = -1, right = (1000000LL * 1000000LL) + 1;
    while (right - left > 1)
    {
        ll mid = (left + right) / 2;
        ll use = 0;
        for (int i = 0; i < n; i++)
        {
            // a[i]を減らして対応できるかを確認
            if (a[i] * f[i] <= mid)
            {
                continue;
            }
            ll boarder = mid / f[i];
            use += a[i] - boarder;
        }
        if (use <= k)
        {
            right = mid;
        }
        else
        {
            left = mid;
        }
        // cout << "left:" << left << ", right:" << right << endl;
    }
    cout << right << endl;
    return 0;
}


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

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

  ll res = 0;
  int a;
  for (int i = 0; i < n; i++)
  {
    cin >> a;
    res += a - 1;
  }

  cout << res << endl;
}

Measured memory_bytes: 256
import numpy as np
import math
n = int(input())

#list(map(データ型, input().split))で入力された文字列を指定したデータ型に変換して、コンマ区切りのリストを作る
p_list = list(map(int, input().split()))
q_list = list(map(int, input().split()))


#np.array(リスト)とすることで、リスト型をNumpy配列に変換できる
p_np = np.array(p_list)
q_np = np.array(q_list)

pAnswer = 1
qAnswer = 1
for val in range(n):
	a = 0
	for va in range(0,val+1):
		if va != val : 
			if p_np[va] < p_np[val] :
				a += 1
			else :
				continue
		else:
			pAnswer += math.factorial(n - val -1) * (p_list[val] -1 -a)
			

for val in range(n):
	a = 0
	for va in range(0,val+1):
		if va != val : 
			if q_np[va] < q_np[val] :
				a += 1
			else :
				continue
		else:
			qAnswer += math.factorial(n - val -1) * (q_list[val] -1 -a)
			
print(abs(pAnswer - qAnswer))

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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)

using namespace std;

using pii = pair<int, int>;

template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

bool match(char c1, char c2) {
    return c1 == c2 || c1 == '?' || c2 == '?';
}

// return L.
// L[i] (0 <= i < a.size()) is the length of the longest common prefix of a[i:] and b.
vector<int> get_L(string a, string b) {
    vector<int> L(a.size());
    REP(i, a.size()) {
        int j = 0;
        while (i + j < a.size() && j < b.size() && match(a[i + j], b[j])) {
            ++j;
        }
        L[i] = j;
    }
    return L;
}

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    vector<string> a(3);
    REP(i, 3) cin >> a[i];

    map<pii, vector<int>> L;
    REP(i, 3) REP(j, 3) {
        if (i == j) continue;
        L[pii(i, j)] = get_L(a[i], a[j]);
    }

    int result = a[0].size() + a[1].size() + a[2].size();

    REP(k0, 3) { // a[k0] is the prefix of s.
        REP(k1, 3) {
            if (k1 == k0) continue;
            REP(k2, 3) {
                if (k2 == k0 || k2 == k1) continue;
                REP(i, a[k0].size() + 1) FOR(j, i, a[k0].size() + a[k1].size() + 1) {
                    // a[k1] starts at index i of s.
                    // a[k2] starts at index j of s.

                    int first, last;

                    // check whether a[k0] and a[k1] have overlap (and match).
                    first = i;
                    last = min(a[k0].size(), i + a[k1].size());
                    if (first < last) { // have overlap.
                        if (last - first > L[pii(k0, k1)][i]) { // do not match.
                            continue;
                        }
                    }

                    // check whether a[k0] and a[k2] have overlap (and match).
                    first = j;
                    last = min(a[k0].size(), j + a[k2].size());
                    if (first < last) { // have overlap.
                        if (last - first > L[pii(k0, k2)][j]) { // do not match.
                            continue;
                        }
                    }

                    // check whether a[k1] and a[k2] have overlap (and match).
                    first = max(i, j);
                    last = min(i + a[k1].size(), j + a[k2].size());
                    if (first < last) { // have overlap.
                        if (last - first > L[pii(k1, k2)][j - i]) { // do not match.
                            continue;
                        }
                    }

                    int length_s = max(a[k0].size(), max(i + a[k1].size(), j + a[k2].size()));
                    amin(result, length_s);
                }
            }
        }
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <iomanip>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define tle ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
const int mod = 998244353;
const int mxn = 1e6 +7;
ll _,n,m,t,k,u,v,ans,cnt,ok,lim;
ll w[mxn] , cost[mxn] ,  far[mxn] , siz[mxn];
char ch;
#define lc now<<1
#define rc now<<1|1
string str ;
ll a[mxn];
struct node{int u,v;}p[mxn];
void init(){for(int i=1;i<=n;i++) far[i] = i , siz[i] = 1 ;}
ll root(ll x)
{
    if(x==far[x]) return x;
    return far[x] = root( far[x] ) ;
}
void up(ll u,ll v)
{
    u = root(u) ; v = root(v) ;
    if(u!=v){
        far[v] = u ;
        ///cout<<siz[v]<<" "<<siz[u]<<endl;
        ans+=siz[u]*siz[v]*1ll;
        siz[u]+=siz[v];
    }
}
int main()
{
    cin>>n>>m;
    init();
    for(int i=1;i<=m;i++)
    {
        cin>>p[i].u>>p[i].v;
    }
    lim = n*(n-1)/2; ans = 0 ;
    for(int i=m;i>0;i--)
    {
        a[i] = lim - ans ;
        /// cout<<far[ p[i].u ]<<" "<<far[ p[i].v ]<<endl;
        /// cout<<"     ---- " << ans<<endl;
        up(p[i].u,p[i].v);
    }
    for(int i=1;i<=m;i++)
        cout<<a[i]<<endl;
}

Measured memory_bytes: 12288
<>;
map{push@$_,$_[--$|]for@_=glob}<>;
$==1e9+7;
sub f{my($x,$b,$w)=($_,1,1);$_-"@_"and($c,$d)=f($x),$b=$b*$c%$=,$w=$w*$d%$=for@$x;$w,$b+$w}
print+(f)[$_=1]%$=

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

int main()
{
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    ll ans=1e18;
    for(int i=0;i<=n-k;i++)
    {
        ans=min(ans,a[i+k-1]-a[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
  #include <string.h>

  #define N 1046527
  #define NIL (-1)
  #define L 14

  char H[N][L];

  int getChar(char c){
      if (c == 'A')return 1;
      else if(c == 'C')return 2;
      else if(c == 'G')return 3;
      else if(c == 'T')return 4;
      else return 0;
  }

  long long getkey(char s[]){
      long long sum = 0, p = 1,i;
      for (i = 0; i < strlen(s); i++) {
          sum += p*getChar(s[i]);
          p *= 5;
      }
      return sum;
  }

  int h1(int key){return key % N;}
  int h2(int key){return 1 + (key % (N - 1));}

  int search(char s[]){
      long long key, i, h;
      key = getkey(s);
      for (i = 0;; i++) {
          h = (h1(key) + i * h2(key)) % N;
          if (strcmp(H[h], s) == 0) {
              return 1;
          }else if(strlen(H[h]) == 0){
              return 0;
          }
      }

      return 0;

  }

  int insert(char s[]){
      long long key, i=0, h;

      key = getkey(s);

       while(1){

          h = (h1(key) + i * h2(key))% N;
          if (strcmp(H[h], s) == 0 ){
              return 1;
          }else if(strlen(H[h]) == 0 ){
              strcpy(H[h], s);
              return 0;
          }
          i++;
      }
  }

  int main(void){

      int i, num, h;
      char s[L], com[9];

      for (i = 0;i < N; i++) {
          H[i][0] = '\0';
      }

      scanf("%d", &num);

      for (i = 0; i < num; i++) {

          scanf("%s %s",com, s);

          if(com[0] == 'i'){
              insert(s);
          }else {
              if(search(s) == 1){
                  printf("yes\n");
              }else{
                  printf("no\n");
              }
          }
      }

      return 0;
  }



Measured memory_bytes: 16016
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1ll(i, n) for(int i = 1ll; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1ll; return;}
#define yes {cout << "YES\n"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

void solve() {
    int n; cin >> n;
    int a, b, c = 0, ansa = 0, ansb = 0;
    cin >> a >> b;
    loop(i, n - 2) {
        int x; cin >> x;
        c ^= x;
    }
    if (a + b < c)
        no;
    loop(bit, 60)
        if (c & (1ll << bit))
            ansb ^= (1ll << bit);
    int delta = a + b - c;
    if (delta & 1ll)
        no;
    delta >>= 1ll;
    loop(bit, 60)
        if (delta & (1ll << bit)) {
            if (ansb & (1ll << bit))
                no;
            ansb ^= (1ll << bit);
            ansa ^= (1ll << bit);
        }
    for (int bit = 59; bit >= 0; --bit)
        if ((ansb & (1ll << bit)) && !(ansa & (1ll << bit)) && (ansb ^ (1ll << bit)) >= b) {
            ansa ^= (1ll << bit); ansb ^= (1ll << bit);
        }
    if (!ansa || ansa > a)
        no;
    cout << a - ansa;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}


Measured memory_bytes: 3644
H, W = map(int, input().split())
s_li = [input() for i in range(H)]
for h in range(H):
    for w in range(W):
        cnt = 0
        if s_li[h][w] == "#":
            print("#",end="")
            continue
        for i in range(-1, 2):
            for k in range(-1, 2):
                if 0 <= h + i < H and 0 <= w + k < W and s_li[h + i][w + k] == "#":
                    cnt += 1
                    # print("zahyo = ", h + i, w + k)
        print(cnt,end="")
    print()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

bool comp(pair<int, int> a, pair<int, int> b){
    return a.second < b.second;
}

int main(){
    int N, M; cin >> N >> M;
    vector<pair<int, int>> ab;
    rep(i,M){
        int a, b;
        cin >> a >> b;
        ab.emplace_back(a,b);
    }

    sort(ab.begin(), ab.end(), comp);

    int ans = 0;
    int right_end = 0;
    rep(i,M){
        if (right_end <= ab[i].first){
            right_end = ab[i].second;
            ans++;
        }
    }
    cout << ans << endl;

}



Measured memory_bytes: 4280
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1005;

struct data
{
	int w, s, v;
};

int n;
int cache[N][20005];
data a[N];

bool comp(data &d1, data &d2)
{
	return (d1.w+d1.s)<(d2.w+d2.s);
}

int dp(int idx, int wt)
{
	if(idx==n+1)
		return 0;
	int &ans=cache[idx][wt];
	if(ans!=-1)
		return ans;
	ans=dp(idx+1, wt);
	if(a[idx].s>=wt)
		ans=max(ans, a[idx].v + dp(idx+1, wt+a[idx].w));
	return ans;
}

int32_t main()
{
	IOS;
	memset(cache, -1, sizeof(cache));
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i].w>>a[i].s>>a[i].v;
	sort(a+1, a+n+1, comp);
	int ans=dp(1, 0);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 157440
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <cstdlib>
#include <set>

using namespace std;
 
int main(void){

    string S;
    set<char> string_set;
    
    cin >> S;

    for(int i =0; i <3; i++){
        string_set.insert(S[i]);
    }

    if(string_set.size() > 1){
        cout << "Yes";

        return 0;
    } 

    cout << "No";




    return 0;
}

Measured memory_bytes: 888
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace competitive_programming
{
    class Program
    {
        static void Main(string[] args)
        {
            var main = new Program();
            main.solve();
        }

        void solve()
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            long rs = S.Count(c => c == 'R');
            long gs = S.Count(c => c == 'G');
            long bs = S.Count(c => c == 'B');
            long count = rs * gs * bs;

            for (var i = 0; i < N; i++)
            {
                for (var j = 1; j < N; j++)
                {
                    var ll = i - j;
                    var rr = j + i;
                    if (!(0 <= ll && ll < N && 0 <= rr && rr < N)) continue;
                    if (!(S[ll] != S[i] && S[rr] != S[i] && S[ll] != S[rr])) continue;
                    count--;
                }
            }
            Console.WriteLine(count);
        }

        public static long Gcd(long a, long b)
        {
            Func<long, long, long> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
    }

    struct Vector2
    {
        public Vector2(long x, long y)
        {
            this.x = x;
            this.y = y;
        }
        public long x;
        public long y;
    }

    struct Vector3
    {
        public int x;
        public int y;
        public int z;
    }
}


Measured memory_bytes: 18452
N = int(input())
A = list(map(int, input().split()))

Sf = [A[0]]
for i in range(1, N):
  Sf.append(Sf[-1] + A[i])

A = A[::-1]
Sb = [A[0]]
for i in range(1, N):
  Sb.append(Sb[-1] + A[i])
Sb = Sb[::-1]

answer = 10 ** 15
for i in range(N - 1):
  answer = min(answer, abs(Sf[i] - Sb[i + 1]))
  
print(answer)

Measured memory_bytes: 30184
#include <iostream>
#include <stack>
using namespace std;
static const int N = 100;
static const int WHITE= 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[N][N];
int color[N], D[N], F[N], TT;
int NT[N];

int next(int U) {
	for (int v = NT[U]; v < N; v++) {
		NT[U] = v + 1;
		if (M[U][v]) return v;
	}
	return -1;
}

void dfs_visit(int R) {
	for (int i = 0; i < n; i++) NT[i] = 0;

	stack<int>S;
	S.push(R);
	color[R] = GRAY;
	D[R] = ++TT;

	while (!S.empty()) {
		int U = S.top();
		int V = next(U);
		if (V != -1) {
			if (color[V] == WHITE) {
				color[V] = GRAY;
				D[V] = ++TT;
				S.push(V);
			}
		}
		else {
			S.pop();
			color[U] = BLACK;
			F[U] = ++TT;
		}
	}
}

void dfs() {
	for (int i = 0; i < n; i++) {
		color[i] = WHITE;
		NT[i] = 0;
	}
	TT = 0;
	for (int u = 0; u < n; u++) {
		if (color[u] == WHITE) dfs_visit(u);
	}
	for (int i = 0; i < n; i++) {
		cout << i + 1 << " " << D[i] << " " << F[i] << endl;
	}
}

int main() {
	int U, K, V;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) M[i][j] = 0;
	}
	for (int i = 0; i < n; i++) {
		cin >> U >> K;
		U--;
		for (int j = 0; j < K; j++) {
			cin >> V;
			V--;
			M[U][V] = 1;
		}
	}

	dfs();
	return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, h[maxn], dp[maxn];
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> h[i];
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    for(int i = 3; i <= n; i++)
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    cout << dp[n];
    return 0;
}


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

using namespace std;

vector< string > str;
string S;

bool dfs(int bit, string &T) {
  if(T > S) return true;
  if(S.substr(0, T.size()) != T && T <= S) return false;
  for(int i = 0; i < 26; i++) {
    if((bit >> i) & 1) continue;
    T.push_back((char) (i + 'a'));
    if(dfs(bit | (1 << i), T)) return true;
    T.pop_back();
  }
  return (false);
}


int main() {
  cin >> S;
  string ans;
  if(dfs(0, ans)) {
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1000000000;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
    int n;
    cin >> n;
    vector< pair< pair<string, int>, int> > v(n);
    vector< pair<int, int> > ret;
    for (int i = 0; i < n; i++){
	    string s; int x;
	    cin >> s >> x;
	    v[i].f = {s, -x};
	    v[i].s = i + 1;
    }
    sort(all(v));
    for(int i = 0; i < n; i++)
      cout << v[i].s << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long gcd(long long x, long long y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

long long lcm(long long x, long long y) {
  long long g = gcd(x, y);
  return (x / g * y);
}

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  long long t[n];
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }
  long long ans = 1;
  for (int i = 0; i < n; i++) {
    ans = lcm(t[i], ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
#else

#endif



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Togliere nei problemi con query online

    int A, B;
    cin >> A >> B;
    cout << A*B << "\n";
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

const ll N=1e5+10;
vector<map<ll,ll>> G(N);
vec c(N);
ll n;

void dfs(ll f, ll pre) {
  ll ng=-1;
  if(pre!=-1) {
    ng=c[G[pre][f]];
  }
  ll cur=1;
  for(auto p:G[f]) {
    ll t=p.first;
    ll id=p.second;
    if(t==pre) continue;
    if(cur==ng) cur++;
    c[id]=cur++;
    dfs(t,f);
  }
}


int main() {
  cin >> n;
  for(ll i=0;i<n-1;i++) {
    ll a,b;
    cin >> a >> b;
    a--,b--;
    G[a][b]=i;
    G[b][a]=i;
  }
  ll ans=0;
  for(ll i=0;i<n;i++) {
    ans=max((ll)G[i].size(),ans);
  }
  cout << ans << endl;
  dfs(0,-1);
  for(ll i=0;i<n-1;i++) {
    cout << c[i] << endl;
  }
}

Measured memory_bytes: 19456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B,C,D;
  cin >> N;
  A = N / 1000;
  B = (N-A*1000)/100;
  C = (N-A*1000-B*100)/10;
  D = N % 10;
  if((A==B&&B==C) || (B==C&&C==D)){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(3*n);
    for(int i = 0;i < 3*n;i ++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    ll ans=0;
    for(int i = 1;i < 2*n;i += 2){
        ans += a[i];   
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int AMAX = 100000;
	public static void main(String[] args) {
		int i=0,j=0,k=0;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[] p = new int[n];
		int cnt=0;
		int cnt2=0;
		for(i=0;i<n;i++) {
			p[i] = parseInt(sc.next());
			if(p[i]==i+1) {
				cnt++;
			} else {
				cnt2+=(int)ceil((double)cnt/2);
				cnt=0;
			}
		}
		sc.close();
		cnt2+=(int)ceil((double)cnt/2);
		out.println(cnt2);
	}
}


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

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

int n,m;
const double pi=3.1415926535;

signed main()
{
	n=read();
	printf("%.3lf\n",2*n*pi);
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;

int inf = 1e18;
const int N = 5e5+5;
int mod = 1e9+7;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
bool help(int mid)
{

}
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int h,n;
       cin>>h>>n;
       int a[n+1];
       int b[n+1];
       rep(i,1,n+1)
       cin>>a[i]>>b[i];
       int dp[n+3][h+3];
       for(int i=0;i<n+3;++i)
        for(int j=0;j<h+3;++j)
        dp[i][j] = INT_MAX;
       for(int i=1;i<=n;++i)
       {
           for(int j=1;j<=h;++j)
           {
               if(j<=a[i])
                dp[i][j] = min(dp[i-1][j],b[i]);
               else
                dp[i][j] = min(dp[i-1][j],dp[i][j-a[i]]+b[i]);
           }
       }
       cout<<dp[n][h];
    }
    return 0;
    }


Measured memory_bytes: 78720
n = int(input()) # n is even
x = [int(i) for i in input().split()]
medPlus = sorted(x)[n // 2]
medMinus = sorted(x)[n // 2 - 1]
for i in range(n):
    print(str(medPlus) if x[i] <= medMinus else str(medMinus))

Measured memory_bytes: 26772
#include <iostream>
#include <cmath>

using namespace std;

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

    if (((fabs(b - a) <= d) && (fabs(c - b) <= d)) || (fabs(c - a) <= d)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<ll, ll> P;

template <typename T = string, typename S = char>
class Manacher{
    T s;
    vector<int> R;

    void construct(){
        int i = 0, j = 0;
        while(i < s.size()){
            while(i - j >= 0 && i + j < s.size() && s[i-j] == s[i+j]) j++;
            R[i] = j;
            int k = 1;
            while(i - k >= 0 && i + k < s.size() && k+R[i-k] < j){
                R[i+k] = R[i-k];
                k++;
            }
            i += k;
            j -= k;
        }
    }

public:
    explicit Manacher(T target, S dummy = '$'){
        s.push_back(dummy);
        for(int i = 0; i < target.size(); i++){
            s.push_back(target[i]);
            s.push_back(dummy);
        }
        unsigned int n = s.size();
        R = vector<int>(n, -1);
        construct();
    }

    /**
     *
     * @param pos: 求めたい半径の中心(0-indexed)
     * @return: posを中心とする奇数長の最長の回文の長さ
     */
    int getOddDiameter(int pos){
        return (R[pos * 2 + 1] / 2 - 1) * 2 + 1;
    }

    /**
     *
     * @param pos: 求めたい半径の中心(0-indexed)
     * @return posとpos+1の間を中心とする偶数長の最長の回文の長さ
     */
    int getEvenDiameter(int pos){
        return (R[pos * 2 + 2] - 1) / 2 * 2;
    }


};

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

    Manacher<string, char> m(s);
    for(int j = 1; j < s.size(); j++){
        int i = j;
        while(true) {
            int d = m.getOddDiameter(i) / 2;
            if (2 * i > s.size() - 1) {
                if (i + d == s.size() - 1) {
                    cout << j + 1 << endl;
                    return 0;
                }
                else{
                    break;
                }
            }
            else{
                if(d == i){
                    i += d;
                }
                else{
                    break;
                }
            }
        }
    }


    return 0;
}



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

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}


ll const mod = 1e9+7;
int main() {
  int N;
  string S;
  cin >> S;
  N = S.size();
  vector<vector<ll>> memo(N+1,vector<ll>(2,0));
  memo[0][0] = 1;
  rep2(i,1,N+1) {
    auto t = S[i-1];
    if (t=='0') {
      memo[i][0] = memo[i-1][0]%mod;
      memo[i][1] = memo[i-1][1]*3%mod;
    }
    else {
      memo[i][0] = memo[i-1][0]*2%mod;
      memo[i][1] = (memo[i-1][0] + memo[i-1][1]*3)%mod;
    }
  }
  cout << (memo[N][0] + memo[N][1])%mod << endl;
}

Measured memory_bytes: 5760
#include<stdio.h>

#define INF 2000000000
#define min(a,b) ((a)<(b)?(a):(b))

int main(){
	int n,i,j;
	char s[50][51];
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%s",s[i]);
	int allco[50][26]={{0}},ans[26]={0};
	for(i=0;i<26;i++)ans[i]=INF;
	for(i=0;i<n;i++){
		j=0;
		while(s[i][j]!=0){
			allco[i][s[i][j]-'a']++;
			j++;
		}
	}
	for(i=0;i<26;i++){
		for(j=0;j<n;j++){
			ans[i]=min(ans[i],allco[j][i]);
		}
	}
	for(i=0;i<26;i++){
		for(j=0;j<ans[i];j++){
			printf("%c",'a'+i);
		}
	}puts("");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
using namespace std;

struct Info {
	long Input;
	long A;

	Info(long i, long a) {
		Input = i;
		A = a;
	}
};

bool cmpA(const Info& a, const Info& b) {
	return a.A < b.A;
}

int main() {

	long N;
	cin >> N;

	vector<Info> A(N, Info(0, 0));
	long aval;

	for (long i = 1; i <= N; i++) {
		cin >> aval;
		A[i - 1] = Info(i, aval);
	}

	sort(A.begin(), A.end(), cmpA);

	for (long i = 0; i < N; i++) {
		cout << A[i].Input << " ";
	}

	cout << endl;

	return 0;
}



Measured memory_bytes: 2432
import std.stdio;
import std.algorithm;
import std.conv;
import std.array;
import std.string;
import std.math;
import std.functional;
import std.range;
import std.typecons;
import std.format;
import std.bigint;

void main(string[] args) {
  readln.solve.writeln;
}

auto solve(string line1) {
  auto _ = line1.chomp.split.map!(to!BigInt).array;
  BigInt X = _[0];
  BigInt Y = _[1];

  int res = 0;
  BigInt ind = 1;
  while (X * ind <= Y) {
    res++;
    ind *= 2;
  }
  return res;
} unittest {
  assert(solve("3 20") == 3, "1");
  assert(solve("25 100") == 3, "2");
  assert(solve("314159265 358979323846264338") == 31, "3");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#include<string>
#include<sstream>
#define ll long long 
#define ld long double
#define rep(i,n) for(i=0;i<n;i++)
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL) 
using namespace std;
int main()
{
	fastio;
	int a,b,c;
    cin>>a>>b>>c;
    if (c<a&&c>b || c>a&&c<b)
        cout<<"Yes"<<endl;
    else 
        cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, x, y;

double dist(double x, double y, double x1, double y1){
	return sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
}

double mat[8][8];

int main(){
	cin>>n;
	double res = 0.0;
	vector<pair<int,int> > vec;
	for(int i = 0; i < n; ++i){
		cin>>x>>y;
		vec.push_back(make_pair(x, y));		   
	}
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			if(i != j){
				mat[i][j] = dist(vec[i].first, vec[i].second, vec[j].first, vec[j].second);
			}
		}
	}
	double sum = 0;
	int cnt = 0;
	for(int i = 0; i < n; ++i){
		double x = 0;
		for(int j = 0; j < n; ++j){
			if(i != j){
				x += mat[i][j];
				cnt++;
			}
		}
		sum += x;
	}
	cout<<setprecision(12);
	cout<<(sum)/n<<endl;
	return 0;
}


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

int main(){
  int n, x;
  cin >> n >> x;
  vector<int> m(n);
  int allpow = 0;
  for(int i = 0; i < n; i++){
    cin >> m.at(i);
    allpow += m.at(i);
  }
  sort(m.begin(), m.end());

  int ans = (x - allpow) / m.at(0);
  cout << ans + n << endl;

}


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

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

if N!=0 and A[0]!=0:
    print(-1)
    exit()
elif N==0:
    if A[0]==1:
        print(1)
        exit()
    else:
        print(-1)
        exit()


limit = sum(A)
ans = 1
cur = 1
for i in range(1,N+1):
    nxt = min(cur*2, limit)
    limit -= A[i]
    ans += nxt
    cur = nxt - A[i]
    if i<N and cur<=0:
        print(-1)
        exit()
if cur<0:
    print(-1)
    exit()
print(ans)

Measured memory_bytes: 83400
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<set>
#include<cmath>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll INF =  1LL << 60;
const int inf = 1 << 20;
ll n, m, x, y, q, d,z, w = 0, sum = 0, ans = 0;
const int MAX = 510000;
const int MOD = 1000000007;
int main(void) {
	cin >> n; vector<ll> a;
	string s;
	while (n > 0) {
		n--;
		s += (char)'a' + n % 26;
		n /= 26;
	}reverse(ALL(s));
	cout << s << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int INF = (1<<30);
 
int main(){
  int n, m;
  int d[1001], c[1001];
  int dp[1001][1001];
 
  cin >> n >> m;
  for(int i=0; i<n; i++) cin >> d[i];
  for(int i=0; i<m; i++) cin >> c[i];
  for(int i=0; i<m+1; i++) {
    for(int j=0; j<n+1; j++) {
      dp[i][j] = INF;
    }
  }
 
  dp[0][0] = 0;
 
  for(int i=1; i<m+1; i++) {
    for(int j=0; j<n; j++) {
      if( dp[i-1][j] == INF ) continue;
      dp[i][j] = min(dp[i][j], dp[i-1][j]);
      dp[i][j+1] = min(dp[i][j+1], dp[i-1][j] + d[j]*c[i-1]);
    }
  }
 
  int ans = INF;
  for(int i=0; i<m+1; i++) {
    ans = min(ans, dp[i][n]);
  }
 
  cout << ans << endl;
}

Measured memory_bytes: 5080
/* ex4_3
   kento_titech*/
#include<stdio.h>
int snow_height(int x,int y);
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    printf("%d\n",snow_height(a,b));//積雪の高さを求める関数

    return 0;
}
int snow_height(int x,int y){
        int height;
        height=(y-x)*(y-x+1)/2-y;//1からy-xの総和が東側の塔の高さ。
                                    //積雪はそこからｙ引いたもの.
        return(height);

    }

Measured memory_bytes: 128