akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <vector>

int main()
{
    int n, k, c;
    std::cin >> n >> k >> c;
    std::string str;
    std::cin >> str;

    std::vector<int> l, r;
    std::map<int, int> map_l, map_r;
    int count_l = 0;
    int count_r = 0;
    int rest_l  = c + 1;
    int rest_r  = c + 1;

    for (int i = 0; i < n; ++i)
    {
        int j = (n - 1) - i;
        if (str[i] == 'o' && rest_l >= c)
        {
            ++count_l;
            map_l.insert(std::make_pair(count_l, i));
            rest_l = 0;
        }
        else
        {
            ++rest_l;
        }
        l.push_back(count_l);

        if (str[j] == 'o' && rest_r >= c)
        {
            ++count_r;
            map_r.insert(std::make_pair(count_r, j));
            rest_r = 0;
        }
        else
        {
            ++rest_r;
        }
        r.push_back(count_r);
    }

    for (int i = 0; i < n; ++i)
    {
        int j = (n - 1) - i;

        if (str[i] == 'o')
        {
            int count = l[i] + r[j] - 1;
            if (count == k)
            {
                if (map_l.at(l[i]) == i && map_r.at(r[j]) == i)
                {
                    std::cout << i + 1 << std::endl;
                }
            }
        }
    }

    return 0;
}


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

int main(){
  long n,m,k;
  double a,nd,md,kd,ld,p;
  cin >> n >> k;
  nd = n;
  kd = k;
  for(double i = 1; i < n+1; i++){
    m = log2(kd/i) +1;
    ld=log2(kd/i) +1;
    md = m;
    if(ld == md)
      md--;
   if(i < k)
     a += pow(0.5,md);
    else
      a += 1;
  }
  p = a / n;
  cout << setprecision(15) << p << endl;

  
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define xfor(i, a, b) for (int i = a; i < b; i++)
#define ifor(i, a, b) for (int i = a; i <= b; i++)
#define rxfor(i, b, a) for (int i = b; i > a; i--)
#define rifor(i, b, a) for (int i = b; i >= a; i--)
#define foreach(v, c)                                                          \
  for (typeof((c).begin()) v = (c).begin(); v != (c).end(); ++v)
#define all(a) a.begin(), a.end()
#define in(a, b) ((b).find(a) != (b).end())
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;

int main() {
  MPII mp;
  int n;
  int x;
  cin >> n;
  xfor(i, 0, n - 1) {
    cin >> x;
    mp[x]++;
  }
  xfor(i, 0, n) { cout << mp[i + 1] << endl; }
}


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

typedef long long ll;

ll K, sv[66], ans[66];

const int N = 50;

int main(){

  cin >> K;

  ll div = K/N, lft = K%N;

  for(int i = 0; i < N; i++)sv[i] = div + (i < lft);

  for(int i = 0; i < N; i++){

    ll sum = 0;

    for(int j = 0; j < N; j++)if(i != j)sum += sv[j];

    ans[i] = N * (sv[i] + 1) - sum - 1;

  }

  cout << N << '\n';

  for(int i = 0; i < N; i++)
    cout << (i ? " " : "") << ans[i];

  puts("");





}


Measured memory_bytes: 256
class _Node {
  constructor(key, parent = null, left = null, right = null) {
    this.key = key;
    this.parent = parent;
    this.left = left;
    this.right = right;
  }

  getChildrenNumber() {return Number(this.left !== null) + Number(this.right !== null);}

  isLeftChild() {
    if (this.parent === null) return null;
    return this.parent.left === this;
  }

  getLeftOrRight() {return this.isLeftChild() ? 'left' : 'right';}

  getSuccessor() {
    let n;
    if (this.right !== null) {
      n = this.right;
      while (n.left !== null) n = n.left;
    } else {
      n = this.parent;
      while (!n.isLeftChild && n.parent != null) n = n.parent;
    }
    return n;
  }
}

class BinaryTree {
  constructor() {
    this.root = null;
  }

  static get Node() { return _Node; }

  insert(key) {
    if (this.root === null) {
      this.root = new BinaryTree.Node(key);
      return;
    }
    let x = this.root, y;
    let newNode = new BinaryTree.Node(key);
    while (x !== null) {
      y = x;
      x = x[key < x.key ? 'left' : 'right'];
    }
    newNode.parent = y;
    y[key < y.key ? 'left' : 'right'] = newNode;
  }

  find(key, n = this.root) {
    if (n === null || n.key === key) return n;
    return this.find(key, n[key < n.key ? 'left' : 'right']);
  }

  delete(key) {
    const n = this.find(key);
    const leftOrRight = n.getLeftOrRight();
    switch (n.getChildrenNumber()) {
    case 0:
      n.parent[leftOrRight] = null;
      break;
    case 1:
      n.parent[leftOrRight] = n.left || n.right;
      n.parent[leftOrRight].parent = n.parent;
      break;
    default:
      const skey = n.getSuccessor().key;
      this.delete(skey);
      n.key = skey;
    }
  }

  printByIneorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      innerFunc(n.left);
      str += ` ${n.key}`;
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  printByPreorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      str += ` ${n.key}`;
      innerFunc(n.left);
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  print() {
    this.printByIneorder();
    this.printByPreorder();
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const tree = new BinaryTree();
  let cmd;
  for (let i = 0; i < n; i++) {
    cmd = lines[i];
    switch (cmd.charAt(0)) {
    case 'i': tree.insert(Number(cmd.split(' ')[1])); break;
    case 'f': console.log(tree.find(Number(cmd.split(' ')[1])) ? 'yes' : 'no'); break;
    case 'd': tree.delete(Number(cmd.split(' ')[1])); break;
    default: tree.print();
    }
  }
})();



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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0, sizeof(a))

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

