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

using lint = long long;

void solve() {
    int n, k;
    lint m;
    std::cin >> n >> k >> m;

    std::vector<std::pair<int, int>> ps(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> ps[i].first;
        ps[i].second = i;
    }

    std::sort(ps.begin(), ps.end());
    std::vector<int> ord(n);
    for (int j = 0; j < n; ++j) {
        ord[ps[j].second] = j;
    }

    int ok = n, ng = 0;
    // ok以下がk番目になる部分列の個数>=m
    while (ok - ng > 1) {
        int mid = (ok + ng) / 2;

        lint sum = 0;
        int cnt = 0, r = -1;
        for (int l = 0; l < n; ++l) {
            while (r < n && cnt < k) {
                ++r;
                if (r < n && ord[r] <= mid) ++cnt;
            }
            sum += n - r;
            if (ord[l] <= mid) --cnt;
        }

        (sum >= m ? ok : ng) = mid;
    }

    std::cout << ps[ok].first << std::endl;
}

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

    solve();

    return 0;
}



Measured memory_bytes: 5224
N = int(input())
a = {}
for i in range(N):
    a[i + 1] = int(input())

i = 1
cnt = 0
while True:
    next_i = a[i]
    cnt += 1
    if next_i < 1:
        print(-1)
        break
    elif next_i == 2:
        print(cnt)
        break

    a[i] = 0
    i = next_i

Measured memory_bytes: 17892
import math
n = int(input())
s = 0
t = 0
x = []
for I in range(n):
 a,b = map(int,input().split())
 x.append(a+b)
 s += b
x.sort(reverse = True)
for I in range(math.ceil(n/2)):
 t += x[2*I]
print(t-s)
 

Measured memory_bytes: 7516
// ABC160 B

#include <iostream>
#include <string>

using namespace std;

int main(){
    long int sum = 0, anw = 0;
    cin >> sum;
    while(sum >= 500){
        sum -= 500;
        anw += 1000;
    }
    while(sum >= 5){
        sum -= 5;
        anw += 5;
    }
    cout << anw << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,k;
    cin >> a >> b >> k;
    for(int i=a;i<=min(b,a+k-1);i++){
        cout << i << endl;
    }
    for( int i=max(b-k+1,a+k);i<=b;i++){
        cout << i << endl;
    }
}




Measured memory_bytes: 256
// 2020-09-13 21:06:52
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
const int mod = 1000000007;
struct mint {
  ll val;
  constexpr mint(ll v = 0) noexcept : val(v % mod) {
    if (val < 0) val += mod;
  }
  constexpr mint operator + (const mint& rhs) const noexcept {
    return mint(*this) += rhs;
  }
  constexpr mint operator - (const mint& rhs) const noexcept {
    return mint(*this) -= rhs;
  }
  constexpr mint operator * (const mint& rhs) const noexcept {
    return mint(*this) *= rhs;
  }
  constexpr mint operator / (const mint& rhs) const noexcept {
    return mint(*this) /= rhs;
  }
  constexpr mint operator ~ () const noexcept {
    ll a = this->val, b = mod, u = 1, v = 0;
    while (b > 0) {
      ll t = a / b;
      a -= t * b;
      u -= t * v;
      ll c = a; a = b; b = c;
      ll w = u; u = v; v = w;
    }
    if (u < 0) u += mod;
    u %= mod;
    return u;
  }
  constexpr mint& operator += (const mint& rhs) noexcept {
    val += rhs.val;
    if (val >= mod) val -= mod;
    return *this;
  }
  constexpr mint& operator -= (const mint& rhs) noexcept {
    if (val < rhs.val) val += mod;
    val -= rhs.val;
    return *this;
  }
  constexpr mint& operator *= (const mint& rhs) noexcept {
    val = val * rhs.val % mod;
    return *this;
  }
  constexpr mint& operator /= (const mint& rhs) noexcept {
    val = val * (~(mint(rhs))).val % mod;
    return *this;
  }
  friend mint modpow (mint a, ll n) noexcept {
    auto res = mint(1);
    while(n > 0) {
      if(n&1) res *= a;
      a *= a;
      n >>= 1;
    }
    return res;
  }
  friend std::ostream& operator << (std::ostream& os, const mint& a) noexcept {
    return os << a.val;
  }
  friend std::string debug_s (mint a) noexcept {
    return std::to_string(a.val);
  }
};

// clang-format on
mint dp[2020];
bool visited[2020];
mint rec(int n) {
  debug(n);
  if (visited[n]) return dp[n];
  mint cur = 0;
  REPC(i, 3, n) cur += rec(n - i);
  return dp[n] = cur + 1;
}
void answer() {
  int s;
  cin >> s;
  dp[0] = dp[1] = dp[2] = 0;
  dp[3] = dp[4] = dp[5] = 1;
  REPC(i, 6, s) {
    rep(j, i - 2) dp[i] += dp[j];
    dp[i] += 1;
  }
  cout << dp[s] << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>

using namespace std;

int n,ba=0;
bool r=true;
string st;

int main(){
    //scanf("%d",&n);
    //printf("%d\n",q);
    cin>>st;
    n=st.length();
    
    if(st[0]=='A'){
        for(int i=1;i<n;i++){
            if(st[i]<='Z'){
                if(st[i]=='C'){
                    if(ba)r=false;
                    else ba=i;
                }
                else r=false;
            }
            //printf("%d\n",r);
        }
    }
    r= r and 2<=ba and ba!=n-1;
    
    cout<<(r ? "AC":"WA")<<endl;
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())
turn = 0
while a > 0 and c > 0:
  if turn == 0:
    c -= b
    turn = 1
  elif turn == 1:
    a -= d
    turn = 0
if turn == 0:
  print('No')
elif turn == 1:
  print('Yes')

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)

