akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MAXNUM 211111
typedef long long ll;
#define rep(i,s,t) for(int i=s;i<t;i++)
char s[MAXNUM],st[MAXNUM];
ll num[MAXNUM];
vector<int> tmp;
const ll mod=998244353;
void add(ll &a,ll b)
{
    a+=b;
    if(a>=mod)a-=mod;
}
void sub(ll &a,ll b)
{
    a-=b;
    if(a<0)a+=mod;
}
int main()
{
    int n;scanf("%d%s",&n,s);
    rep(i,1,n+1)if((n%i==0)&&((n/i)&1))
        tmp.push_back(i);
    rep(i,0,tmp.size())
    {
        int k=tmp[i];
        ll r=0;
        rep(j,0,k)add(r,r),add(r,s[j]-'0');
        int x=0;
        rep(j,0,n/k)
        rep(kk,0,k)
        {
            st[x]= (j & 1) != 0 == !(s[kk] - '0');
            x++;
        }
        int flag=1;
        rep(kk,0,n)
        {
            if(s[kk]<st[kk]+'0'){flag=0;break;}
            else if(s[kk]>st[kk]+'0')break;
        }
        add(r,flag);num[i]=r;
    }
    ll res=0;
    rep(i,0,tmp.size())
    {
        rep(j, 0, i)
            if (tmp[i] % tmp[j] == 0)sub(num[i], num[j]);
        add(res, num[i] * 2 * tmp[i] % mod);
    }
    printf("%lld\n",res);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,c=0,a=0; cin>>n;
  int h[n]; for(int i=0;i<n;i++) cin>>h[i];
  for(int i=1;i<n;i++){
    if(h[i-1]<h[i]) a=max(a,c),c=0;
    else c++;
  }
  cout<<max(a,c);
}

Measured memory_bytes: 3964
import java.util.*;

public class Main {
    private static int[] roots;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        UnionFind uf = new UnionFind(n);
        
        while (m-- > 0) {
            int x = sc.nextInt() - 1;
            int y = sc.nextInt() - 1;
            sc.nextInt();
            uf.unite(x, y);
        }
        
        System.out.println(uf.connectedComponent);
    }
    
    public static class UnionFind {
        int[] par;
        int connectedComponent;
    
        UnionFind(int n) {
            par = new int[n];
            connectedComponent = n;
            for (int i = 0; i < n; i++) {
                par[i] = i;
            }
        }
    
        int root(int x) {
            if (par[x] == x) return x;
            par[x] = root(par[x]);
            return par[x];
            // 1-2-4の場合、4の親=2を4の根=1に繋ぎ変えた上で親を返す
            // ↑根まで辿る深さを減らす為
        }
    
        void unite(int x, int y) {
            int rx = root(x);
            int ry = root(y);
            if (rx != ry) {
                par[ry] = rx;
                connectedComponent--;
            }
        }
    
        boolean same(int x, int y) {
            int rx = root(x);
            int ry = root(y);
            return rx == ry;
        }
        
        void printPar() {
            System.out.println(Arrays.toString(par));
        }
    }
}

Measured memory_bytes: 90452
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int main() {
  int n,ans=0;
  cin >> n;
  int a[n+1];
  FOR(i,1,n+1) {
    cin >> a[i];
  }
  FOR(i,1,n+1) {
    if(i == a[a[i]]) {
      ans++;
    }
  }
  cout << ans/2;
}

Measured memory_bytes: 640
n = gets.to_i
r = Array.new(n)
for i in 0..n-1
  r[i] = gets.to_i
end
minv = r[0]
maxv = -10**9
for i in 1..n-1
  maxv = [maxv,r[i]-minv].max
  minv = [minv,r[i]].min
end
puts maxv

Measured memory_bytes: 10280
import random
import sys
input = sys.stdin.readline


class BIT():
    """区間加算、一点取得クエリをそれぞれO(logN)で答える
    add: 区間[l, r)にvalを加える
    get_val: i番目の値を求める
    i, l, rは0-indexed
    """
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def _add(self, i, val):
        while i > 0:
            self.bit[i] += val
            i -= i & -i

    def get_val(self, i):
        """i番目の値を求める"""
        i = i + 1
        s = 0
        while i <= self.n:
            s += self.bit[i]
            i += i & -i
        return s

    def add(self, l, r, val):
        """区間[l, r)にvalを加える"""
        self._add(r, val)
        self._add(l, -val)


r, c, n = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]

def solve(x1, y1):
    if y1 == 0:
        return x1
    if x1 == r:
        return r + y1
    if y1 == c:
        return r + c + (r-x1)
    if x1 == 0:
        return r + c + r + (c-y1)

