akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> v;
	for(int i=0;i<3*n;++i){
		int x;
		cin>>x;
		v.push_back(x);
	}
	sort(v.begin(),v.end());
	long long int sum=0;
	int j=0;
	for(int i=3*n-2;i>j;i-=2){
		sum+=v[i];
		++j;
	}
	cout<<sum;

}

Measured memory_bytes: 2420
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll INF = 1e18;
struct edge{ll to,cost;};

VL dijkstra(vector<vector<edge> > &graph, int s){
    int n = graph.size();
    VL d(n, INF);
    d[s] = 0;
    priority_queue<PL, vector<PL>, greater<PL> > q;
    q.push(make_pair(0, s));
    while (!q.empty()){
        PL a = q.top();
        q.pop();
        int now = a.second;
        if(d[now] < a.first) continue;
        REP(i,graph[now].size()){
            edge e = graph[now][i];
            int next = e.to;
            if (d[next] > d[now] + e.cost){
                d[next] = d[now] + e.cost;
                q.push(make_pair(d[next], next));
            }
        }
    }
    return d;
}

int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--;
    t--;

    vector<vector<edge> > g1(n), g2(n);
    while (m--) {
        int u = in() - 1, v = in() - 1, a = in(), b = in();
        g1[u].push_back((edge){v, a});
        g1[v].push_back((edge){u, a});
        g2[u].push_back((edge){v, b});
        g2[v].push_back((edge){u, b});
    }

    VL d1 = dijkstra(g1, s);
    VL d2 = dijkstra(g2, t);

    VL ans(n);
    REP(i,n) ans[i] = 1e15 - d1[i] - d2[i];
    FORR(i,n-2,0) ans[i] = max(ans[i], ans[i+1]);
    REP(i,n) printf("%lld\n", ans[i]);

    return 0;
}

Measured memory_bytes: 19012
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Q = sc.nextInt();
        String str = sc.next();
        int[] arr = new int[N+1];
        for(int i = 0; i < N; i++) {
            if(i+1 < N && str.charAt(i) == 'A' && str.charAt(i+1) == 'C') {
                arr[i+1] = arr[i] + 1;
            } else {
                arr[i+1] = arr[i];
            }
        }
        for(int q = 0; q < Q; q++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            --l;
            --r;
            System.out.println(arr[r] - arr[l]);
        }

    }
}


