akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.AGC016
{
    class Shrinking
    {
        public static void Main()
        {
            var alphabet = "abcdefghijklmnopqrstuvwxyz";
            var prev = new Dictionary<char, int>();
            var max = new Dictionary<char, int>();
            foreach(var c in alphabet) {
                prev.Add(c, -1); max.Add(c, -1);
            }
            var s = ReadLine().Trim();
            for (var i = 0; i < s.Length; ++i) {
                if (max[s[i]] < i - prev[s[i]] - 1) {
                    max[s[i]] = i - prev[s[i]] - 1;
                }
                prev[s[i]] = i;
            }
            foreach(var c in alphabet) {
                if (max[c] < s.Length - prev[c] - 1) {
                    max[c] = s.Length - prev[c] - 1;
                }
            }
            WriteLine(max.Where(_ => _.Value >= 0).Min(_ => _.Value));

        }
    }
}


Measured memory_bytes: 13408
#include<stdio.h>
int main(void)
{
	int i,j,n,m,a[101];
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(a[i]>a[j]){
				m=a[i];
				a[i]=a[j];
				a[j]=m;
			}
		}
	}
	printf("%d\n",a[n-1]-a[0]);
	return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))
flag = 1
cnt = 0
while flag:
    flag = 0
    for i in range(n-1,0,-1):
        if a[i] < a[i-1]:
            a[i],a[i-1] = a[i-1],a[i]
            flag = 1
            cnt += 1
print(' '.join(map(str,a)))
print(cnt)


Measured memory_bytes: 5596
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var ABCK = Sarray();
            if (ABCK[3] % 2 == 0)
                WriteLine(ABCK[0] - ABCK[1]);
            else
                WriteLine(ABCK[1] - ABCK[0]);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
def main():
    from sys import stdin

    readline = stdin.readline

    N = int(readline().rstrip())
    
    c0 , c1 , c2 , c3 = 0 , 0 , 0 , 0

    for i in range(N):
        test = readline().rstrip()

        if test == "AC":
            c0 += 1
        elif test == "WA":
            c1 += 1
        elif test == "TLE":
            c2 += 1
        elif test == "RE":
            c3 += 1

    c0 = "AC x " + str(c0)
    c1 = "WA x " + str(c1)
    c2 = "TLE x " + str(c2)
    c3 = "RE x " + str(c3)


    print(c0 + "\n" + c1 + "\n" + c2 + "\n" + c3)

main()

Measured memory_bytes: 9212
x = int(input())
n = int((10**9)**(1/5))
for a in range(10**3):
    for b in range(10**3):
        if a**5 - b**5 == x: 
            print(a, b)
            exit()
        elif a**5 + b**5 == x:
            print(a, -b)
            exit()
print('error')

Measured memory_bytes: 9328
import math

N, D = map(int, input().split())
x = []
for _ in range(N):
    x.append(list(map(int, input().split())))

a = [i**2 for i in range(300)]
n = 1
t = 0
for i in range(N):
    k = i + n
    for j in range(k, N):
        count = 0
        for l in range(D):
            count += (x[i][l] - x[j][l]) ** 2
        n += 1
        if count in a:
            t += 1
    n = 1

print(t)


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

int main(void) {
    int k, length, sum;
    int c;

    while(1) {
        cin >> k;
        if(k == 0) break;

        length = k*(k-1)/2;
        //int* c = new int[length];

        sum = 0;
        for(int i=0; i < length; i++) {
            cin >> c;
            sum += c;
        }

        if(k > 2) {
            sum = sum / (k-1);
        }


        cout << sum << endl;


    }
}

Measured memory_bytes: 3096
#include <iostream>
#include <list>
#include <vector>

using namespace std;