def compress(array):
    set_ = set([])
    for i in range(len(array)):
        a, b = array[i]
        set_.add(a)
        set_.add(b)
    memo = {value : index for index, value in enumerate(sorted(list(set_)))}
    max_ = 0
    for i in range(len(array)):
        array[i][0] = memo[array[i][0]]
        array[i][1] = memo[array[i][1]]
        max_ = max(max_, *array[i])
    return max_, array

query = []
for i in range(n):
    x1, y1, x2, y2 = info[i]
    if (x1 % r == 0 or y1 % c == 0) and (x2 % r == 0 or y2 % c == 0):
        pos1, pos2 = solve(x1, y1), solve(x2, y2)
        if pos1 > pos2:
            pos1, pos2 = pos2, pos1
        query.append([pos1, pos2 + 1])

m, query = compress(query)
bit = BIT(m)  
for i in range(len(query)):
    begin, end = query[i]
    if bit.get_val(begin) != bit.get_val(end - 1):
        print("NO")
        exit()
    tmp = random.randrange(0, 10**18)
    bit.add(begin, end, tmp)
print("YES")

Measured memory_bytes: 128308
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

struct Edge{
	int to, cost;
};

typedef pair<int, int> P;

const int MAX_V = 3010;
const int INF = 1 << 30;

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

	int n, m;
	cin >> n >> m;

	char c0;
	vector<Edge> vec[MAX_V];
	for(int i = 0; i < m; ++i){
		int a, b, c, d;
		cin >> a >> c0 >> b >> c0 >> c >> c0 >> d;
		--a, --b;
		vec[a].push_back(Edge{b, c});
		vec[b].push_back(Edge{a, d});
	}

	int x1, x2, y1, y2;
	cin >> x1 >> c0 >> x2 >> c0 >> y1 >> c0 >> y2;
	--x1, --x2;

	int d[MAX_V];
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + n, INF);
	d[x1] = 0;
	que.push(P(0, x1));

	while(!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0; i < vec[v].size(); ++i){
			Edge e = vec[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}

	int ans1 = d[x2];
	//cout << ans1 << endl;

	priority_queue<P, vector<P>, greater<P> > que2;
	fill(d, d + n, INF);
	d[x2] = 0;
	que2.push(P(0, x2));

	while(!que2.empty()){
		P p = que2.top();
		que2.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0; i < vec[v].size(); ++i){
			Edge e = vec[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que2.push(P(d[e.to], e.to));
			}
		}
	}

	int ans2 = d[x1];
	//cout << ans2 << endl;

	cout << y1 - (ans1 + ans2 + y2) << endl;

	return 0;
}

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

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

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

  int lb = 0;
  int ub = 1 << 30;
  while (ub - lb > 1) {
    int mb = (lb + ub) / 2;
    int c = 0;
    for (int i = 0; i < N; ++i) {
      c += (A[i] + mb - 1) / mb - 1;
      if (c > K) break;
    }
    (c <= K ? ub : lb) = mb;
  }

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

  return 0;
}


Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 998244353;

int64_t pow(int a, int b) {
    int64_t res = 1;
    for (int i = 0; i < b; i++) {
        res *= (int64_t)a;
        res %= MOD;
    }
    return res;
}

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

    int n; cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    vector<int> cnt(100001, 0);
    for (int i = 0; i < n; i++) {
        if (i == 0 && v[i] != 0) {
            cout << 0 << endl;
            return 0;
        }
        if (i != 0 && v[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
        cnt[v[i]]++;
    }
    int64_t res = 1;
    for (int i = 1; i < (int)cnt.size(); i++) {
        res *= pow(cnt[i-1], cnt[i]);
        res %= MOD;
    }
    cout << res << endl;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

LL N, D, H;


template <std::uint_fast64_t Modulus> class modint {
	using u64 = std::uint_fast64_t;

public:
	u64 a;

	constexpr modint(const u64 x = static_cast<u64>(0)) noexcept
		: a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - static_cast<u64>(2);
		while (exp) {
			if (exp % static_cast<u64>(2) != static_cast<u64>(0)) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= static_cast<u64>(2);
		}
		return *this;
	}
};

using mint = modint<1000000007>;

mint dp[1234567], im[1234567];
mint fact[1234567];

int main() {
	LL N, D, H;
	cin >> N >> H >> D;
	mint fimos = 0;
	fact[0] = 1;
	for (int i = 1; i <= N; ++i) {
		fact[i] = fact[i - 1] * i;
		fimos += fact[i];
	}
	dp[0] = fact[N];
	im[1] = fact[N];
	for (int i = 1; i <= H; ++i) {
		mint tmp = (im[i] - ((i - D < 0) ? 0 : im[i - D]));
		tmp *= fimos;
		dp[i] = tmp;
		im[i + 1] = tmp + im[i];
	}
	mint ans = dp[H] / fimos;
	cout << ans.a << endl;
	return 0;
}

Measured memory_bytes: 28928
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	char a,b;
	scan(a>>b);
	if((a=='H')^(b=='H')) prin("D");
	else prin("H");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string T;
  int A;
  cin >> T;
  T= T +' ';
  A = T.size();
  for(int i=0; i < A-1 ; i++)
  {
    if(T.at(i) == '?')
    {
        T.at(i) = 'D';
    }
    cout << T.at(i);
  }
}

