akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n, m;
const int mod = (int)1e9 + 7;
const int maxN = 5005;
int mult(int a, int b) {
    return (1LL * a * b) % mod;
}

int pw(int a, int b) {
    if (b == 0) return 1;
    if (b & 1) return mult(a, pw(a, b - 1));
    int res = pw(a, b / 2);
    return mult(res, res);
}

int sub(int a, int b) {
    int s = a - b;
    if (s < 0) s += mod;
    return s;
}

int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
};

int fact[maxN], invfact[maxN], inv[maxN];

void init() {
    inv[1] = invfact[1] = invfact[0] = fact[0] = fact[1] = 1;
    for (int i = 2; i < maxN; i++) {
        fact[i] = mult(fact[i - 1], i);
        inv[i] = mult(inv[mod % i], mod - mod / i);
        invfact[i] = mult(invfact[i - 1], inv[i]);
    }
}

int cnk(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return mult(fact[n], mult(invfact[k], invfact[n - k]));
}

int invNumber(int a) {
    return pw(a, mod - 2);
}
int pw2[maxN];
int inv2[maxN];
int dp[maxN][maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    init();
    cin >> n >> m;
    pw2[0] = 1;
    inv2[0] = 1;
    for (int i = 1; i <= m; i++) inv2[i] = mult(inv2[i - 1], pw(2, mod - 2));
    for (int i = 1; i <= m; i++) pw2[i] = mult(2, pw2[i - 1]);
    for (int i = 1; i <= m; i++) dp[0][i] = 1;
    for (int bit = 0; bit < n; bit++) {
        int cur_sum = 0;
        for (int i = 1; i <= m; i++) {
            if (i > 1) {
                cur_sum = sum(cur_sum, mult(dp[bit][i - 1], mult(i - 1, inv2[i - 1])));
            }
            dp[bit + 1][i] = mult(cur_sum, pw2[i - 1]);
            dp[bit + 1][i] = sum(dp[bit + 1][i], mult(dp[bit][i], i + 1));
        }
    }
    cout << dp[n][m];
    return 0;
}

Measured memory_bytes: 101484
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from fractions import gcd
from functools import lru_cache, reduce

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")


S = sys.stdin.readline().rstrip()
c = list(S)
if c[0] == c[1] or c[1] == c[2] or c[2] == c[3]:
    print('Bad')
else:
    print('Good')


Measured memory_bytes: 19404
//=================================
// Created on: 2018/07/03 04:30:35
//=================================
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long N;
    // max(f(i),f(j),f(k))+1
    // 1 2 3 4 5 6 7 8 9
    // 0,1,1,2,2,2,2,2,2
    cin >> N;
    N--;
    int ans = 0;
    for (; N > 0; N /= 3, ans++) {}
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3092
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<random>
#include<map>
#include<queue>
using namespace std;


int main(){

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

  sort(a.begin(), a.end());
  // for(int i=0; i<n; i++) cerr << a[i] << " ";
  // cerr << endl;

  vector<int> m;
  int tmp = a[0];
  int cnt = 0;
  for(int i=0; i<n; i++){
    if( tmp != a[i] ){
      m.push_back( cnt );
      tmp = a[i];
      cnt = 1;
    }else{
      cnt++;
    }
  }
  m.push_back( cnt );

  // for(int i=0; i<m.size(); i++) cerr << m[i] << " ";
  // cerr << endl;

  int s = 0;
  bool f = false;

  int q = 0;
  for(int i=0; i<m.size(); i++){
    if( m[i] == 1 ) continue;
    else{
      s += m[i];
      f = true;
    }

    if( m[i] % 2 == 0 ){
      q++;
    }
  }
  if( !f ){
    cout << m.size() << endl;
    return 0;
  }

  if( q % 2 == 1 ) cout << m.size()-1 << endl;
  else cout << m.size() << endl;

  // cerr << s << endl;
  // if( s % 2 == 0 ) cout << m.size()-1 << endl;
  // else cout << m.size() << endl;

  return 0;
}








// EOF


Measured memory_bytes: 1276
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << p.first << " " << p.second;
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

ll H, W;

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

  ll N;
  std::cin >> N >> H >> W;
  std::vector< std::pair<ll, ll> > vp(N, {0LL, 0LL});

  ll ans = 0LL;
  for (ll i = 0; i < N; i++) {
    ll a, b;
    std::cin >> a >> b;
    if ((a / H) * (b / W) > 0) ans++;
  }

  print(ans);
  return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

inline int topbit(unsigned long long x){
	return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
	return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
	return __builtin_parity(x);
}


int K;
int A[111];

int l[111];//label


/*
floor((m+1-l[i])/2)>A[i]
(m-l[i])/2>A[i]
m-l[i]>2*A[i]
m>2*A[i]+l[i]
*/
bool check(){
	int m=0;
	rep(i,K)chmax(m,A[i]+l[i]);
	rep(i,K)if(m>2*A[i]+l[i])return false;
	return true;
}