int main() {
    int N, M;
    list<int> ds, ts;

    cin >> N;
    for (int i = 0; i < N; i++) {
        int d;
        cin >> d;
        ds.push_back(d);
    }
    ds.sort();

    cin >> M;
    for (int i = 0; i < M; i++) {
        int t;
        cin >> t;
        ts.push_back(t);
    }
    ts.sort();

    if (N < M) {
        cout << "NO" << endl;
        return 0;
    }

    auto ds_itr = ds.begin();
    for (auto ts_itr = ts.begin(); ts_itr != ts.end(); ++ts_itr) {
        while (*ds_itr < *ts_itr) {
            ds_itr++;
        }
        if (*ds_itr > *ts_itr) {
            cout << "NO" << endl;
            return 0;
        }
        ds_itr++;
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef pair<int, int> P;

template<typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return (a * b) / gcd(a, b);
}

int rec(int a, int acc) {
    if (a == 0) throw "hoge";
    if (a % 2 == 1) {
        return acc;
    }
    else {
        return rec(a / 2, acc + 1);
    }
}

int fn(int a) {
    return rec(a, 0);
}

int main()
{
    int N; cin >> N;
    vector<int> evens;
    for (int i = 0; i < N; i++) {
        int a;  cin >> a;
        if (a % 2 == 0) {
            evens.push_back(a);
        }
    }

    const int len = evens.size();
    int ans = 0;
    for (int i = 0; i < len; i++) {
        ans += fn(evens[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <ll> vll;

int n;
vi v, c;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n;
  v.resize(n);
  c.resize(n);
  for (int& elem: v) cin >> elem;
  for (int& elem: c) cin >> elem;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] - c[i] > 0) ans += v[i] - c[i];
  }
  cout << ans << '\n';
  return (0);
}


Measured memory_bytes: 256
package main

import (
    "fmt"
)

func main(){
    // Your code here!
    
    var n int
    var w,ans string
    flag := true

    fmt.Scan(&n)
    
    array := make([]string, n)
    
    for i := 0; i < n; i++ {
        fmt.Scan(&w)
        array[i] = w
        
        if i != 0 {
            if array[i-1][len(array[i-1])-1:] != w[:1]{
                flag =false
            }
            for j := 0; j < i-1; j++ {
                if array[j] == array[i]{
                    flag = false
                }
            }
        }
        
        if !flag{
            break
        }
    }
    
    if flag{
        ans = "Yes"
    } else {
        ans = "No"
    }

    fmt.Println(ans)
}


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

int main() {
  int h, w, b;
  char a;
  cin >> h >> w;

  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      string s;
      cin >> s;

      if (s=="snuke") {
        a=65+j;
        b=i+1;
      } 
    }
  }

  cout << a << b;
}

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

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

  int min = 99999;
  // ここにプログラムを追記
  for(int i = 0; i < N; i++) {
    int j, k;
	int total = 1;
    for(j = 0; j < N - i; j++) {
      total *= 2;
    }
    for(k = j; k < N; k++) {
      total += K;
    }
    if(min > total) {
      min = total;
    }
  }
  cout << min << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, N;
  cin>>N>>A;
  int maisu;
  maisu=N/500;
  if(N-maisu*500<=A){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

#define For(i, j, k) for (int i = j; i <= k; i++)
#define Forr(i, j, k) for (int i = j; i >= k; i--)

using namespace std;

const int N = 1e6 + 10;
const int Mod = 998244353;

int Pow(int x, int e) {
	int ret = 1;
	while (e) {
		if (e & 1) ret = 1ll * ret * x % Mod;
		x = 1ll * x * x % Mod;
		e >>= 1;
	}
	return ret;
}

int fac[N], rfac[N];

int C(int n, int m) {
	if (n < 0 || m < 0 || m > n) return 0;
	return 1ll * fac[n] * rfac[m] % Mod * rfac[n - m] % Mod;
}

int f(int n, int m, int T) {
	if (T <= 0) return 0;
	return (C(n + m, n) - C(n + m, m - T) + Mod) % Mod;
}

int main() {

	int n = N - 5;
	fac[0] = 1;
	For(i, 1, n) fac[i] = 1ll * fac[i - 1] * i % Mod;
	rfac[n] = Pow(fac[n], Mod - 2);
	Forr(i, n, 1) rfac[i - 1] = 1ll * rfac[i] * i % Mod;

	int L, ans = 0;
	scanf("%d%d", &n, &L);
	For(r, (L + 1) / 2, L) {
		int b = L - r;

		if (r == b) ans = (ans + f(r, b - 1, r - n + 1)) % Mod;
		else if (n > r - b) ans = (ans + f(r, b, r - n + 1)) % Mod;
		else ans = (ans + C(r + b, r)) % Mod;
	} 
	printf("%d\n", ans);
	
	return 0;
}

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

S = {}
cnt=0
for i in range(N):
    if i-A[i] in S:
        cnt+=S[i-A[i]]
    t = A[i]+i
    if t in S:
        S[t]+=1
    else:
        S[t]=1

print(cnt)


Measured memory_bytes: 40668
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <climits>
#include <queue>
#include <cstring>
#include <stack>
#include <map>
using namespace std;
#define rep(i,a,b) for(int i=a; i<=b; i++)
#define ii pair <int, int>
#define fi first
#define se second
#define ll unsigned long long
int n, w;
ll f[101][100001];
ii a[101];

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
//	freopen("Test.inp", "r", stdin);
//    freopen("Test.out", "w", stdout);
    cin>>n>>w;
    rep(i,1,n) cin>>a[i].fi>>a[i].se;
    rep(i,1,n){
        rep(j,1,w){
            f[i][j]=f[i-1][j];
            if(a[i].fi<=j) f[i][j] = max(f[i][j], f[i-1][j-a[i].fi] + a[i].se);
        }
    }
    cout<<f[n][w];
	return 0;
}