Measured memory_bytes: 3932
n = int(input().rstrip())

num = []
while True:
    sho = n // 26
    amari = n % 26
    if amari == 0:
        amari = 26
        sho = n // 26 - 1

    num.append(amari)
    if sho == 0:
        break
    n = sho

num.reverse()

ans = ''
for i in num:
    ans += chr(i - 1 + ord('a'))

print(ans)


Measured memory_bytes: 9184
let () = Scanf.scanf "%d\n" @@ fun n ->
  let xys = Array.init n @@ fun i ->
    Scanf.scanf "%d %d\n" @@ fun x y -> x, y, i in
  Array.sort compare xys;
  let convex =
    Array.of_list @@
    let h, t =
      match
        Array.fold_left (fun stack (x, y, i) ->
          let rec drop = function
            | ([] | [_]) as stack -> stack
            | ((x1, y1, _) :: (((x2, y2, _) :: _) as rest)) as stack ->
                if 0 < (x1 - x2) * (y - y1) - (y1 - y2) * (x - x1)
                then stack
                else drop rest in (x, y, i) :: drop stack) [] xys
      with
      | [] -> [], []
      | h :: t -> [h], t in
    Array.fold_right (fun (x, y, i) stack ->
      let rec drop = function
        | ([] | [_]) as stack -> stack
        | ((x1, y1, _) :: (((x2, y2, _) :: _) as rest)) as stack ->
            if 0 < (x1 - x2) * (y - y1) - (y1 - y2) * (x - x1)
            then stack
            else drop rest in (x, y, i) :: drop stack) (Array.sub xys 0 (n - 1)) h @ t in
  let convex = Array.sub convex 0 (Array.length convex - 1) in
  let ps = Array.make n 0. in
  for i = 0 to Array.length convex - 1 do
    let (x1, y1, _) = convex.(i) in
    let (x2, y2, j) = convex.((i + 1) mod Array.length convex) in
    let (x3, y3, _) = convex.((i + 2) mod Array.length convex) in
    ps.(j) <-
      0.5 -. acos
        (float_of_int ((x1 - x2) * (x3 - x2) + (y1 - y2) * (y3 - y2)) /.
         sqrt
           ((float_of_int (x1 - x2) ** 2. +. float_of_int (y1 - y2) ** 2.) *.
            (float_of_int (x3 - x2) ** 2. +. float_of_int (y3 - y2) ** 2.)))
      /. (8. *. atan 1.)
  done;
  Array.iter (Printf.printf "%.20f\n") ps


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main()
{
    int len, k;
    cin >> len >> k;

    string s;
    cin >> s;

    if(s[k-1] == 'A')
    {
        s[k-1] = 'a';
    }
    else if(s[k-1] == 'B')
    {
        s[k-1] = 'b';
    }
    else
    {
        s[k-1] = 'c';
    }
    
    cout << s << endl;

    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
	double r;
	double menseki;
	double syu;
	
	scanf("%lf", &r);
	
	menseki = r * r * 3.1415926535897932;
	syu = 2 * r * 3.1415926535897932;
	
	printf("%lf %lf\n", menseki, syu);
	
	return (0);
}

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

int main() {
int N;
  string S;
  cin >>N>>S;
  int ans = 0;
  for(int i=0;i<N-2;i++){
   if(S[i] =='A' && S[i+1] =='B' && S[i+2] == 'C') ans++;
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 256
import heapq
from collections import defaultdict, deque
from math import ceil, factorial
from fractions import gcd
import sys
sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 10**9+7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))


N, K = mii()

if K == 0 or N == K:
    print(0)
    exit()

d, m = divmod(N, K)

ans = min(m, abs(m-K))
print(ans)

Measured memory_bytes: 5624
// #include <cstdio>
// #include <cmath>
#include <bits/stdc++.h>