#define debug(x) cerr << #x << " " << x << endl
#define print(x) cout << x;
#define println(x) cout << x << endl;
#define spc << " " <<

#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define eb emplace_back
#define np next_permutation

using ll = long long;
using Pii = pair<int, int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;
template<class T>using VV = vector<vector<T>>;
using Vi = vector<int>;
using VVi = vector<vector<int>>;

int main() {
   int N; cin >> N;
   Vi A = Vi(N); rep(i, N) cin >> A[i];

   int ans = 0;
   rep(i, N-1) {
      int min_i = i;
      REP(j, i, N) {
         if (A[min_i] > A[j]) min_i = j;
      }
      swap(A[min_i], A[i]);
      if (min_i != i) ans++;
   }
   cout << A[0]; REP(i, 1, N) cout << " " << A[i]; cout << endl;
   cout << ans << endl;
   return 0;
}



Measured memory_bytes: 3104
ans_list = []
def make_pieces(w, d, s):
    if w == 0 and d == 0:
        print(w, d, s)
    s %= (2 * w + 2 * d)
    while True:
        if w > s:
            return [s, d], [w - s, d]
        s -= w
        if d > s:
            return [w, s], [w, d - s]
        s -= d
        if w > s:
            return [w - s, d], [s, d]
        s -= w
        if d > s:
            return [w, s], [w, d - s]
        s -= d


while True:
    n, w, d = map(int, input().split())
    P = [[w, d]]
    if n == 0 and w == 0 and d == 0:
        break
    for i in range(n):
        p, s = map(int, input().split())
        new_pieces = make_pieces(P[p - 1][0], P[p - 1][1], s)
        #print(new_pieces)
        if new_pieces[0][0] * new_pieces[0][1] < new_pieces[1][0] * new_pieces[1][1]:
            P = P[:p - 1] + P[p:] + [new_pieces[0]] + [new_pieces[1]]
        else:
            P = P[:p - 1] + P[p:] + [new_pieces[1]] + [new_pieces[0]]
        #print(P)

    S_list = []
    for i in P:
        S_list.append(i[0] * i[1])

    S_list.sort()
    ans_list.append(S_list)

for i in range(len(ans_list)):
    I = ans_list[i]
    for j in range(len(I)):
        J = I[j]
        if j == len(I) - 1:
            print(J, end = "")
        else:
            print(J, end=" ")
    print()


Measured memory_bytes: 6272
def main():
  n,k=map(int,input().split())
  num=[int(i) for i in input().split()]
  
  dp=[0]*(k+1)
  for i in range(k):
    flag=False
    for j in range(n):
      if i+1-num[j]>=0:
        if  dp[i+1-num[j]]==0:
          flag=True
          break
    if flag:
      dp[i+1]=1
    else:
      continue
  if dp[k]:
    print('First')
  else:
    print('Second')          
if __name__=='__main__':
  main()

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

int main(){

  int N; cin >> N;
  vector<int> L(N);
  for(int i = 0; i < N; i++){
    cin >> L[i];}
  
  sort(L.begin(),L.end());
  int cnt = 0;
  for(int i = 0; i < N-2; i++){
    for(int j = i+1; j < N-1; j++){
      //最長辺について求める これはL[i]+L[j]未満でなければいけない
      
      int c = lower_bound(L.begin(),L.end(),L[i]+L[j])-L.begin();
      c--;
      cnt += max(0, c-j);
    }
  }
  
  cout << cnt << endl; return 0;}
      

Measured memory_bytes: 256
import fractions

A, B, C, D=map(int, input().split())
x=C*D//fractions.gcd(C, D)
p=B//C-(A-1)//C
q=B//D-(A-1)//D
r=B//x-(A-1)//x
print(int(B-(A-1)-(p+q-r)))

Measured memory_bytes: 5048
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


struct Node{
  int key;
  struct Node *l,*r,*p;
};

void insert(int );
void inorder(struct Node *);
void preorder(struct Node *);
struct Node *find(struct Node *,int);
struct Node *treeMinimum(struct Node *);
struct Node *treeSuccessor(struct Node *);
void treeDelete(struct Node *);

struct Node *root,*NIL;

int main(){
  int n,i,h;
  struct Node *a;
  char x[10];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    strcpy(x,"");
    scanf("%s",x);
    if(0==(strcmp(x,"print"))){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if(0==(strcmp(x,"insert"))){
      scanf("%d",&h);
      insert(h);
    }else if(0==(strcmp(x,"find"))){
      scanf("%d",&h);
      a=find(root,h);
     if(a==NIL) printf("no\n");
      else       printf("yes\n");
    }else if(0==(strcmp(x,"delete"))){
      scanf("%d",&h);
      treeDelete(find(root,h));
    }
     }
    return 0;
  }


void insert(int k){
  struct Node *x=root,*y=NIL,*z;

  z=(struct Node *)malloc(sizeof(struct Node));

  z->key=k;
  z->l=NIL;
  z->r=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->l;
    else    x=x->r;
  }
  z->p=y;
  if(y==NIL) root=z;
  else{
    if(z->key < y->key) y->l=z;
    else  y->r=z;
  }
}