Measured memory_bytes: 78336
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
using ll = long long;
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
int main() {
	string s;
	cin >> s;
	int n = s.size();
	string t = "keyence";
	rep(i, 8) {
		string ns = s.substr(0, i) + s.substr(n - 7 + i);
		if (ns == t) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    int N; cin >> N;
    string s1, s2; cin >> s1 >> s2;
    s1 += '#';
    
    int cnt = 0, ans = 1, p = -1;
    char INIT = (char)('A' - 1);
    char prev = INIT;
    rep(i,0,s1.length()) {
        if(prev == INIT) cnt++;
        else if(s1[i] == prev) cnt++;
        else {
            // printf("cnt = %lld, prev = %c\n", cnt, prev);
            if(cnt == 2) {
                if(p == -1) (ans *= 6) %= MOD;
                else if(p == 2) (ans *= 3) %= MOD;
                else if(p == 1) (ans *= 2) %= MOD;

                p = cnt;
            }
            if(cnt == 1) {
                if(p == -1) (ans *= 3) %= MOD;
                else if(p == 1) (ans *= 2) %= MOD;
                // p == 2 -> do nothing

                p = cnt;
            }
            cnt = 1;
        }
        prev = s1[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import copy
import random

D = list(map(int, input().split()))
q = int(input())

for x in range(q):
    y, z = map(int, input().split())
    while True:
        r = random.randint(0,3)
        if r == 0:
            Dt = copy.copy(D)
            temp = Dt[0]
            Dt[0] = Dt[4]
            Dt[4] = Dt[5]
            Dt[5] = Dt[1]
            Dt[1] = temp
        elif r== 1:
            Dt = copy.copy(D)
            temp = Dt[0]
            Dt[0] = Dt[2]
            Dt[2] = Dt[5]
            Dt[5] = Dt[3]
            Dt[3] = temp
        elif r== 2:
            Dt = copy.copy(D)
            temp = Dt[0]
            Dt[0] = Dt[3]
            Dt[3] = Dt[5]
            Dt[5] = Dt[2]
            Dt[2] = temp
        elif r == 3:
            Dt = copy.copy(D)
            temp = Dt[0]
            Dt[0] = Dt[1]
            Dt[1] = Dt[5]
            Dt[5] = Dt[4]
            Dt[4] = temp

        D = copy.copy(Dt)
        if Dt[0] == y and Dt[1] == z:
            print(Dt[2])
            break



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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 200003;

using Complex = complex<double>;

// Reference: http://www.prefield.com/algorithm/math/fft.html
vector<Complex> DFT(const vector<Complex>& p, int n, int sign = 1) {
  const double theta = 2.0 * M_PI / n * sign;
  int unit = 1;
  vector<Complex> q = p;
  for (int m = n; m >= 2; m >>= 1) {
    int mh = m >> 1;
    for (int i = 0; i < mh; i++) {
      Complex w = Complex(cos(theta * unit * i), sin(theta * unit * i));
      for (int j = i; j < n; j += m) {
        int k = j + mh;
        Complex x = q[j] - q[k];
        q[j] += q[k];
        q[k] = w * x;
      }
    }
    unit *= 2;
  }
  int i = 0;
  for (int j = 1; j < n - 1; j++) {
    for (int k = n >> 1; k > (i ^= k); k >>= 1);
    if (j < i) swap(q[i], q[j]);
  }
  return q;
}
 
vector<Complex> InvDFT(const vector<Complex>& p, int n) {
  auto q = DFT(p, n, -1);
  for(int i = 0; i < n; i++) {
    q[i] /= n;
  }
  return q;
}
 
vector<Complex> MultiplyFFT(
    const vector<Complex>& p1, const vector<Complex>& p2) {
  int d = p1.size() + p2.size() - 1;
  int n = 1;
  while(n < d + 1) n *= 2;
 
  auto q1 = p1;
  q1.resize(n);
  auto q2 = p2;
  q2.resize(n);
  auto r1 = DFT(q1, n);
  auto r2 = DFT(q2, n);
 
  vector<Complex> s(n);
  for(int i = 0; i < n; i++) {
    s[i] = r1[i] * r2[i];
  }
  return InvDFT(s, n);
}

vector<int64> MultiplyFFT(
    const vector<int64>& p1, const vector<int64>& p2) {
  vector<Complex> q1;
  for (int i = 0; i < p1.size(); i++) {
    q1.emplace_back(p1[i], 0);
  }
  vector<Complex> q2;
  for (int i = 0; i < p2.size(); i++) {
    q2.emplace_back(p2[i], 0);
  }
  vector<Complex> r = MultiplyFFT(q1, q2);
  vector<int64> s;
  for (int i = 0; i < r.size(); i++) {
    s.push_back(llround(r[i].real()));
  }
  return s;
}

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

  // i = 2^p
  vector<int64> i_to_p(P, -1);
  vector<int64> p_to_i(P - 1, -1);
  {
    int64 x = 1;
    for (int i = 0; i < P - 1; i++) {
      i_to_p[x] = i;
      p_to_i[i] = x;
      x *= 2;
      x %= P;
    }
  }

  int n;
  cin >> n;

  int64 delta = 0;
  vector<int64> xs(P - 1);
  for (int i = 0; i < n; i++) {
    int64 a;
    cin >> a;
    if (a == 0) continue;
    xs[i_to_p[a]] += 1;
    delta += a * a % P;
  }
  vector<int64> ys = MultiplyFFT(xs, xs);
  int64 ans = 0;
  for (int i = 0; i < ys.size(); i++) {
    int k = i % (P - 1);
    ans += p_to_i[k] * ys[i];
  }
  ans -= delta;
  ans /= 2;
  cout << ans << endl;
}

Measured memory_bytes: 66864
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;



int main(){
    long long int a,b;
    cin >> a >> b;
    long long int x=a*b;
    long long int tmp=0;
    long long int r=0;
    if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  /* 最小公倍数を出力 */
  cout << x/b;
 
  return 0;
}
        

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

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int N;
int A, B, C;
int D[101];
int main() {
    double ans = 0;
    cin >> N;
    cin >> A >> B >> C;
    rep(i, N) cin >> D[i];
    int x = A;
    int y = C;
    ans = 1.0 * y / x;
    sort(D, D + N);
    reverse(D, D + N);
    rep(i, N) {
        double t = 1.0 * (y + D[i]) / (x + B);
        if (ans < t) {
            ans = t;
            y += D[i];
            x += B;
        }
    }
    cout << (int) ans <<endl;
    return 0;
}

Measured memory_bytes: 3120
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
#define inf 1e10
using namespace std;

const int maxn = 210000;

int n;
multiset<ll>ql,qr;
multiset<ll>::iterator it;
ll addL,addR,len,re;

int main()
{
	scanf("%d",&n);
	for(int i=1,las=0;i<=n;i++,las=len)
	{
		ll l,r; scanf("%lld%lld",&l,&r);
		len=r-l;
		if(i==1)
		{
			ql.insert(-inf); ql.insert(l);
			qr.insert(inf); qr.insert(l);
			continue;
		}
		addL-=len,addR+=las;
		ll pl=*ql.rbegin()+addL,pr=*qr.begin()+addR;
		if(l<pl)
		{
			it=ql.end();it--; ql.erase(it);
			ql.insert(l-addL); ql.insert(l-addL);
			re+=pl-l;
			qr.insert(pl-addR);
		}
		else if(l<=pr)
			ql.insert(l-addL),qr.insert(l-addR);
		else
		{
			it=qr.begin(); qr.erase(it);
			qr.insert(l-addR); qr.insert(l-addR);
			re+=l-pr;
			ql.insert(pr-addL);
		}
	}
	printf("%lld\n",re);
	
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define mod 1000000007
bool isPrime[1000001];
ll power(ll a,ll b)
{
    ll result = 1;
    while(b>0)
    {
        if(b%2)
        {
            result = (a*result)%mod;
        }
        a = (a*a)%mod;
        b = b/2;
    }
    return result;
}
int gcd(int a,int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    memset(isPrime,1,sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for(int i=2;i*i<=1000000;i++)
    {
        if(isPrime[i])
        {
            for(int j=i*i;j<=1000000;j+=i)
            {
                isPrime[j] = 0;
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int t,n;
    t = 1;
    for(int i=0;i<t;i++)
    {
        int n,k;
        cin>>n>>k;
        double arr[n];
        for(int i=0;i<n;i++)
        {
            cin>>arr[i];
            arr[i] = (arr[i]+1)/2;
        }
        double sum = 0;
        for(int i=0;i<k;i++)
        {
            sum+=arr[i];
        }
        double maxi = sum;
        for(int i=k;i<n;i++)
        {
            sum+=arr[i];
            sum-=arr[i-k];
            maxi = max(sum,maxi);
        }
        cout<<fixed<<setprecision(15)<<maxi;
    }
    return 0;
}


Measured memory_bytes: 5352
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define rep(i, n) for (signed i = 0; i < signed(n); i++)
#define REP(i, s, n) for (signed i = signed(s); i < signed(n); i++)
#define rrep(i, n) for (signed i = signed(s) - 1; i >= 0; i--)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, const T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, const T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

void calc() {
	int n; cin >> n;
	V v(n); input(v);
	int minv = *min_element(all(v));
	int maxv = *max_element(all(v));
	bool ok = false;
	if (minv == maxv) {
		int a = minv;
		ok = (a == n - 1 || a * 2 <= n);
	} else if (minv + 1 == maxv) {
		int c = 0;
		rep(i, n) c += v[i] == minv;
		ok = maxv >= c + 1 && maxv <= c + (n - c) / 2 && (n - c >= 2);
	}

	cout << (ok ? "Yes" : "No") << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	calc();
#ifdef _MSC_VER
	system("pause");
#endif
}

Measured memory_bytes: 1024
import java.util.*;
  public class Main{
    public static void main(String[]args){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int count = 0;
      int [] data = new int[50];

      for(int i = 0;i<N;i++){
        data[i] = sc.nextInt();
      }
      
      for(int k = 0;k<N;k++){
        if(data[k] != k+1){
          count++;
        }
      }
        if(count<=2){
          System.out.println("YES");
        }
        if(count>2){
          System.out.println("NO");
        }
    }
  }


Measured memory_bytes: 21844
from collections import defaultdict
from math import gcd
from functools import reduce
n = int(input())
A = list(map(int, input().split()))
ans = 0

U = 10**6+1
is_prime = [1]*U
is_prime[0] = 0
is_prime[1] = 0
for p in range(2, int(U**.5)+1):
    if is_prime[p]:
        for q in range(2*p, U, p):
            is_prime[q] = 0


def sieve(n):
    n += 1
    res = [i for i in range(n)]
    for p in range(2, int(n**.5)+1):
        if res[p] < p:
            continue
        for q in range(p**2, n, p):
            if res[q] == q:
                res[q] = p
    return res


min_factor = sieve(U)


def prime_factor(n):
    res = defaultdict(int)
    while 1 < n:
        res[min_factor[n]] += 1
        n //= min_factor[n]
    return res


for a in A:
    for k, v in prime_factor(a).items():
        if 1 <= is_prime[k]:
            is_prime[k] = 0
            continue
        ans = 1
        break
    else:
        continue
    break

if ans == 0:
    print('pairwise coprime')
else:
    if reduce(gcd, A) == 1:
        print('setwise coprime')
    else:
        print('not coprime')


Measured memory_bytes: 210108
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  ll n;
  cin>>n;
  vector<vecll> a(n, vecll(n));
  for(auto&& l:a)for(auto&& e:l)cin>>e;
  vecll dp(1<<n);
  for(auto&& i:irange(0,1<<n)) {
    ll sum = 0;
    for(auto&& j:irange(0l,n)) {
      if((i>>j)&1) {
        for(auto&& k:irange(0l,j)) {
          if((i>>k)&1) {
            sum += a[j][k];
          }
        }
      }
    }
    dp[i] = sum;
  }
  for(auto&& i:irange(0,1<<n)) {
    for (int U = (1 << n) - 1; U >= 0; --U) {
      U &= i;
      dp[i] = max(dp[i], dp[U] + dp[i^U]);
    }
  }
  cout<<dp.back()<<endl;
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T *)array, (T *)(array + N), val);
}

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

int main(){
    ll  n ,k;
    cin >> n >> k;
    ll cnt = 0;
    if(k == 0){
        dump(n * n);
    }
    else{
        for(int b = k + 1;b <= n;b++){
            cnt += (n / b) * (b - k);
            if(n % b >= k)cnt += (n % b) - (k - 1);
        }
        dump(cnt);
    }

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll k,x;
    cin>>k>>x;
    ll val1=(x-k+1);
    ll val2=(x+k-1);
    for(ll i=val1;i<=val2;i++)
    {
        cout<<i<<" ";
    }
    return 0;
}

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

int main() {
	string s;
  	cin >> s;
  
  	bool can = true;
  
  	for(int i = 0; i < s.size() - 1; i++) {
      for(int j = i + 1; j < s.size(); j++) { 
    	if(s.at(i) == s.at(j)) can = false;
      }
    }
  
  	if(can) {
    	cout << "yes" << endl;
    }else {
    	cout << "no" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
ll p2(ll a)
{
    ll s=1,r=2;
    while(a)
    {
        if(a&1)
            s=(s*r)%mod;
        r=(r*r)%mod;
        a>>=1;
    }
    return s;
}
ll pow(ll a, ll b, ll m)
{
    ll ans = 1;
    a %= m;
    while(b)
    {
        if(b & 1)
            ans = (ans % m) * (a % m) % m;
        b /= 2;
        a = (a % m) * (a % m) % m;
    }
    ans %= m;
    return ans;
}
ll inv(ll x, ll p)
{
    return pow(x, p - 2, p);
}
ll C(ll n, ll m, ll p)
{
    if(m > n)
        return 0;
    ll up = 1, down = 1;
    for(int i = n - m + 1; i <= n; i++)
        up = up * i % p;
    for(int i = 1; i <= m; i++)
        down = down * i % p;
    return up * inv(down, p) % p;
}
ll Lucas(ll n, ll m, ll p)
{
    if(m == 0)
        return 1;
    return C(n % p, m % p, p) * Lucas(n / p, m / p, p) % p;
}
int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=p2(n)-Lucas(n,a,mod)-Lucas(n,b,mod)-1;
    cout<<(ans%mod+mod)%mod<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,count1=0,a;
    vector<int>s;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a;
        s.push_back(a);
    }
    for(i=0;i<n;i=i+2)
    {
        if(s[i]%2!=0)
            count1++;
    }
    cout<<count1<<endl;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;


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

for(int i=0;i<n;i++)
a[i]-=i+1;

sort(a,a+n);
long long ans=0;

if(n%2==1){
  for(int i=0;i<n;i++)
  ans+=abs(a[i]-(a[n/2]));

  cout <<ans<<endl;
  return 0;
}

else {
  long long ans2=0;
  for(int i=0;i<n;i++){
    ans+=abs(a[i]-a[n/2]);
    ans2+=abs(a[i]-a[n/2-1]);
  }
  cout<<min(ans,ans2)<<endl;
}

}


Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  ll n,x;
  cin >> n>>x;
  
  vector<ll> p(n);
  
  rep(i,n){
  cin>>p[i];
  }
   
  sort(all(p));
  
  ll ans = 0;
  rep(i,n){
    if(i==n-1){
      if(x==p[i])ans++;
      break;
    }
    else if(x>=p[i]) {
    x-=p[i];
    ans++;
    }
    else break;
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 256
program example
	implicit none

	integer :: N,M,wa=0,i
    integer,allocatable :: A(:)
    
    read(*,*) N,M
    
    allocate(A(N))
    
    read(*,*) A

    do i=1,N
    	if(A(i)>=(sum(A)/(4.0d0*dble(M)))) then
        	wa=wa+1
        end if
    end do
    
    if(wa>=M) then
    	write(*,*) "Yes"
    else
    	write(*,*) "No"
        
    end if
    

end program example


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#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 <codecvt>
#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>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){
  ll n;cin>>n;
  vector<ll>x(n),y(n);
  rep(i,n)cin>>x[i]>>y[i];
  if(n==1){
    cout<<1<<endl;
    return false;
  }
  ll ans=INF;
  rep(_,n)rep(__,n){
    if(_==__)continue;
    ll p=x[_]-x[__];
    ll q=y[_]-y[__];
    vector<bool>use(n,false);
    ll num=n;
    rep(i,n)rep(j,n){
      if(x[j]-x[i]==p and y[j]-y[i]==q and use[i]==false){
        use[i]=true;
        num--;
        break;
      }
    }
    chmin(ans,num);
  }
  cout<<ans<<endl;
  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 256
a,b = map(int,input().split())
if a==b:
  print("Draw")
elif a>b:
  if a==13 and b==1:
    print("Bob")
  else:
    print("Alice")
else:
  if a<b:
    if a==1 and b==13:
      print("Alice")
    else:
      print("Bob")


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)


const int EK_MAX = 111;
const int EK_EDGE_MAX = 10010;
const LL INF = 1234567890123456;

template <class T> class EK{
	vector<int> V[EK_MAX];
	pair<int , int> edge[EK_EDGE_MAX];
	T f[EK_EDGE_MAX * 2];
	int d[EK_MAX];
	int n;
	
	int rev(int a){
		return a / 2 * 2 + (a + 1) % 2;
	}
	
	void bfs(int s){
		fill(d , d + EK_MAX , -1);
		d[s] = 0;
		queue<int> Q;
		Q.push(s);
		while(!Q.empty()){
			int x = Q.front(); Q.pop();
			for(vector<int>::iterator it = V[x].begin() ; it != V[x].end() ; ++it){
				if(f[*it] == 0) continue;
				int y = (*it) % 2 == 1 ? edge[(*it)/2].first : edge[(*it)/2].second;
				if(d[y] >= 0) continue;
				d[y] = d[x] + 1;
				Q.push(y);
			}
		}
	}
	
public:
	
	EK(){
		n = 0;
		fill(f , f + EK_EDGE_MAX * 2 , 0);
	}
	
	int put(int a , int b , T c){
		edge[n] = make_pair(a , b);
		V[a].push_back(2*n);
		V[b].push_back(2*n+1);
		f[2*n] = c;
		f[2*n+1] = 0;
		return n++;
	}
	
	T ans(int s , int t){
		while(1){
			bfs(s);
			if(d[t] < 0){
				T x = 0;
				for(vector<int>::iterator it = V[s].begin() ; it != V[s].end() ; ++it){
					x += f[(*it)/2*2+1] * ((*it) % 2 == 0 ? 1 : -1);
				}
				return x;
			}
			queue<int> Q;
			T y = INF;
			for(int i = t ; i != s ;){
				for(vector<int>::iterator it = V[i].begin() ; it != V[i].end() ; ++it){
					if(f[rev(*it)] == 0) continue;
					int z = (*it) % 2 == 1 ? edge[(*it)/2].first : edge[(*it)/2].second;
					if(d[z] == d[i] - 1){
						i = z;
						y = min(y , f[rev(*it)]);
						Q.push(*it);
						break;
					}
				}
			}
			while(!Q.empty()){
				int x = Q.front(); Q.pop();
				f[rev(x)] -= y;
				f[x] += y;
			}
		}
	}
};

int N;
LL s;
EK<LL> solve;

int main(){
	cin >> N;
	repp(i,1,N+1){
		int a;
		cin >> a;
		if(a<0){
			solve.put(0,i,-a);
		} else {
			solve.put(i,N+1,a);
			s += a;
		}
		for(int k = i*2 ; k <= N ; k += i) solve.put(i,k,INF);
	}
	cout << s - solve.ans(0,N+1) << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  vector<pair<double, double>> A(1250);    
  vector<pair<double, double>> B(1250);    
  rep(i, 1250){
  A.at(i).first=(i)*0.08;
  A.at(i).second=(i);    
  }
  rep(i, 1250){
  B.at(i).first=(i)*0.1;
  B.at(i).second=(i);    
  }
  
  int a,b;
  cin >> a >> b;
  int i=0,j=0,imax=0,jmax=0;
    rep(k, 1250){
      if(A.at(k).first>=a+1){
        imax=k;
      break;
      }
      else if (A.at(k).first<a)
        i++;
    }
  
        rep(k, 1250){
      if(B.at(k).first>=b+1){
        jmax=k;
      break;
      }
      else if (B.at(k).first<b)
        j++;
    }
  
  
      rep2(k,i,imax){
      rep2(l,j,jmax){
      if(A.at(k).second==B.at(l).second)
      {
      cout << k<< endl;
        return 0;
      }
        
      }
      
      
      }
  cout << -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int h,w,x,y;
    cin>>h>>w;
    string s[h];
    int dx[]={1,1,1,0,0,-1,-1,-1};
    int dy[]={1,0,-1,1,-1,1,-1,0};
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='.'){
                int cnt=0;
                for(int k=0;k<8;k++){
                    x=dx[k]+i,y=dy[k]+j;
                    if(x>=0&&x<h&&y>=0&&y<w&&s[x][y]=='#')cnt++;
                }
                s[i][j]=char('0'+cnt);
            }
        }
    }
    for(int i=0;i<h;i++){
            cout<<s[i]<<endl;;
    }
}


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

int main(){
    string s;
    cin >> s;
    string ans;
    for(int i = 0; i < (int)s.size(); i++)
    {
        if(s[i]=='1' || s[i]=='0'){
            ans.push_back(s[i]);
        }
        else if(ans.size()>0 && s[i]=='B'){
            ans.pop_back();
        }
    }
    cout << ans << endl;
    return 0;
}

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


int main()
{
	int a, b;
	cin >> a >> b;
	if ( a > b)
		cout << "a > b" << endl;
	else if (a < b) 
		cout << "a < b" << endl;
	else
		cout << "a == b" << endl;

	return 0;
}



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

public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      String S = br.readLine();
      System.out.println(S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5) ? "Yes" : "No");
    }catch(Exception e){
    }
  }
}

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

