akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    int a,b;
    int ans = 0;
    cin >> a >> b;
    for (int i=a; i<=b; ++i)
    {
        string str = to_string(i);
        bool can = true;
        for(int j=0; j<str.size(); ++j)
        {
            if(str[j]!=str[str.size()-1-j])
            {
                can = false;
                break;
            }
        }
        if(can) ++ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String args[]){
	int a,b,c,d,e;
	Scanner in = new Scanner(System.in);
	a = in.nextInt();
	b = in.nextInt();
	c = in.nextInt();
	d = in.nextInt();
	e = in.nextInt();
	int ans = Math.min(a,Math.min(b,c)) + Math.min(d,e)-50;
	System.out.println(ans);
    }
}

Measured memory_bytes: 12000
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N,M,X;
  vector<ll> C(N);
  vector<vector<ll>> A(N, vector<ll>(M));
  
  REP(i,N) {
    cin >> C[i];
    REP(j,M)
      cin >> A[i][j];
  }
  map<int, vector<ll>> dp;
  dp[0] = {0, 0, 0, 0, 0};
  
  auto solve = [&](auto f, int val, vector<int> list) -> int {
    bool end = true;
    REP(j, M)
      if (list[j] < X) {
        end=false;
        break;
      }
    if (end)
      return 0;
    else if (val >= N)
      return 999999999;
    
    auto r = f(f, val+1, list);
    REP(j, M)
      list[j] += A[val][j];
    r = min(r, f(f, val+1, list) + (int)C[val]);
    return r;
  };

  auto res = solve(solve, 0, vector<int>(M, 0));
  return (res < 999999999 ? res : -1);
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}




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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  sort(S.begin(), S.end());
  S.erase(unique(S.begin(), S.end()), S.end());
  cout << ((N == S.size()) ? "yes" : "no") << "\n";
}

Measured memory_bytes: 3608
N, K, Q = [int(i) for i in input().split()]

cnt_dct = {}
for i in range(Q):
    A = int(input()) - 1
    cnt_dct[A] = cnt_dct.get(A, 0) + 1

for i in range(N):
    cnt = cnt_dct.get(i, 0)
    
    if K + cnt > Q:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 9060
#!/usr/bin/env python
# coding: utf-8

# In[8]:


S = input()
K = int(input())


# In[10]:


cnt = 0
ans = 0
tmp = S[0]
fcnt = 0
for s in S:
    if tmp == s:
        cnt += 1
        tmp = s
    else:
        ans += cnt//2
        if fcnt == 0:
            fcnt = cnt
        cnt = 1
        tmp = s
if fcnt == 0:
    fcnt = cnt
ans += cnt//2
ans *= K

if len(S) == fcnt:
    ans = (len(S)*K)//2
elif S[0] == S[-1]:
    ans -= (fcnt//2 + cnt//2 - (fcnt+cnt)//2) * (K-1)
print(ans)


# In[ ]:






Measured memory_bytes: 9180
import math

def main():
    N = int(input())
    A = list(map(int, input().split()))
    max_at_level = [0]*(N+1)
    total_leafs = sum(A)
    large_level = math.ceil(math.log(total_leafs, 2))
    vertices_in_layer = 1
    total_vertex_count = 0
    next_level_possible_space = 1
    for level in range(N+1):
        level_possible_space = next_level_possible_space
        leafs_in_level = A[level]
        total_leafs -= leafs_in_level
        # print(f"total_leafs: {total_leafs}, leafs_in_level: {leafs_in_level}, level_possible_space: {level_possible_space}")
        level_open_space = level_possible_space - leafs_in_level
        if level_open_space < 0:
            print(-1)
            return
        additional_vertices_in_level = min(level_open_space, total_leafs)
        total_vertex_count += leafs_in_level + additional_vertices_in_level
        next_level_possible_space = min(2*level_open_space, total_leafs)

    print(total_vertex_count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 20524
#include <stdio.h>
#define N 2000000

int A[N+1], n;

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i + 1;
}

void maxHeapify(int i){

  int l, r, largest, temp;

  l = left(i);
  r = right(i);
  if(l <= n && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= n && A[r] > A[largest]) largest = r;

  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(largest);
  }
  
}

int heapExtractMax(){

  int max;
  
  if(n < 1) printf("heap underflow\n");
  max = A[1];
  A[1] = A[n];
  n--;
  maxHeapify(1);
  return max;
}

void heapIncreaseKey(int i, int key){

  int temp;

  if(key < A[i]) printf("new key is smaller than current key\n");
  A[i] = key;
  while(i > 1 && A[parent(i)] < A[i]){
    temp = A[i];
    A[i] = A[parent(i)];
    A[parent(i)] = temp;
    i = parent(i);
  }
}