bool ex[111];
int pos[111];
signed main(){
	cin>>K;
	rep(i,K)cin>>A[i];

	if(!check()){
		cout<<-1<<endl;
		return 0;
	}

	vint ans;
	int rem=0;

	while(*max_element(A,A+K)){
		int len=ans.size();
		for(int i=0;i<K;i++){
			if(A[i]==0)continue;

			if(find(ans.end()-rem,ans.end(),i)!=ans.end())continue;
			ans.pb(i);
			A[i]--;
			int memrem=rem;
			rem++;

			if(ans.size()>=K){
				bool isperm=true;
				memset(ex,0,sizeof(ex));
				for(int j=0;j<K;j++){
					int a=ans[ans.size()-1-j];
					if(ex[a])isperm=false;
					ex[a]=true;
				}
				if(isperm)rem=0;
			}



			memset(l,0,sizeof(l));
			rep(j,rem){
				int a=ans[ans.size()-1-j];
				l[a]=1;
			}

			int ma=-1001001001,mi=1001001001;
			rep(j,K){
				chmax(ma,A[j]-1+l[j]);
				chmin(mi,2*(A[j]-1+l[j]));
			}

			int argma=1001001001,argmi=-2;
			rep(j,rem){
				int a=ans[ans.size()-1-j];
				if(ma==A[a])chmin(argma,j);
				if(mi==2*A[a])chmax(argmi,j);
			}
			rep(j,K)if(!l[j]&&A[j]-1==ma)argma=-1;


			if(ma<=mi)break;
			if(ma-mi==1&&argma>argmi)break;


			for(int j=rem;j<K&&j<ans.size();j++){
				int a=ans[ans.size()-1-j];
				if(l[a])break;
				if(ma==A[a]-1)break;
				l[a]=1;
			}
			if(check())break;


			A[i]++;
			rem=memrem;
			ans.pop_back();			
		}
		if(len==ans.size())break;
	}

	rep(i,ans.size()){
		if(i)cout<<" ";
		cout<<ans[i]+1;
	}cout<<endl;

	return 0;
}


Measured memory_bytes: 3644
import numpy as np
import collections

n = int(input())
A = list(map(int, input().strip().split()))
C = collections.Counter(A)
#print(C)
s = 0
for v in C.values():
    s += v * (v-1) // 2
#print(s)
#print()
for i in range(n):
    print(s - C[A[i]] + 1)


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

int main(){

  int W,H,x,y,r;

  cin >>W >>H >>x >>y >>r;
  if(-100<=x&&x<=100 && -100<=y&&y<=100 && 0<W&&W<=100 && 0<H&&H<=100 && 0<r&&r<=100){
    if(0>x-r || x+r>W)
      cout <<"No" <<endl;
    else if(0>y-r || y+r>H)
      cout <<"No" <<endl;
 
    else cout <<"Yes" <<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<string>
using namespace std;
int w,h;
string map[40];
int vec[4][2]={{0,1},{0,-1},{-1,0},{1,0}};
int move(int x,int y){
	int ans=1;
	map[x][y]='#';
	for(int i=0;i<4;i++){
		if((x+vec[i][0]>=0)&&(y+vec[i][1]>=0)&&(x+vec[i][0]<h)&&(y+vec[i][1]<w)){
			if(map[x+vec[i][0]][y+vec[i][1]]=='.'){
				ans+=move(x+vec[i][0],y+vec[i][1]);
			}
		}
	}
	return ans;
}

int main(){
	while(cin>>w>>h,w){
		int fx,fy;
		for(int i=0;i<h;i++){
			cin>>map[i];
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(map[i][j]=='@'){
					fx=i;
					fy=j;
					break;
				}
			}
		}
		int ans=move(fx,fy);
		cout<<ans<<endl;
		
	}
}

Measured memory_bytes: 1212
H, W = map(int,input().split())
N = 10
cost = [[0] * N for _ in range(N)]
for i in range(N):
    for j, c in enumerate(map(int, input().split())):
        cost[i][j] = c

for k in range(N):
    for i in range(N):
        for j in range(N):
            cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])

ans = 0
for _ in range(H):
    for x in map(int, input().split()):
        if x >= 0:
            ans += cost[x][1]
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#define LIMIT 200001
using namespace std;
int main()
{
	int h, w, n;
	int i, j, k;
	int Fi, Fj;
	int Tyoko[LIMIT], Ayoko[LIMIT];
	int Ttate[LIMIT], Atate[LIMIT];
	int tate, yoko;
	string s, t;

	cin >> h >> w >> n;
	cin >> Fi >> Fj;
	cin >> s;
	cin >> t;

	for (i = 0; i < n; i++) {
		switch (s[i]) {
			case 'L': Ttate[i] = 0; Tyoko[i] = -1; break;
			case 'R': Ttate[i] = 0; Tyoko[i] = 1; break;
			case 'U': Ttate[i] = -1; Tyoko[i] = 0; break;
			case 'D': Ttate[i] = 1; Tyoko[i] = 0; break;
		}
		switch (t[i]) {
			case 'L': Atate[i] = 0; Ayoko[i] = -1; break;
			case 'R': Atate[i] = 0; Ayoko[i] = 1; break;
			case 'U': Atate[i] = -1; Ayoko[i] = 0; break;
			case 'D': Atate[i] = 1; Ayoko[i] = 0; break;
		}
	}

	/*
	cout << endl << "tate yoko print:" << endl;
	for (i = 0; i < n; i++) {
		cout << "[" << i << "] " << Ttate[i] << " / " << Tyoko[i] << endl;
	}
	for (i = 0; i < n; i++) {
		cout << "[" << i << "] " << Atate[i] << " / " << Ayoko[i] << endl;
	}
	cout << endl;
	*/

	tate = Fi;
	for (i = 0; i < n; i++) {
		if (Ttate[i] == -1) {
			tate--;
		}
		if (tate == 0) {
			cout << "NO" << endl;
			return 0;
		}
		if (Atate[i] == 1 && tate!=h ) {
			tate++;
		}
		
	}

	tate = Fi;
	for (i = 0; i < n; i++) {
		if (Ttate[i] == 1) {
			tate++;
		}
		if (tate == h+1) {
			cout << "NO" << endl;
			return 0;
		}
		if (Atate[i] == -1 && tate>1 ) {
			tate--;
		}
		
	}

	yoko = Fj;
	for (i = 0; i < n; i++) {
		if (Tyoko[i] == -1) {
			yoko--;
		}
		if (yoko == 0) {
			cout << "NO" << endl;
			return 0;
		}
		if (Ayoko[i] == 1 && yoko!=w) {
			yoko++;
		}
		
	}

	yoko = Fj;
	for (i = 0; i < n; i++) {
		if (Tyoko[i] == 1) {
			yoko++;
		}
		if (yoko == w+1) {
			cout << "NO" << endl;
			return 0;
		}
		if (Ayoko[i] == -1 && yoko>1) {
			yoko--;
		}
		
	}

	cout << "YES" << endl;
	return 0;
}

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