int devide(vector<int> h) {
	int zero_count = 0;
	for (int i = 0; i < h.size(); i++)
		if (h[i] == 0)
			zero_count++;
	int zero_repeat = 0;
	for (int i = 1; i < h.size(); i++)
		if (h[i - 1] == 0 && h[i] == 0)
			zero_repeat++;
	int ans = zero_count - zero_repeat;
	if (h[0] != 0 && h[h.size() - 1] != 0)
		ans++;
	if (h[0] == 0 && h[h.size() - 1] == 0)
		ans--;
	return ans;
}

int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++)
		cin >> h[i];
	int count = 0;
	while (devide(h) != 0) {
		count += devide(h);
		for (int i = 0; i < h.size(); i++)
			if (h[i] != 0)
				h[i]--;
	}
	cout << count << endl;
	return 0;
}

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

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

int main(void) {
    
    int d,g; 
    cin >> d >> g;
    int p[d], c[d];
    rep(i,d){
        cin >> p[i];
        cin >> c[i];
    }

    int ans = 1e9;
     
    rep(i,1<<d){
        int score = 0;
        int tmp = 0;
        int not_kantou = 0;
        rep(j,d){
            if(i>>j&1){
                score += (j+1)*100*p[j]+c[j];
                tmp += p[j];
            }else{
                not_kantou = j;
            }
        }
        if(score >= g){
            ans = min(ans,tmp);
        }else{
            int k = 1;
            while(score < g && k < p[not_kantou]){
                score += 100*(not_kantou+1);
                tmp++;
                k++;
            }
            if(score>=g){
                ans = min(ans,tmp);
                // cout << "ans is " << ans << "i is " << i << endl;
                // cout << score << endl;

            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int wh[100001] = {};

int main(void) {
	int w, h, n;
	cin >> w >> h >> n;
	int at_most_w=0,at_most_h=0;
	for (int i = 0; i<n; i++) {
		int x, y; 
		scanf("%d%d",&x,&y);
		wh[y] = max(wh[y], x);
		at_most_w=max(x,at_most_w);at_most_h=max(y,at_most_h);
	}
	
	int x_position, y_position, MIN;
    MIN = wh[h - 1] + (h - 1);
    x_position = wh[h - 1];
    y_position = h - 1;
	
	for (int i = 0; i<h - 1; i++) {
		y_position--;
		int a = x_position, b = y_position;
		MIN = min(MIN, a+b);
		
		if (a < wh[b]) {
			x_position = wh[y_position];
			int a = x_position, b = y_position;
			
			MIN = min(MIN, a+b);
		}
	}
		
	cout << min(MIN,min(at_most_w,at_most_h)) << endl;

	return 0;
}


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

int dp[2005][2005];
vector<int> G[300005];
int mindist[300005];

void add_edge(int u, int v) {
  G[u].push_back(v);
}

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

  for (int i = 0; i < m; i++) {
    int u, v; cin >> u >> v;
    add_edge(u, v + 100000);
    add_edge(u + 100000, v + 200000);
    add_edge(u + 200000, v);
  }

  int s, t; cin >> s >> t;

  for (int i = 0; i < 300005; i++)
    mindist[i] = 0x3f3f3f3f;
  mindist[s] = 0;

  queue<int> q;
  q.push(s);

  while (!q.empty()) {
    int p = q.front(); q.pop();
    for (int h : G[p]) {
      if (mindist[p] + 1 < mindist[h]) {
        mindist[h] = mindist[p] + 1;
        q.push(h);
      }
    }
  }

  if (mindist[t] < 0x3f3f3f3f) {
    cout << mindist[t]/3 << endl;
  } else {
    cout << -1 << endl;
  }
}

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

int main() {
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;
#define LL long long
#define mp make_pair
#define fr first
#define sc second
#define pb push_back
#define lc (x<<1)
#define rc ((x<<1)|1)
const int N=105;
char s[N];
int cnt[27];
int main(){
     //freopen("in.txt","r",stdin);
     //freopen("out.txt","w",stdout);
    int i,j,n,m,k;
    scanf("%d%d",&n,&m);
    for (i=1;i<=n;i++){
        scanf("%s",s+1);
        for (j=1;j<=m;j++) cnt[s[j]-'a']++;
    }
    k=(n/2)*(m/2);
    for (i=0;k;k--){
        for (;i<26&&cnt[i]<4;i++);
        if (i==26) {puts("No");return 0;}
        cnt[i]-=4;
    }
    k=(n%2)*(m/2)+(m%2)*(n/2);
    for (i=0;k;k--){
        for (;i<26&&cnt[i]<2;i++);
        if (i==26) {puts("No");return 0;}
        cnt[i]-=2;
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 256
let bfs vs n =
  let d = Array.make n (-1) in
  d.(0) <- 0;
  let rec doit = function
    | [] -> ()
    | i :: que ->
      que @ List.fold_right (fun v q ->
        if d.(v-1) <> (-1) then q
        else begin
          d.(v-1) <- d.(i) + 1;
          (v - 1) :: q
        end) vs.(i) []
      |> doit in
  doit [0];
  d

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let n = read_int () in
  let vs = Array.make n [] in
  for _ = 0 to n - 1 do
    match read_line () |> split_on_char ' ' |> List.map int_of_string with
    | u :: _ :: l -> vs.(u-1) <- l
    | _ -> assert false
  done;
  bfs vs n |> Array.iteri (fun i e -> Printf.printf "%d %d\n" (i + 1) e)

Measured memory_bytes: 2428
import sys

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

for i in range(1, n+1):
    if i % 3 == 0:
        print(' ', i, sep='', end='')
    else:
        x = i
        while x > 0:
            if x % 10 == 3:
                print(' ', i, sep='', end='')
                break
            x //= 10
print()


Measured memory_bytes: 6164
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	s = strings.Replace(s, "a", "", -1)
	if len(s) != 2 {
		fmt.Println("No")
		return
	}
	s = strings.Replace(s, "b", "", -1)
	if len(s) != 1 {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
}


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

int main() {
    
    int N;
    cin >> N;
    int t[N + 1] ={0}, x[N + 1] = {0}, y[N + 1] = {0};
    for(int i = 1; i <= N; i++){
        cin >> t[i] >> x[i] >> y[i];
    }


    for(int i = 1; i <= N; i++){
        int dt = t[i] - t[i-1];
        int dist = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
        if(dist > dt){
            cout << "No" << endl;
            return 0;
        }

        if((dt % 2 == 0) && (dist % 2 == 1)){
            cout << "No" << endl;
            return 0;
        }

        if((dt % 2 == 1) && (dist % 2 == 0)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 1408
n = int(input())
a = list(map(int, input().split()))

l = {}
for i in a:
    l.setdefault(i, 0)
    l[i] += 1
l2 = [i for i in l.keys() if l[i] >= 2]
if len(l2) <= 1:
    print(0)
else:
    l2.sort()
    if l[l2[-1]] >= 4:
        print(l2[-1] ** 2)
    else:
        print(l2[-1] * l2[-2])

Measured memory_bytes: 18188
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] points = {sc.nextInt(), sc.nextInt(), sc.nextInt()};
    String forWin = "spr";
    sc.nextLine();
    String t = sc.nextLine();
    int ans = 0;
    
    for(int i = 0; i < k; i++){
      int cnt = 1;
      for(int j = i; j < n; j += k){
        char cur = t.charAt(j);
        
        if(j + k < n && cur == t.charAt(j + k)){
          cnt++;
        }else{
          ans += points[forWin.indexOf(cur)] * (cnt / 2 + cnt % 2);
          cnt = 1;
        }
      }
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 40524