using namespace std;

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

    long first;
    long rest;
    long count;
    long min_count = n;
    for (long i = 0; i <= n; i++) {
        count = 0;
        first = i;
        while (first > 0) {
            count += first % 6;
            first /= 6;
        }
        rest = n - i;
        while (rest > 0) {
            count += rest % 9;
            rest /= 9;
        }
        min_count = min(min_count, count);
        if (min_count == 1) break;
    }

    cout << min_count  << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0;
  string s;
  std::cin >> x>>s>>z;
  rep(i,x){
    if(s[i]!=s[z-1])s[i]='*';
  }
  std::cout << s << '\n';
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int h, w;
  cin >> h >> w;
  vvi v(h, vi(w));
  rep(i, h) rep(j, w) {
    char c;
    cin >> c;
    v[i][j] = c - '0';
  }
  vvi dp(h, vi(w, INF));
  dp[0][0] = 0;
  rep(i, h) rep(j, w) {
    if (i > 0) cmin(dp[i][j], dp[i - 1][j] + v[i][j]);
    if (j > 0) cmin(dp[i][j], dp[i][j - 1] + v[i][j]);
  }
  cout << dp.back().back() << endl;
}

Measured memory_bytes: 3156
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
const int maxn=1e5+1;
int n;
int a[maxn][4];
int f[maxn][4];

int main(){
	cin>>n;
	for (int i=0;i<n;i++){
		for (int j=1;j<=3;j++){
			cin>>a[i][j];
		}
	}
	f[0][1]=a[0][1];f[0][2]=a[0][2];f[0][3]=a[0][3];
	for (int i=1;i<n;i++){
		for (int j=1;j<=3;j++){
			for (int k=1;k<=3;k++){
				if (k==j) continue;
				f[i][k]=max(f[i][k],f[i-1][j]+a[i][k]);
			}
		}
	}
//	for (int i=1;i<n;i++){
//		for(int j=1..3) {
//			
//			for(int k=1..3) {
//				if (k==j) continue;
//				dp[i][j]=min(dp[i][j], dp[i-1][j]+a[i][k]);
//			} 
//		} 
	
//	}
	int max=-1;
	for (int i=1;i<=3;i++){
		if (f[n-1][i]>max) max=f[n-1][i];
	}
	cout<<max<<endl;
	return 0;
}

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

 int main(){

  int n = 4;

  int a[4];

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

  sort(a,a+n);

  if(a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;



 return 0;
 }


Measured memory_bytes: 256
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;//ハッシュテーブル用
using System.Linq;

class Program
{
    //Hashtable ht = new Hashtable();
    static List<int> s = new List<int>();
    static List<int>[] sl;
    static decimal result;
    static int N,K,Q;
    //StringBuilder strresult= new StringBuilder("");//Append(str ○○)関数で文字を追加していく



    static void Main()
    {
        //Modular mo = new Modular(0);//素数で割った余りを出せで使う。()内が初期値。★使い方：Modular型で宣言すると、その時点でのその素数で割った余りを保持する変数になる（powべき乗、Fac累乗、nCr組み合わせも関数として存在）
        //Node<> no = new Node<>();//UnionFind★Find関数で根っこの値を返す（根っこの値が一緒なら同グループ）、Unite関数で二つの木をくっつける
        //Permutation<> pe = new Permutation<>();//配列＆リストを並べ替えた場合の全ケースを出力★All関数でリスト形式で返す。
        //Treap<> tr = new Treap<>();//平衡二分木★Insert()関数で挿入、FindIndex()関数で該当する大きさの物が入るべき配列番号を返す。
        //PriorityQueue<int,int> pr = new PriorityQueue<int,int>();//優先度付キュー★Add(key,value)で格納、Dequeue()で取りだし。keyが小さいものから取り出す。
Read1();
      string tmp = Console.ReadLine();
                    int[,] check=new int[N,N];
      //文字列をyでぶった切って比較する。
      //checkによるスキップを効かせるために後ろから探査する。
      for(int y=N-1;y>0;y--)
      {       
      //動的計画法を利用。
//xスタートとyスタートで比較した場合の共通部分長さcheck(x,y)を保存する。
//★yの切り口によってcheckの足しこみ境界が変わるのをどう処理する？
      for(int x=y-1;x>=0;x--)
      {
        int i;
        for(i=0;i<y-x && i<N-y;i++){
        if(tmp[y+i]==tmp[x+i]){
//iで一致してたらi+1のcheckを見る。
//これが０でないということはtmp[x+i+1]==tmp[y+i+1]であり、check[x+i+1,y+i+1]にはi+1以降の一致数が保存されているということ。
          if(y+i+1<N && x+i+1<N){//尻の部分で配列からはみ出さないように。尻にはcheckがないが普通に一致をカウントするだけ。
          if(check[x+i+1,y+i+1]>0){
            i+=check[x+i+1,y+i+1];
            if(i>=y-x){i=y-x-1;}//check加算時にy側まではみ出さないようにする。
            i++;break;}//breakする前に、自分が一致している分のi++を忘れずに。
          }
        }else{break;}
        }
        check[x,y]=i;//要は、x,yに来ればiだけ共通部分スキップできるということ。
        if(i>result){result=i;}
      }
      }      
      Console.WriteLine(result.ToString());
    }


    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }

    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
        N = int.Parse(tmp[0]);
        K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {
        sl = new List<int>[N];
        for (int i = 0; i < N; i++) {
            sl[i] = new List<int>();
            string[] tmp = Console.ReadLine().Split(' ');
            for (int j = 0; j < K; j++) {
                sl[i].Add(int.Parse(tmp[j]));
            }
        }

    }
}


