akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;


signed main(){
	int n,k;cin >> n >> k;
	vector<int> c(n), g(n);
	bool isdottika = true;
	vector<vector<int> > b(10, vector<int>());
	for(int i = 0; i < n; i++){
		cin >> c[i] >> g[i];
		g[i]--;
		if(g[i] > 1)isdottika = false;
	}
	for(int i = 0; i < n; i++){
		b[g[i]].push_back(c[i]);
	}
	for(int i = 0; i < 10; i++){
		sort(ALL(b[i]), greater<int>());
	}
	for(int i = 0; i < 10; i++){
		for(int j = 1; j < b[i].size(); j++){
			b[i][j] += b[i][j-1];
		}
	}
	vector<vector<int> > dp(10, vector<int>(k+1,0));
	if(b[0].size() != 0){
		for(int i = 1; i < k+1; i++){
			int c = i >= b[0].size() ? b[0].size() : i;
			dp[0][i] = b[0][c-1] + c*(c-1);
		}
	}
	for(int i = 1; i <= k; i++){
		for(int j = 1; j < 10; j++){
			int tmp = dp[j-1][i];
			for(int l = 1; l <= i && l <= b[j].size(); l++){
				tmp = max(tmp, dp[j-1][i-l] + b[j][l-1] + l*(l-1));
			}
			dp[j][i] = tmp;
		}
	}
	cout << dp[9][k] << endl;


	return 0;
}




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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int i;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int result = 0;
  int ele = 0, num = 0;
  for (i = 0; i < n; i++) {
    if (num != a[i]) {
      if (ele >= num) {
        result += ele - num;
      } else {
        result += ele;
      }
      ele = 0;
      num = a[i];
    }
    ele++;
  }
  if (ele >= num) {
    result += ele - num;
  } else {
    result += ele;
  }
  cout << result << endl;
  return 0;
}


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


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

  int ha=0;
  for(int i=0;i<n;++i){
    if(a[i]*4*m<s){
      ha++;
    }
  }
  //cout << s/(4*m) << endl;
  if(n-ha>=m){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
long long n,a,b,c,d;
int main()
{
    scanf("%lld%lld%lld",&n,&a,&b);
    if(n<=a+b)
    {
        if(a>=n)
            printf("%lld",n);
        else
            printf("%lld",a);
    }
    else
    {
        c=n/(a+b);
        d=n%(a+b);
        if(d>a)
            printf("%lld",a*c+a);
        else
            printf("%lld",a*c+d);
    }
    return 0;
}


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

int64_t gcd( int64_t x, int64_t y ) {
	return y ? gcd( y, x % y ) : x;
}

int64_t lcm( int64_t x, int64_t y ) {
	return y / gcd( x, y ) * x;
}

int main() {
	ios_base::sync_with_stdio( false );

	int a, b;
	while( (cin >> a) && (cin >> b) ) {
		cout << gcd( a, b ) << ' ' << lcm( a, b ) << '\n';
	}
}



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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //



// --------- library end - //


int main(){

  ll H, W, A, B;
  cin >> H >> W >> A >> B;

  rep(h, B){
    cout << string(A, '0') << string(W-A, '1') << endl;
  }
  rep(h, H-B){
    cout << string(A, '1') << string(W-A, '0') << endl;
  }

}

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

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

int i=1;
while(1){
int x=i;

if(x%3==0){
cout<<" "<<i;
}
else{
while(1){
if(x%10==3){
cout<<" "<<i;
break;
}
x/=10;
if(x==0) break;
}
}
if(++i >n) break;
}
cout<<endl;
return 0;
}



Measured memory_bytes: 3068
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>b)
		printf("a > b\n");
	if(a<b)
		printf("a < b\n");
	if(a==b)
		printf("a == b\n");
	return 0;
}

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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//
//

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}


 long long a,b,c,s,t,x,y,z;
 long long A,B,C,S,T,X,Y,Z;

 long long cnt;

 long double pi=3.14159265358979323846;

 string N,M;

unsigned long long D;

//long long mam(long long a, long long b){}

int main(){

	cin>>N;

	if(N[N.size()-1]=='s') cout<<N<<"es";
	else cout<<N<<"s";


	return 0;

}


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

void print(const vector<string> &ban) {
    int h = ban.size();
    rep(i,h) {
        cout << ban[i] << endl;
    }
}

void encode(const string &s, vector<string> &ban) {
    int n = s.length();
    int h = 1;
    rep(i,n) if (s[i] == '/') ++h;
    ban.resize(h);
    int nowh = 0;
    rep(i,n) {
        if (s[i] == '/') {
            nowh++;
            continue;
        }
        if (s[i] == 'b') {
            ban[nowh].push_back('b');
        }
        else {
            int blank = (int)(s[i]-'0');
            rep(i,blank) ban[nowh].push_back('.');
        }
    }
}

void move_ball(int a, int b, int c, int d, vector<string> &ban) {
    ban[a][b] = '.';
    ban[c][d] = 'b';
    return;
}