void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(struct Node *u){
  if(u==NIL) return ;
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}

struct Node *find(struct Node *a,int k){
  while(1){
    if(a->key==k) break;
    if(k < a->key && a->l !=NIL) a=a->l;
    else if(k > a->key && a->r!=NIL)   a=a->r;
    else return NIL;
   }
  return a;
    }

struct Node *treeMinimum(struct Node *x){
  while(x->l !=NIL) x=x->l;
  return x;
}    
struct Node *treeSuccessor(struct Node *x){
  if(x->r !=NIL) return treeMinimum(x->r);
  struct Node *y=x->p;
  while(y !=NIL && x == y->r){
    x=y;
    y=y->p;
  }
  return y;
}

void treeDelete(struct Node *z){
  struct Node *y,*x;
  if(z->l == NIL || z->r == NIL) y=z;
  else y=treeSuccessor(z);
  if(y->l !=NIL){
    x=y->l;
  }else{
    x=y->r;
  }
  if(x!=NIL) x->p=y->p;

  if(y->p ==NIL){
    root=x;
  }else{
    if(y==y->p->l){
      y->p->l=x;
    }else{
      y->p->r=x;
    }
  }

  if(y!=z) z->key =y->key;

  free(y);
}


Measured memory_bytes: 20460
using System;
class Test
{
    static void Main()
    {
        while (true)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[2]);
            if (str[1] == "?") break;
 
            switch (str[1])
            {
                case "+":
                    Console.WriteLine(a + b);
                    break;
                case "-":
                    Console.WriteLine(a - b);
                    break;
                case "*":
                    Console.WriteLine(a * b);
                    break;
                case "/":
                    Console.WriteLine(a / b);
                    break;
            }
        }
    }
}

Measured memory_bytes: 20020
class UnionFind:
    def __init__(self, max_size):
        self.parent = [i for i in range(max_size+1)]
        self.depth = [0 for _ in range(max_size+1)]
        self.cnt = [1 for i in range(max_size+1)]
    def find(self, x):
        if self.parent[x]==x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x]) 
            return self.parent[x]
    
    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return
        elif self.depth[x]<self.depth[y]:
            self.parent[x] = y
            self.cnt[y] += self.cnt[x]
        else:
            self.parent[y] = x
            self.cnt[x]+=self.cnt[y]
            if self.depth[x]==self.depth[y]:
                self.depth[x]+=1
    def same(self, x, y):
        return self.find(x)==self.find(y)
    def size(self,x):
        return self.cnt[self.find(x)]

n,m = map(int,input().split())
utree = UnionFind(n+10)
for _ in range(m):
    x,y,z = map(int,input().split())
    utree.unite(x,y)
s = {utree.find(i) for i in range(1,n+1)}
print(len(s))

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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

#include <complex>
typedef complex<double> Point;
typedef vector<Point> Polygon;


double dot(Point a, Point b){
  return real(conj(a) * b);
}
double cross(Point a, Point b){
  return imag(conj(a) * b);
}

Point curr(const Polygon& a, int x){ return a[x]; }
Point next(const Polygon& a, int x){ return a[(x + 1) % a.size()]; }

int sign(double x){
  if(x > EPS) return 1;
  if(x < -EPS) return -1;
  return 0;
}

enum{OUT, ON, IN};
int contains(const Polygon& P, const Point& p){
  bool in = false;
  REP(i, P.size()){
    Point a = curr(P, i) - p;
    Point b = next(P, i) - p;
    if(a.imag() > b.imag()) swap(a, b);
    if(a.imag() <= 0 && 0 < b.imag() && sign(cross(a, b)) < 0){
      in = !in;
    }
    if(cross(a, b) == 0 && dot(a, b) <= 0) return ON;
  }
  return in ? IN : OUT;
}

int main(){
  while(true){
    Polygon P(3);
    REP(i, 3) cin >> P[i].real() >> P[i].imag();
    Point p;
    cin >> p.real() >> p.imag();
    p.imag() -= EPS / 2;
    if(cin.eof()) break;
    if(contains(P, p) == IN) cout << "YES" << endl;
    else if(contains(P, p) == OUT) cout << "NO" << endl;
    else if(contains(P, p) == ON) assert(false);
  }
  return 0;
}

Measured memory_bytes: 1224
//----------------------------------------------------------------------
#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 main(void) {
    int n; cin >> n;
    string tmp; cin >> tmp;
    vector<int> num;
    for(int i = 0; i < n; ++i) {
        string s;
        s = tmp[i];
        num.push_back(stoi(s));
    }
    bool check1[10], check2[10][10], check3[10][10][10];
    rep(i,10) {
        check1[i] = false;
        rep(j,10){
            check2[i][j] = false;
            rep(k,10) check3[i][j][k] = false;
        }
    }

    int ans = 0;
    for(int i = 0; i < n; ++i) {
        int num1 = num[i];
        if(!check1[num1]) {
            check1[num1] = true;
            for(int j = i + 1; j < n; ++j) {
                int num2 = num[j];
                if(!check2[num1][num2]) {
                    check2[num1][num2] = true;
                    for(int k = j + 1; k < n; ++k) {
                        int num3 = num[k];
                        if(!check3[num1][num2][num3]) {
                            check3[num1][num2][num3] = true;
                            ans++;
                        }
                    }
                }
            }
        }
    }
   cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
using namespace std;
typedef long long ll;