Measured memory_bytes: 108640
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
from collections import Counter as co
h=co(d)
p=co(t)
x='YES'
for i in p:
  if p[i]>h.get(i,0):
    x='NO'
    break
print(x)

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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

ll dfs(ll x){
    if(x==1)return 1;
    else {
        return 1 + 2*dfs(x/2);
    }
}

int main() {
    ll n, m, i, j, k;
    ll h;
    cin >> h;
    cout << dfs(h) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long a,b,c;
    scanf("%ld%ld%ld", &a, &b, &c);
    if(a==b && b==c) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }


    return 0;
}


Measured memory_bytes: 128
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  n <- unsafeSignedDecimal <$> T.getLine :: IO Int
  ws <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  let
    (s0 : ss) = scanr1 (+) ws
  print . minimum . map (abs . subtract s0 . (2 *)) $ ss

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
#include <iostream>
using namespace std;
int main() {
	int A, B, C, X, Y;
	int x, y, sum;
	int min = 1000000000;
	cin >> A >> B >> C >> X >> Y;

	for (int i = ((X > Y) ? X : Y);i >= 0;i--) {
		sum = i * C * 2;
		x = X - i;
		y = Y - i;

		if (x > 0)
			sum += x * A;
		if (y > 0)
			sum += y * B;
		if (sum < min)
			min = sum;
	}

	cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#define PLUS 0x2B
#define MINUS 0x2D

using namespace std;

int main () {
  int a[8];
  int p;
  cin >> p;
  const char plus = PLUS;
  const char minus = MINUS;
  if (p < 0 || p > 9999) {
    cout << "wrong entry\n";
    return 0;
  }
  for (int i = 3; i >= 0; i--) {
    a[i*2] = p / (int) pow(10,i);
    a[i*2+1] = -a[i*2];
    p -= a[i*2] * (int) pow(10,i);
  }
  int b;
  char ch[3];
  for (int i = 0; i < 2; i++) {
    for (int j = 2; j < 4; j++) {
      for (int k = 4; k < 6; k++) {
        b = a[6] + a[i] + a[j] + a[k];
        ch[2] = i % 2 ? minus : plus;
        ch[1] = j % 2 ? minus : plus;
        ch[0] = k % 2 ? minus : plus;
        if (b - 7 == 0) {
          cout << a[6] << ch[0] << a[4] << ch[1] << a[2] << ch[2] << a[0] << "=7" << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}


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

int main()
{
  int N;
  while (cin >> N && N != 0) {
    vector<vector<int> > v(30);
    vector<pair<int,string> > scores(N);
    for (int i = 0; i < N; i++) {
      int c;
      scores[i].first = 0;
      cin >> scores[i].second >> c;
      for (int j = 0; j < c; j++) {
        int m;
        cin >> m;
        v[m].push_back(i);
      }
    }
    for (int i = 0; i < 30; i++) {
      const int s = N - v[i].size() + 1;
      for (vector<int>::const_iterator it = v[i].begin(); it != v[i].end(); ++it) {
        scores[*it].first += s;
      }
    }
    sort(scores.begin(), scores.end());
    cout << scores[0].first << ' ' << scores[0].second << endl;
  }
  return 0;
}

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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 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...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll M;
    cin>>M;
    vector<ll> d(M),c(M);
    ll sum=0;
    ll N=0;
    REP(i,M){
        cin>>d[i]>>c[i];
        sum+=(d[i]*c[i]);
        N+=c[i];
    }

    ll ans=N-1+(sum-1)/9;

    cout<<ans<<endl;
}

Measured memory_bytes: 6372
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  cout << (s.substr(0, 4) == "YAKI" ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3620
def examA():
    S, T = LSI()
    A, B = LI()
    U = SI()
    if S==U:
        print(A-1,B)
    else:
        print(A,B-1)
    return

def examB():
    S = SI()
    N = len(S)
    ans = ""
    for i in range(N):
        ans += "x"
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examB()

"""

"""

Measured memory_bytes: 4952
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	priority_queue<ll, vector<ll>, greater<ll>>ng, ps;
	int cnt = 0;
	rep(i, 0, N) {
		ll a; cin >> a;
		if (a < 0)ng.push(a);
		else ps.push(a);
	}
	int s = ng.size();
	if (s % 2 != 0)--s;
	rep(i, 0, s) {
		ll a = ng.top();
		ng.pop();
		ps.push(-a);
	}
	if (!ng.empty() && !ps.empty() && ng.top() < 0 && abs(ng.top()) > ps.top()) {
		ll a = ng.top();
		ng.pop();
		ng.push(-a);

		a = ps.top();
		ps.pop();
		ps.push(-a);
	}
	ll ans = 0;
	while (!ng.empty()) {
		ans += ng.top();
		ng.pop();
	}
	while (!ps.empty()) {
		ans += ps.top();
		ps.pop();
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 5516
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
using namespace std;
#define ll long long int
int main(){
   ll x1,x2,x3,x4,x5;
   cin>>x1>>x2>>x3>>x4>>x5;
   cout<<15-x1-x2-x3-x4-x5;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> arr(n);
    vector<int> good(n);
    for (int i=0; i<n; i++) {
        cin >> arr[i];
        good[i] = i+1;
    }
    bool stat = 0;
    for (int i=0; i<n; i++) {
        for (int j=i; j<n; j++) {
            swap(arr[i], arr[j]);
            if (arr == good) {
                stat = 1;
                break;
            }
            swap(arr[i], arr[j]);
        }
    }
    cout << (stat ? "YES" : "NO");
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

#define PI 3.14159265358979

int main (void){
	double a,b,c;
	double s,l,h;
	
	scanf("%lf %lf %lf",&a,&b,&c);
	s = (a*b*sin(c*PI/180.0))/2;
	l = a+b+ sqrt(a*a+b*b-2*a*b*cos(c*PI/180.0));
	h = 2*(s/a);
	printf("%.9f\n%.9f\n%.9f\n",s,l,h);
	return 0;
}

Measured memory_bytes: 652
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int h, w, k;
char s[310][310];
int nextStaw;
int ans[310][310];

bool hasNoStaw(int line)
{
	for (int j = 0 ; j < w ; j++)
	{
		if (s[line][j] == '#')
			return false;
	}
	return true;
}

int main()
{
	scanf("%d%d%d\n", &h, &w, &k);
	
	for (int i = 0 ; i < h ; i++)
		scanf("%s", s[i]);
		
	nextStaw = 1;
	bool noStawInLine = true;
	for (int i = 0 ; i < h ; i++)
	{
		if (hasNoStaw(i) == false)
		{
			bool isFirst = true;
			int p = 0;
			while (p < w)
			{
				if (s[i][p] == '#')
				{
					if (true == isFirst)
					{
						for (int q = 0 ; q < p ; q++)
							ans[i][q] = nextStaw;
					
						isFirst = false;
					}
					ans[i][p] = nextStaw;
					nextStaw++;
				}
				else
				{
					if (false == isFirst)
						ans[i][p] = ans[i][p - 1];
				}
				
				p++;
			}
			
			if (true == noStawInLine)
			{
				noStawInLine = false;
				for (int ii = 0 ; ii < i ; ii++)
					for (int jj = 0 ; jj < w ; jj++)
						ans[ii][jj] = ans[i][jj];
			}
		}
		else
		{
			for (int j = 0 ; j < w ; j++)
				ans[i][j] = ans[i - 1][j];
		}
	}
	
	
	for (int i = 0 ; i < h ; i++)
	{
		printf("%d", ans[i][0]);
		for (int j = 1 ; j < w ; j++)
			printf(" %d", ans[i][j]);
		printf("\n");
	}
	
	return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	int n;
	cin >> n;
	vector<int> v1(n);
	rep(i, n) cin >> v1.at(i);

	vector<int> v2;
	copy(v1.begin(), v1.end(), back_inserter(v2) );
	sort(v2.begin(), v2.end(), greater<int>());
	int mx = v2.at(0);
	int smx = v2.at(1);
	rep(i, n) {
		if (v1.at(i)==mx) cout << smx << endl;
		else cout << mx << endl;
	}
}

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

int main(){
  int N;
  cin>>N;
  for(int i=0;i<N;i++){
    string s;
    cin>>s;
    if (s=="Y"){
      cout<<"Four"<<endl;
      return 0;
    }
  }
  cout<<"Three"<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
  char b;
  cin>>b;
  if(b=='A'){
    cout<<"T"<<endl;}
  else if(b=='T'){
    cout<<"A"<<endl;}
  else if(b=='G'){
    cout<<"C"<<endl;}
  else if(b=='C'){
    cout<<"G"<<endl;}
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a, b, c, d, e, k;

  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &d);
  scanf("%d", &e);
  scanf("%d", &k);
  if(b-a<=k&&c-a<=k&&d-a<=k&&e-a<=k&&c-b<=k&&d-b<=k&&e-b<=k&&d-c<=k&&e-c<=k&&e-d<=k){
    printf("Yay!\n");
  }else{
    printf(":(\n");
  }
  return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    int N;
    cin >> N;
    vector<int> D(N);
    for(int i = 0; i < N; i++) cin >> D[i];
    ll sum = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(i == j) continue;
            sum+=D[i]*D[j];
        }
    }
    cout << sum / 2 << endl;
}


Measured memory_bytes: 3604
// AOJ 2800: Mod!Mod!
// 2017.8.8 bal4u@uu
// 2017.11.20

#include <stdio.h>
#include <stdlib.h>

int c[3];
char buf[1000002], *p;
int tr[10] = { 0,1,2,0,1,2,0,1,2,0 }; 

int main()
{
	int n;
	int i, a, b;
	
	fgets(buf, 10, stdin), n = atoi(buf);
	fgets(p=buf, 1000002, stdin);
	for (i = 0; i < n; i++) c[tr[*p & 0xf]]++, p += 2;
	if (!c[1] && !c[2]) a = 1;
	else {
		a = c[0]; n -= c[0];
		if (n <= 3) a += n;
		else {
			b = c[1] - c[2]; 
			if      (b ==  0) a += 2 * c[1];
			else if (b ==  1) a += 2 * c[2] + 1;
			else if (b ==  2) a += 2 * c[2] + 2;
			else if (b >   2) a += 2 * c[2] + 3;
			else if (b == -1) a += 2 * c[1] + 1;
			else if (b == -2) a += 2 * c[1] + 2;
			else if (b <  -2) a += 2 * c[1] + 3;
		}
	}
	printf("%d\n", a);
	return 0;
}

Measured memory_bytes: 2804
A,B,C=map(int,input().split());d=0
if A%2:print(0);quit()
if A==B==C:print(-1);quit()
while A%2==B%2==C%2==0:A,B,C=B//2+C//2,C//2+A//2,A//2+B//2;d+=1
print(d)

Measured memory_bytes: 2940
#include <stdio.h>
#include <math.h>
#define N 8
#define NOTFREE 10
#define FREE 0
void putQ(int);
int r,c,col[N],row[N],dpos[2*N],dneg[2*N],C[N][N];
int main(){
  int n,i,j,k;
  for(j=0;j<N;j++){
    col[j]=row[j]=FREE;
    }
  for(j=0;j<2*N;j++){
    dpos[j]=dneg[j]=FREE;
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      C[i][j]=FREE;
    }
  }
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d%d",&r,&c);
    C[r][c]=NOTFREE;
    
    }
     
    
  putQ(0);

  return 0;
}

void putQ(int i){
   int k,j,u,al;
  
  
 
  if(i==N){
    for(j=0;j<N;j++){
      for(k=0;k<N;k++){
	if(C[j][k]==NOTFREE)
	  if(row[j]!=k)
	    return ;
      }
    }
    for(j=0;j<N;j++){
      for(k=0;k<N;k++){
	if(row[j]==k)printf("Q");
	else {
	   printf(".");
	}
	
      }
      printf("\n");
    }
    
  }
 
    for(j=0;j<=N-1;j++){
    if(col[j]==NOTFREE||dpos[i+j]==NOTFREE||dneg[i-j+N-1]==NOTFREE)
      continue;
    
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOTFREE;
    putQ(i+1);
    col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
 
  }
}
      

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

int magic(int k);

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	int N;
	cin>>N;
	int a=0,b=0,c=0,d=0;
	while(N--)
	{
		string s;
		cin>>s;
		if(s=="AC")
			a++;
		if(s=="WA")
			b++;
		if(s=="TLE")
			c++;
		if(s=="RE")
			d++;
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<b<<endl;
	cout<<"TLE x "<<c<<endl;
	cout<<"RE x "<<d<<endl;
	return 0;
		
}


Measured memory_bytes: 3536
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mood;
		}
		x = x * x % mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, a[50];
int ma = -INF, mi = INF;
int x, y;
vector<P> ans;
int cnt;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (ma < a[i]) {
			ma = a[i];
			x = i + 1;
		}
		if (a[i] < mi) {
			mi = a[i];
			y = i + 1;
		}
	}
	if (mi*-1 < ma) {
		for (int i = 0; i < n; i++) {
			if (a[i] < 0) {
				cnt++;
				ans.push_back({ x,i + 1 });
			}
		}
		for (int i = 1; i < n; i++) {
			cnt++;
			ans.push_back({ i,i + 1 });
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			if (0 < a[i]) {
				cnt++;
				ans.push_back({ y,i + 1 });
			}
		}
		for (int i = n; i > 1; i--) {
			cnt++;
			ans.push_back({ i,i - 1 });
		}
	}
	cout << cnt << endl;
	for (int i = 0; i < (int)ans.size(); i++)cout << ans[i].first << " " << ans[i].second << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;