int main()
{
	int n;
	while (cin >> n) {
		int count = 0;
		for (int a = 0; a < 10; a++) {
			for (int b = 0; b < 10; b++) {
				for (int c = 0; c < 10; c++) {
					for (int d = 0; d < 10; d++) {
						if (a + b + c + d == n)
							count++;
					}
				}
			}
		}
		cout << count<<endl;
	}

	return 0;
}

Measured memory_bytes: 3088
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    
    int e = B-A;
    
    if(e<=0){
    System.out.println("delicious");
    }else if(e<=X){
    System.out.println("safe");
    }else{
    System.out.println("dangerous");
    }
    }
}

Measured memory_bytes: 35500
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

 class Radix {
 private:
   const char* s;
   int a[128];
 public:
   Radix(const char* s = "0123456789ABCDEF") : s(s) {
     int i;
     for(i = 0; s[i]; ++i)
       a[(int)s[i]] = i;
   }
   std::string to(long long p, int q) {
     int i;
     if(!p)
       return "0";
     char t[64] = { };
     for(i = 62; p; --i) {
       t[i] = s[p % q];
       p /= q;
     }
     return std::string(t + i + 1);
   }
   std::string to(const std::string& t, int p, int q) {
     return to(to(t, p), q);
   }
   long long to(const std::string& t, int p) {
     int i;
     long long sm = a[(int)t[0]];
     for(i = 1; i < (int)t.length(); ++i)
       sm = sm * p + a[(int)t[i]];
     return sm;
   }
 };
 
int main(){
    ll D, G; cin >> D >> G;
    vll p(D+1), c(D+1);
    for(int i=1; i<D+1; i++){
        cin >> p[i] >> c[i];
    }
    ll min = 100000000000;
    for(int i=0; i<pow(2,D); i++){
        ll m = 0;
        ll g = G;
        Radix r;
        string k = r.to(i, 2);
        if(k.size() < D){
            string l = "";
            for(int i=0; i<D-k.size(); i++){
                l += '0';
            }
            k = l + k;
        }
        for(int j=0; j<D; j++){
            if(k[j] == '1'){
                m += p[j+1];
                g -= 100*(j+1)*p[j+1];
                g -= c[j+1];
            }
        }
        if(g > 0){
            for(int n=D-1; n>=0; n--){
                if(k[n] == '0'){
                    if(g > p[n+1]*(n+1)*100){
                        m += p[n+1];
                    }
                    else{
                        m += g/((n+1)*100);
                        if(g%((n+1)*100)!=0){
                            m++;
                        }
                        break;
                    }
                }
            }
        }
        if(min > m){min = m;}
    }
    cout << min;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int &i:A)
    cin>>i;
  vector<bool> B(N,true);
  vector<int> C(0);
  for(int i=N;i>0;i--){
    bool bo=true;
    for(int j=0,k=0;k<i;j++){
      if(!B[N-j-1])
        continue;
      if(A[N-j-1]==i-k){
        C.push_back(i-k);
        B[N-j-1]=false;
        bo=false;
        break;
      }
      k++;
    }
    if(bo){
      puts("-1");
      return 0;
    }
  }
  for(int i=N-1;i>=0;i--)
    cout<<C[i]<<endl;
}

Measured memory_bytes: 3644
N=int(input())
s=bin(N)[2:]
K=len(s)
mod=10**9+7
#bp[i][j]は上からiビット以上が確定でN>>(K-i)-v>>(K-i)=jとなる通り数
bp=[[0]*(3) for i in range(K+1)]
bp[0][0]=1
for i in range(1,K+1):
    if s[i-1]=="0":
        bp[i][0]=(bp[i-1][1]+bp[i-1][0])%mod
        bp[i][1]=bp[i-1][1]
        bp[i][2]=(bp[i-1][1]+bp[i-1][2]*3)%mod
    else:
        bp[i][0]=bp[i-1][0]
        bp[i][1]=(bp[i-1][1]+bp[i-1][0])%mod
        bp[i][2]=(bp[i-1][1]*2+bp[i-1][2]*3)%mod