Measured memory_bytes: 62992
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(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()

int main()
{
  int A, B;
  cin >> A >> B;
  int ans = 0;
  for (int i = A; i <= B; ++i)
  {
    string S = to_string(i);
    if (S[0] == S[4] && S[1] == S[3])
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	int N; cin >> N;
	vector<int> a(N); rep(i, 0, N) { cin >> a[i]; }
	int b = 0, c = 0;
	rep(i, 0, N) {
		if (a[i] % 2)b++;
		else c++;
	}
	c += b / 2;
	b %= 2;
	dump(b, c);
	if (b == 0)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 640
while line = gets
    xa, ya, xb, yb, xc, yc, xd, yd = line.chomp.split.map{|z| (z.to_f * 100000).to_i}
dya = yb-ya
dxa = xb-xa
dyc = yd-yc
dxc = xd-xc
    puts (dya * dyc == -1 * dxa * dxc) ? "YES" : "NO"
#    puts "#{dya * dyc} #{dxa*dxc} #{} "
end



Measured memory_bytes: 6880
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<stack>
#include <algorithm>
#include <functional>
//#include<stdlib.h>
using namespace std;


int main() {
	int n, m, t,p=0; bool c;//t:0
	cin >> n;
	m = n / 2;
	vector<short>b(n);
	vector<short>g(n);
	for (int a = 0; a < n; a++) 
	{
		cin >> b[a];
		if (m < a) { g[a] = b[a]; p += g[a]; }
	}
	for (int a = m; a >= 0; a--)
	{
		a++;
		t = a;
		c = true;
		while (true)
		{
			t += a;
			if (t > n) { break; }
			if (g[t-1] == 1) { c = !c; }
		}
		a--;
		if (c != (b[a]==0)) { g[a] = 1; }
		else { g[a] = 0; }
		p += g[a];
	}
	cout << p << endl;
	for (int a = 0; a < n; a++) { if (g[a] == 1) { cout << a+1 <<" "; } }
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>a>>b>>c>>d;
	e=c/__gcd(c,d)*d;
	long long lasta=(a+c-1)/c*c;
	long long lastb=(b)/c*c;
	long long cnum=(lastb-lasta)/c+1LL;
	lasta=(a+d-1)/d*d;
	lastb=(b)/d*d;
	long long dnum=(lastb-lasta)/d+1LL;
	lasta=(a+e-1)/e*e;
	lastb=(b)/e*e;
	long long eenum=(lastb-lasta)/e+1LL;
	cout<<(b-a+1LL)-cnum-dnum+eenum<<endl;
	return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)
ll N;
char s[101010];
ll mk[100];
ll i,j, an;
ll ans;
int main(){
    scanf("%lld%s", &N, s);
    fornum(i,0,N){
        mk[s[i] - 'a']++;
        //printf("%lld,%lld\n", i, ans);
    }
    ans = 1;
    fornum(i,0,30){
        (ans *= mk[i] + 1) %= MOD;
    }
    (ans += MOD - 1) %= MOD;
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 384
n,m=map(int,input().split())

if n>2 and m>2:
    print((n-2)*(m-2))
elif n==2 or m==2:
    print(0)
elif n==1 and m==1:
    print(1)
else:
    if n==1:
        print(m-2)
    else:
        print(n-2)

Measured memory_bytes: 3060
import numpy as np


N, W = map(int, input().split())
w_v = [[int(_) for _ in input().split()] for _ in range(N)]
dp = np.zeros([N, W+1], dtype=int)
dp[0][w_v[0][0]:] = w_v[0][1]

for i in range(1, N):
    key = w_v[i][0]
    dp[i][:key] = dp[i-1][:key]
    dp[i][key:] = np.maximum(dp[i-1][key:], dp[i-1][:-key] + w_v[i][1])

print(dp[-1][-1])

Measured memory_bytes: 92108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    string s;
    cin >> s;
    int N = s.size();
    ll a[N], b[N];
    ll x = s[0]-'0';
    a[0] = min(x, 11-x), b[0] = min(x+1, 11-x-1);
    rep2(i, 1, N-1){
        x = s[i]-'0';
        a[i] = min(a[i-1]+x, b[i-1]+10-x);
        if(x == 9) b[i] = b[i-1];
        else{
            b[i] = min(a[i-1]+x+1, b[i-1]+9-x);
        }
    }
    cout << a[N-1] << endl;
}

Measured memory_bytes: 17028
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int D = Integer.parseInt(sc.next());
        int[] c = new int[26];
        int[] cd = new int[26];
        for (int i = 0; i < 26; i++) {
            c[i] = Integer.parseInt(sc.next());
        }
        int[][] s = new int[D][26];
        for (int i = 0; i < D; i++) {
            for (int j = 0; j < 26; j++) {
                int temp = Integer.parseInt(sc.next());
                s[i][j] = temp;
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < D; i++) {
            int con = best(c, cd, s, i + 1);
            cd[con] = i + 1;
//            int temp = Integer.parseInt(sc.next());
//            t[i] = temp;
//            int temp = max[i];
//            cd[temp - 1] = i + 1;
//            ans += s[i][temp - 1] - totalSubC(c, cd, i + 1);
//            sb.append(ans);
//            sb.append(max[i]);
            sb.append(con + 1);
            sb.append("\n");
        }
//        int m = Integer.parseInt(sc.next());
//        for (int i = 0; i < m; i++) {
//            int d = Integer.parseInt(sc.next());
//            int q = Integer.parseInt(sc.next());
//            int old = t[d - 1];
//            t[d - 1] = q;
//            ans = total(c, cd, s, t, D);
//            t[d - 1] = old;
//            Arrays.fill(cd, 0);
//            sb.append(ans);
//            sb.append("\n");
//        }
        System.out.println(sb.toString());
    }

    private static int totalSubC(int[] c, int[] cd, int d) {
        int ans = 0;
        for (int i = 0; i < 26; i++) {
            ans += c[i] * (Math.max(0, d - cd[i]));
        }
        return ans;
    }

    private static int total(int[] c, int[] cd, int[][] s, int[] t, int D) {
        int ans = 0;
        for (int i = 0; i < D; i++) {
            cd[t[i] - 1] = i + 1;
            ans += s[i][t[i] - 1] - totalSubC(c, cd, i + 1);
        }
        return ans;
    }

    private static int best(int[] c, int[] cd, int[][] s, int d) {
        int ans = 0;
        int max = -1000000;
        for (int i = 0; i < 26; i++) {
            int old = cd[i];
            cd[i] = d;
            for (int j = 0; j < 26; j++) {
                int temp = s[d - 1][j] - totalSubC(c, cd, d);
                if (max < temp) {
                    ans = j;
                    max = temp;
                }
            }
            cd[i] = old;
        }
        return ans;
    }
}

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

#include <atcoder/all>
using namespace atcoder;

int main() {
    int N, D;
    cin >> N >> D;
    vector<ll> x(N), y(N);
    rep(i, N) {
        cin >> x[i] >> y[i];
    }
    two_sat ts(N);
    rep(i,N) {
        for(int j = i+1; j<N; ++j) {
            if (abs(x[i]-x[j])<D) {
                ts.add_clause(i, false, j, false);
            }
            if (abs(x[i]-y[j])<D) {
                ts.add_clause(i, false, j, true);
            }
            if (abs(y[i]-x[j])<D) {
                ts.add_clause(i, true, j, false);
            }
            if (abs(y[i]-y[j])<D) {
                ts.add_clause(i, true, j, true);
            }
        }
    }
    if (!ts.satisfiable()) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    auto ans = ts.answer();
    rep(i, N){
        if (ans[i]) {
            cout << x[i] << endl;
        } else {
            cout << y[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
typedef long long ll;

#define MXN 200005
int N,M;
pii E[MXN];
vector<ll> Ans;

int P[MXN];
ll Sz[MXN];
void uf_init(int N){ FOR(i,0,N){P[i]=i; Sz[i]=1;} }
int Find(int x)
{
    if(P[x]==x)return x;
    return P[x]=Find(P[x]);
}
void Union(int x, int y)
{
    int px = Find(x), py = Find(y);
    if( px!=py )
    {
        if(Sz[px]>Sz[py])
        {
            Sz[px]+=Sz[py];
            P[py]=px;
        }
        else
        {
            Sz[py]+=Sz[px];
            P[px]=py;
        }
    }
}

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

    cin>>N>>M;
    FOR(i,1,M)cin>>E[i].f>>E[i].s;
    ll Co = 0;//connected pairs
    uf_init(N);
    FORD(i,M,1)
    {
        Ans.pb(Co);
        int u = E[i].f, v = E[i].s;
        if( Find(u)!=Find(v) )
        {
            Co+=Sz[ Find(u) ]*Sz[ Find(v) ];
            Union(u,v);
        }
    }
    ll Tot = (ll)N*(N-1)/2;
    FORD(i,M-1,0)
    {
        cout<<Tot-Ans[i]<<'\n';
    }

    return 0;
}


Measured memory_bytes: 4212
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int N = sc.nextInt();
        long[] A = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
        }
        long left = -10000000000l;
        long right = 10000000000l;
        // long preans = -1;
        while (true) {
            // long lv = calc(A, left);
            // long rv = calc(A, right);
            long m1 = (left*2+right)/3;
            long m2 = (left+right*2)/3;
            // System.err.println("m1 "+m1);
            // System.err.println("m2 "+m2);
            // long mv = calc(A, mid);
            
            long mv1 = calc(A, m1);
            long mv2 = calc(A, m2);

            if(mv1<mv2){
                right = m2;
            }else{
                left = m1;
            }

            if(m2-m1<=1){
                ans = Math.min(mv1, mv2);
                break;
            }
        }
        System.out.println(ans);
    }

    long calc(long[] A, long val) {
        long ret = 0;
        for (int i = 0; i < A.length; i++) {
            ret += Math.abs(A[i] - val - i);
        }
        return ret;
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 61604
using System;
using System.Collections.Generic;

class A
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int n = int.Parse(s[0]);
        int k = int.Parse(s[1]);

        if (n < k)
        {
            string str = "";
            for (int i = 0 ; i < k; i++)
            {
                str += n;
            }
            Console.WriteLine(str);
            return;
        }
        else
        {
            string str = "";
            for (int i = 0 ; i < n; i++)
            {
                str += k;
            }
            Console.WriteLine(str);
            return;            
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

template<typename T>
vector<T> smallest_prime_factors(T n) {
    vector<T> spf(n + 1);
    for (int i = 0; i <= n; i++) spf[i] = i;
    for (T i = 2; i * i <= n; i++) {
        if (spf[i] == i) {
            for (T j = i * i; j <= n; j += i) {
                if (spf[j] == j) {
                    spf[j] = i;
                }
            }
        }
    }
    return spf;
}

template<typename T>
map<T, int> factolization(T x, vector<T> &spf) {
    map<T, int> ret;
    while (x != 1) {
        ret[spf[x]] += 1;
        x /= spf[x];
    }
    return ret;
}

int main() {
  int n; cin>>n;
  long long ans = 0;
  auto spf = smallest_prime_factors(10000010);
  REP(i, 1, n+1) {
    auto result = factolization(i, spf);
    long long cur = 1;
    for (auto x: result) cur *= (x.second + 1);
    ans += i * cur;
  }
  print(ans);

  return 0;
}

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

namespace AtCoderABC123
{
    class Program
    {
        public static void Main(string[] args)
        {
            int[] p = new int[5];
            p[0] = int.Parse(Console.ReadLine());
            p[1] = int.Parse(Console.ReadLine());
            p[2] = int.Parse(Console.ReadLine());
            p[3] = int.Parse(Console.ReadLine());
            p[4] = int.Parse(Console.ReadLine());
            int k = int.Parse(Console.ReadLine());
            bool ff = false;
            for (int i = 0 ; i < 4; i++)
            {
                for (int j = i + 1; j < 5; j++)
                {
                    if (p[j] - p[i] > k) ff = true;
                }
            }
            Console.WriteLine((ff)? ":(":"Yay!");
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
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;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/


signed main() {
	int n;
	cin >> n;
	for (int i = 1; i <= 50000; i++) {
		int k = i * 1.08;
		if (k == n) {
			cout << i << endl; return 0;
		}
	}
	cout << ":(" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
	long long a, b, c, d, e, f;
	long long p, q, r;
	long long x, y, z;
	for (; scanf("%lld %lld %lld %lld %lld %lld", &a, &b, &c, &d, &e, &f) !=EOF;){
		c = c * 1000;
		f = f * 1000;
		p = (a*e) - (d*b);
		q = (c*e) - (f*b);
		x = q / p;
		p = (b*d) - (e*a);
		q = (c*d) - (f*a);
		y = q / p;
		if (x < 0){
			printf("-");
			x = -x;
		}
			printf("%lld.%03lld ", x / 1000, x % 1000);
			if (y < 0){
				printf("-");
				y = -y;
			}
		printf("%lld.%03lld\n", y / 1000, y % 1000);
	}
		return 0;
	}

Measured memory_bytes: 2652
import bisect

def gcd(a,b):
    if b == 0:
        return abs(a)
    else:
        return gcd(b, a%b)

N,M = map(int, input().split())
S = input()
T = input()


if S[0] != T[0]:
    print(-1)
    exit()

if len(S) == len(T):
    if S == T:
        print(len(S))
    else:
        print(-1)
    exit()

gcd1 = gcd(len(S), len(T))
lcm = len(S)*len(T) // gcd1

SS = []
TT = []
i = 0
j = 0
while i < N:
    SS.append(i*lcm//N + 1)
    i += 1
while j < M:
    TT.append(j*lcm//M + 1)
    j += 1

ind = 0
ind_max = j-1

for i,v in enumerate(SS):
    ind = bisect.bisect_left(TT, v,ind, j)
    if ind == j:
        break
#    print(ind)
    if TT[ind] == v:
        if S[i] == T[ind]:
            continue
        else:
            print(-1)
            exit()
print(lcm)


Measured memory_bytes: 11036
#include <string>
#include <iostream>
#include <vector>
#include <algorithm> 
using namespace std;
int main()
{
  long long int a,b,c=0;
  cin>>a>>b;
  c=std::__gcd(a,b);
  c=a/c;
  c=c*b;
  cout<<c;
  
 
  return 0;
}
 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		 Scanner scan = new Scanner(System.in);
	     String str = scan.nextLine();
	     String[] chars = str.split(" ");
	     int A = Integer.valueOf(chars[0]);
	     int B = Integer.valueOf(chars[1]);
	     if(0<A&A<10) {
	    	 if(0<B&B<10) {
	    		 System.out.println(A*B);
	    		 return;
	    	 }
	     }
	     System.out.println(-1);
	}

}


Measured memory_bytes: 23124
#include <stdio.h>

int main(){
    int L, R, d, i;
    int count = 0;
    scanf("%d %d %d", &L, &R, &d);

    for(i = L; i <= R; i++){
        if(i % d == 0){
            count++;
        }
    }
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 1716
#include <cstdio>
typedef long long ll ;

int main(){
    int N;
    scanf("%d",&N);
    ll a[N+1];
    
    a[0] = 2;
    a[1] = 1;
    if(N==1){
        printf("%lld",a[1]);
    }else{
        for(int i=2;i<=N;i++){
            a[i] = a[i-1] + a[i-2];
        }
        printf("%lld",a[N]);
    }
}

Measured memory_bytes: 128
n, _m = gets.split.map(&:to_i)
likes = {}
n.times do |_i|
  gets.split.map(&:to_i)[1..-1].each do |f|
    likes[f] = (likes[f] || 0) + 1
  end
end
puts likes.select { |_k, v| v == n }.size


Measured memory_bytes: 1788
#include<stdio.h>

int main(){
	int banyak, jumlah;
	int crane = 2;
	int turtle = 4;
	scanf("%d %d", &banyak, &jumlah);
	if(banyak > jumlah || jumlah % 2 == 1 || banyak * 2 > jumlah|| banyak * 4 < jumlah){
		printf("No");
	}
	else{
		printf("Yes");
	}
	
	
	return 0;
	
}

Measured memory_bytes: 1732
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
const int mod=998244353;
int n,st[210],top;
bool vis[210][210];
ll ans,cpow[210];
struct pt
{
	int x,y;
}a[210];
bool check(int p,int q,int r)
{
	if((a[p].x-a[q].x)*(a[q].y-a[r].y)==(a[q].x-a[r].x)*(a[p].y-a[q].y)) return 1;
	return 0;
}
int main()
{
	scanf("%d",&n);
	cpow[0]=1;
	for(int i=1;i<=n;i++) cpow[i]=(cpow[i-1]<<1)%mod;
	
	ans=cpow[n];
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i].x,&a[i].y);
	memset(vis,0,sizeof(vis));
	for(int i=1;i<=n;i++)
		for(int j=1;j<=i-1;j++)
			if(!vis[i][j])
			{
				top=2;st[1]=i;st[2]=j;
				for(int k=1;k<=n;k++)
					if(k!=i&&k!=j&&check(i,j,k)) st[++top]=k;
				ans=(ans-cpow[top]+top+1+mod)%mod;	
					
				for(int k=1;k<=top;k++)
					for(int l=1;l<=k-1;l++)
						vis[st[k]][st[l]]=vis[st[l]][st[k]]=1;
			}
	ans=(ans-n-1+mod)%mod;
	printf("%lld",ans);	
	return 0;
}
/*5
0 4
1 2
0 0
2 4
2 0*/

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef pair<int, pi> pii;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define fax(i, a) for (int i = 0; i < (a); i++)
#define f0x(i, a, b) for (int i = (a); i < (b); i++)
#define faxd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define f0xd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define memeset memset

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 3005;
const ld PI = 4*atan((ld)1);

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
ll dp[MX][MX]; ll a[MX], b[MX];
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int N,M; cin >> N >> M;
   fax(i,N) cin >> a[i];
   fax(i,M) cin >> b[i];
   dp[0][0] = 0;
   for(int i = 1; i <= N; i++){
	   for(int j = 1; j <= M; j++){
		   if(a[i-1] == b[j-1]){
			   dp[i][j] = ((dp[i-1][j] + dp[i][j-1])%MOD) + 1;
		   }
		   else{
			   dp[i][j] = ((((dp[i-1][j] + dp[i][j-1])%MOD) - dp[i-1][j-1])+MOD)%MOD;
		   }
		   dp[i][j] %= MOD;
	   }
   }
   cout << (dp[N][M]+1)%MOD<< "\n";
}


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

#define int long long

int A[52];
long long DP[52][52][2502];

void solve() {
    int n, a;
    cin >> n >> a;
    for (int i = 0; i < n; i++) {
        cin >> A[i+1];
    }
    for (int i = 1; i <= n; i++) {
        for (int k = 1; k <= 2500; k++) {
            DP[i][1][k] = DP[i - 1][1][k];
        }
        DP[i][1][A[i]]++;
    }

    for (int j = 2; j <= n; j++)
        for (int i = 1; i <= n; i++) {
            for (int k = 1; k <= 2500; k++) {
                DP[i][j][k] += DP[i - 1][j][k];
                DP[i][j][k] += DP[i - 1][j-1][max(k - A[i], 0LL)];
                //if(DP[i][j][k] > 0)
                //cout << DP[i][j][k] << "\n";
            }
        }
//    for(int i = 0; i <= n; i++){
//
//        for(int k = 0; k <= 33; k++)
//            cout << DP[1][i][k] << " ";
//        cout << "\n";
//    }
    long long ans = 0;
    for (int i = 1; i <= n; i++)
        ans += DP[n][i][a * i];
    cout << ans << "\n";
}

#undef int

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    bool multitest = false;
    // multitest = true;
    if (multitest) {
        int t; cin >> t;
        while (t--)
            solve();
    }
    else
        solve();
}




Measured memory_bytes: 52644
from bisect import bisect
mod = 10**9+7
n,k = map(int,input().split())
*a,= map(int,input().split())
b = []
ans = 0
for j,x in enumerate(a):
	i = bisect(b,x)
	ans += (j-i)*k
	b.insert(i,x)
a.sort(reverse=True)
bef = a[-1]
j=0
for i,cur in enumerate(a):
	if cur==bef:
		ans += k*(k-1)*j//2
	else:
		ans += k*(k-1)*i//2
		j = i
		bef = cur
print(ans%mod)


Measured memory_bytes: 3188
def nCr(n,r,fac,finv):
    mod = (10**9)+7
    ans = fac[n] * (finv[r] * finv[n-r] % mod) % mod
    return ans

n,k = map(int,input().split())
als = list(map(int,input().split()))
als.sort()
ans = 0
mod = (10**9)+7
fac = [1,1]+[0]*n
finv = [1,1]+[0]*n
inv = [1,1]+[0]*n
for i in range(2,n+1):
    fac[i] = fac[i-1] * i % mod
    inv[i] = mod - inv[mod%i] * (mod//i) % mod
    finv[i] = finv[i-1] * inv[i] % mod

for i in range(n):
    if i >= k-1:
        ans += als[i] * nCr(i,k-1,fac,finv) % mod
        ans = ans % mod
    if i <= n-k:
        ans -= als[i] * nCr(n-i-1,k-1,fac,finv) % mod
        ans = ans % mod

print(ans)
        


Measured memory_bytes: 64424
import heapq
 
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
 
q = []
heapq.heapify(q)
heapq.heappush(q, (-(A[0] + B[0] + C[0]), 0, 0, 0))  # heapq では昇順ソートするためマイナスにする
 
for _ in range(K):
    m, i, j, k = heapq.heappop(q)
    print(-m)
    if i + 1 < X:
        s = (-(A[i+1] + B[j] + C[k]), i+1, j, k) 
        if s not in q:
            heapq.heappush(q, s)
    if j + 1 < Y:
        s = (-(A[i] + B[j+1] + C[k]), i, j+1, k) 
        if s not in q:
            heapq.heappush(q, s)
    if k + 1 < Z:
        s = (-(A[i] + B[j] + C[k+1]), i, j, k+1) 
        if s not in q:
            heapq.heappush(q, s)

Measured memory_bytes: 3828
let golf k a b =
  let a_mod_k = a mod k in
  if a_mod_k = 0 then "OK"
                 else if (a - a_mod_k + k) <= b then "OK" else "NG"

let k = read_int ()
let a, b = Scanf.sscanf (read_line()) "%d %d" (fun a b -> (a, b))
let () = Printf.printf "%s\n" (golf k a b)

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

const int DIM = 1e5 + 5;

int deg[DIM];

vector<int> edg[DIM];
deque<int> que;

int dfs( int x, int f, bool &ok ) {
    int nr = 0;
    
    for( int y : edg[x] ) {
        if( y == f )
            continue;
        
        bool aux = dfs( y, x, ok );
        
        if( aux == true )
            deg[x] --;
    }
    
    if( deg[x] - (f != 0) >= 2 )
        ok = true;
    else
        return ( deg[x] - (f != 0) == 1 );
    
    return false;
}

int main( void ) {
    
    int n;
    cin >> n;
    
    for( int i = 2; i <= n; i ++ ) {
        int x, y;
        cin >> x >> y;
        
        edg[x].push_back( y );
        edg[y].push_back( x );
        deg[x] ++; deg[y] ++;
    }
    
    bool ok = false;
    bool aux = dfs( 1, 0, ok );
    
    if( ok == false )
        ok = !aux;
    
    cout << ( (ok == true) ? "First\n" : "Second\n" );
    return 0;
}


Measured memory_bytes: 6272
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

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

int N;
int a;
int main(void){
    int c = 1;
    cin >> N;
    vector<PI> V;
    REP(i,N){
        cin >> a;
        V.push_back(PI(a, c++));
    }
    sort(V.begin(),V.end());
    REP(i,N) cout << V[i].second << " ";
    cout << endl;
    return 0;
}



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

int main() {
	int h,i,j,k,s;
	cin >> k >> s;
	for(h=0;h<=k;h++){
		for(i=0;i<=k-h;i++){
			j=k-h-i;
				if(h*10000+i*5000+j*1000==s){
					cout << h << " " << i << " " << j << "\n";
				return 0;
			}
		}
	}

		cout << "-1 -1 -1" << "\n";

}


Measured memory_bytes: 256
import sys

n= int(sys.stdin.readline())

d = dict()
for _ in range(n):
    s= sys.stdin.readline().strip()
    a= [ c for c in s ]
    a.sort()
    s= "".join(a)
    d[s]= d.get(s,0) + 1
#
c= 0
for m in d.values(): c += (m*(m-1))//2
print( c )

Measured memory_bytes: 17808
package main

import (
	"fmt"
	"math/big"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	sum := big.NewInt(0)
	for i := 1; i <= n; i++ {
		if i%3 != 0 && i%5 != 0 {
			sum.Add(sum, big.NewInt(int64(i)))
		}
	}
	fmt.Printf("%s\n", sum.String())
}


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

int main(){
    double n,m;
    cin >> n >> m;
    vector<double> a(n);
    rep(i,n) cin >> a[i];
    int sum = 0;
    rep(i,n) sum += a[i];
    int res = 0;
    rep(i,n){
        if(a[i]/sum >= 1/(4*m)){
            res++;
            if(res == m){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
n = int(input())
x = [i + 1 for i in range(n - (n % 2))]
y = [[x[i], x[len(x) - i - 1]] for i in range(len(x) // 2)]
ans = []
for i in range(len(y) - 1):
    for j in range(2):
        for k in range(2):
            ans.append([y[i][j], y[i + 1][k]])
if n == 3:
    ans = [[1, 3], [2, 3]]
elif n == 4:
    ans = [[1, 2], [1, 3], [2, 4], [3, 4]]
elif n % 2 == 1:
    for i in range(len(x) - 1, len(x) + 1):
        for j in range(2):
            ans.append([y[i % len(y)][j], n])
else:
    for i in range(2):
        for j in range(2):
            ans.append([y[len(y) - 1][i], y[0][j]])
print(len(ans))
for ans0 in ans:
    print(" ".join(map(str, ans0)))

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

int main() {
  int x;
  cin >> x;
  if(x == 0){
    cout << 1 << endl;
  }
  if(x == 1){
    cout << 0 << endl;
  }
  
}


Measured memory_bytes: 3632
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
    void run(){
        Scanner sc = new Scanner(System.in);
        TreeSet<String> registeredId = new TreeSet<String>();
        boolean opened = false;

        int n = sc.nextInt();
        for(int i=0; i<n; i++){
            registeredId.add(sc.next());
        }
        int m = sc.nextInt();
        for(int i=0; i<m; i++){
            String touchId = sc.next();
            if(registeredId.contains(touchId)){
                if(opened){
                    System.out.println("Closed by " + touchId);
                    opened = false;
                }
                else{
                    System.out.println("Opened by " + touchId);
                    opened = true;
                }
            }
            else{
                System.out.println("Unknown " + touchId);
            }
        }
    }
    public static void main(String[] args) {
        //new AOJ2440().run();
        new Main().run();
    }
}

Measured memory_bytes: 20436
//zombie462 ak ioi
#include <bits/stdc++.h>
#define N 2000010
#define mod 1000000007
#define int long long
using namespace std;
int x[6],y[6],fac[N],ifac[N],inv[N];
int C(int n,int m){
	return (n<0 || m<0 || n<m)?(0):(fac[n]*ifac[m]%mod*ifac[n-m]%mod);
}
int calc(int n,int m){
	return C(n+m,n);
}
int calc1(int a,int b){
	return (calc(x[5]+1-a,y[5]+1-b)-calc(x[4]-a,y[5]+1-b)-calc(x[5]+1-a,y[4]-b)+calc(x[4]-a,y[4]-b))%mod;
}
int calc2(int a,int b){
	return (calc(a-x[0]+1,b-y[0]+1)-calc(a-x[1],b-y[0]+1)-calc(a-x[0]+1,b-y[1])+calc(a-x[1],b-y[1]))%mod;
}
signed main(){
	for (int i=0;i<6;++i) cin>>x[i];
	for (int i=0;i<6;++i) cin>>y[i];
	fac[0]=fac[1]=inv[0]=inv[1]=ifac[0]=ifac[1]=1;
	for (int i=2;i<N;++i) fac[i]=fac[i-1]*i%mod;
	for (int i=2;i<N;++i) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for (int i=2;i<N;++i) ifac[i]=ifac[i-1]*inv[i]%mod;
	int ans=0;
	for (int i=x[2];i<=x[3];++i) ans=(ans+calc1(i,y[3]+1)*calc2(i,y[3])%mod*(i+y[3]+1))%mod;
	for (int i=x[2];i<=x[3];++i) ans=(ans-calc1(i,y[2])*calc2(i,y[2]-1)%mod*(i+y[2]))%mod;
	for (int i=y[2];i<=y[3];++i) ans=(ans+calc1(x[3]+1,i)*calc2(x[3],i)%mod*(i+x[3]+1))%mod;
	for (int i=y[2];i<=y[3];++i) ans=(ans-calc1(x[2],i)*calc2(x[2]-1,i)%mod*(i+x[2]))%mod;
	cout<<(ans+mod)%mod<<endl;
}

Measured memory_bytes: 47104
l,r=map(int,input().split())
if l//2019 != r//2019:
  print(0)
  exit()
l0=l%2019
r0=r%2019
mi=2018
for i in range(l0,r0):
  for j in range(l0+1,r0+1):
    mi=min(mi,(i*j)%2019)
print(mi)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;

int main() {
    ll n,k,c; cin >> n >> k >> c;
    string s; cin >> s;
    vector<int> l(k + 1),r(k + 1);
    int cnt = 1;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'o') l[cnt] = i, cnt++, i += c;
        if (cnt > k) break;
    }
    cnt = k;
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'o') r[cnt] = i, cnt--, i -= c;
        if (cnt <= 0) break;
    }
    for (int i = 1; i <= k; i++) {
        if (l[i] == r[i]) cout << l[i] + 1 << "\n";
    }
}

Measured memory_bytes: 3332
#create date: 2020-07-05 21:01

import sys
stdin = sys.stdin
from collections import defaultdict

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    s = defaultdict(int)
    for _ in range(n):
        a = ns()
        s[a] += 1

    print("AC x {}".format(s["AC"]))
    print("WA x {}".format(s["WA"]))
    print("TLE x {}".format(s["TLE"]))
    print("RE x {}".format(s["RE"]))
if __name__ == "__main__":
    main()

Measured memory_bytes: 9480
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int main()
{
    int n = 50;
    ll k;cin >> k;
    ll hoge = k%n;
    vector<ll> ans;
    ll h =k/n;
    rep(i,hoge){
        ans.push_back(n+h+n-hoge);
    }
    rep(i,n-hoge){
        ans.push_back(h-hoge+n-1);

    }
    cout << n << endl;
    for(auto p:ans)cout << p << " ";
    return 0;
}

Measured memory_bytes: 3576
S = input()
op_cnt = len(S) - 1
ans = 0
for i in range((2 ** op_cnt)):
    k = 0
    for j in range(op_cnt):
        if ((i >> j) & 1):
            ans += int(S[k:j+1])
            k = j+1
    ans += int(S[k:])

print(ans)

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    vector<vector<int>> dist(h, vector<int>(w, INF));
    queue<pair<int, pii>> que;
    for(int i = 0; i < h; ++i){
        cin >> a[i];
        for(int j = 0; j < w; ++j){
            if(a[i][j] == '#'){
                que.push({0, {i, j}});
                dist[i][j] = 0;
            }
        }
    }
    int ans = 0;
    while(!que.empty()){
        auto q = que.front();
        int i = q.second.first, j = q.second.second, c = q.first;
        que.pop();
        if(i != 0 && dist[i-1][j] > c + 1) {dist[i-1][j] = c + 1; que.push({c+1, {i-1, j}});}
        if(i != h-1 && dist[i+1][j] > c + 1) {dist[i+1][j] = c + 1; que.push({c+1, {i+1, j}});}
        if(j != 0 && dist[i][j-1] > c + 1) {dist[i][j-1] = c + 1; que.push({c+1, {i, j-1}});}
        if(j != w-1 && dist[i][j+1] > c + 1) {dist[i][j+1] = c + 1; que.push({c+1, {i, j + 1}});}
    }
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 17424
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

void err() {
	puts("No");
	exit(0);
}

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

	int N;
	cin >> N;
	vector<int>S(1<<N);
	for (int i = 0; i < (1<<N); i++)cin >> S[i];
	sort(all(S));
	reverse(all(S));

	multiset<int>rem;
	for (int i = 0; i < (1 << N); i++)rem.insert(S[i]);
	rem.erase(--rem.end());

	queue<int>q1, q2;
	q1.push(S[0]);
	while (q1.size() < 1 << N) {
		while (q1.size()) {
			int tp = q1.front();
			q1.pop();
			q2.push(tp);
			auto itr = rem.lower_bound(tp);
			if (itr == rem.begin())err();
			--itr;
			q2.push(*itr);
			rem.erase(itr);
		}
		swap(q1, q2);
	}
	puts("Yes");

	return 0;
}


Measured memory_bytes: 13568
#include<bits/stdc++.h>
#define ll long long
#define foi(a,n) for(int i = a; i < (int)n; i++)
#define foj(a,n) for(int j = a; j < (int)n; j++)
#define pb(a) push_back(a)
#define ln '\n'
#define fastio 	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define cases int tests; cin >> tests; while(tests--)
using namespace std;

int main(){
	fastio;
	ll n, m, p;
	//~ cases
	{	
		cin >> n;
		m = 0; p = 0;
		string s;
		cin  >> s;
		foi(0, n){
			if(s[i] == 'R')m++;
		}
		if(m == 0){
			cout << 0;
		}
		else{
			foi(m, n){
				if(s[i] == 'R')p++;
			}
			cout << p;
		}
		
	}
}


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

X,Y = map(int, input().split())
p=int(1e9+7)
if (X+Y)%3 or X>Y*2 or Y>X*2:
    print(0)
else:
    N=int((X+Y)/3)
    k=X-N
    if k==0 or k==N:
        print(1)
    else:
        fac=[1]*(N+1)
        inv=[1]*(N+1)
        finv=[1]*(N+1)
            
        num=max(k,N-k)
        for j in range(num-1):
            i=j+2
            fac[i]=fac[i-1]*i % p
            r=int(p%i)
            q=p//i
            inv[i]=p- inv[r]*q %p
            finv[i]=finv[i-1]*inv[i] % p
        for j in range(N-num):
            i=num+1+j
            fac[i]=fac[i-1]*i % p
        print(int(fac[N]*(finv[k]*finv[N-k] % p) % p))
        

Measured memory_bytes: 60932
//再帰 メモ

#include <cstdio>
#include <algorithm>
using namespace std;

int dp(int, int);

int w[1001];
int v[1001];
int memo[101][10001];

int main(){
    int N,W;
    scanf("%d %d",&N,&W);
    
    for(int i = 0; i < 101; i++){
        for(int j = 0; j < 10001; j++){
            memo[i][j] = -1;
        }
    }

    for(int i = 0; i < N; i++){
        scanf("%d %d",&v[i],&w[i]);
    }

    printf("%d\n",dp(N,W));

    return 0;
}

int dp(int i,int j){
    if(i == 0){
        return 0;
    }
    if(memo[i][j] >= 0){
        return memo[i][j];
    }
    if(j - w[i - 1] < 0){
        return memo [i][j] = dp(i - 1,j);
    }

    return memo[i][j] = max(dp(i - 1,j),dp(i,j - w[i - 1]) + v[i - 1]);
}


Measured memory_bytes: 7032
l = []
ans = []
a, b, k = list(map(int, input().split()))
l.append(a)
l.append(b)
i = 1

for i in range(1, min(l) + 1):
    if (a % i) == 0 and (b % i) == 0:
       ans.append(i) 

print(ans[-k])

Measured memory_bytes: 3060
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=200005;
int n;
map<int,int>cnt;
int a[maxn];

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d",&n);
	rep(i,n)scanf("%d",&a[i]),cnt[a[i]]++;
	sort(a,a+n);
	int ans=0;
	for(int i=n-1;i>=0;i--){
		if(cnt[a[i]]==0)continue;
		for(int j=30;j>=0;j--){
			int tmp=(1<<j)-a[i];
			if(!cnt.count(tmp))continue;
			if((tmp!=a[i]&&cnt[tmp]>=1)||(tmp==a[i]&&cnt[tmp]>=2)){
				ans++;
				cnt[a[i]]--;
				cnt[tmp]--;
				break;
			}
		}
	}
	printf("%d\n",ans);
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


Measured memory_bytes: 10368
M, K = map(int, input().split())

def xor_match(M, K) :
	if K >= 2 ** M :
		return '-1' 

	elif (M, K) == (0, 0) :
		return '0 0'

	elif (M, K) == (1, 0) :
		return '0 0 1 1'

	elif (M, K) == (1, 1) :
		return '-1'

	init = 1

	if K == 0 :
		p_left = [1, 0, 1]
		init = 2
	else :
		p_left = [0, K, 0]

	p_right = []
	for i in range(init, 2**M) :
		if i == K :
			continue
		
		p_right.append(i)

	p = map(str, p_left + p_right + [K] + p_right[::-1])
	return ' '.join(p)

print(xor_match(M, K))

Measured memory_bytes: 28816
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;


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

	int sum = 0;
	while(n--)
	{
		int l,r;
		cin >> l >> r;
		sum += r-l+1;
	}
	cout << sum;
	return 0;
}

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

int main() {
    string s;
    int cnt[26] = {};
    while(cin >> s) {
        for(int i = 0; i < s.size(); i++) {
            if(isupper(s[i])) s[i] = tolower(s[i]);
            if(s[i] >= 'a' && s[i] <= 'z') {
                cnt[s[i] - 'a']++;
            }
        }
    }
    for(int i = 0; i < 26; i++) {
        cout << (char)('a' + i) << " : " << cnt[i] << endl;
    }
}



Measured memory_bytes: 3200
using System;
// using System.Collections.Generic;
// using System.Linq;
// using System.Text;

class Program
{
    static void Main()
    {
        string S = Console.ReadLine();
        string O = "RUD";
        string E = "LUD";
        bool flg = true;
        for (int i = 0; i < S.Length; i++)
        {
            if (1 == (i + 1) % 2 && !O.Contains(S[i]))
            {
                flg = false;
                break;
            }
            if (1 == i % 2 && !E.Contains(S[i]))
            {
                flg = false;
                break;
            }
        }
        Console.WriteLine(flg ? "Yes" : "No");
        return;
    }
}

Measured memory_bytes: 25872
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(num,init,name) vector<int> name((num),(init));
int main(){
    
    int n,k;
    int tmp;
    cin>>n>>k;
    vec(n,0,a);
    rep(i,n){
        cin>>a[i];
        if(a[i]==1){
            tmp=i;
        }
    }
    cout<<ceil((n-1)/(double)(k-1))<<endl;
    return 0;


}



Measured memory_bytes: 640