ll A[100010], sum[100010];
bool jud[100010];

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

	for (int i = 0; i < N; i++) 
		cin >> A[i];
	
	sort(A, A + N);

	sum[0] = A[0];
	for (int i = 1; i < N; i++)
		sum[i] = sum[i - 1]+A[i];

	jud[N - 1] = true;
	int ans = 1;
	for (int i = N - 2; i >= 0; i--) {
		if (jud[i + 1] && sum[i] * 2 >= A[i + 1]) {
			jud[i] = true;
			ans++;
		}
		else
			break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2048
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    L, R, d = map(int, input().split())
    ans = 0
    for i in range(L, R+1):
        if i%d == 0:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62076
n = gets.chomp.to_i
Node = Struct.new(:num, :parent, :left, :right)

class BinSearchTree
  attr_accessor :root
  def initialize
    @root = nil
  end

  def inorder(r, order)
    if r.nil?.!
      inorder(r.left, order)
      order << r.num
      inorder(r.right, order)
    end
  end
  
  def preorder(r, order)
    if r.nil?.!
      order << r.num
      preorder(r.left, order)
      preorder(r.right, order)
    end
  end
  
  def find(k)
    x = @root
    flag = false
    until x.nil?
      if k == x.num
        flag = true
        break
      elsif k < x.num
        x = x.left
      elsif x.num < k
        x = x.right      
      end
    end
    flag
  end

  def insert(k)
    x = @root
    y = nil
    z = Node.new
    z.num = k
    until x.nil?
      y = x
      if z.num < x.num
        x = x.left
      else
        x = x.right
      end
    end
    z.parent = y
    if y.nil?
      @root = z
    else
      if z.num < y.num
        y.left = z
      else
        y.right = z
      end
    end
  end
end

bst = BinSearchTree.new

n.times do
  cmd, i = gets.chomp.split.map{|t| t.match?(/\d/) ? t.to_i : t}
  case cmd
  when "insert"
    bst.insert(i)
  when "print"
    root = bst.root
    in_res, pre_res = [], []
    bst.inorder(root, in_res)
    puts " " + in_res.map(&:to_s).join(' ')
    bst.preorder(root, pre_res)
    puts " " + pre_res.map(&:to_s).join(' ')
  when "find"
    puts bst.find(i) ? "yes" : "no"
  end
end


Measured memory_bytes: 86000
#include <iostream>
using namespace std;
int card[255][14]={{0}};
int main(void){
  int n;
  cin>>n;
  for(int i=0; i<n; i++){
      char c;
      int num;
      cin>>c>>num;
      card[(int)c][num]=1;
  }
  for(int i=1; i<=13; i++){
      if(card[(int)'S'][i]==0){
          cout<<"S "<<i<<endl;
      }
  }
  for(int i=1; i<=13; i++){
      if(card[(int)'H'][i]==0){
          cout<<"H "<<i<<endl;
      }
  }
  for(int i=1; i<=13; i++){
      if(card[(int)'C'][i]==0){
          cout<<"C "<<i<<endl;
      }
  }
  for(int i=1; i<=13; i++){
      if(card[(int)'D'][i]==0){
          cout<<"D "<<i<<endl;
      }
  }

}



Measured memory_bytes: 3108
a, b, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans_1 = min(a) + min(b)
ans_2 = 10 ** 9
for i in range(m):
    x, y, c = map(int, input().split())
    res = a[x - 1] + b[y - 1] - c
    ans_2 = min(ans_2, res)

print(min(ans_1, ans_2))

Measured memory_bytes: 18612
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> S;
  if(S[2]==S[3]&&S[4]==S[5])Out("Yes");
  else Out("No");
}

Measured memory_bytes: 256
function rl()
   local r = {}
   for word in io.read():gmatch("%S+") do
      table.insert(r, tonumber(word))
   end
   return r
end

function ru()
   return unpack(rl())
end

function pu(x, ...)
   if x then
      io.write(x, ' ')
      return pu(...)
   else
      io.write('\n')
   end
end

N = ru()
counts = {AC = 0, WA = 0, TLE = 0, RE = 0}
for i = 1, N do
   Si = io.read()
   counts[Si] = counts[Si] + 1
end
for _, verdict in ipairs({'AC', 'WA', 'TLE', 'RE'}) do
   print(string.format("%s x %d", verdict, counts[verdict]))
end


Measured memory_bytes: 2572
/* C++ */
// ?????¢????´¢???P121

#include <stdio.h>


int main(void)
{
	int n = 0; int S[10001];		// ????´¢????±?
	int q = 0; int T;			// ????´¢??????
	int C = 0;						// ?????´??°

	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		scanf("%d", &S[i]);
//		printf("%d\n", S[i] );
	}

	scanf("%d", &q);

//	printf("q=%d\n", q);

	for (int i = 0; i < q; i++)
	{
//		printf("----\n");
		scanf("%d", &T);
//		printf("T=%d\n", T);

// 		//1. ??????????????¢????´¢
// 		for(int j = 0; j < n; j++){
// //			printf("%d", j);
// 			if(S[j] == T){
// 				C++;
// 				break;
// 			}
// 		}
		//2. ??????????????£????????¢????´¢
		int j = 0;
		S[n] = T;
		while(S[j] != T) j++;
		if(j != n) C++;
	}

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

	return 0;
}