string decode(const vector<string> &ban) {
    int h = ban.size();
    string ret;
    rep(i,h) {
        int blank = 0;
        rep(j,ban[i].size()) {
            if (ban[i][j] == '.') blank++;
            else {
                if (blank > 0) {
                    ret.push_back((char)(blank+'0'));
                    blank = 0;
                }
                ret.push_back(ban[i][j]);
            }
        }
        if (blank > 0) ret.push_back((char)(blank+'0'));
        ret.push_back('/');
    }
    ret.pop_back();
    return ret;
}

int main() {
    while (true) {
        string s;
        cin >> s;
        if (s == "#") break;
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        --a,--b,--c,--d;
        vector<string> ban;

        encode(s,ban);
        // print(ban);
        move_ball(a,b,c,d,ban);
        // print(ban);
        string ans = decode(ban);
        cout << ans << endl;
    }
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;

template <class T> using Vec = vector<T>;

/* 定数 */
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;

#define ALL(v) v.begin(), v.end()

#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 N, M;
    cin >> N >> M;
    i32 MAX = 10;
    Vec<i32> a(N, MAX);
    bool exists = true;
    for (int i = 0; i < M; i++) {
        u32 s, c;
        cin >> s >> c;
        if (a[s - 1] == MAX) a[s - 1] = c;
        else if (a[s - 1] != c) exists = false;
    }
    if (N > 1 && a[0] == 0) exists = false;
    else if (N > 1 && a[0] == MAX) a[0] = 1;
    i32 sum = 0;
    i32 d = 1;
    for (i32 i = N - 1; i >= 0; i--) {
        if (a[i] == MAX) a[i] = 0;
        sum += a[i] * d;
        d *= 10;
    }

    if (exists) cout << sum << endl;
    else cout << -1 << endl;
}


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

int main() {
    int m, f, r;

    while(1) {
      	cin >> m >> f >> r;
        if(m==-1 && f==-1 && r==-1) break;
      
        int sum = m + f;
      
        if(m==-1 || f==-1) cout << 'F' << endl;

        else {
            if(sum>=80) cout << 'A' << endl;
            else if(65<=sum && sum<80) cout << 'B' << endl;
            else if(50<=sum && sum<65) cout << 'C' << endl;
            else if(30<=sum && sum<50 && r>=50) cout << 'C' << endl;
            else if(30<=sum && sum<50 && r<50) cout << 'D' << endl;
            else if(sum<30) cout << 'F' << endl;
        }
    }
}


Measured memory_bytes: 3064
from collections import deque


def main():
    queue = deque()
    for _ in range(int(input())):
        command = input().split()
        if len(command) == 2:
            if command[0] == 'insert':
                queue.appendleft(command[1])
            else:   # delete
                try:
                    queue.remove(command[1])
                except ValueError:
                    pass
        elif command[0] == 'deleteFirst':
            queue.popleft()
        else:   # deleteLast
            queue.pop()

    print(' '.join(queue))


if __name__ == '__main__':
    main()



Measured memory_bytes: 69736
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
		int N, M;
		cin >> N >> M;
		vector<int> P(M, 0), Y(M, 0);
		vector<int> d[N + 1];
		for ( int i = 0; i < M; i++ ) {
				cin >> P[i] >> Y[i];
				d[P[i]].push_back(Y[i]);
		}

		for ( int i = 1; i <= N; i++ ) {
				sort (d[i].begin(), d[i].end());
		}

		for ( int i = 0; i < M; i++ ) {
				printf( "%012lld\n", ll(P[i]) * 1000000 + (int)(lower_bound(d[P[i]].begin(), d[P[i]].end(), Y[i]) - d[P[i]].begin()) + 1 );
		}
		
		return 0;
}