int main() {
	int N, x;
	cin >> N >> x;
	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];
	sort(a.begin(), a.end());

	int ans;
	for (ans = 0; ans < N; ans++) {
		if (a[ans] <= x) {
			x -= a[ans];
		}
		else {
			cout << ans << endl;
			return 0;
		}
	}

	cout << (x == 0 ? N : N - 1 )<< endl;

}

Measured memory_bytes: 3620
import scala.io.StdIn._

object Main extends App {
  val Array(x, y) = readLine.split(" ").map(_.toInt)

  val ans = (0 to 50).exists { i =>
    i <= x &&
    i * 2 + (x - i) * 4 == y
  }

  println(if (ans) "Yes" else "No")
}



Measured memory_bytes: 54756
import collections

N = int(input())
X = []
for i in range(N):
    X.append(list(map(int, input().split())))

div = []
for i in range(N):
    for j in range(N):
        if(i == j):
            continue
        div.append(tuple((X[i][0]-X[j][0], X[i][1]-X[j][1])))
        
c = collections.Counter(div)
c_s = sorted(c.items(), key=lambda x:x[1], reverse=True)

if(N == 1):
    print(1)
else:
    print(N-c_s[0][1])

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

struct mint{
    static const long long MOD = 1000000007;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

mint operator*(long long l, mint r){ return r * l; }

std::ostream& operator<<(std::ostream& stream, const mint& m){
    stream << m.v;
    return stream;
}

int main(){
    ll n;
    cin >> n;
    cout << mint(10).pow(n) - 2 * mint(9).pow(n) + mint(8).pow(n) << endl;
    return 0;
}


Measured memory_bytes: 3632
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var n, a, b int