Measured memory_bytes: 1064
from collections import defaultdict
H, W, N = map( int, input().split())
D = defaultdict( int)
def check(t):
    a, b = t
    if a == 0 or a == H-1:
        return False
    if b == 0 or b == W-1:
        return False
    return True
for _ in range(N):
    a, b = map( int, input().split())
    a, b = a-1, b-1
    if a >= 1:
        if b >= 1:
            D[(a-1,b-1)] += 1
        if b < W-1:
            D[(a-1,b+1)] += 1
        D[(a-1,b)] += 1
    if a < H-1:
        if b >= 1:
            D[(a+1,b-1)] += 1
        if b < W-1:
            D[(a+1,b+1)] += 1
        D[(a+1,b)] += 1
    if b >= 1:
        D[(a,b-1)] += 1
    if b < W-1:
        D[(a,b+1)] += 1
    D[(a,b)] += 1
ANS = [0]*10
for c in D:
    if check(c):
        ANS[D[c]] += 1
ANS[0] = (H-2)*(W-2)- sum(ANS)
for ans in ANS:
    print(ans)

Measured memory_bytes: 182360
import java.io.*;
import java.util.Arrays;

class Main{
    public static void main (String[ ] args) throws Exception{
        BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
        String str = br.readLine();

        String[] strarr = str.split(" ");
        int w = Integer.parseInt(strarr[0]);
        int h = Integer.parseInt(strarr[1]);
        int x = Integer.parseInt(strarr[2]);
        int y = Integer.parseInt(strarr[3]);
        int r = Integer.parseInt(strarr[4]);
        
        if(((0 <= (x - r)) && ((x + r) <= w)) && ((0 <= (y - r)) && ((y + r) <= h)))
        {
            System.out.println("Yes");
        }
        else
        {
            System.out.println("No");
        }
    }
}

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



int if_prime_number( int number );



int main(int argc, char **argv)
{
	int i;
	int number;
	int Ans = 0;
	char inputline[12];
	
	
	fgets( inputline, sizeof( inputline ), stdin );
	sscanf( inputline, "%d",  &number);
	printf("%d:", number );
	
	
	
	for(i = 2; i <= sqrt((double)number); i++){
		if(if_prime_number(i) != 0){
			continue;
		}
		while(number % i == 0){
			number /= i;
			printf(" %d", i);
		}
	}
	if( number != 1 ){
		printf(" %d", number);
	}
	printf("\n");
		
	
	return 0;
}



int if_prime_number( int number )
{
	int i;
	
	
	if(number == 2)
		return 0;
	if(number < 2 || number % 2 == 0){
		return 1;
	for(i = 3; i <= sqrt((double)number); i += 2){
		if(number % i == 0)
			return 1;
		}
	}
	
	
	return 0;	
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int h,w;
    cin >> h >> w;
    if(h==0) return 0;
    int ah=1,aw=10000;
    for(int i=1;i<=150;i++){
      for(int j=i+1;j<=150;j++){
        if(h*h+w*w<i*i+j*j||(h*h+w*w==i*i+j*j&&h<i)){
          if(ah*ah+aw*aw>i*i+j*j||(ah*ah+aw*aw==i*i+j*j&&ah>i)){
            ah=i,aw=j;
          }
        }
      }
    }
    cout << ah SP aw << endl;
  }
  return 0;
}



Measured memory_bytes: 3008
from sys import exit

x, n = map(int, input().split())
p = list(map(int, input().split()))
for d in range(x+1): #0に達した時点で0を出力して終了するので、大きい側は気にしなくてよい
    for s in [-1, 1]:
        a = x + d*s
        if p.count(a) == 0:
            print(a)
            exit()

Measured memory_bytes: 9044
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
using namespace std;
//
int main(){
  int N;
  int cnt=0;
  set<int> S;
  cin>>N;
  FOR(i,0,N){
    int A;
    cin>>A;
    if(A>=3200){
      cnt++;
      continue;
    }
    int B=A/400;
    S.insert(B);
  }
  cout<<max((int)S.size(),1)<<" "<<S.size()+cnt<<endl;
  return 0;
}


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

#define INF 1000000007
#define mem(dp,a) memset(dp,a,sizeof dp)
#define flash ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define f(i,n) for (ll i=0;i<n;i++)
#define sieve(j,mp) for(ll j=2*i ; j<=mp ; j+=i)
#define pb(x) push_back(x)
#define mp(x,y) push_back(make_pair(x,y))
#define tr(c,it) for(((c).begin())it=(c).begin();it!=(c).end();it++)
#define test ll t=1; while(t--)
#define F first
#define S second
ll dfs(ll x, vector<ll> g[], ll dp[])
{
    if(dp[x]!=-1) return dp[x]+1;
    ll val=0;
    f(i,g[x].size())
    val=max(val,dfs(g[x][i],g,dp));
    dp[x]=val;
    return val+1;
}
main()
{
    flash
    clock_t launch=clock();
    test
    {
        ll n,m,x,y,ans=0; cin>>n>>m;
        vector<ll> g[n+1];
        ll dp[n+1]; mem(dp,-1);
        f(i,m)
        {
            cin>>x>>y;
            g[x].pb(y);
        }
        rep(i,1,n+1)
        if(dp[i]==-1) dfs(i,g,dp);
        rep(i,1,n+1)
        ans=max(ans,dp[i]);
        cout<<ans<<endl;
    }
    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
    return 0;
}