void maxHeapInsert(int key){

  n++;
  A[n] = -1;
  heapIncreaseKey(n, key);
}

int main(){

  int key;
  char str[8];

  while(1){
    scanf("%s", str);
    if(str[0] == 'e' && str[1] == 'n') break;
    if(str[0] == 'i'){
      scanf("%d", &key);
      maxHeapInsert(key);
    } else {
      printf("%d\n", heapExtractMax());
    }
  }
  
  return 0;
}

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

int main(){
    int A,B,C;
    cin >> A >> B >> C;

    if(A==B && A!=C)cout << "Yes" <<endl ;
    else if(A==C && A!=B)cout << "Yes" <<endl ;
    else if(C==B && A!=B)cout << "Yes" <<endl ;

    else cout << "No" << endl;
    
}


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

int a[100010], b[100010], x[100010], r[100010][20];

int *binary(int *seq, const int len, const int key) {
	int flag, left, mid, right;
	flag = 0; left = 0; right = len-1;
	mid = (left+right)/2;
//	printf("  %d %d %d\n", left, mid, right);
	while (left <= right && flag < 2) {
		if ((left+right)%2) {
			if (*(seq+mid) < key) left = mid + 1;
			else if (*(seq+mid) == key) { left = mid; flag++; }
			else if (*(seq+mid+1) > key) right = mid - 1;
			else if (*(seq+mid+1) == key) { right = mid; flag++; }
			else break;
		} else {
			if (*(seq+mid) < key) left = mid + 1;
			else if (*(seq+mid) > key) right = mid - 1;
			else { right = mid; flag++; }
		}
		mid = (left+right)/2;
//		printf("  %d %d %d\n", left, mid, right);
	}
	return seq+mid;
}

int main() {
	int D, from, i, j, k, L, max, N, *ptr, Q, to;
	scanf("%d", &N);
	for (i=0;i<N;i++) scanf("%d", &x[i]);
	scanf("%d%d", &L, &Q);
	for (j=0;j<Q;j++) scanf("%d%d", &a[j], &b[j]);

	for (i=0;i<N-1;i++) {
		ptr = binary(x, N, x[i]+L);
		r[i][0] = ptr-x+1;
	}
	r[N-1][0] = N+10;

	for (k=1;k<20;k++) {
		for (i=0;i<N-1;i++) {
			if (r[i][k-1] == N+10) r[i][k] = N+10;
			else r[i][k] = r[r[i][k-1]-1][k-1];
		}
		r[N-1][k] = N+10;
	}
//	for (i=0;i<N;i++) for (k=0;k<5;k++) printf("r[%d][%d] = %d\n", i, k, r[i][k]);
//	return 0;
//	printf("\n");

	for (k=0;k<20;k++) {
		if (r[0][k] == N) break;
	}
	max = k+1;

	for (j=0;j<Q;j++) {
		D = 0;
		if (a[j]>b[j]) { from = b[j]; to = a[j]; }
		else { from = a[j]; to = b[j]; }
		do {
			ptr = binary(r[from-1], max, to);
//			printf(" %d %d %d\n", from, to, *ptr);
			i = ptr-r[from-1];
			k = 1;
			while (i-->0) k *= 2;
			D += k;
			from = *ptr;
		} while (*ptr < to);
		printf("%d\n", D);
	}

	return 0;
}


Measured memory_bytes: 9728
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
  ll n,k;
  cin>>n>>k;
  k = min(n,k);
  vector<ll> v;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
  }
  sort(all(v));
  ll ans = 0;
  rep(i,0,n-k){
    ans += v[i];
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
	int n, m, c;
	int b[20];
	int a[20][20];
	cin >> n >> m >> c;
	for (int i = 0; i < m; i++)
		cin >> b[i];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++)
			cin >> a[i][j];
	}
	int sum = 0, count = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++)
			sum += a[i][j] * b[j];
		if (sum + c > 0)
			count++;
		sum = 0;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
ls = len(S)
lt = len(T)

unrestorable = 'z'*50
ans = unrestorable
for i in range(ls-lt+1):
    for j, t in enumerate(T):
        s = S[i+j]
        if s != t and s != '?':
            break
    else:
        key = (S[:i]+T+S[i+lt:]).replace('?', 'a')
        ans = min(ans, key)

print(ans if ans != unrestorable else 'UNRESTORABLE')


Measured memory_bytes: 9044
#include <cstdio>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