print(sum(bp[-1])%mod)


Measured memory_bytes: 3064
import copy
N = int(input())
X = []
X.append(list(map(int, input().split())))
#Y = []
T = (X[0][0] + X[0][1]) % 2
max = abs(X[0][0]) + abs(X[0][1])
for i in range(1,N):
  X.append(list(map(int, input().split())))
  t = abs(X[i][0]) + abs(X[i][1])
  if t % 2 != T:
    print(-1)
    exit()
  if max < t:
    max = t
    
# 奇数: D =    1, 2, 4, 8...
# 偶数: D = 1, 1, 2, 4, 8...
# sum(D) > max
D = []
sum = 0
if T == 0:
  max -= 1
t = 1
while 1:
  D.append(t)
  sum += t
  if sum >= max:
    break
  t *= 2
if T == 0:
  D.append(1)
D.reverse()

# m
print(len(D))
# d1, d2, ... dm
s = ""
for i in range(len(D)):
  s += str(D[i]) + " "
print (s)

# w1, w2, ... wm
for i in range(N):
  U = X[i][0] + X[i][1]
  V = X[i][0] - X[i][1]
  s = ""
  for j in range(len(D)):
    if U >= 0:
      if V >= 0:
        s += "R"
        U -= D[j]
        V -= D[j]
      else:
        s += "U"
        U -= D[j]
        V += D[j]
    else:
      if V >= 0:
        s += "D"
        U += D[j]
        V -= D[j]
      else:
        s += "L"
        U += D[j]
        V += D[j]
  print(s)

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, k;
    cin >> n >> k;

    vector a(n, 0L);
    for (auto&& aa : a) {
        cin >> aa;
    }

    for (auto i : irange(k, n)) {
        if (a[i] > a[i - k]) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
}

Measured memory_bytes: 4840
//by Sshwy
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)

namespace RA{
    int rnd(int p){return 1ll*rand()*rand()%p;}
    int rnd(int L,int R){return rnd(R-L+1)+L;}
}
const int N=505;
int n;
int a[N];
int b[N*N];
int c[N],ok[N]; // counter of usage
vector<int> v;
int main(){
    scanf("%d",&n);
    FOR(i,1,n)scanf("%d",&a[i]),b[a[i]]=i;
    FOR(i,1,n*n)if(b[i])v.pb(b[i]);
    FOR(i,1,n*n){
        if(b[i]){
            if(c[b[i]]+1==b[i]) c[b[i]]++,ok[b[i]]=1;
            else return puts("No"),0;
        }else {
            bool flag=0;
            for(int j:v)if(!ok[j] && c[j]<j-1){ ++c[j],b[i]=j,flag=1;break; }
            if(flag==0)for(int j:v)if(ok[j] && c[j]<n){ ++c[j],b[i]=j,flag=1;break; }
            if(flag==0)return puts("No"),0;
        }
    }
    puts("Yes");
    FOR(i,1,n*n)printf("%d%c",b[i]," \n"[i==n*n]);
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string S;
  cin >> S;
  cout << (N & 1 || S.substr(0, N / 2) != S.substr(N / 2, N / 2) ? "No" : "Yes")
       << '\n';
  return 0;
}


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

int n,c[3];
int main() {
    scanf("%d",&n);
    for(int i=0;i<n;i++) {
        int v;
        scanf("%d",&v);
        if(v%2==1) c[0]++;
        else if(v%4!=0) c[1]++;
        else c[2]++;
    }
    if(c[0]<=c[2]) puts("Yes");
    else if(c[0]>c[2]+1) puts("No");
    else if(c[1]==0) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 764
#include <iostream>

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

#ifdef DEBUG_ON
    freopen("input", "r", stdin);
#endif

    int d, t, s;
    std::cin >> d >> t >> s;
    if (s * t >= d) {
        std::cout << "Yes" << '\n';
    } else {
        std::cout << "No" << '\n';
    }
    return 0;
}

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

#define FOUND 1
#define NOT_FOUND -1

int search(int [], int, int);

int main(){
  int *S, *T;
  int n, q;
  int count = 0;
  int i, j;
  
  scanf("%d",&n);
  S = (int *)malloc((n+1) * sizeof(int));

  for(i=0; i<n; i++)
    scanf("%d",&S[i]);

  scanf("%d",&q);
  T = (int *)malloc(q * sizeof(int));
  
  for(i=0; i<q; i++)
    scanf("%d",&T[i]);
 
  for(i=0; i<q; i++){
    if(search(S, n, T[i])==FOUND)
    count++;
  }

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

  free(S);
  free(T);
  return 0;
}

int search(int A[], int n, int key){
  int i=0;
  A[n] = key;

  while(A[i]!=key)
    i++;

  if(i==n)
    return NOT_FOUND;
  
  return FOUND;
}



Measured memory_bytes: 2144
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

const int M = 1000005;

int main() {
    int n,sum=0;
    cin >> n;
    vector<ll> cnt(M);
    rep(i,n) {
        int a;
        cin >> a;
        cnt[a]++;
    }
    ll tot=0;
    rep(i,M) tot+=i*cnt[i];
    int q;
    cin >> q;
    rep(i,q) {
        int b,c;
        cin >> b >> c;
        tot-=b*cnt[b];
        tot-=c*cnt[c];
        cnt[c]+=cnt[b];
        cnt[b]=0;
        tot+=b*cnt[b];
        tot+=c*cnt[c];
        cout << tot << endl; 
    }
}

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