Measured memory_bytes: 9216
while True:
    m, nMin, nMax = map(int, input().split())
    if m == 0 and nMax == 0 and nMin == 0:
        break
    P = []
    Max = 0
    ans = 0
    for i in range(m):
        P.append(int(input()))
    else:
        for i in range(nMax-nMin+1):
            if i == 0 or Max <= P[nMin+i-1] - P[nMin+i]:
                Max = P[nMin+i-1] - P[nMin+i]
                ans = nMin + i
        else:
            print(ans)


Measured memory_bytes: 5616
def select_type(n, satis_day):
    type = satis_day[n].index(max(satis_day[n]))
    return type

total_days = int(input())
c = list(map(int, input().split()))
satis_day = [[0] * 26 for i in range(total_days)]
for i in range(total_days):
    satis_day[i] = list(map(int, input().split()))

total_satis = 0
not_held_count = [0] * 26

for i in range(total_days):
    # type = int(input())
    # type -= 1
    type = select_type(i, satis_day)
    
    not_held_count = list(map(lambda x: x+1, not_held_count))
    not_held_count[type] = 0
    
    today_decrease = 0
    for j in range(26):
        today_decrease += c[j] * not_held_count[j]
    
    total_satis += (satis_day[i][type] - today_decrease)
    # print(total_satis)
    print(type+1)
    

Measured memory_bytes: 9524
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;
int main(){
  ll n;
  cin >>n;
  ll x[n],a[n];
  for(ll i=0;i<n;i++) cin >>x[i],a[i]=x[i];
  sort(a,a+n);
  ll k=(n/2)-1,l=n/2;
  for(ll i=0;i<n;i++){
     if(x[i]<=a[k])cout <<a[l]<<endl;
     else cout <<a[k]<<endl;
  }
}


Measured memory_bytes: 5376
A,B,M = map(int,input().split())

a = list(map(int,input().split()))
b = list(map(int,input().split()))
data = [0] * M
for i in range(M):
    x,y,c = map(int,input().split())
    x-=1
    y-=1
    data[i] = [x,y,c]

can = []

can.append(min(a)+min(b))

for i in range(M):
    can.append(a[data[i][0]]+b[data[i][1]]-data[i][2])

print(min(can))

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

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

  int sum=0;
  if(a>b){
    sum+=a;
    a-=1;
  }else{
    sum+=b;
    b-=1;
  }
  if(a>b){
    sum+=a;
    a-=1;
  }else{
    sum+=b;
    b-=1;
  }
  
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7

h, w, k = map(int, input().split())

dp = [[0 for _ in range(h + 1)] for _ in range(w + 1)]
dp[1][0] = 1

cnts = []
for i in range(w + 1):
    cnt = 0
    for j in range(1 << i):
        if not '11' in bin(j)[2:]: cnt += 1
    cnts.append(cnt)

for i in range(1, h + 1):
    for j in range(1, w + 1):
        dp[j][i] += dp[j][i - 1] * cnts[max(0, w - (j + 1))] * cnts[max(0, (j - 1) - 1)]
        if 1 <= j - 1 <= w:
            dp[j][i] += dp[j - 1][i - 1] * cnts[max(0, w - (j + 1))] * cnts[max(0, (j - 2) - 1)]
        if 1 <= j + 1 <= w:
            dp[j][i] += dp[j + 1][i - 1] * cnts[max(0, w - (j + 2))] * cnts[max(0, (j - 1) - 1)]
        dp[j][i] %= MOD

print(dp[k][h])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    bool reversed = false;
    for (int i = 0; i < Q; i++) {
        int T;
        scanf("%d", &T);
        switch (T) {
        case 1:
          if (reversed) reversed = false; else reversed = true;
          break;
        case 2:
          int F;
          char C;
          scanf("%d %c", &F, &C);
          if (reversed) {
              if (F == 1) F = 2; else F = 1;
          }
          switch (F) {
          case 1:
            S.insert(S.begin(), C);
            break;
          case 2:
            S.push_back(C);
            break;
          }
        }
  }
  if (reversed) {
      for_each(S.rbegin(), S.rend(), [](char c){printf("%c", c);});
      cout << endl;
      return 0;
  }
  cout << S << endl;
}

Measured memory_bytes: 900
#include <iostream>
#include <vector>
#include <bitset>

using namespace std;
struct SegTree {
    int size;
    vector<bitset<26> > node;
    SegTree(string S) {
        int len = S.size();
        size = 1;
        while(size < len) size *= 2;
        node.resize(size * 2 - 1, 0UL);
        for(int i = 0; i < len; i++) {
            node[size - 1 + i][S[i] - 'a'] = true;
        }
        for(int i = size - 2; i >= 0; i--) {
            node[i] = node[2 * i + 1] | node[2 * i + 2];
        }
    }

    void update(int pos, char c) {
        pos += size - 1;
        node[pos].reset();
        node[pos][c - 'a'] = true;
        while(pos > 0) {
            pos = (pos - 1) / 2;
            node[pos] = node[2 * pos + 1] | node[2 * pos + 2];
        }
    }

    bitset<26> _get(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = size;
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return node[k];
        auto vl = _get(a, b, 2 * k + 1, l, (l + r) / 2);
        auto vr = _get(a, b, 2 * k + 2, (l + r) / 2, r);
        return vl | vr;
    }

    int get(int a, int b) {
        auto res = _get(a, b);
        return res.count();
    }
};