int main(void) {
  ll x, y;
  scanf("%lld%lld", &x, &y);
  int res = 0;
  while(x <= y) {
    ++res;
    x *= 2;
  }
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 128
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        ArrayList <Integer> a=new ArrayList<Integer>(n);
        for(int i=0;i<n;i++)
        {
            int x=sc.nextInt();
            a.add(x);
        }
        int ans=Integer.MAX_VALUE;
        for(int k=1;k<=100;k++)
        {
            int mans=0;
          for(int i=0;i<n;i++)
        {
            mans+=((a.get(i)-k)*(a.get(i)-k));
        }
            ans = Math.min(ans,mans);
        }
        
        System.out.println(ans);
	}
}


Measured memory_bytes: 21844
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextInt();
		}
		int[] ans = new int[N];
		for (int i = N; i >= 1; --i) {
			int s = 0;
			for (int j = 2 * i; j <= N; j += i) {
				s ^= ans[j - 1] % 2;
			}
			ans[i - 1] = s ^ A[i - 1];
		}
		int cnt = 0;
		for (int v : ans) {
			cnt += v;
		}
		PrintWriter pw = new PrintWriter(System.out);
		pw.println(cnt);
		int p = 0;
		for (int i = 0; i < N; ++i) {
			if (ans[i] == 0)
				continue;
			pw.print((i + 1) + (p == cnt - 1 ? "\n" : " "));
			++p;
		}
		pw.close();
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 80240
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <tuple>

using namespace std;

template< typename T >
struct edge {
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x) {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
    vector< T > dist(g.size(), numeric_limits< T >::max());
    dist[s] = 0;

    using Pi = pair< T, int >;
    priority_queue< Pi, vector< Pi >, greater< Pi > > que;
    que.emplace(dist[s], s);

    while(!que.empty()) {
        auto [cost, idx] = que.top();
        que.pop();
        if(dist[idx] < cost) continue;
        for(auto &e : g[idx]) {
            auto next_cost = cost + e.cost;
            if(dist[e.to] <= next_cost) continue;
            dist[e.to] = next_cost;
            que.emplace(dist[e.to], e.to);
        }
    }
    return dist;
}

int main(void) {
    int N, M, S;
    cin >> N >> M >> S;
    WeightedGraph<int64_t> g(2500*N);
    while(M--) {
        int U, V, A, B;
        cin >> U >> V >> A >> B;
        --U; --V;
        for(int j=0; j<2500; j++) {
            if(j < A) continue;
            g[2500*U+j].emplace_back(2500*V+j-A, B);
            g[2500*V+j].emplace_back(2500*U+j-A, B);
        }
    }
    for(int i=0; i<N; i++) {
        int C, D;
        cin >> C >> D;
        for(int j=0; j<2500; j++) {
            g[2500*i+j].emplace_back(2500*i+min(j+C,2499), D);
        }
    }

    vector<int64_t> dist = dijkstra(g, min(S, 2499));
    for(int i=1; i<N; i++) {
        int64_t ans = numeric_limits<int64_t>::max();
        for(int j=0; j<2500; j++) {
            ans = min(ans, dist[2500*i+j]);
        }
        cout << ans << endl;
    }
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 10000000000;

using namespace std;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	long long g = gcd(a, b);
	return a / g * b;
}

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

	ll all = 0;
	rep(i, n) {
		all += a[i];
	}

	ll ans = INF;
	ll now = 0;
	for (int i = 0; i < n - 1; i++) {
		now += a[i];
		all -= a[i];
		ans = min(ans, abs(all - now));
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
h, w, k = map(int, input().split())
C = []
for _ in range(h): C.append(input())
import itertools
ans = 0
for bit in range(1<<(h+w)):
    c = 0
    for i in range(h):
        for j in range(w):
            if bit>>(w+i) & 1 and bit>>j & 1: c += C[i][j] == '#'
    if c == k: ans += 1
print(ans)


Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
ll dp[2001];
ll func(ll s)
{
	if(s==0)
	return 1;
	if(s<0)
	return 0;
	if(dp[s]!=-1)
	return dp[s];
	ll temp=0;
	for(ll j=3;j<=s;j++)
	{
		temp=(temp+func(s-j))%mod;
	}
	return dp[s]=temp;
}
int main()
{
	ll s;
	cin>>s;
	ll ans;
	ll i,j;
	for(i=0;i<2001;i++)
	{
		dp[i]=-1;
    }
	ans=func(s);
	cout<<ans;
}

Measured memory_bytes: 3692
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const N = readln.chomp.to!long;

    double res = 0;
    foreach (i; 0..N) {
        const tmp = readln.split;
        auto value = tmp[0].to!double;
        if (tmp[1] == "BTC") value *= 380000;
        res += value;
    }
    writeln(res);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int Mod=1e9+7,Inv3=(Mod+1)/3;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}int n,ans,tmp;