Measured memory_bytes: 7808
class Segtree():

    def __init__(self, n):
        self.num = 1 << (n - 1).bit_length()
        self.tree = [0] * 2 * self.num
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = max(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = max(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        res = 0
        l, r = l + self.num, r + self.num
        while l < r:
            if l & 1:
                res = max(res, self.tree[l])
                l += 1
            if r & 1:
                res = max(res, self.tree[r - 1])
            l, r = l >> 1, r >> 1
        return res


n, k = map(int, input().split())
a = [int(input()) for _ in range(n)]

# 解説AC
a_max = max(a) + 1
seg_dp = Segtree(a_max)
for ai in a:
    tmp = seg_dp.query(max(ai - k, 0), min(ai + k + 1, a_max))
    seg_dp.update(ai, tmp + 1)
print(max(seg_dp.tree))


Measured memory_bytes: 138760
import math

class Point():
    def __init__(self, x=None, y=None):
        self.x = x
        self.y = y

class Vector():
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def inner_product(self, vec):
        return self.x*vec.x + self.y*vec.y

    def outer_product(self, vec):
        return self.x*vec.y - self.y*vec.x

    def norm(self):
        return math.sqrt(self.x**2 + self.y**2)

n = int(input())
points = []
for i in range(n):
    x, y = list(map(int, input().split(' ')))
    points.append(Point(x, y))
points.extend(points[0:2])

is_convex = True
for i in range(1, n+1):
    a, b, c = points[i-1:i+2]
    vec1, vec2 = Vector(a.x - b.x, a.y - b.y), Vector(c.x - b.x, c.y - b.y)
    theta = math.degrees(math.atan2(vec2.outer_product(vec1), vec2.inner_product(vec1)))
    if theta < 0:
        is_convex = False
        break

if is_convex:
    print(1)
else:
    print(0)


Measured memory_bytes: 5752
#include<bits/stdc++.h>
#define MAX 200005
using namespace std;
 
int a[30], c, d;
string s, t;

int main(){
  cin >> s >> t;
  for(int i = 0; i < 26; i++) a[i] = -1;
  for(int i = 0; i < s.size(); i++){
    c = s[i]-'a'; d = t[i]-'a';
    if(a[c] != d){
      if(a[c] == -1){
        a[c] = d;
      }else{
        puts("No");
        return 0;
      }
    }   
  }
  sort(a, a+26);
  for(int i = 0; i < 25; i++){
    if(a[i] == a[i+1] && a[i] != -1){
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}

Measured memory_bytes: 776
A=[1,2,3,4,5,6,7,8,9]
B=[1,2,3,4,5,6,7,8,9]
C=[]

N=int(input())
for a in A:
    X=N/a
    C.append(X)

for b in B:
    if b in C :
        print("Yes")
        break
    
    if (b==9) and (not b in C):
        print("No")

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


#include <iomanip>

int main()
{
	int n; cin >> n;
	vector<double> va(n);

	REP(i, n) cin >> va[i];
	sort(ALL(va));

	REP(i, n - 2)
	{
		REP(j, n - i)
			va[j] /= 2;
	}

	va[0] /= 2;
	va[1] /= 2;

	double ans = accumulate(ALL(va), (double)0);

	cout << setprecision(12) << ans << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int x,N,M,m[300],i;
	int num = 0;
	scanf("%d %d",&N,&M);
	for(i=0;i<M;i++){
		scanf("%d",&m[i]);
	}
	//num????£N/2
	x = N;
	for(;;){
		x = x/2;
		num = num + x;
		if(x == 1) break;
	}
	num = num - M;
	printf("%d\n",num);
	return 0;	
}

Measured memory_bytes: 2744
na = lambda: list(map(int, input().split()))
n = int(input())
w = [input() for _ in range(n)]

if len(set(w)) != n:
    print("No")
    exit()
for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <utility>
#include <string.h>
#include <math.h>
using namespace std;
typedef long long int ll;
const ll mod = 998244353;
const ll INF = 1e9 + 5;

int a[100];
void solve()
{
	int n, m, sum=0;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> a[i], sum+=a[i];
	sort(a, a + n, greater<int>());
	if (a[m - 1] < (sum + 4 * m - 1) / (4 * m))
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

}

int main()
{
//	int t;
//	cin >> t;
//	while(t-->0)
	solve();
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = []
for i in range(N):
    A.append(input())
B = []
for i in range(M):
    B.append(input())
isOK = False
for i in range(N - M + 1):
    if(isOK):
        break
    for j in range(N - M + 1):
        flag = True
        for k in range(M):
            if(flag == False):
                break
            for l in range(M):
                if(A[i + k][j + l] != B[k][l]):
                    flag = False
                    break
        if(flag):
            print('Yes')
            isOK = True
            break
if(isOK == False):
    print('No')

Measured memory_bytes: 3064
X, K, D = map(int, input().split())
X = abs(X)
if X - K * D >= 0:
    print(X - K * D)
    exit()
else:
    n = X // D
    x = X - n * D
    if (K - n) % 2 == 0:
        print(x)
    else:
        print(min(x + D, D - x))


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

public class hello
{

    public static void Main()
    {
        var a = new bool[1 << 15];
        GeneratePrime(a);
        var b = GeneratePrime(1 << 14);
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            getAns(a, b, n);
        }
    }

    static void getAns(bool[] a, List<int> b, int n)
    {
        var count = 0;
        for (int i = 0; i < b.Count(); i++)
        {
            if (b[i] > n / 2) break;
            if (a[n - b[i]]) count++;
        }
        Console.WriteLine(count);
    }
    static List<int> GeneratePrime(int m)
    {
        var a = new List<int>();
        int p;
        var sqrtMax = Math.Sqrt(m);
        var s = Enumerable.Range(2, m - 1).ToList();
        do
        {
            p = s.First();
            a.Add(p);
            s.RemoveAll(n => n % p == 0);
        }
        while (p < sqrtMax);
        a.AddRange(s);
        return a;
    }
    static void GeneratePrime(bool[] p)
    {
        int prime;
        var m = p.Length;
        var sqrtMax = Math.Sqrt(m);
        var searchList = Enumerable.Range(2, m - 1).ToList();
        do
        {
            prime = searchList.First();
            p[prime] = true;
            searchList.RemoveAll(n => n % prime == 0);
        }
        while (prime < sqrtMax);
        foreach (var x in searchList)
            p[x] = true;
    }
}



Measured memory_bytes: 18416
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,t,a;
  cin>>n>>t>>a;
  int ma=999999;
  int ans;
  for(int i=1;i<=n;i++){
    int s;
    cin>>s;
    if(abs(1000*t-6*s-1000*a)<ma){ans=i;ma=abs(1000*t-6*s-1000*a);}
  }
  cout<<ans;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
// #pragma GCC optimize("O2")
typedef long long int ll;
typedef long double ld;
typedef map <ll,ll> mm;
typedef vector <ll> mv;
typedef pair <ll,ll> mp;
typedef set <ll> ms;
typedef multiset <ll> mms;
typedef queue <ll> mq;
typedef deque <ll> mdq;
typedef stack <ll> mst;
typedef priority_queue <ll> mpq;
typedef priority_queue <ll, vector<ll>, greater<ll> > mmh;
typedef complex<double> cd;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flush cout.flush();
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb(v) push_back(v)
#define lb(v) lower_bound(v)
#define ub(v) upper_bound(v)
#define cn continue
#define forl(i,n) for(ll i=0;i<n;i++)
#define forlr(i,n) for(ll i=n-1;i>=0;i--)
#define rev(s) reverse(s.begin(),s.end())
void swap(ll &a,ll &b) {
	ll tmp=a;
	a=b;
	b=tmp;
}
ll atoistring(string s) {
	stringstream lol(s);
	ll x;
	lol>>x;
	return x;
}
void pv(mv v) {
	forl(i,v.size()) cout<<v[i]<<" ";
	cout<<"\n";
}
void pa(ll *v, ll size) {
	forl(i,size) cout<<v[i]<<" ";
	cout<<"\n";
}
void removeDups(mv &v) {
	sort(all(v));
	mv::iterator it = unique(v.begin(), v.end());
	v.resize(distance(v.begin(), it));
}
// ll facs[], facsinv[];
// ll nck(ll N,ll K,ll mod) {
// 	if(N<K) return 0;
// 	return (((facs[N]*facsinv[N-K])%mod)*facsinv[K])%mod;
// }
inline ld kthRoot(ld n, ll k) {
	return pow(k, (1.0 / k) * (log(n) / log(k)));
}
ll power(ll x, ll y, ll p) {
	ll res=1;
	x=x%p;
	while(y>0) {
		if(y&1) res = (res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void checkmod(ll &x, ll mod) {
	if(x>=mod) x%=mod;
}
ll ncr(ll n, ll r, ll mod) {
	ll ans = 1;
	forl(i,min(r,n - r)) {
		ans *= n - i;
		checkmod(ans,mod);
		ans *= power(i+1, mod - 2,mod);
		checkmod(ans,mod);
	}
	return ans;
}
ll sumofgp(ll a, ll n, ll m) {
	// n = number of terms - 1
	if(n < 0) return 0;
	if(n == 0) return 1;
	if(n==1) return (1+a)%m;
	ll ans;
	if(n%2) ans=(1+a)*sumofgp((a*a)%m,(n-1)/2,m);
    else ans=1+((a*(1+a))%m)*sumofgp((a*a)%m,n/2-1,m);
    return ans%m;
}
ll power_of_2_not_less(ll n) {
	if(!n) return 1;
	n--;
	n |= n>>1;
	n |= n>>2;
	n |= n>>4;
	n |= n>>8;
	n |= n>>16;
	n |= n>>32;
	n++;
	return n;
}
ll mod = 1e9 + 7;
// void checktime()
// {
// 	struct timespec ts;
// 	printf("Running Program\n");
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double st=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	// Call Funcn Here
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double en=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	printf("Program ended\nTime = %Lf\n",en-st);
// }

void thisIsMain() {
	ll n, d;
	cin>>n>>d;
	ll ans = 0;
	forl(i,n) {
		ll x, y;
		cin>>x>>y;
		if(x * x + y * y <= d * d) ans ++ ;
	}
	cout<<ans<<"\n";
}

int main(void)
{
	fastio
	ll t = 1;
	// cin>>t;
	while(t--) thisIsMain();
	return 0;
}

Measured memory_bytes: 3656
a,b,k = map(int, input().split())
ans = []
if a > b:
    a,b = b,a
for i in range(1,b+1):
    if a%i == 0 and b%i == 0:
        ans.append(i)
for i in range(k):
    p = ans.pop()
print(p)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
  int N;
  string ANS="No";;
  cin>>N;
  if(N>81)ANS="No";
  else rep(i,9)rep(j,9)if((i+1)*(j+1)==N)ANS="Yes";
  cout<<ANS<<"\n";
}

Measured memory_bytes: 256
N,M = map(int, input().split())
A = [[] for i in range(N)]
for i in range(M):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    A[a].append(b)
    A[b].append(a)

if len(A[0])+len(A[-1]) != len(set(A[0]+A[-1])):
        print("POSSIBLE")
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 51620
// Union Find Tree
// 高速にグループ分けをするデータ構造
// * 2つメンバーが所属するグループを同じグループにまとめる
// * 2つのメンバーが同じグループに所属するか判定する
//
// verifyした問題
// B - Union Find
// https://atcoder.jp/contests/atc001/tasks/unionfind_a

#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

// Union Find Tree
class UnionFindTree {
   private:
    vector<int> parent;
    vector<int> rank;
    int root(int x) { return parent[x] == x ? x : parent[x] = root(parent[x]); }
    vector<int> size;  // グループのメンバー数
   public:
    // コンストラクタ n: メンバー数
    UnionFindTree(int n) {
        parent.resize(n);
        iota(parent.begin(), parent.end(), 0);
        rank.assign(n, 0);
        size.assign(n, 1);
    }
    // メンバーxとメンバーyが同じグループに所属しているかどうかを返す
    bool same(int x, int y) { return root(x) == root(y); }
    // メンバーxとメンバーyが所属するグループを合併する
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;

        if (rank[x] < rank[y]) {
            parent[x] = y;
            size[y] += size[x];
        } else {
            parent[y] = x;
            size[x] += size[y];
            if (rank[x] == rank[y]) rank[x]++;
        }
        return true;
    }
    // メンバーxが所属するグループのサイズを返す
    int getGroupSize(int x) { return size[root(x)]; }
};

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

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

    UnionFindTree uft(n + 1);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        uft.unite(x, y);
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (uft.same(a[i], i + 1)) ans++;
    }
    
    cout << ans << endl;
}


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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

void resolve()
{
    int N;
    cin >> N;
    vector<int> h(N);
    RPT0(i, N) cin >> h[i];

    vector<int> dp(N);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    RPT(i, 2, N - 1)
    dp[i] =
        min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));

    cout << dp[N - 1] << endl;
}

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


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

int main() {

	int k, n;
	cin >> k >> n;

	int first; cin >> first;
	int prev = first, total = 0, biggest = 0;

	for(int i = 1; i < n; i++) {
		int now; cin >> now;
		int this_dist = now - prev;	
		total += this_dist;
		biggest = max(biggest, this_dist);
		prev = now;
	}

	int now = first; now += k;
	int this_dist = now - prev; 
	total += this_dist;
	biggest = max(biggest, this_dist);

	cout << total - biggest << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    string s;
    cin>>s;
    int n = s.size();
    int ans=0;
    rep(i,0,n/2-1){
        if(s[i]!=s[n-1-i]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc093/tasks/abc093_a
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
#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()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, k;
    cin >> a >> b >> k;
    set<int> st;
    if (2 * k >= b - a + 1) {
        FOR(i, a, b + 1) cout << i << "\n";
    } else {
        FOR(i, a, a + k) cout << i << "\n";
        FOR(i, b - k + 1, b + 1) cout << i << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func contains(s []int, e int) int {
	for i, v := range s {
		if e == v {
			return i
		}
	}
	return -1
}

//Main
var sc = bufio.NewScanner(os.Stdin)

const MAX = 200000 + 1

func main() {
	sc.Split(bufio.ScanWords)
	N, K := nextInt(), nextInt()
	var A [MAX]int

	for i := 1; i <= N; i++ {
		A[i] = nextInt()
	}

	if A[1] == 1 {
		fmt.Println(A[1])
		return
	}

	var stack []int
	var indx int
	line := 0
	loop := 0

	next := A[1]
	colors := make([]int, N+1)
	colors[1] = 1
	stack = append(stack, 1)
	for i := 1; i <= N; i++ {
		indx = colors[next]
		if indx == 0 {
			stack = append(stack, next)
			colors[next] = i + 1
		} else {
			line = indx - 1
			loop = i - indx + 1
			break
		}
		next = A[next]
	}

	//TLE
	// stack = append(stack, 1)
	// for i := 1; i <= N; i++ {
	// 	indx = contains(stack, next)
	// 	if indx == -1 {
	// 		stack = append(stack, next)
	// 	} else {
	// 		line = indx
	// 		loop = i - indx
	// 		break
	// 	}
	// 	next = A[next]
	// }
	if K < line {
		fmt.Println(stack[K])
	} else {
		stack = stack[line:]
		fmt.Println(stack[(K-line)%(loop)])
	}

}


Measured memory_bytes: 12832
#include <bits/stdc++.h>
//#include <unordered_map>
#define M ((ll)1e9+7)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi acos(-1)
typedef long long ll;
using namespace std;
void solve()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int j=1;
    vector<int> v;
    for(int i=0;i<n;i++)
    {
        if(a[i]==j)
        {
            v.pb(j);
            j++;
        }
    }
    if(v.size()==0)
    cout<<-1<<endl;
    else
    
    cout<<n-v.size()<<endl;
}
int main()
{
   solve();
   return 0;
}

Measured memory_bytes: 2168
def fib(n):
    if n ==0 or n == 1:
        return 1
    l = [0] * (n+1)
    l[0] = 1
    l[1] = 1

    for i in range(2,n+1):
        l[i] = l[i-2] + l[i-1]
    return l[i]

print(fib(int(input())))



Measured memory_bytes: 5600
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int n,m,a[1000];

int main()
{
	while(cin>>n>>m,n){
		rep(i,n)cin>>a[i];
		
		int t=inf, d=0, ans=-1;
		
		rep(i,n-1){
			
			for(int j=0;j*a[i]<=m;j++){
				if(t<j*a[i]||t==j*a[i]&&d<=a[i]){
					
					if(t==j*a[i]&&d==a[i])ans=n-1;
					
					goto NEXT;
				}
			}
			
			t=m/a[i]*a[i]; d=a[i];
			ans=i;
			
			NEXT:;
			
		}
		
		if(ans!=n-1){
			for(int j=0;j*a[n-1]<=m;j++){
				if(t<j*a[n-1]||t==j*a[n-1]&&d<a[n-1]){
					goto END;
				}
			}
			ans=n-1;
			END:;
		}
		
		cout<<ans+1<<endl;
	}
	
	return 0;
}

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



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

long long x[110000];

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

long long mn=1100000000;
for(int i=0; i< n-k+1;i++){
  long long  dis=min(abs(x[i])+abs(x[i]-x[i+k-1]),abs(x[i+k-1])+abs(x[i+k-1]-x[i]));
  if( mn > dis) mn=dis;
}
cout<<mn<<endl;
}


Measured memory_bytes: 1024
A=[[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
n=int(input())
for _ in range(n):
    b,f,r,v=map(int,input().split())
    A[b-1][f-1][r-1]+=v

for n,Ai in enumerate(A):
    for ai in Ai:
        for i in ai:
            print("",i,end="")
        print()
    if n==3:
        break
    print("#"*20)


Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define debug(...) #__VA_ARGS__ << ": " << __VA_ARGS__
using ii=long long;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    vector<int> dp(k + 1);
    dp[0] = 1;
    for (int i = 0; i <= k; ++i) {
        int ok = 0;
        for (int j : v) {
            if (i >= j) ok |= dp[i - j];
        }
        dp[i] = !ok;
    }
    cout << (dp[k] ? "Second" : "First") << "\n";
}


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

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    unordered_map<ll, ll> mp;
    rep(i, n){
        cin >> a[i];
        if (mp.find(a[i]) == mp.end()){
            mp[a[i]] = 1;
        }else{
            mp[a[i]] += 1;
        }
    }

    ll mp_size = mp.size();
    vector<ll> arr;
    for(auto x: mp){
        arr.push_back(x.second);
    }
    sort(arr.begin(), arr.end());
    ll ans = 0;
    for(ll i=0;i<(mp_size-k);i++){
        ans += arr[i];
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 16016
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)


int main()
{
    
  
   
    int n,b;
    scf(n),scf(b);

    int ans=(log(n)/log(b)) +1;

    prin(ans);

  }

    


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

#define int ll
#define FOR(i,n,k) for(int i=n;i<k;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int32_t main()
{
    IOS;
    int a,b,x;
    cin>>a>>b>>x;
    if(a==0) cout<<(b/x) - (a/x) + 1<<"\n";
    else if(a==1 && b==1 && x==1) cout<<"1\n";
    else if(a==1) cout<<(b/x) - (a/x)<<"\n";
    else
    {
    	a = max(0LL,a-1);
    	cout<<(b/x) - (a/x)<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
#      
import collections, atexit, math, sys, bisect 

sys.setrecursionlimit(1000000)
def getIntList():
    return list(map(int, input().split()))    

try :
    #raise ModuleNotFoundError
    import numpy
    def dprint(*args, **kwargs):
        #print(*args, **kwargs, file=sys.stderr)
        # in python 3.4 **kwargs is invalid???
        print(*args,  file=sys.stderr)
    dprint('debug mode')
except Exception:
    def dprint(*args, **kwargs):
        pass



inId = 0
outId = 0
if inId>0:
    dprint('use input', inId)
    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #标准输出重定向至文件
if outId>0:
    dprint('use output', outId)
    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #标准输出重定向至文件
    atexit.register(lambda :sys.stdout.close())     #idle 中不会执行 atexit
    
N, M = getIntList()
#print(N)

print(N+ M//2)







Measured memory_bytes: 38640
#include <bits/stdc++.h> 
 
using namespace std;
 
 template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 

int main(){
    string S;
    cin>>S;
    reverse(S.begin(),S.end());
    string str[]={"dream","dreamer","erase","eraser"};
    REP(i,4)reverse(str[i].begin(),str[i].end());
    int cnt=0;
    while(cnt<SZ(S)){
        if(cnt+7<=SZ(S)&&S.substr(cnt,7)==str[1]){
            cnt+=7;
        }else if(cnt+6<=SZ(S)&&S.substr(cnt,6)==str[3]){
            cnt+=6;
        }else if(cnt+5<=SZ(S)&&S.substr(cnt,5)==str[0]){
            cnt+=5;
        }else if(cnt+5<=SZ(S)&&S.substr(cnt,5)==str[2]){
            cnt+=5;
        }else{
            break;
        }
    }
    if(cnt==SZ(S))cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define LL long long 
#define LD long double
const int mod=1e9+7;
int sum1[300005][70],sum0[300005][70],n;
LL a[300005],er[70],ans[70];
int main()
{
	scanf("%d",&n);er[0]=1;
	for(int i=1;i<=65;i++)
		er[i]=er[i-1]*2%mod;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		LL ss=a[i];
		for(int j=0;j<=61;j++)
		{
			if(ss&1)sum1[i][j]++;
			else    sum0[i][j]++;
			ss>>=1;
		}
	}
	LL sum=0;
	for(int i=1;i<=n;i++)
	{
		LL ss=a[i];
		for(int j=0;j<=61;j++)
		{
			if(ss&1)(ans[j]+=sum0[i-1][j])%=mod;
			else (ans[j]+=sum1[i-1][j])%=mod;
			(sum1[i][j]+=sum1[i-1][j])%=mod;
			(sum0[i][j]+=sum0[i-1][j])%=mod;
			ss>>=1;
		}
	}
	for(int i=0;i<=61;i++)
		sum=(sum+ans[i]*er[i]%mod)%mod;
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 166656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  int n;
  cin >> n;

  vector<int> x(n), y(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];

    c[i] = i;
  }

  int pm = 0;
  double sum = 0;

  do {
    for (int i = 1; i < n; i++) {
      int idx1 = c[i - 1];
      int idx2 = c[i];

      int x1 = x[idx1];
      int x2 = x[idx2];
      int y1 = y[idx1];
      int y2 = y[idx2];

      double rd = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
      double d = sqrt(rd);

      sum += d;
    }
    pm++;
  } while (next_permutation(c.begin(), c.end()));

  double ans = sum / pm;

      cout << setprecision(12);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())
h_list = list(map(int, input().split()))
x_list = list(reversed(h_list))
ans = [0] * N

prev = 0
for i in range(N):
    x = x_list[i]
    if i == 0:
        prev = x
        continue
    if x >= prev:
        ans[N - (i + 1)] += ans[N - i] + 1
    else:
        ans[N - (i + 1)] = 0
    prev = x

print(max(ans))


Measured memory_bytes: 14228
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    string s;
    cin >> s;
    if(s.substr(0,4) == "YAKI") cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

typedef pair<int, int> point;

const int MAXN = 2e4 + 5;

set<point> s;
vector<int> nodes;

int n, D, comp[MAXN], x[MAXN], y[MAXN];
bool bio[MAXN];

void dfs(int v) {
	bio[v] = true;
	
	int val = x[v / 2];
	if(v & 1) val = y[v / 2];
	
	while(true) {
		
		auto it = s.lower_bound(point(val - D + 1, 0));
		if(it == s.end()) break;
		
		if((*it).second == v) it ++;
		
		if(it == s.end()) break;
		if((*it).first >= val + D) break;
		
		int w = (*it).second + 1;
		if((w & 1) == 0) w -= 2;
		
		s.erase(it);
		dfs(w);
		
	}
	
	nodes.push_back(v);
}

int cookie;
void rev_dfs(int v) {
	comp[v] = cookie;
	
	int val = y[v / 2];
	if(v % 2) val = x[v / 2];
	
	int vv = v + 1;
	if((vv & 1) == 0) vv -= 2;
	
	while(true) {
		auto it = s.lower_bound(point(val - D + 1, 0));
		
		if(it == s.end()) break;
		if((*it).second == vv) it ++;
		
		if(it == s.end()) break;
		if((*it).first >= val + D) break;
		
		int w = (*it).second;
		s.erase(it);
		rev_dfs(w);
	}
}

bool ok() {
	memset(bio, 0, sizeof bio);
	memset(comp, 0, sizeof comp);

	s.clear();
	REP(i, n) {
		s.insert(point(x[i], 2 * i)); 
		s.insert(point(y[i], 2 * i + 1)); 
	}
	nodes.clear();
	
	REP(i, n) {
		if(!bio[2 * i]) {
			s.erase(point(y[i], 2 * i + 1));
			dfs(2 * i);
		}
		if(!bio[2 * i + 1]) {
			s.erase(point(x[i], 2 * i));
			dfs(2 * i + 1);
		}
	}
	
	s.clear();
	REP(i, n) {
		s.insert(point(x[i], 2 * i)); 
		s.insert(point(y[i], 2 * i + 1)); 
	}
	
	reverse(nodes.begin(), nodes.end());
	
	cookie = 1;
	for(auto v: nodes) {
		if(!comp[v]) {
			int val = x[v / 2];
			if(v & 1) val = y[v / 2];
			
			s.erase(point(val, v));
			rev_dfs(v);
		}
		cookie ++;
	}
	
	REP(i, n) if(comp[2 * i] == comp[2 * i + 1]) return false;
	return true;
}

void solve() {
	int lo = 0, hi = 1e9;

	while(lo < hi) {
		D = (lo + hi + 1) >> 1;
		if(ok()) lo = D;
		else hi = D - 1;
	}
	cout << lo << endl;
}

int main() {
	cin >> n;
	REP(i, n) {
		cin >> x[i] >> y[i];
	}
	
	solve();
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define mp map<int,int>
#define vi vector<int>
#define M INT_MAX
#define MI INT_MIN
#define ll long long int
#define pii pair<int,int>
#define F first
#define S second
void solve()
{
	int a,b,c;
	cin>>a>>b>>c;
	a+=c;
	int diff=a-b;
	if(diff<=0)cout<<"0"<<endl;
	else
	{
		if(diff&1)
		cout<<(diff+1)/2<<endl;
		else
		cout<<(diff/2)<<endl;
	}
}
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int m=n;
  int a[9];
  int sum=0;
  for(int i=0;i<9;i++){
    a[i]=n%10;
    n/=10;
    sum+=a[i];
  }
  if(m%sum==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n,k; cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    vector<bool> dp(110000,0);

    for(int i = 0; i <= k; i++){
        for (int j = 0; j < n; j++){
            if(i-a[j] >= 0){
                bool s = dp[i];
                bool t = !dp[i-a[j]];
                s |= t;
                dp[i] = s;
            }
        }
    }
    if(dp[k]) cout << "First" << endl;
    else cout << "Second" << endl;

return 0;
}

Measured memory_bytes: 3632
#include<iostream>

int main(void){
  int num,sum=0;
  std::string str;
  while(true){
    std::cin>>str;
    if(str=="0") break;
    sum=0;
    for(int i=0;i<str.size();i++){
      num=str[i]-'0';
      sum+=num;
    }
    std::cout<<sum<<std::endl;
  }
  return 0;
}



Measured memory_bytes: 3180
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

struct Dice{
  int t, r, f;
  int top() { return t; }
  int bottom() { return 7 - t; }
  int right() { return r; }
  int left() { return 7 - r; }
  int front() { return f; }
  int back() { return 7 - f; }
  void toFront() { swap(f, t); t = 7 - t; }
  void toBack() { toFront(); toFront(); toFront(); }
  void toRight() { swap(t, r); t = 7 - t; }
  void toLeft() { toRight(); toRight(); toRight(); }
  void toClock() { swap(f, r); r = 7 - r; }
  void toConter() { toClock(); toClock(); toClock(); }
  int roll(int tt, int ff) {
    REP(i,30) {
      if (i % 10 == 0) toRight();
      else if (i % 10 == 5) toFront();
      else toClock();
      if (tt == t && ff == f) return r;
    }
    return 0;
  }
};


bool movalble(int face) {return (face==4||face==5||face==6);};
int high[256][256];
int topmap[256][256];
int ans[6];

void mydebug(){
	REP(j,256){
		REP(k,256){
			if(topmap[j][k]!=0) cout << "(" << j << "," << k << ")" << topmap[j][k] << "(high:" << high[j][k] << ") " ;
		}
	}
	cout << endl;
}

int main(){
	int n;
	while(cin >> n,n){
		REP(i,256) REP(j,256) { high[i][j] = 0; topmap[i][j] = 0;}
		REP(i,6) ans[i] = 0;
		REP(i,n){
			Dice d;
			d.t = 1; d.f = 3; d.r = 5;
			int t,f;
			cin >> t >> f;
			d.roll(t,f);
			int x = 128, y = 128;
			int nowhigh = high[x][y];
			bool isstop = false;
			for(;isstop==false;){
				int dir = 0;
				isstop = true;
				if(movalble(d.front())&&high[x-1][y]<nowhigh) dir = max(dir,d.front());
				if(movalble(d.back())&&high[x+1][y]<nowhigh) dir = max(dir,d.back());
				if(movalble(d.right())&&high[x][y+1]<nowhigh) dir = max(dir,d.right());
				if(movalble(d.left())&&high[x][y-1]<nowhigh) dir = max(dir,d.left());
				if(dir!=0&&dir==d.front()){
					d.toFront(); isstop = false; nowhigh = high[x-1][y]; x--; 
					continue;
				}
				if(dir!=0&&dir==d.back()){
					d.toBack(); isstop = false; nowhigh = high[x+1][y]; x++;
					continue;
				}
				if(dir!=0&&dir==d.right()){
					d.toRight(); isstop = false; nowhigh = high[x][y+1]; y++;
					continue;
				}
				if(dir!=0&&dir==d.left()){
					d.toLeft(); isstop = false; nowhigh = high[x][y-1]; y--;
					continue;
				}
			}
			high[x][y]++;
			if(topmap[x][y]!=0){
				if(ans[topmap[x][y]-1]!=0){
					ans[topmap[x][y]-1]--;
				}
			}
			topmap[x][y] = d.top();
			ans[d.top()-1]++;
			//mydebug();
		}
		REP(i,6){
			cout << ans[i];
			if(i!=5) cout << " ";
			else cout << endl;
		}
	}
}

Measured memory_bytes: 1676