int main() {
    int N, Q;
    string S;
    cin >> N >> S >> Q;
    SegTree sg(S);

    for(int i = 0; i < Q; i++) {
        int q;
        cin >> q;
        if(q == 1) {
            // update
            int pos;
            char c;
            cin >> pos >> c;
            sg.update(pos - 1, c);
        } else {
            int l, r;
            cin >> l >> r;
            cout << sg.get(l - 1, r) << endl;
        }
    }

}

Measured memory_bytes: 9592
void mD(char C, int *D) {
  switch (C) {
    int t;
  case 'N':
    t = D[0]; D[0] = D[1]; D[1] = D[5]; D[5] = D[4]; D[4] = t;
    break;
  case 'S':
    t = D[0]; D[0] = D[4]; D[4] = D[5]; D[5] = D[1]; D[1] = t;
    break;
  case 'E':
    t = D[0]; D[0] = D[3]; D[3] = D[5]; D[5] = D[2]; D[2] = t;
    break;
  case 'W':
    t = D[0]; D[0] = D[2]; D[2] = D[5]; D[5] = D[3]; D[3] = t;
    break;
  }
  return;
}

int main(void) {
  int D[6], d, Q, q;
  char C[]={'N','N','N','E','E','E'}; int c;
  for(d=0;d<6;d++)
    scanf("%d",&D[d]);
  scanf("%d",&Q);
  for (q=0;q<Q;q++) {
    int t,f;
    scanf("%d %d\n",&t,&f);
    for (c=0;D[0]!=t;c++)
      mD(C[c], D);
    while(D[1] != f) {
      int t;
      t = D[1]; D[1] = D[2]; D[2] = D[4]; D[4] = D[3]; D[3] = t;
    }
    printf("%d\n", D[2]);
  }
  return 0;
}

Measured memory_bytes: 600
S = input()
ans = 0

# 旧: 非効率コード
# center = int(len_S / 2)
#
# former = S[:center]
# if len_S % 2 != 0:
#     center += 1
# latter = S[center:][::-1]
#
# for f, l in zip(former, latter):
#     if f != l:
#         ans += 1

for i in range(len(S) // 2):
    if S[i] != S[-(i+1)]:
        ans += 1
print(ans)


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int h,w,c[200];
char s[200][200];
int main()
{
	cin>>h>>w;
	for(int i=0;i<h;i++)cin>>s[i];
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)c[s[i][j]]++;
	for(int i=0;i<(h-(h&1))*(w-(w&1))/4;i++)
	{
		bool g=false;
		for(int j='a';j<='z';j++)
			if(c[j]>3){c[j]-=4;g=true;break;}
		if(!g){puts("No");return 0;}
	}
	int f=0;
	switch((h&1)+(w&1))
	{
		case 0:
			puts("Yes");
			return 0;
		case 2:
			for(int j='a';j<='z';j++)
				if(c[j]&1)f++;
			puts(f==1?"Yes":"No");
			return 0;
		default:
			for(int j='a';j<='z';j++)
				if(c[j]&1)f++;
			puts(f?"No":"Yes");
			return 0;
	}
}


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