inline int Fp(int x,int k){int ans=1;for(;k;k>>=1,x=1ll*x*x%Mod)if(k&1)ans=1ll*ans*x%Mod;return ans;}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),tmp=Fp(n,Mod-2);
	Rep(i,1,n)tmp=1ll*tmp*Inv3%Mod,ans=(ans+1ll*tmp*Fp(n-i+1,Mod-2))%Mod;
	cout<<ans<<"\n";
	return 0;
}




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

int main()
{

	int N, x, y, b, p, sum1, sum2;

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

		cin >> x >> y >> b >> p;

		sum1 = x * b + y * p;

		if( b < 5 ) { while( ++b < 5 ); }
		if( p < 2 ) { while( ++p < 2 ); }

		sum2 = ( x * b + y * p ) * 0.8;

		cout << ( sum1 < sum2 ? sum1 : sum2 ) << endl;

	}

	return 0;

}

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

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

  
  int n = count(str.begin(), str.end(), 'R');

if(n == 0){
  cout << "0" << endl;
}else if(n == 1){
  cout << "1" << endl;
}else if(n == 3 ){
  cout << "3" << endl;
}else if(n == 2){
  if(str == "RSR"){
    cout << "1" << endl;
  }else{
      cout << "2" << endl;
  }
}
  
  return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  int sum = 0;
  for (int i = A; i <= B; i++){
    int j = 1;
    for (j; true ; j *= 10){
      if (i / j == 0)
        break;
    }
    j /= 10;
    int J = j;
    int m = 0;
    for (j; j > 0; j /= 10){
      int k = (i % (j * 10) - i % j )/ j;
      int l = k * (J / j);
      m += l;
    }
    if (m - i == 0)
      sum += 1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 



int main(void){
    ll n;
    cin>>n;
    ll x = n-1;
    ll ans = 1;
    for(ll i=1;i*i<=x;i++){
        if(i==1){
            ll tmp = x/i;
            if(x!=1)ans++;
            continue;
        }
        if(x%i==0){
            ll tmp = x/i;
            if(i==tmp)ans++;
            else ans+=2;
        }
    }
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            ll t = n;
            while(t%i==0)t/=i;
            if((t-1)%i==0)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}



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

// macros
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define INT_IN(a) int a; cin >> a
#define STR_IN(s) string s; cin >> s
#define PRINTLN(s) cout << s << endl
#define PRINTDOUBLELN(s) cout << setprecision(12) << (s) << endl;

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

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

template <typename T>inline T max(vector<T> v){T max=v[0]; FOR(i, 1, v.size())max=MAX(v[i], max); return max;}
template <typename T>inline T min(vector<T> v){T min=v[0]; FOR(i, 1, v.size())min=MIN(v[i], min); return min;}
template <typename T>inline vector<T> concat(vector<T> a, vector<T> b){vector<T> ab; ab.reserve(a.size()+b.size());ab.insert(ab.end(),a.begin(),a.end());ab.insert(ab.end(),b.begin(),b.end());return ab;}

// types
typedef long long LL;

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

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

int main(){
    double r;
    cin >> r;
    PRINTLN(fixed << setprecision(12) << r * r * PI << " " << 2 * r * PI);
    return 0;
}

Measured memory_bytes: 3204
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    map<ll, ll> mp;
    rep(i, N) {
        ll A;
        cin >> A;
        mp[A]++;
    }
    ll cnt = 0;
    for(P p : mp) {
        if (p.second % 2 == 1) {
            cnt++;
        }
    }
    print(cnt);
    return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<set>
#include<queue>
#include<stack>
#include<vector>
#define rep(i,l,r) for(int i=l;i<r;i++)
using namespace std;
int main()
{
	set<int> a;
	priority_queue<int> b;
	int n,t;
	cin>>n;
	rep(i,0,n)
	{
		cin>>t;
		if(a.find(t)==a.end())
		a.insert(t);
		else
		{
			b.push(t);
			a.erase(t);
		}
	}
	long long s;
	if(!b.empty())
	{
		s=b.top();
		b.pop();
	}
	else
	s=0;
	if(!b.empty())
	{
		s*=b.top();
	}
	else
	s=0;
	cout<<s<<endl;
	return 0;
} 

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

int main() {
 string s, t;
  cin >> s >> t;
  long long a, b;
  cin >> a >> b;
  string p;
  cin >> p;
  if (p == s)
  	cout << a - 1 << ' ' << b << '\n';
  else
    cout << a << ' ' << b - 1 << '\n';
}


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

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

    vl p(m);
    vector<vector<P>> v(n+1);
    rep(i, m) {
        ll y;
        cin >> p[i] >> y;
        v[p[i]].pb(make_pair(y, i));
    }

    exrep(i, 1, n) {
        sort(all(v[i]));
    }

    vl q(m);
    exrep(i, 1, n) {
        rep(j, v[i].size()) {
            q[v[i][j].second] = j+1;
        }
    }

    rep(i, m) {
        printf("%06d%06d\n", p[i], q[i]);
    }

    re0;
}