bool check(string &s){
    int half = s.size()/2;
    REP(i,s.size()/2){
        if(s[i] != s[half+i]){
            return false;
        }
    }
    return true;
}
int main(void){
    string S; cin >> S;

    S = S.substr(0,S.size()-2);
    while(S.size()){
        if(check(S)){
            cout << S.size() << en;
            return 0;
        }
        else{
            S = S.substr(0,S.size()-2);
        }
    }
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
A = list(range(1, n + 1))
B = LI()
ans = 0
D = defaultdict(int)
for i in range(n - 1):
    D[A[i] + B[i]] += 1
    ans += D[A[i + 1] - B[i + 1]]

D2 = defaultdict(int)
for i in range(n - 1, 0, -1):
    D2[A[i] - B[i]] += 1
    ans += D2[A[i - 1] + B[i - 1]]

print(ans // 2)



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

// 0-indexed
template <class T>
struct BIT {
  int treesize;
  vector<T> lst;
  // constructor
  BIT(int newn = 0) : treesize(newn), lst(newn + 1, 0) {}
  // a_place += num
  void add(int place, T num) {
    ++place;
    while (place <= treesize) {
      lst[place] += num;
      place += place & -place;
    }
  }
  // sum between [0,place)
  T sum(int place) {
    T res = 0;
    while (place > 0) {
      res += lst[place];
      place -= place & -place;
    }
    return res;
  }
  // sum [l,r)
  T sum(int left, int right) { return sum(right) - sum(left); }
};

int n;
string s, t;
vector<int> target;
vector<vector<int>> cnt;

long long solve();

int main() {
  cin >> s;
  n = s.size();
  cout << solve() << endl;
  return 0;
}

long long solve() {
  cnt.resize(26);
  for (int i = 0; i < n; ++i) cnt[s[i] - 'a'].push_back(i);
  // cannnot
  {
    for (int i = 0; i < 26; ++i)
      for (int j = i + 1; j < 26; ++j)
        if (cnt[i].size() & cnt[j].size() & 1) return -1;
  }
  {
    vector<int> now(26, 0);
    for (int i = 0; i < n; ++i) {
      int id = s[i] - 'a';
      if (now[id] < cnt[id].size() / 2) t += s[i];
      ++now[id];
    }
    string revt = t;
    reverse(revt.begin(), revt.end());
    for (int i = 0; i < 26; ++i)
      if (cnt[i].size() & 1) t += 'a' + i;
    t += revt;
    now.assign(26, 0);
    for (int i = 0; i < n; ++i)
      target.push_back(cnt[t[i] - 'a'][now[t[i] - 'a']++]);
  }
  long long res = 0;
  // calc inversion num
  {
    BIT<long long> bit(n);
    for (int i = 0; i < n; ++i) {
      res += i - bit.sum(target[i]);
      bit.add(target[i], 1);
    }
  }
  return res;
}


Measured memory_bytes: 8028
#include<bits/stdc++.h>
using namespace std;
vector<bool>seen;
vector<int>cost;
vector<vector<int>>Graph;
void dfs(int nv,int pv){
  seen[nv]=true;
  if(nv!=0)cost[nv]+=cost[pv];
  for(auto next_v:Graph[nv]){
    if(seen[next_v])continue;
    dfs(next_v,nv);
  }
}
int main(){
  int N,Q;
  cin>>N>>Q;
  seen.resize(N);
  cost.resize(N);
  Graph.reserve(N);
  for(int i=0;i<N-1;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    Graph[a].push_back(b);
    Graph[b].push_back(a);
  }
  for(int i=0;i<Q;i++){
    int p,v;
    cin>>p>>v;
    p--;
    cost[p]+=v;
  }
  dfs(0,0);
  for(int i=0;i<N;i++){
    cout<<cost[i]<<" ";
  }
}

Measured memory_bytes: 23552
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stdio.h>
#include <stack>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <assert.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define TR(i,x) for(__typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))

using namespace std;

const double eps = 1e-8;

#define PB push_back
#define MP make_pair

typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int,int> PII;
typedef long long int64;
typedef long long LL;
typedef unsigned int UI;
typedef long double LD;
typedef unsigned long long ULL;

int main() {
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int res = 0;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            if (i * r + j * g > n) continue;
            int cur = n - i * r - j * g;
            if (cur % b == 0) {
                ++res;
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
namespace ABC128.A
{
    using System.Collections.Generic;
    using System.Linq;
    using static System.Console;
    public class Program
    {
        public static void Main(string[] args)
        {
            var l = ReadInputsAsInt().ToList();
            WriteLine(Solve(l[0], l[1]));
        }

        public static int Solve(int a, int p) => (a * 3 + p) / 2;
        static IEnumerable<int> ReadInputsAsInt() => ReadLine().Split(' ').Select(x => int.Parse(x));
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int i,j,n,a[5001],b[5001]={0},sum=0,ma,mi;
int main(void)
{
	cin >> n;
	for(i=1;i<n+1;i++){
		cin >> a[i];
		if(0<a[i] && a[i]<400)a[i]=1;
		else if(a[i]>399 && a[i]<800)a[i]=2;
		else if(a[i]>799 && a[i]<1200)a[i]=3;
		else if(a[i]>1199 && a[i]<1600)a[i]=4;
		else if(a[i]>1599 && a[i]<2000)a[i]=5;
		else if(a[i]>1999 && a[i]<2400)a[i]=6;
		else if(a[i]>2399 && a[i]<2800)a[i]=7;
		else if(a[i]>2799 && a[i]<3200)a[i]=8;
		else if(a[i]>3199)a[i]=9;
	}
	for(i=0;i<9;i++){
		for(j=1;j<n+1;j++){
			if(a[j]==i){
				b[i-1]=1;
			}
		}
	}	
	for(i=1;i<n+1;i++){
		if(a[i]==9){
			b[8]+=1;
		}
	}
	for(i=0;i<8;i++)sum+=b[i];
	if(sum==0)
		mi=1;
		
	else mi=sum;
	ma=b[8]+sum;
	cout << mi << " " << ma << endl;
	return 0;
}

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

int ft_strlen(char *str) {
    int i = 0;
    int len = 0;
    while (*str++)
        len++;
    return len;
}

int main() {
    int K;
    char S[101];
    scanf("%d", &K);
    scanf("%s", S);

    int len = ft_strlen(S);
    char *ans;
    if (len <= K) {
        ans = S;
    } else {
        ans = malloc((K + 4) * sizeof(char));
        int i = 0;
        while (i < K) {
            ans[i] = S[i];
            i++;
        }
        ans[i] = '.';
        ans[i+1] = '.';
        ans[i+2] = '.';
        ans[i+3] = '\0';
    }
    printf("%s\n", ans);
    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int N;
vector<ll> A;


void input() {
  cin >>N;
  A.assign(N, 0);
  rep(i, N) cin >>A[i];
}

void solve1(vector<vector<ll>> &bit) {
  // bit[i][j] := i番目のビットがjであるものの個数、であるように埋めていく
  rep(i, N){
    ll a = A[i];
    for (int j=0; j<100; j++){
      int bi2 = a % 2;
      bit[j][bi2]++;
      a /= 2;
    }
  }
}

int main() {
  input();
  vector<vector<ll>> bit(100, vector<ll>(2, 0));
  // bit[i][j] := i番目のビットがjであるものの個数
  solve1(bit);

  ll co2 = 1;
  ll res = 0;
  rep(i, 100){
    // Xorで関係がある、0の数と1の数を掛け合わせたものにビットが表す値をかけて足す
    ll tmp = bit[i][0] * bit[i][1] % MOD;
    res = (res + tmp * co2 % MOD) % MOD;
    co2 = co2 * 2 % MOD;
  }
  cout <<res <<endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define rep2(i,s,t) for(int i = s; i <= t; ++i)
#define rev(i,n) for(int i = n-1; i >= 0; --i)
#define rev1(i,n) for(int i = n; i > 0; --i)
#define rev2(i,s,t) for(int i = s; i >= t; --i)
#define F first
#define S second
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;
// エラストテネスの篩
const int NMAX = 1e+3+1;
int prime[NMAX];
vector<int> pri;
void Sieve(){
  rep(i,NMAX) prime[i] = true;
  prime[0] = prime[1] = false;
  for(int i=2;i<NMAX;++i){
    if(prime[i]){
      pri.push_back(i);
      int j = i;
      while(j<=NMAX){
	prime[j] = false;
	j += i;
      }
    }
  }
}

// ユークリッドの互除法で最大公約数を求める
int gcd(int a,int b){
  if(b==0) return a;
  return gcd(b,a%b);
}
// 最小公倍数
int lcm(int a,int b){
  return a*b/gcd(a,b);
}

int main()
{
  int n; cin >> n;
  vector<int> b(n);
  rep(i,n) cin >> b[i];

  vector<int> a;
  rep(i,n) {
    if(b[i] != 1) a.push_back(b[i]);
  }
  n = a.size();
  
  Sieve();
  
  vector<bool> f(1e+6+1, false);
  rep(i,n) {
    vector<int> tmp;
    if(f[a[i]]) goto AAA;
    tmp.push_back(a[i]);
    rep(j,pri.size()) {
      if(a[i] % pri[j] == 0) {
	if(f[pri[j]]) goto AAA;
	tmp.push_back(pri[j]);
	if(a[i] / pri[j] == 1) continue;
	if(f[a[i] / pri[j]]) goto AAA;
	tmp.push_back(a[i] / pri[j]);
      }
    }
    for(auto val: tmp) {
      f[val] = true;
    }
  }
  

  cout << "pairwise coprime" << "\n";  
  return 0;
  
 AAA:
  int g = a[0];
  rep(i,b.size()) {
    g = gcd(g, b[i]);
  }
  if(g == 1) cout << "setwise coprime" << "\n";
  else cout << "not coprime" << "\n";
  return 0;
}


Measured memory_bytes: 11288
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <set>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 10000000000
#define MAX 100000
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

ll gcd(ll a, ll b) {
    if(b==0) return a;
    return gcd(b, a%b);
}

int main(void) {
    ll n;
    ll a[MAX], b[MAX], c[MAX];
    ll i;
    cin >> n;
    for(i=0; i<n; i++)
        cin >> a[i];
    sort(a, a+n);
    
    for(i=0; i<n; i++)
        cin >> b[i];
    sort(b, b+n);
    
    for(i=0; i<n; i++)
        cin >> c[i];
    sort(c, c+n);
    
    ll ans=0;
    for(i=0; i<n; i++) {
        ans+=(lower_bound(a, a+n, b[i])-a)*(n-(upper_bound(c, c+n, b[i])-c));
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 2560
#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>;

int cnt = 0;
map<int, int> mp;

void enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            ++mp[i];
            if (N / i != i) {
                ++mp[N / i];
            }
        }
    }
    return;
}

int main() {
    long long N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    rep(i, 2) enum_divisors(A[i]);

    vector<vector<int>> num(mp.size(), vector<int>(2));
    int i = 0;
    for (auto x : mp) {
        num[i][0] = x.first;
        num[i][1] = x.second;
        ++i;
    }
    reverse(num.begin(), num.end());

    if (N > 2) {
        for (int i = 2; i < N; ++i) {
            rep(j, num.size()) {
                if (A[i] % num[j][0] == 0) ++num[j][1];
            }
        }
    }
    rep(i, num.size()) if (num[i][1] == N || num[i][1] == N - 1) {
        cout << num[i][0] << endl;
        break;
    }
}


Measured memory_bytes: 3720
//#include "pch.h"
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>
#include <iomanip>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define double long double
#define int long long
#define mii map<int,int>
#define pii pair<int,int>
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf 10000000000000000 //10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
	int a, b, k;
	cin >> a >> b >> k;
	int cnt = 0;
	for (int i = min(a, b); i >= 1; i--) {
		if (a%i == 0 && b%i == 0) {
			cnt++;
			if (cnt == k) {
				cout << i << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  long long a,b,x;
  cin >> a >> b >> x;
  if(a==0){
    cout << b/x+1 << endl;
    return 0;
  }
  cout << b/x-(a-1)/x << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <tuple>

using namespace std;

int main() {
	int N, P;
	string S;
	vector<tuple<string, int, int>> SPs;
	int num;
	
	cin >> N;

	for (int i = 0; i < N;i++) {
		cin >> S >> P;
		SPs.push_back(make_tuple(S, -P, i+1));
	}
	sort(SPs.begin(), SPs.end());

	for (tuple<string, int, int>SP : SPs) {
		tie(ignore, ignore, num) = SP;
		cout << num << "\n";
	}

	return 0;
}

Measured memory_bytes: 3464
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

void hmax(int a){
  int l=2*a,r=2*a+1,largest, c;
  if(l<=H && A[l]>A[a])largest=l;
  else largest=a;
  if(r<=H && A[r]>A[largest])largest=r;
  if(largest != a){
    c=A[a];
    A[a]=A[largest];
    A[largest]=c;
    hmax(largest);
  }
}

int extract(){
  int maxv;
  if(H<1)return -INFTY;
  maxv=A[1];
  A[1]=A[H--];
  hmax(1);
  return maxv;
}

void iK(int i, int key){
  if(key<A[i])return;
  A[i]=key;
  while(i>1 && A[i/2]<A[i]){
    swap(A[i], A[i/2]);
    i=i/2;
  }
}

void insert(int key){
  H++;
  A[H]=-INFTY;
  iK(H, key);
}

int main(){
  int key;
  char com[10];
  while(1){
    scanf("%s", com);
    if(com[0]=='e' && com[1]=='n')break;
    if(com[0]=='i'){
      scanf("%d", &key);
      insert(key);
    }else{
      printf("%d\n", extract());
    }
  }
  return 0;
}



Measured memory_bytes: 6472
# coding: utf-8
W, a, b = map(int, input().split())
l1 = b - (a + W)
l2 = a - (b + W)

if l1 < 0 and l2 < 0:
    print(0)
elif l1 > l2:
    print(l1)
else:
    print(l2)

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

int main()
{
    int K, S;
    cin >> K >> S;
    int answer = 0;
    for (int x = 0; x < K + 1; ++x)
    {
        for (int y = 0; y < K + 1; ++y)
        {
            if (S - x - y <= K && S - x - y >= 0)
            {
                ++answer;
            }
        }
    }
    cout << answer << endl;
}

Measured memory_bytes: 3572
n = gets.to_i
arr, hsh1, hsh2 = Array.new, Hash.new(0), Hash.new(0)
n.times{
    arr << gets.to_f
    hsh1[arr.last] += 1
}
sum = 0
hsh1.to_a.sort_by{|k, v| k}.each{|k, v|
    hsh2[k] += sum * 3 + v - 1
    sum += v
}
arr.each{|x| puts hsh2[x]}


Measured memory_bytes: 7952
<?php

while ($tmp = rtrim(fgets(STDIN))) {
    $text[] = strtolower($tmp);
    if (preg_match('/END_OF_TEXT/',$tmp)) break;
}

$search = array_shift($text);
$words = array();
foreach ($text as $line) {
    $words = array_merge($words, explode(" ", $line));
}

$words_count = array_count_values($words);
echo $words_count[$search] . PHP_EOL;


Measured memory_bytes: 9404
#include <iostream>

using namespace std;
int a,b,c;
int main(void){
    // Your code here!
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(x<r||W-x<r||y<r||H-y<r){cout<<"No"<<endl;}
    else{cout<<"Yes"<<endl;}
}



Measured memory_bytes: 3100
N,M = map(int,input().split())
stu_loc=[list(map(int,input().split())) for i in range (N)]
ch_loc=[list(map(int,input().split())) for i in range (M)]
for i in range(N):
    dist = 10**9
    num = 100
    for j in range(M):
        #print(abs(stu_loc[i][0]-ch_loc[j][0])+abs(stu_loc[i][1]-ch_loc[j][1]))
        if dist>abs(stu_loc[i][0]-ch_loc[j][0])+abs(stu_loc[i][1]-ch_loc[j][1]):
            dist=abs(stu_loc[i][0]-ch_loc[j][0])+abs(stu_loc[i][1]-ch_loc[j][1])
            num=j
    print(num+1)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    CINS(int, A1, N);
    CINS(int, A2, N);

    int temp = A1[0];
    for (int i = 0; i < N; i++) {
        temp += A2[i];
    }
    int sum = temp;
    for (int i = 1; i < N; i++) {
        temp -= A2[i-1];
        temp += A1[i];
        sum = max(sum,temp);
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
using point = pair<double, double>;

double l2_dist(point p1, point p2){
  double dx = p1.first - p2.first, dy = p1.second - p2.second;
  return sqrt(dx * dx + dy * dy);
}

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

  vector<point> xy(N);
  for(int i = 0; i < N; i++){
    double x, y;
    cin >> x >> y;
    xy[i] = make_pair(x, y);
  }

  auto max_r = [&](double x, double y){
                 point p = make_pair(x, y);
                 double ret = 0;
                 for(int i = 0; i < N; i++){
                   ret = max(ret, l2_dist(p, xy[i]));
                 }
                 return ret;
               };

  auto fx = [&](double x){
              double ly = 0, uy = 1000;
              double fl = max_r(x, ly), fu = max_r(x, uy);
              while(abs(fl - fu) > 1e-12){
                double m1 = (2 * ly + uy) / 3, m2 = (ly + 2 * uy) / 3;
                double f1 = max_r(x, m1), f2 = max_r(x, m2);
                if(f1 < f2){
                  uy = m2;
                  fu = max_r(x, uy);
                }else{
                  ly = m1;
                  fl = max_r(x, ly);
                }
              }
              return fl;
            };

  double lx = 0, ux = 1000;
  double fl = fx(lx), fu = fx(ux);
  while(abs(fl - fu) > 1e-7){
    //cout << lx << ' ' << ux << endl;
    //cout << fl << ' ' << fu << endl;
    double m1 = (2 * lx + ux) / 3, m2 = (lx + 2 * ux) / 3;
    double f1 = fx(m1), f2 = fx(m2);
    if(f1 < f2){
      ux = m2;
      fu = fx(m2);
    }else{
      lx = m1;
      fl = fx(m1);
    }
  }

  cout << setprecision(20) << fl << endl;
}

  
                                        


Measured memory_bytes: 256
#include <cstdio>

int main(void) {
    int x, y, ans=0;
    scanf("%d %d", &x, &y);
    if(x==0) {
        ans=(y>0)?y:-y+1;
        printf("%d", ans);
        return 0;
    }
    if(y==0) {
        ans=(x>0)?x+1:-x;
        printf("%d", ans);
        return 0;
    }
    if((x>0 && y<0) || (x<0 && y>0)) {
        ans=1;
        x=x<0?-x:x;
        y=y<0?-y:y;
        ans+=(x>y)?x-y:y-x;
    }
    else     ans+=(x>y)?x-y+2:y-x;
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

void solve() {
    string s;
    cin >> s;
    set<char> st;
    for(const auto &it:s ) st.insert(it);

    auto ans = (st.count('7') == 1 ) ? "Yes" : "No";
    cout << ans << endl;

}

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


Measured memory_bytes: 3628
s = int(input())
lst = []
lst.append(s)
a = s
i = 2
while True:
  if a % 2 == 0:
    b = int(a / 2)
  else:
    b = 3 * a + 1
  if b in lst:
    print(i)
    break
  lst.append(b)
  a = b
  i += 1

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

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

  char S[110];
  bool flag=false;

  for(int i=0;i<N;i++){
    cin>>S[i];
    if(S[i]=='Y'){
      flag=true;
    }
  }

  if(flag){
    cout<<"Four"<<endl;
  }else{
    cout<<"Three"<<endl;
  }

  return 0;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(int i = a; i < b; i++)
#define endl "\n"
const int mod = 1e9+7;
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int power(int a,int b){ int res=1; a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) { return b?gcd(b,a%b):a;}

int main()
{	
	sync
	int r, c;
	cin >> r >> c;
	string s[r];
	// char arr[r][c];
	ll arr[r][c];
	for(int i = 0; i < r; i++){
		cin >> s[i];
	}
	arr[r-1][c-1] = 1;
	for(int i = r-1; i >= 0; i--)
	{
		for(int j = c-1; j >= 0; j--)
		{
			if(s[i][j] == '#'){
				arr[i][j] = 0;
				continue;
			}
			if(i < r-1 && j < c-1)
				arr[i][j] = (arr[i+1][j]%mod + arr[i][j+1]%mod)%mod;
			else if(i < r-1)
				arr[i][j] = arr[i+1][j]%mod;
			else if(j < c-1)
				arr[i][j] = arr[i][j+1]%mod;
			else
				continue;
		}
	}
	cout << arr[0][0];
	return 0;
}

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

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

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

  string n;
  cin >> n;

  if (n.at(0) == n.at(1) && n.at(1) == n.at(2)) {
    cout << "Yes" << endl;
  } else if (n.at(1) == n.at(2) && n.at(2) == n.at(3)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  string s;
  cin >> s;
  int p = 0, n = 0;
  REP(i, (int)s.size()) {
    if (s[i] == '+') p++;
    else n++;
  }
  dump(p-n);
  return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7

def main():
    H, W, K = map(int, readline().rstrip().split())
    K -= 1
    dp = [[0] * W for _ in range(H+1)]
    dp[0][0] = 1
    for i in range(H):
        for j in range(W):
            for k in range(2**(W-1)):
                b = bin(k)[2:].zfill(W-1)
                # 近接する2つの横線がつながってるか判定
                flg = True
                for l in range(W-2):
                    if b[l] == b[l+1] == '1':
                        flg = False
                        break
                if not flg:
                    continue
                if j >= 1 and b[j-1] == '1':
                    # 左方向に横線を辿るケース
                    dp[i+1][j-1] += dp[i][j]
                    dp[i+1][j-1] %= MOD
                elif j <= W-2 and b[j] == '1':
                    # 右方向に横線を辿るケース
                    dp[i+1][j+1] += dp[i][j]
                    dp[i+1][j+1] %= MOD
                else:
                    # 横線を辿らないケース
                    dp[i+1][j] += dp[i][j]
                    dp[i+1][j] %= MOD

    print(dp[H][K])
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
using namespace std;
char A[1020][1020];
typedef struct
{
  int J;
  int O;
  int I;
}Sum;
Sum B[1020][1020];
int n,m,k;
void SumInput()
{
  for(int i=1;i<=n;i++)
    {
      for(int j=1;j<=m;j++)
	{
	  B[i][j].J=B[i-1][j].J+B[i][j-1].J-B[i-1][j-1].J;
	  B[i][j].O=B[i-1][j].O+B[i][j-1].O-B[i-1][j-1].O;
	  B[i][j].I=B[i-1][j].I+B[i][j-1].I-B[i-1][j-1].I;
	  switch(A[i][j])
	    {
	    case 'J':
	      B[i][j].J+=1;
	      // cout<<"i="<<i<<" "<<"j="<<j<<" "<<A[i][j]<<endl;
	      break;
	    case 'O':
	      B[i][j].O+=1;break;
	    case 'I':
	      B[i][j].I+=1;break;
	    }
	}
    }
}
void Print()
{
 for(int i=0;i<=n;i++)
    {
      for(int j=0;j<=m;j++)
	{
	  cout<<B[i][j].J<<" ";
	}
      cout<<endl;
    }
}
int main()
{
  int a,b,c,d;
  int ju,oc,ic;
  cin>>n>>m>>k;
  //cout <<n<<" "<<m<<" "<<k<<endl;
  for(int i=1;i<=n;i++)
    {
      for(int j=1;j<=m;j++)
	{
	  cin>>A[i][j];
	}
    }
  SumInput();
  // Print();
   for(int i=0;i<k;i++)
    {
      cin>>a>>b>>c>>d;
      ju=B[c][d].J+B[a-1][b-1].J-B[a-1][d].J-B[c][b-1].J;
      oc=B[c][d].O+B[a-1][b-1].O-B[a-1][d].O-B[c][b-1].O;
      ic=B[c][d].I+B[a-1][b-1].I-B[a-1][d].I-B[c][b-1].I;
      cout<<ju<<" "<<oc<<" "<<ic<<endl;
      }
  return 0;
}

Measured memory_bytes: 13000
N, M = list(map(int, input().split()))
result = 0
if N == 1 and M == 1:
    result = 1
elif N == 1:
    result = M - 2
elif M == 1:
    result = N - 2
else:
    result = (N - 2) * (M - 2)
print(result)

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

int main(){
    int x,y;
    cin >> x >> y;
    if(x>=0&&y>=0){
        if(x<y){
            cout << abs(abs(x)-abs(y)) << endl;
        }
        else{
            if(y==0)cout << abs(abs(x)-abs(y))+1 << endl;
            else cout << abs(abs(x)-abs(y))+2 << endl;
        }
    }
    else if(x<0&&y>=0){
        if(y==0)cout << abs(abs(x)-abs(y)) << endl;
        else cout << abs(abs(x)-abs(y))+1 << endl;
    }
    else if(x>=0&&y<0){
        if(x==0)cout << abs(abs(x)-abs(y))+1 << endl;
        else cout << abs(abs(x)-abs(y))+1 << endl;
    }
    else{
        if(x<y){
            cout << abs(abs(x)-abs(y)) << endl;
        }
        else{
            cout << abs(abs(x)-abs(y))+2 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {a} else {gcd(b, a % b)}
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let p: u64 = it.next().unwrap().parse().unwrap();
    let q: u64 = it.next().unwrap().parse().unwrap();
    let mut q = q / gcd(p, q);
    let mut ans = 1;
    for k in 2.. {
        if k * k > q {
            break;
        }
        if q % k == 0 {
            ans *= k;
            while q % k == 0 {
                q /= k;
            }
        }
    }
    if q > 1 {
        ans *= q;
    }
    println!("{}", ans);
}

fn main() {
    run();
}



Measured memory_bytes: 5020
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
 
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
#define setpr(x) cout << setprecision((x))
#define PI atan(1)*4
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mk(a , b) { min((a) , (b)) , max((a) , (b)) }
#define flush cout.flush()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endc "\n"
#define MOD 1000000007
#define mod(x) (x) %= MOD
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
 
ll gcd(ll a, ll b){
    while(true){
        if(a>b)
            swap(a,b);
        if (a == 0) 
            return b; 
        ll p = b % a  , q = a;
        a = p;
        b = q;
    }
}
 
ll powerMod(ll x,ll y){
    ll res = 1;
    x %= MOD;
    while(y > 0){
        if(y & 1)res = (res*x)%MOD;
        y = y >> 1;
        x = (x * x)%MOD;
    }
    return res%MOD;
}


//  ==========     //\\       //||     ||====//||
//      ||        //  \\        ||     ||   // ||
//      ||       //====\\       ||     ||  //  ||
//      ||      //      \\      ||     || //   ||
//  ========== //        \\  ========  ||//====|| 
//  code

vector< vector<ll> > matmul(vector< vector<ll> > a , vector< vector<ll> > b){
    vector< vector<ll> > c;
    c.resize((int)a.size() , vector<ll> ((int)b[0].size()));

    for(int i = 0; i < a.size(); i++){
        for(int j = 0; j < b[0].size(); j++){
            c[i][j] = 0;
            for(int k = 0; k < b.size(); k++){
                c[i][j] += a[i][k] * b[k][j];
                c[i][j] %= MOD;
            }
        }
    }
    return c;
}

vector< vector<ll> > matexp(vector< vector<ll> > basic, vector< vector<ll> > m, ll n){
    while(n){
        if(n % 2){
            basic = matmul(m, basic);
        }
        m = matmul(m, m);
        n /= 2LL;
    }
    return basic;
}


int32_t main(){
    init;
    ll n,i,j,k,l,p;
    cin >> n >> k;

    vector< vector<ll> > a(n, vector<ll>(n)), ans(n, vector<ll>(n, 0));
    for(i = 0; i < n; i++)
        ans[i][i] = 1LL;

    for(auto &i : a){
        for(auto &j : i)
            cin >> j;
    }
    
    a = matexp(ans, a, k);
    ll answer = 0;
    for(auto i : a)for(auto j : i) answer = (answer + j) % MOD;
    cout << answer << endc;
    return 0;
}

Measured memory_bytes: 3812
#include <stdio.h>
#include <vector>
#include <utility>
#include <queue>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, n, a, b, max = 0, cnt = 1;
  scanf("%lld", &n);
  vector< pair<ll, ll> > vec[n];
  pair<ll, ll> now;
  ll ans[n - 1];
  bool flg[n];
  for(i = 0; i < n - 1; ++i) {
    scanf("%lld%lld", &a, &b);
    vec[--a].push_back(make_pair(--b, i));
    vec[b].push_back(make_pair(a, i));
  }
  for(i = 0; i < n; ++i) if(vec[i].size() > max) max = vec[i].size();
  printf("%lld\n", max);
  for(i = 0; i < n; ++i) flg[i] = true;
  queue< pair<ll, ll> > q;
  q.push(make_pair(0, 0));
  while(q.size()) {
    now = q.front(), q.pop();
    flg[now.first] = false;
    cnt = 1;
    for(i = 0; i < vec[now.first].size(); ++i) if(flg[vec[now.first][i].first]) {
      if(cnt == now.second) cnt++;
      ans[vec[now.first][i].second] = cnt, q.push(make_pair(vec[now.first][i].first, cnt));
      cnt++;
    }
  }
  for(i = 0; i < n - 1; ++i) printf("%lld\n", ans[i]);
  return 0;
}


Measured memory_bytes: 8960
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<cmath>
#include<cstring>
#include<climits>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
inline int read() {
	bool f=0;int x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c==EOF)exit(0);if(c=='-')f=1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return !f?x:-x;
}
#define MAXN 200000
#define INF 0x3f3f3f3f
double a[MAXN+5],s[MAXN+5];
int main(){
	int n=read(),k=read();
	for(int i=1;i<=n;i++)
		a[i]=(1.0+read())/2,s[i]=s[i-1]+a[i];
	double Max=0;
	for(int i=k;i<=n;i++)
		Max=max(Max,s[i]-s[i-k]);
	printf("%.8lf\n",Max);
	return 0;
}


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

using ll = long long;
using P = pair<ll, double>;
using PP = pair<P, ll>;

int main() {
  ll v[4];
  for (int i = 0; i < 4; i++) cin >> v[i];
  ll N;
  cin >> N;

  PP p[4];
  double d[4] = {0.25, 0.5, 1, 2};
  int k[4] = {8, 4, 2, 1};
  for (int i = 0; i < 4; i++) {
    p[i] = PP(P(v[i] * k[i], d[i]), k[i]);
  }
  sort(p, p + 4);

  ll ans = 0;
  for (int i = 0; i < 4; i++) {
    if (p[i].first.second <= N) {
      int num = N / p[i].first.second;
      ans += num * (p[i].first.first / p[i].second);
      N -= p[i].first.second * num;
    }
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scanner = new Scanner(System.in);

    char[] array = scanner.next().toCharArray();

    int count = 0;

    for(int i = 0; i < array.length; i++) {
      for(int l = 0; l < array.length; l++) {
        if(i == l) {
          continue;
        }
        count += array[i] == array[l] ? 1 : 0;
      }
    }

    System.out.println(count == 4 ? "Yes" : "No");

    scanner.close();
  }
}

Measured memory_bytes: 21716
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Console.Out.Flush();
    }
    Scanner cin = new Scanner();

    void Solve()
    {
        long a = cin.Nextlong, b = cin.Nextlong, x = cin.Nextlong;

        long low = a / x + ((a % x == 0) ? 0 : 1);
        long high = b / x;
        Console.WriteLine(high - low + 1);

    }
}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return Console.ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 2e5+5;

ll n , m , a[N] , cnt[N] , pre[N];

bool check(ll mid)
{
    ll sum=0 , tmp , idx;
    for(int i=1; i<N; i++)
    {
        idx = max((ll)0 , mid - i - 1);
        tmp = cnt[i] * (pre[N-1]-pre[idx]);
        sum += tmp;
    }
    return sum >= m;
}

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

    cin >> n >> m;
    for(int i=1; i<=n; i++)
        cin >> a[i] , cnt[a[i]]++;

    for(int i=1; i<N; i++)
        pre[i] = pre[i-1]+cnt[i];


    ll l=1 , h=2e5 , mid , idx=-1;
    while(l<=h)
    {
        mid = (l+h)/2;
        if (check(mid))
        {
            idx = max(idx , mid);
            l=mid+1;
        }
        else h=mid-1;
    }

    ll ans = 0;
    for(int i=1; i<N; i++)
    {
        ll ii = max((ll)0 , idx-i); //bigger than idx
        ll tmp = cnt[i] * (pre[N-1]-pre[ii]);
        ans += tmp*2*i;
        m -= tmp;
    }

    ans += idx*m;
    cout << ans << '\n';

    return 0;
}

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;

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

    i32 dp0 = 0, dp1 = 1;
    for (auto& e : n) {
        i32 d = e - '0';
        i32 tmp0 = min(dp0 + d, dp1 + (10 - d));
        i32 tmp1 = min(dp0 + d + 1, dp1 + (10 - (d + 1)));
        dp0 = tmp0, dp1 = tmp1;
    }

    cout << dp0 << endl;
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;

int main(){
  ll N; cin>>N;
  int ans = 100;
  for(int i=1;i<=sqrt(N);i++){
    if(N % i) continue;
    ll a = i;
    ll b = N / i;
    int len_a = to_string(a).size();
    int len_b = to_string(b).size();
    int len = max(len_a,len_b);
    ans = min(ans,len);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Kleene Inversion
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 2000;
const int MOD = 1000000007;

/* typedef */

typedef long long ll;

/* global variables */

int as[MAX_N], bs[MAX_N], cs[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++) scanf("%d", as + i);

  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (as[j] > as[i]) {
	bs[i]++;
	if (j < i) cs[i]++;
      }

  int sum = 0, ck = (ll)k * (k - 1) / 2 % MOD;
  for (int i = 0; i < n; i++)
    sum = (sum + ((ll)k * cs[i] % MOD + (ll)ck * bs[i] % MOD) % MOD) % MOD;
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 256
n = int(input())
ls = []
for i in range(n):
  ls.append(int(input()))

idx = 0
flg = 0
for j in range(n):
  idx = ls[idx]-1
  if idx == 1:
    flg = 1
    break
if flg == 1:
  print(j+1)
else:
  print(-1)

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;

int main() {
  ll n;
  cin >> n;
  st s;
  cin >> s;
  
  ll r = 0, g = 0, b = 0;
  vrep(i, s) {
    if(i == 'R')r = r + 1;
    else if(i == 'G')g = g + 1;
    else b = b + 1;
  }

  ll ans = r * g * b;
  
  rep(i, 0, n){
    rep(j, 1, n){
      if(i - j >= 0 && i + j < n) if(s.at(i) != s.at(i - j) && s.at(i) != s.at(i + j) && s.at(i - j) != s.at(i + j)) ans = ans - 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636