int main() {
 int N;
 cin >> N;
 
 vector<double> v(N);
 for(int i = 0; i < N; i++){
   cin >> v.at(i);
 }
 
 sort(v.begin(), v.end());
 reverse(v.begin(), v.end());
 
 for(int j = 0; j < N - 1; j++){
   double X,Y;
   X = v.at(N - 1 - j);
   Y = v.at(N - 2 - j);
   v.pop_back();
   v.at(N - 2 - j) = (X + Y) / 2;
 }
 
 cout << v.at(0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}



int main() {
	string A, B;
	cin >> A >> B;
	if (A.size() > B.size()) {
		cout << "GREATER" << endl;
		return 0;
	}
	if (A.size() < B.size()) {
		cout << "LESS" << endl;
		return 0;
	}
	rep(i, A.size()) {
		if (A.at(i) > B.at(i)) {
			cout << "GREATER" << endl;
			return 0;
		}
		if (A.at(i) < B.at(i)) {
			cout << "LESS" << endl;
			return 0;
		}
	}
	cout << "EQUAL" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;

int main(){
  int a,b;cin>>a>>b;
  if(a!=1 && b!=1){
    cout<<1<<endl;
  }
  
  if(a!=2 && b!=2){
    cout<<2<<endl;
  }
  
  if(a!=3 && b!=3){
    cout<<3<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define f1 first
#define s2 second
#define pb push_back
#define mp make_pair
#define ll long long
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);
const ll mod=1e9+7;
const int N=1e5+4;

ll n,mod1,dp[N][150][2],ans1;
string str;

ll dpf(ll i,ll sum,bool flag){
	if(i==n){
		if(sum==0){
			return 1;
		}
		return 0;
	}
	if(dp[i][sum][flag]!=-1)return dp[i][sum][flag]%mod;

	ll ans=0,sa;
	if(flag)sa=str[i]-'0';
	else sa=9;

	for(int j=0;j<=sa;j++){
		ans+=dpf(i+1,(sum+j)%mod1,sa==j && flag)+mod;
		ans%=mod;
	}
	dp[i][sum][flag]=(ans+mod)%mod;
	return dp[i][sum][flag];
}

int main(){
	//fri("in.txt");
	//fro("out.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>str>>mod1;
	n=str.length();
	memset(dp,-1,sizeof(dp));
	ans1=dpf(0,0,1)-1;
	cout<<(ans1+mod)%mod;

return 0;
}


Measured memory_bytes: 235392
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vl v(MAX_N);
    rep(i, n) {
        ll a;
        cin >> a;
        v[a]++;
    }
    
    ll ans = 0;
    exrep(i, 0, 100000) {
        chmax(ans, v[i] + v[i+1] + v[i+2]);
    }

    out(ans);
    re0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace  std;
int n;
int a[100100100];
int main ()
{
	cin>>n;
	for(int x=1;x<=100;x++)
	{
		for(int y=1;y<=100;y++)
		{
			for(int z=1;z<=100;z++)
			{
				int q=x*x+y*y+z*z+x*y+x*z+y*z;
				a[q]++;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		cout<<a[i]<<endl;
	}
	return 0;
} 

Measured memory_bytes: 3868
// https://atcoder.jp/contests/abc175/tasks/abc175_d
#include <bits/stdc++.h>
using namespace std;
// #define int int64_t
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N, K;
    cin >> N >> K;
    vector<int> P(N);
    vector<int64_t> C(N);
    for (auto &&x : P) {
        cin >> x;
        x--;
    }
    for (auto &&x : C) {
        cin >> x;
    }

    int64_t ans = -1e12;
    // スタート位置
    REP(i, N) {
        // 循環する要素を求める（Pi != i なので自分自身へループしない）
        vector<int64_t> v;
        for (int j = i;; j = P[j]) {
            v.push_back(C[j]);
            // 開始時点に戻ったら終了
            if (P[j] == i)
                break;
        }
        // 循環する要素の長さ
        int m = v.size();
        // 循環する要素の合計
        auto sum = accumulate(begin(v), end(v), 0LL);
        int64_t cur = 0;
        for (int r = 1; r <= m; ++r) {
            if (r > K)
                break;
            cur += v[r - 1];
            // 先頭からスコアを加算し、残りの長さに対して何回循環するか数える
            ans = max(ans, cur + (K - r) / m * max<int64_t>(sum, 0));
        }
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
int n,num[101];
 
int used[101][101],mem[101][101];
bool check(int l,int r){
  if(l==r) return 0;
  for(int i=l;i<=r;i++) if(num[l]!=num[i])return 0;
  return 1;
}
 
int dfs(int l,int r){
  if(l==r)return 0;
  if(check(l,r))  return 1;
  if(used[l][r]++)return mem[l][r];
   
  int res=0;
  for(int i=0;num[l]==num[l+i];i++)
    for(int j=0;num[l]==num[r-j];j++)
      res|=dfs(l+i+1,r-j-1);
  
  for(int i=l;num[l]==num[i];i++)
    for(int j=r;num[l]==num[j];j--)
      for(int k=i+1;k<j;k++)
	if(num[l]==num[k])res|=dfs(i+1,k-1)&&dfs(k+1,j-1);
  
   
  for(int i=l;i<r;i++) res|=dfs(l,i)&&dfs(i+1,r);
  return mem[l][r]=res;
}
 
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>num[i];
  cout<<(dfs(0,n-1)?"yes":"no")<<endl;;
  return 0;
}

Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }

    ll cnt = 0;
    for(int i = n - 1; i >= 0; --i){
        ll k = (a[i] + cnt + b[i] - 1) / b[i];
        if (k != 0) cnt += b[i] * k - (a[i] + cnt);
    }

    cout << cnt << endl;
}

Measured memory_bytes: 1792
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1007;
const ll mod=1000*1000*1000+7;
const ll inf=1e18;

int n, k;

int tab[nax][nax];

ll dp[1<<21];

int main()
{
	scanf("%d", &n);
	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++)
			scanf("%d", &tab[i][j]);
	dp[0]=1;
	for (int i=0; i<(1<<n); i++)
	{
		int x=__builtin_popcount(i);
		dp[i]%=mod;
		for (int j=0; j<n; j++)
			if (!(i&(1<<j)))
				dp[i^(1<<j)]+=dp[i]*tab[x][j];
	}
	
	
	printf("%lld\n", dp[(1<<n)-1]);
	return 0;
}


Measured memory_bytes: 18688
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t=1;
    //cin>>t;
    while(t--)
    {
        string s,t;
        cin>>s>>t;
        int l=0,n=s.length(),ans=INT_MAX,m=t.length(),i,j,k,cnt=0;
        for(i=0;i<=n-m;i++)
        {
            cnt=0;
            l=0;
            for(k=i;k<n&&k<i+m;k++)
            {
                if(s[k]!=t[l])
                    cnt++;
                    l++;

            }
            ans=min(ans,cnt);

        }
        cout<<ans<<endl;
    }

}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define rrep(i,n) for(int i=1; i<n; i++)

using namespace std;
using vi = vector<int>;

int main(){
    int a, b, c, k;
    cin >> a >> b >> c;
    cin >> k;
    rep(i,k){
        if (a >= b) b *= 2;
        else if (b >= c) c *= 2;
        else break;
    }
    if (a < b && b < c) cout << "Yes" << endl;
    else cout <<"No" << endl; 

    return 0;
}

Measured memory_bytes: 3596
import math

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

about = [math.ceil(a/10)*10,math.ceil(b/10)*10,math.ceil(c/10)*10,math.ceil(d/10)*10,math.ceil(e/10)*10]
one = [a%10,b%10,c%10,d%10,e%10]
one.sort()
count = 0
for i in one:
    if i != 0:
        count = i
        break
if sum(one) == 0:
    count = 10
print(sum(about)+count-10)

Measured memory_bytes: 3064