Measured memory_bytes: 8576
#include<iostream>
using namespace std;
int main() {
	double a, b;
	while (cin >> a >> b){
		if (a < 35.5 && b < 71)cout << "AAA";
		else if (a < 37.5 && b < 77)cout << "AA";
		else if (a < 40 && b < 83)cout << "A";
		else if (a < 43 && b < 89)cout << "B";
		else if (a < 50 && b < 105)cout << "C";
		else if (a < 55 && b < 116)cout << "D";
		else if (a < 70 && b < 148)cout << "E";
		else cout << "NA";
		cout << endl;
	}
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;typedef vector<ll> vll;
int main(){
  ll n, m;
  cin >> n >> m;
  if (m == 0) {
    cout << 0 << endl;
    return 0;
  }
  vll x(n), y(n), z(n);
  for (ll i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> z[i];
  }
  vll ppp(n), ppm(n), pmm(n), pmp(n);
  for (ll i = 0; i < n; i++) {
    ppp[i] = x[i] + y[i] + z[i];
    ppm[i] = x[i] + y[i] - z[i];
    pmm[i] = x[i] - y[i] - z[i];
    pmp[i] = x[i] - y[i] + z[i];
  }
  sort(ppp.begin(), ppp.end());
  sort(ppm.begin(), ppm.end());
  sort(pmm.begin(), pmm.end());
  sort(pmp.begin(), pmp.end());
  
  vll s(8);
  for (ll i = 0; i < m; i++) {
    s[0] += ppp[n-1-i];
    s[1] += ppm[n-1-i];
    s[2] += pmm[n-1-i];
    s[3] += pmp[n-1-i];
    s[4] -= ppp[i];
    s[5] -= ppm[i];
    s[6] -= pmm[i];
    s[7] -= pmp[i];
  }
  sort(s.begin(), s.end());
  
  cout << s[7] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int n,k,mini,a[2010],sum,sum2;
vector<pair<int,int>> dot;
bool flag=1;
const long long MOD=1e9+7;
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]!=a[i-1])
			flag=0;
		for(int j=0;j<i;j++){
			if(a[j]>a[i])
				sum++;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(a[j]>a[i]){
				sum2++;
			}
		}
	}
	if(flag){
		cout<<'0'<<endl;
		return 0;
	}
	long long int ans=0,k2;
	k2=k*(k-1)/2;
	k%=MOD;
	k2%=MOD;
	ans=(sum*k%MOD+sum2*k2%MOD)%MOD;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::*;
//use std::collections::*;

#[fastout]
fn main() {
    input! {
        s: String
    }
    let mut res = 0;
    for c in s.chars() {
        if c == '1' {
            res += 1;
        }
    }
    println!("{}", res);
}

Measured memory_bytes: 2180
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main(args: Array<String>) {
    val n = readInt()
    val s = readString()

    var cond1Sum = s.count { it == 'R' }.toLong() * s.count { it == 'G' }.toLong() * s.count { it == 'B' }.toLong()
    for (i in 0 until n) {
        for (j in i + 1 until n) {
            val k = 2 * j - i
            if (k >= n) continue
            if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) cond1Sum -= 1
        }
    }
    println(cond1Sum)
}

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