	fmt.Scan(&n, &a, &b)

	answer := 0

	for i := 1; i <= n; i++ {
		iStr := strconv.Itoa(i)
		splitedIStr := strings.Split(iStr, "")

		sum := 0
		for _, j := range splitedIStr {
			jInt, _ := strconv.Atoi(j)
			sum += jInt
		}

		if (a <= sum) && (sum <= b) {
			answer += i
		}
	}

	fmt.Println(answer)
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  map<pair<int, int>, int> mp;
  rep2(i, 1, n+1){
    string s = to_string(i);
    int fr = s.front() - '0', ba = s.back() - '0';
    mp[{fr, ba}]++;
  }
  ll ans = 0;
  rep2(i, 1, 10){
    rep2(j, 1, 10){
      ans += (ll)mp[{i, j}] * mp[{j, i}];
      // cerr << i << " " << j << " " << mp[{i, j}] << " " << mp[{j, i}] << endl;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3700
#include <stdio.h>
#include <math.h>

#define N 500000
#define INFINITY 2000000000

void merge(int,int,int);
void mergeSort(int,int);

int A[N],cnt=0;
int main(){
  int n,i;
  int left=0,mid,right;

  scanf("%d",&n);
  right=n;
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  mergeSort(left,right);
  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  printf("%d\n",cnt);
  return 0;
}

void merge(int left,int mid,int right){
  int n1,n2;
  int i,j,k;
  n1=mid-left;
  n2=right-mid;
  int L[n1],R[n2];
  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1]=INFINITY;
  R[n2]=INFINITY;
  i = 0;
  j = 0;
  for(k = left;k<right;k++){
    cnt++;
    if (L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }else{ 
      A[k] = R[j];
      j = j + 1;
    }
  }
}

void mergeSort(int left,int right){
  int mid;
  if(left+1<right){
    mid = (left + right)/2;
    mergeSort(left, mid);
    mergeSort(mid, right);
    merge(left, mid, right);
  }
}

Measured memory_bytes: 4500
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int A, B;
string S;

int stringToInt(string s){
  int res = 0;
  rep(i, s.size()){
    int a = s[i] - '0';
    res = res*10+a;
  }
  return res;
}

int main() {
  INCANT;
  cin >> A >> B;
  cin >> S;
  rep(i, A) {
    if (S[i]-'0'<0 || S[i]-'0'>9) {
      cout << "No" << endl;
      return 0;
    } 
  }
  if (S[A]!='-') {
    cout << "No" << endl;
    return 0;
  }
  rep(i, B) {
    if (S[i+1+A]-'0'<0 || S[i+1+A]-'0'>9) {
      cout << "No" << endl;
      return 0;
    } 
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <ccomplex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n, k; cin >> n >> k;
	int ans = 0;
	while (n > 0) {
		ans++;
		n /= k;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <regex>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;

const int MOD = 1e9+7;

int main(void){
  ll k, s;
  ll cnt = 0;
  cin >> k >> s;
  for(ll i = 0;i <= k;i++){
    for(ll j = 0;j <= k; j++){
      if(s - i - j <= k && s - i - j >= 0){
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256