int main(){
  ll N;
  cin >> N;
  vector<ll>A(N);
  for(ll i=0; i<N; i++){
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  ll ans=0;
  ans = A.at(0);
  N -= 2;
  ll i=1;
  while(N>0){
    ans += A.at(i);
    N--;
    if(N<1)
      break;
    ans += A.at(i);
    N--;
    i++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
int n,m,a[101];
int main(){
	cin>>n>>m;
	if(m==1){
		cout<<'0'<<endl;
		return 0;
	}
	for(int i=1;i<=m;i++){
		a[i]=1;
		n--;
	}
	a[1]+=n;
	cout<<a[1]-a[2];
	return 0;
}

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

int main(){
    int n, minj;
    string a[36],b[36];
    string s;
    bool flag;
    cin >> n;
    s = "Stable";
    for(int i=0; i<n; i++) cin >> a[i], b[i] = a[i];
    for(int i=0; i<n; i++){
        for(int j=n-1; j>i; j--){
            if(a[j][1] < a[j-1][1]) swap(a[j],a[j-1]);
        };
    };
    for(int i=0; i<n-1; i++){
        cout << a[i] << " ";
    };
    cout << a[n-1] << endl << s << endl;
    for(int i=0; i<n; i++){
        minj = i;
        flag = false;
        for(int j=i+1; j<n; j++){
            if(b[j][1] == b[minj][1]) flag = true;
            else if(b[j][1] < b[minj][1]) minj = j;
        };
        if(b[i][1] != b[minj][1]){
            swap(b[i],b[minj]);
            if(flag) s = "Not stable";
        };
    };
    for(int i=0; i<n-1; i++){
        cout << b[i] << " ";
    };
    cout << b[n-1] << endl << s << endl;
    return 0;
}


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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	string S;
	cin >>S;
	char S0=' ';
	int s=0;
	int i=0;
	while(i<S.size()) {
		if (S0==S.at(i)) {
			i +=2;
			S0=' ';
			if (i<=S.size())
				s++;
		} else {
			s++;
			S0=S.at(i);
			i++;
		}
	}
	cout <<s <<endl;
	return 0;
}



Measured memory_bytes: 640
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
def f(n):
    if n < 2:
        return 1
    else:
        return n * f(n - 2)

"""
2,5が大事
11 > 9 > 7 > 5 > 3 > 1

10 > 8 > 6 > 4 > 2 > 1
10の個数
"""
if N % 2 == 1:
    print("0")
    sys.exit()

# base_ans = 0
# fn = str(f(N))
# while True:
#     if len(fn) < 1:
#         break
#     if fn[-1] == "0":
#         base_ans += 1
#         fn = fn[:-1]
#     else:
#         break
# print(base_ans)

ans = 0
if N >= 10:
    N //= 10
    ans += N

n = copy.deepcopy(N)
while n > 4:
    n //= 5
    ans += n
# 5の倍数
# if N // 50 % 2 == 0:
#     ans += N // 50 // 2 - 1
# else:
#     ans += math.ceil(N // 50 / 2)

# N //= 10
# tmp = 2
# while True:
#     # print(tmp)
#     if N < 5 ** tmp:
#         break
#     ans += N // (5 ** tmp)
#     tmp += 1



print(ans)

Measured memory_bytes: 10924
import java.util.*;

public class Main {
   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
  int n=sc.nextInt();
  for(int j=0;j<n;j++){
	  int tri[] = new int[3];
	  for(int i=0;i<3;i++){
		  tri[i]=sc.nextInt();
	  tri[i]*=tri[i];
	  }
	  Arrays.sort(tri);
if(tri[0]+tri[1]==tri[2])
	System.out.println("YES");
else System.out.println("NO");
  }
      }
}

Measured memory_bytes: 23372
#include <stdio.h>
#include <stdlib.h>
#pragma GCC optimize ("O3")

inline static int gl(void){
    int x = 0;
    for(;;){
        unsigned int c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}

inline static void pl(unsigned int s){
    char str[9];
    int pos=9;
    if(s==0){
        putchar_unlocked('0');
        return;
    }
    do{
        pos--;
        str[pos]=s%10+48;
        s/=10;
    }while(s!=0);
    for(; pos<9; pos++){
        putchar_unlocked(str[pos]);
    }
}

inline static int sp(char* str, unsigned short i){
    if(i>99){
        char c0 = i%10; i/=10;
        char c1 = i%10; i/=10;
        str[0] = i+48;
        str[1] = c1+48;
        str[2] = c0+48;
        return 3;
    }else if(i>9){
        char c0 = i%10; i/=10;
        str[0] = i+48;
        str[1] = c0+48;
        return 2;
    }else{
        str[0] = i+48;
        return 1;
    }
}

char a[1001*500];
char buffer[8*1024*1024];

int main(void){
    const int h=gl(), w=gl();
    int p = 0;
    int pos=0;
    char *aa = a-2; 
    fread(a, 1, 2*w*h, stdin);
    {
        char haveCoin = 0;
        short old_y, old_x;
        for(int i=1; i<=h; i++){
            //fgets_unlocked(a, 1001, stdin);
            if(i%2==1){
                for(int j=1; j<=w; j++){
                    if(haveCoin){
                        pos++;
                        p += sp(buffer+p, old_y)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, old_x)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, i)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, j)+1; buffer[p-1] = '\n';
                    }
                    haveCoin ^= aa[2*j]&1;
                    old_y = i;
                    old_x = j;
                }
            }else{
                for(int j=w; j>0; j--){
                    if(haveCoin){
                        pos++;
                        p += sp(buffer+p, old_y)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, old_x)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, i)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, j)+1; buffer[p-1] = '\n';
                    }
                    haveCoin ^= aa[2*j]&1;
                    old_y = i;
                    old_x = j;
                }
            }
            aa+=2*w;
        }
    }
    pl(pos); putchar_unlocked('\n');
    fwrite(buffer, 1, p, stdout);
    return 0;
}


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