int main(){
  int d,n;
  cin >> d >> n;
  int s;

  if(d==0)s=1;
  else if(d==1) s=100;
  else s=10000;

  int ans=s*n;
  if(n==100) ans+=s;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

int main(void){
  int n, k;
  std::cin >> n >> k;
  std::vector<int> a(n, 0);
  for(auto x : a) {
    int tmp;
    std::cin >> tmp;
    a[tmp - 1]++;
  }
  std::sort(a.begin(),a.end());
  int out = 0;
  for(int i = 0; i < n - k; i++) {
    out += a[i];
  }
  std::cout << out << std::endl;

}


Measured memory_bytes: 1024
#include <iostream>

int main()
{
  char A[210], S[110], T[110];
  int N;

  std::cin >> N >> S >> T;
  
  for (int i = 0; i < N; ++i)
  {
    A[2 * i] = S[i];
    A[2 * i + 1] = T[i];
  }

  A[2 * N] = '\0';

  std::cout << A << std::endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
#print(l)
l2 = list(reversed(l))
#print(l2)
#from itertools import combinations
#a = list(combinations(l, n-1))
#print(a)
from fractions import gcd
L, R = [0], [0]
for i in range(n):
    L.append(gcd(L[i],l[i]))
    R.append(gcd(R[i],l2[i]))
#print(L)
R = list(reversed(R))
#print(R)
g = []
for j in range(n):
    g.append(gcd(L[j],R[j+1]))
print(max(g))


#from functools import reduce

#def gcd_list(numbers):
#    return reduce(gcd, numbers)




Measured memory_bytes: 14052
while True:
	n = input()
	if n == 0: break
	ls = [map(int, raw_input().split())+[0] for i in range(n)]+[[0]*(n+1)]
	for row in range(n+1):
		for col in range(n):
			ls[n][col] += ls[row][col] if row != n else 0
			ls[row][n] += ls[row][col]
		print "".join(map(lambda x: str(x).rjust(5), ls[row]))

Measured memory_bytes: 4232
def main():
    n,q=map(int,input().split())
    s=input()
    td=[list(input().split()) for _ in [0]*q]
    l=0
    r=n-1
    for t,d in td[::-1]:
        if d=="R":
            if 0<=r<=n-1:
                if s[r]==t:
                    r-=1
            if n-1>=l>=1:
                if s[l-1]==t:
                    l-=1
        else:
            if n-1>=l>=0:
                if s[l]==t:
                    l+=1
            if 0<=r<=n-2:
                if s[r+1]==t:
                    r+=1
    print(max(r-l+1,0))
main()

Measured memory_bytes: 28368
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()

ans = 1
temp = 0
res = 0
for i in range(1,n+1):
    m = i
    temp = 0
    while m % 2 == 0:
        m //= 2
        temp += 1

    if temp > res:
        res = temp
        ans = i
    
print(ans)

Measured memory_bytes: 3064
n = int(input())
g = [[-1 for _ in range(n)] for _ in range(n)]

for i in range(n):
  a = int(input())
  for j in range(a):
    x,y = map(int, input().split())
    g[i][x-1] = y

ans = 0
for i in range(1 << n):
  d = [0] * n
  for j in range(n):
    if (i >> j & 1):
      d[j] = 1
  
  ok = True
  for j in range(n):
    if (d[j] == 1):
      for k in range(len(g[j])):
        if (g[j][k] == -1):
          continue
        elif (g[j][k] != d[k]):
          ok = False
  
  if (ok):
    ans = max(ans, sum(d))

print (ans)

Measured memory_bytes: 3064
from collections import defaultdict

n = int(input())

red = []
blue = []

for _ in range(n):
    a, b = map(int, input().split())
    red.append((a, b))

for _ in range(n):
    c, d = map(int, input().split())
    blue.append((c, d))

red.sort()
blue.sort()
cnt = 0

for b in blue:
    max_r_y = -1
    paired = (-1, -1)
    for r in red:
        if r[0] > b[0]:
            break
        if max_r_y < r[1] < b[1]:
            max_r_y = r[1]
            paired = r

    if paired != (-1, -1):
        red.remove(paired)
        cnt += 1

print(cnt)


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

Measured memory_bytes: 6760
import functools as ft
 
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
 
def gcd_list(numbers):
    return ft.reduce(gcd,numbers)
 
N, X = map(int, input().split(" "))
Xi = [int(a) for a in input().split()]
 
def MinusX(Xi_):
    return abs(Xi_-X)
 
def main(Xi):
    Xi = map(MinusX,Xi)
    output = gcd_list(Xi)
    print(output)
 
if __name__ == "__main__":
    main(Xi)

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

#define int long long int
#define double long double
#define pb push_back
#define fi first
#define se second
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pq priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define mem(a,k) memset(a,k,sizeof(a))
#define ub upper_bound
#define lb lower_bound
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define inf LLONG_MAX


main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	string s;
	cin>>s;
	int n=3,i,cnt=0,ans=0;
	for(i=0;i<n;i++)
	{
		if(s[i]=='R')
			cnt++;
		else
		{
			ans=max(ans,cnt);
			cnt=0;
		}
	}
	ans=max(ans,cnt);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3648
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

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

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

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

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	n := readInt()
	m := make(map[int]int)
	for i := 0; i < n; i++ {
		v := readInt()
		m[v]++
	}

	odd := 0
	even := 0
	for _, v := range m {
		if v%2 == 1 {
			odd++
		} else {
			even++
		}
	}
	ans := odd + even
	if even%2 == 1 {
		ans--
	}
	println(ans)
}


Measured memory_bytes: 6784
N=int(input())
def is_prime(N):
    is_prime=[True]*(N+1)
    is_prime[0:2]=False,False
    for i in range(int(N**0.5)+1):
        if is_prime[i]==False:
            continue
        for j in range(i*2,N+1,i):
            is_prime[j]=False
    return is_prime
def primes(N):
    prime=is_prime(N)
    return [i for i in range(N+1) if prime[i]]

p=primes(55555)
ans=[]
for i in p:
    if i%5==3:
        ans.append(i)
for i in ans[:N]:
    print(i,end=' ')

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

int main(){
    string s;
    cin>>s;
    int k;
    cin>>k;
    for(int i=0;i<k;++i){
        if(s[i]!='1'){
            cout<<s[i]<<endl;
            return 0;
        }
    }
    cout<<1<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <ctime>
#include <cassert>


using namespace std;

#define int long long

int cnt[200000];

const int mod = 998244353;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, ans = 1;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; i++)
		cin >> d[i];
	if (d[0] != 0) {
		cout << 0;
		return 0;
	}
	cnt[0] = 1;
	sort(d.begin() + 1, d.end());
	for (int i = 1; i < n; i++) {
		if (d[i] == 0) {
			cout << 0;
			return 0;
		}
		ans = ans * cnt[d[i] - 1] % mod;
		cnt[d[i]]++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int n,m,z;
    z=0;
    cin >> n >> m;
    vector<int> x(m);
    vector<int> x2(m-1);
   for(int i=0; i<m; ++i){
       cin >> x[i];
   }
   sort(x.begin(),x.end());
   
   for(int i=0; i<m-1; ++i){
       x2[i]=x[i+1]-x[i];
       
   }
    sort(x2.begin(),x2.end());

   for(int i=0; i<m-n; ++i){
       z+=x2[i];
       
   }

    cout << z << endl;





   return 0;
}



Measured memory_bytes: 1024
N=int(input())
book1={}
for i in range(1,N+1):
    string,point=input().split()
    point=int(point)
    if  string in book1.keys():
        book1[string][point]=i
    else:
        book1[string]={point:i}
for keys in sorted(book1.keys()):
    for point in sorted(book1[keys].keys(),reverse=True):
        print(book1[keys][point])

Measured memory_bytes: 3060
import sys

n = int(sys.stdin.readline())
A = [int(x) for x in sys.stdin.readline().split()]
q = int(sys.stdin.readline())
Qs = [int(x) for x in sys.stdin.readline().split()]

l = len(A)
N = 2000
dp = [False] * (N+1)
dp[0] = True

for a in A:
    tmp = dp.copy()
    for j in range(N+1):
        if j + a > N:break

        if tmp[j]:
            dp[j+a] = True

for m in Qs:
    if dp[m]:
        print("yes")
    else:
        print("no")


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

int main()
{
	ll n;cin>>n;
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		ll t = n/i;
		ans += i*t*(t+1)/2;
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
  
  int x;
  cin >> x;
  int fine;
  
  int a = x / 500;
  fine = 1000 * a;
  x = x % 500;
  int b = x / 5;
  fine = fine + 5 * b;
  cout << fine << endl;
  
  
}



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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<28);
const ll INFL = (1L<<61);
const int MAX_X = 100001;

int main() {
  int x; cin >> x;
  vl dp(MAX_X+10, 0);
  dp[0] = 1;
  rep(i,MAX_X) {
    rep(j,6) {
      dp[i+100+j] |= dp[i];
    }
  }
  cout << dp[x] << endl;
  return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int a,b;
    char op = 'a';
    while(cin >> a >> op >> b && op != '?')
    {
        if(op == '+')
        {
            cout << a + b << "\n";
        }
        else if(op == '-')
        {
            cout << a - b << "\n";
        }
        else if(op == '*')
        {
            cout << a * b << "\n";
        }
        else
        {
            cout << a / b << "\n";
        }
    }
    
    return 0;
}


Measured memory_bytes: 3088
import sys
readline = sys.stdin.readline

MOD = 10**9+7
def frac(limit):
    frac = [1]*limit
    for i in range(2,limit):
        frac[i] = i * frac[i-1]%MOD
    fraci = [None]*limit
    fraci[-1] = pow(frac[-1], MOD -2, MOD)
    for i in range(-2, -limit-1, -1):
        fraci[i] = fraci[i+1] * (limit + i + 1) % MOD
    return frac, fraci
frac, fraci = frac(1341398)
def comb(a, b):
    if not a >= b >= 0:
        return 0
    return frac[a]*fraci[b]*fraci[a-b]%MOD

N, H, D = map(int, readline().split())

M = 0
for i in range(1, N+1):
    M = (M+frac[i]) % MOD

dp = [0]*(H+2)
dp[1] = frac[N]
Dp = dp[:]

for i in range(2, H+1):
    dp[i] = M*(Dp[i-1] - Dp[max(0, i-D-1)]) % MOD
    Dp[i] = (Dp[i-1] + dp[i]) % MOD
dp[H+1] = (Dp[H] - Dp[max(0, H-D)]) % MOD
print(dp[H+1])


Measured memory_bytes: 98780
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong p) {
	int i=0;
	for(int j = 0; j < k; j++ ) {
		llong sum = 0;
		while( sum + T[i] <= p) {
			sum += T[i];
			i++;
			if(i == n ) return n;
		}
	}
	return i;
}