int main() {
	unsigned long long x;
  	cin >> x;
  
  	unsigned long long val = 100;
  	int count = 0;
  	while (val < x) {
      val += (val / 100);
      count++;
    }
  	cout << count;
  	return 0;
}

Measured memory_bytes: 3636
(r, c) = map(int, input().split())
a = [[v for v in list(map(int, input().split()))] for r in range(r)]
add_c = [sum(l) for l in a]
for i in range(r):
    a[i].append(add_c[i])
add_r = [sum([a[i][j] for i in range(r)]) for j in range(c + 1)]
a.append(add_r)
for i in range(r + 1):
    print(' '.join(map(str, a[i])))

Measured memory_bytes: 7780
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

int main(){
    int n;
    cin >> n;
    cout << int(pow(n, 3)) << endl;
    return 0;
}

Measured memory_bytes: 4020
#include <stdio.h>

int main(void)
{
	int line,i,stack[10] ={0};

	while(scanf("%d",&line) != EOF)
	{
		if(line == 0)
		{
			i--;
			printf("%d\n",stack[i]);
		}
		else
		{
			stack[i] = line;
			i++;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define oo 1000000010
#define mod 1000000007
const int N = 100010;
string s;
int k;

int main(){
	cin >> s;
	cin >> k;
	if((int)s.size() == 1){
		cout << k / 2 << endl;
		return 0;
	}
	int a = 0 , b = 0;
	if(s.back() == s[0]){
		for(int i =0 ; s[i] == s[0];i++)
			a++;
		for(int i = (int)s.size() - 1;s[i] == s[(int)s.size() - 1];i--)
			b++;
		if(a + b >= (int)s.size()){
			cout << (long long)s.size() * k / 2 << endl;
			return 0;
		}
		long long ans = 0;
		for(int i = a;i < (int)s.size() - b - 1;i++){
			if(s[i] == s[i + 1]){
				ans += k;
				s[i + 1] = 'W';
			}
		}
		ans += a / 2;
		ans += b / 2;
		ans += (long long)(k - 1) * ((a + b) / 2);
		cout << ans << endl;
		return 0;
	}
	long long ans = 0;
	for(int i = 0 ;i < (int)s.size() - 1;i++){
		if(s[i] == s[i + 1]){
			ans += k;
			s[i + 1] = 'W';
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000

ll N,M,X,K,Q;
ll A[100010],B,C,D;
set<ll> S;
priority_queue<ll> G[100010];
ll ans;
int main(){
    cin>>N>>M;
    REP(i,N){
        cin>>A[i];
    }
    REP(i,M){
        int a,b;
        cin>>a>>b;
        G[a-1].push(A[b-1]);
        G[b-1].push(A[a-1]);
    }
    REP(i,N){
        if(G[i].empty()){ans++;continue;}
        if(G[i].top()<A[i])ans++;
        DEB(G[i].top())DEB(A[i])DEB(ans)END
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 11032
#include <bits/stdc++.h>
using namespace std;
int main(){
	int P,Q,R;
	vector<int> var(3,0);
for(int i= 0;i<3;i++){
	cin>>var[i];
}
	sort(var.begin(),var.end(),less<int>());
	cout<<var[0] + var[1]<<endl;
	
	return 0;
}

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

  

int32_t main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int count=0;
    for(int i=1;i<=100000000;i++)
    {
		count=(count*10+7)%n;
		if(!count)
		{
		cout<<i;
		return 0;
	    }
	}   
	
	cout<<-1;
 
   

		
	
		  
}


Measured memory_bytes: 3596
//Code by Anshuman Das Gupta

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define MOD 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define loop(I,N) for(int i=I;i<N;i++)
#define sortvec(V) sort(V.begin(),V.end())
#define vec vector<int>
#define endl "\n"
using namespace std;
int fast_power(int base, int power) {
    int result = 1;
    while (power > 0) {

        if (power & 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result % MOD;
}

bool isPrime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0)
            return false;
    }
    if (x == 1)
        return false;
    return true;
}

int binsearch(int a[], int f, int r, int x) {
    while (f <= r) {
        int mid = (f + r) / 2;
        if (a[mid] == x)
            return mid;
        else if (a[mid] > x) {
            r = mid - 1;
        }
        else {
            f = mid + 1;
        }
    }
    return -1;
}
void sieve(int a[], int n) {
    a[0] = 0;
    a[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] == 1) {
            for (int j = i + i; j <= n; j += i) {
                a[j] = 0;
            }
        }
    }
}
int32_t main() {
#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("out.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int x = 1;
        while (a > 0 && c > 0) {
            if (x == 1) {
                c -= b;
            }
            else {
                a -= d;
            }
            x ^= 1;
        }
        if (a > 0)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
//debug
#ifdef grief
#define debug(...) do{\
	fprintf(stderr , "%s - %d : (%s) = " , __PRETTY_FUNCTION__ , __LINE__ , #__VA_ARGS__ );\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> 				void _DO(I&&x){	cerr<<x<<endl;	}
template<typename I,typename...T>	void _DO(I&&x,T&&...tail){	cerr<<x<<" , ";	_DO(tail...);	}
template<typename _a,typename _b> 	ostream& operator << (ostream &_s,const pair<_a,_b> &_p)
{	return _s<<'('<<_p.first<<','<<_p.second<<')';	}
#define IOS
#else
#define debug(...)
#define IOS do{ios_base::sync_with_stdio(0); cin.tie(0);}while(0);
#endif
//type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef priority_queue<pll,vector<pll>,greater<pll> > heap;
//macro
#define SZ(x) ((ll)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define stp setprecision(30)<<fixed
const ll INF=0x3f3f3f3f3f3f3f3f;
const int NF=0x3f3f3f3f;
const ll MAX=1e5+5,Mlg=__lg(MAX)+2;
const ll MOD=1e9+7;
// ready~ go!
// let's coding and have fun!
// I can't solve this problem!
int main(){
	IOS
	string a,b;	cin>>a>>b;
	if(a==b)	cout<<"=\n";
	else cout<<(a>b ? '>':'<')<< '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int h[n];
  for(int i=0;i<n;i++)
   cin>>h[i];
   int dp[n];
   fill(dp,dp+n,INT_MAX);
   dp[0]=0;
   dp[1]=abs(h[1]-h[0]);
   
   for(int i=2;i<n;i++)
   {
         int t=1;
         while(t<=k&&i-t>=0)
         {
           dp[i]=min(dp[i],dp[i-t]+abs(h[i]-h[i-t]));
           t++;  
         }
   }
  cout<<dp[n-1]<<endl;

}

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


int main() {
    int N; cin>>N;
    vector<ll>h(N);
    rep(i,N){
        cin>>h[i];
        h[i]--;
    }
    for(int i=0;i<N-1;i++){
        if(h[i]>h[i+1]){
            h[i+1]++;
            if(h[i]>h[i+1]){
                cout<<"No"<<endl;
                return 0;
            }
            else if(i>=1&&h[i]<h[i-1]){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <utility>
using namespace std;

int main() {
  string S; cin >> S;
  int w; cin >> w;
  int p = 0;
  while (p < S.length()) {
    cout << S[p];
    p += w;
  }
  cout << endl;
}


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

#define endl '\n'
using namespace std;
typedef long long int ll;

const ll INF = 1ll<<60;

ll t;

void init();
void process();

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> t;
}

ll pwer(ll a, ll p)
{
    ll ans = 1;
    for(int i = 0; i < p; i++) ans *= a;
    return ans;
}

ll run(ll mxpw)
{
    ll initSec = 2*(mxpw);
    ll initRun = 2*pwer(3, mxpw)-1-1;
    if(t < initRun) return INF;
    else if(initRun == t) return initSec;
    else 
    {
        ll ans = initSec;
        ll rest = t - initRun;
        ll pw = pwer(3, mxpw);
        while(rest > 0)
        {
            ans += rest/pw, rest %= pw;
            pw /= 3;
        }
        return ans;
    }
}

void process()
{
    ll ans = t;
    for(ll pw = 1; pw < 33; pw++)
    {
        ll res = run(pw);
        ans = min(ans, res);
    }
    cout << ans << endl;
}




Measured memory_bytes: 3152
n = input()
integer = list(map(int, input().split()))

min = integer[0]
max = integer[0]
sum = 0
for i in integer:
    if max<i:
        max = i
    if i < min:
        min = i
    sum += i

print(str(min)+" "+ str(max) +" "+ str(sum))

Measured memory_bytes: 8716
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;

typedef long long ll;

int main() {
  ll a,b,x; cin >> a >> b >> x;
  if ( a == 0 )  cout << b/x+1 << endl;
  else if ( a == 0 && b == 0 ) cout << 1 << endl;
  else   cout << b/x-(a-1)/x << endl;
  return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;
static const long long mod = 1000000007;

ll n;
vll xs, ys;

double f(double x, double y){
  double ans = 0;
  rep(i, n){
    double dist = sqrt((xs[i]-x)*(xs[i]-x) + (ys[i]-y)*(ys[i]-y));
    chmax(ans, dist);
  }
  return ans;  
}

double g(double x){
  double l = 0, r = 1001; 
  rep(_, 80){
    double y1 = (2*l + r)/3;
    double y2 = (l + 2*r)/3;
    if(f(x, y1) > f(x, y2)) l = y1;
    else r = y2;
  }
  return f(x, l);
}

int main() {
  cout << fixed << setprecision(15);

  cin >> n;
  xs.resize(n), ys.resize(n);

  rep(i,n){
    cin >> xs[i] >> ys[i];
  }

  double l = 0, r = 1001; 
  rep(_, 80){
    double x1 = (2*l + r)/3;
    double x2 = (l + 2*r)/3;
    if(g(x1) > g(x2)) l = x1;
    else r = x2;
  }

  cout << g(l) << endl;

  return 0;
}



Measured memory_bytes: 3844
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int l= sc.nextInt();
      	String s = sc.next();
		char[] c=s.toCharArray();
		long r=0;
		long g=0;
		long b=0;
		for(int i=0;i<l;i++){
			if(c[i]=='R'){
				r++;
			}
			if(c[i]=='G'){
				g++;
			}
			if(c[i]=='B'){
				b++;
			}
		}
		long t=r*g*b;
		for(int i=0;i<l;i++){
			for(int j=1;i+2*j<l;j++){
				if(c[i]!=c[i+j]){
					if(c[i+j]!=c[i+2*j]){
						if(c[i+2*j]!=c[i]){
							t--;
                		}
                	}
                }
            //System.out.println(c[i]);
			}
		}
		System.out.println(t);
	}
}

Measured memory_bytes: 35828
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;
#define MAX_H 30
int field[MAX_H][MAX_H];
int initField[MAX_H][MAX_H];

int howManySameColorRight(int i,int j,int W,int color){
	if( j >= W) return 0;
	if(field[i][j] == 0) return 0;
	if(color != field[i][j]) return 0;
	if(j== W-1 && color == field[i][j]) return 1;
	return howManySameColorRight(i,j+1,W,color) + 1;
}

void banishRightN(int i,int j,int n){
	for(int k = 0; k < n; k++){
		field[i][j+k] = 0;
	}
}

void moveBlocks(int H,int W){
	for(int i = H-1; i >= 1; i--){
		for(int j = 0; j < W; j++){
			if(field[i][j] == 0){
				field[i][j] = field[i-1][j];
				field[i-1][j] = 0;
			}
		}
	}
}

void initializeField(int H,int W){
	rep(i,H){
		rep(j,W){
			field[i][j] = initField[i][j];
		}
	}
}

int main()
{
	int H,W,K;
	cin>>H>>W>>K;
	rep(i,H){
		string str;
		cin>>str;
		rep(j,W) initField[i][j] = str[j] - '0';
	}
	ll ans = 0;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
	/*int i = 3;
	int j = 2;*/
			ll localAns = 0;
			initializeField(H,W);
			field[i][j] = 0;
			//p th block banish
			for(int p = 0; p < H + W; p++){
				rep(e,H)moveBlocks(H,W);
				/*cout<<"-----------------"<<endl;
				rep(a,H){
					rep(b,W){
						cout<<field[a][b]<<" ";
					}
					cout<<endl;
				}*/
				ll banishBlocks = 0;
				for(int k = 0; k < H; k++){
					for(int l = 0; l < W; l++){
						int num = field[k][l];
						int blocks = howManySameColorRight(k,l,W,field[k][l]);
						if(blocks >= K){
							banishRightN(k,l,blocks);
							banishBlocks += blocks*num;
						}
					}
				}
				localAns += pow(2.0,p) * banishBlocks;
				//cout<<pow(2.0,p)*banishBlocks<<endl;
			}
			ans = max(ans,localAns);
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    REP(i, 4) {
        if(s[i] == '+')
            ans++;
        else
            ans--;
    }
    cout << ans << endl;
}


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

int main(){
	int n,a[101];
	cin >>n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n-1;i++)
		cout << a[i] << ' ';
	cout<< a[n-1] << endl;
	for(int k = 1;k <n;k++){
		int v,j;
		v = a[k];
		j = k-1;
		while(j >= 0 && a[j] > v){
			a[j+1] = a[j];
			j--;
			a[j+1] = v;
		}
		for(int i=0;i<n-1;i++)
			cout << a[i] << ' ';
		cout<< a[n-1] << endl;
	}

	return 0;
}

Measured memory_bytes: 3044
#include <cstdio>
int N, p[20001], r[20001];
int main()
{
	scanf("%d", &N);
	for (int i = 1; i <= N; i++)
	{
		scanf("%d", p + i);
		r[p[i]] = i;
	}
	for (int i = 1; i <= N; i++)
		printf("%d%c", i * N, " \n"[i == N]);
	for (int i = 1; i <= N; i++)
		printf("%d%c", (N - i + 1) * N + r[i], " \n"[i == N]);
	return 0;
}


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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
const int mod = 1000000007;

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

    bool flag = false;
    for(int i = 1; i <= 9; i++) {
        for(int j = 1; j <= 9; j++) {
            if(i * j == n) {
                flag = true;
            }
        }
    }

    if(flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N 200100
#define mod 1000000007
#define MOD 998244353
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
#define INF 100000000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

signed main()
{
    
    speed
    int k,a,b;cin>>k>>a>>b;
    for(int i=a;i<=b;i++){
    	if(i%k==0){
    		cout<<"OK"<<endl;
    		return 0;
    	}
    }
    cout<<"NG"<<endl;


    

    

 
    return 0;
}

Measured memory_bytes: 3652
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

toSet = map head . group . sort

f _ 1 s = s
f n k s = concat [map (x++) $ f (n-1) (k-1) (a++b) | t <- [0..n-1], let (a,(x:b)) = splitAt t s]

main = do
    n <- getInt
    k <- getInt
    when (n/=0 || k/=0) $ do
        d <- replicateM n getLine
        print $ length $ toSet $ f n k d
        main

Measured memory_bytes: 5740