int solve() {
	llong left = 0;
	llong right = 100000 * 10000 + 1;
	llong mid; 
	while(left <= right) {
		mid = left + (right - left) / 2;
		int v = check(mid);
		if(v >= n) right = mid -1;
		else left = mid + 1;
	}
	return left;
}

main() {
	cin >> n >> k;
	for( int i = 0; i < n; i++) cin >> T[i];
	llong ans = solve();
	cout << ans << endl;
}

Measured memory_bytes: 3872
H, W = map(int, input().split())
s = []
for _ in range(H):
    sr = input()
    s.append(sr)
for i in range(H):
    for j in range(W):
        if s[i][j] == ".":
            continue
        if i == 0 or s[i-1][j] == "#":
            continue
        if i == H-1 or s[i+1][j] == "#":
            continue
        if j == 0 or s[i][j-1] == "#":
            continue
        if j == W-1 or s[i][j+1] == "#":
            continue
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        boolean is9x9 = false;

        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= 9; j++) {
                int multi = i * j;
                if (n == multi) {
                    is9x9 = true;
                    break;
                }
            }
        }

        if (is9x9) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

using namespace std;
#define ll long long
#define pb push_back

int main()
{	
	int n, k;
	cin >> n >> k;
	int arr[n];
	for(int i=0; i<n; i++) cin >> arr[i];
	sort(arr, arr+n);
	int prev = 0;
	vector< int > v;
	for(int i=0; i<n; ) {
		int cnt = 0;
		prev = arr[i];
		if(arr[i]==prev)
		while(arr[i]==prev) {
			cnt++;
			i++;
			if(i==n) break;
		}
		else i++;
		v.pb(cnt);
	}
	sort(v.rbegin(), v.rend());
	int sz = v.size();
	ll sum = 0;
	for(int i=k; i<sz; i++) {
		sum += v[i];
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 4964
#include<bits/stdc++.h>
#define rgi register int
#define ll long long
class fastin{
	private: int _ch,_f;
	public: template<typename _Tp> inline fastin& operator>>(_Tp&_x){
		_x=0; while(!isdigit(_ch)) _f|=(_ch==45),_ch=getchar();
		while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
		_f&&(_x=-_x,_f=0); return *this;}
	fastin() {_ch=_f=0;}
}fin;
class fastout{
	private: int _num[32],_head;
	public: int SUF; template<typename _Tp> inline fastout& operator<<(_Tp _x){
		_Tp _k; if(_x==0) {putchar('0'),putchar(SUF);return *this;} if(_x<0) putchar('-'),_x=-_x;
		while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
		while(_head>0) putchar(_num[_head]),--_head; putchar(SUF); return *this;}
	fastout() {_head=0,SUF=' ';}
}fout;
// ----------------------------
// #define int ll
using namespace std;
const int maxn=200004;
const int mod=998244353,inf=1000000007;

int n;
int a[40]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}; 
signed main()
{
	fin>>n;
	cout<<a[n-1];
	return 0;
}

// ----------------------------
// by imzzy


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] city = new int[n];
		for(int i = 0;i < n; i++) {
			city[i] = 0;
		}
		for(int i = 0; i < m; i++) {
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			city[a]++;
			city[b]++;
		}
		for(int i:city) {
			System.out.println(i);
		}
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef vector<int> vnt;

lli n;
vnt a;
lli d;
long long sum;
lli t;
lli k;
lli s;

int main(){
	cin >> n;
	a = vnt(n);
	for(int i = 0;i < n;i++)
		cin >> a[i];
	for(int i = 0;i < n;i++)
		sum += a[i];
	t = n*(n+1)/2;
	if(sum%t != 0){
		cout << "NO" << endl;
		return 0;
	}
	s = k = sum / t;
	for(int i = 0;i < n;i++){
		int d = a[i] - a[(i+1)%n] + k;
		if(d < 0){
			cout << "NO" << endl;
			return 0;
		}
		if(d % n != 0){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

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

// varibable settings {{{
#define infile "../test/sample-1.in"
#define int long long
const int INF=1e18;
const int MOD=1e9+7;
// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  vector<int> s(n);
  rep(i, n) {
    cin>>s[i];
  }

  int res = 0;
  rep(k, 1, n-2){
    int i = 0;
    int j = n-1;
    int ans = 0;
    set<int> S;
    while(j>=k){
      if (S.find(i) == S.end()){ S.insert(i); }
      else break;
      if (S.find(j) == S.end()){ S.insert(j); }
      else break;

      ans += s[i]+s[j];
      chmax(res, ans);
      i += k;
      j -= k;
    }
  }
  cout << res << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 5760