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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int n,m;
vector<int> edge[610];
double dp[610];
const double INF=1e9;
double ans=INF;
void init()
{
    for (int i = 0; i < 610; i++)
    {
        dp[i]=INF;
    }
    dp[n]=0;
}

int main()
{
    std::cout << std::fixed;
    std::cout << std::setprecision(8);
    cin>>n>>m;
    init();
    for (int i = 0; i < m; i++)
    {
        int s,t;
        cin>>s>>t;
        edge[s].push_back(t);
    }
    for (int i = n - 1; i >= 1; i--)
    {
        int cnt=edge[i].size();
        double tmp=0;
        for (int j = 0; j < cnt; j++)
        {
            tmp+=dp[edge[i][j]]+1;
        }
        tmp/=cnt;
        dp[i]=tmp;
    }
    ans=min(ans,dp[1]);
    for (int del = n - 1; del >= 1; del--)
    {
        for (int i = n - 1; i >= 1; i--)
        {
            if(i!=del || edge[i].size()==1)
            {
                int cnt=edge[i].size();
                double tmp=0;
                for (int j = 0; j < cnt; j++)
                {
                    tmp+=dp[edge[i][j]]+1;
                }
                tmp/=cnt;
                dp[i]=tmp;
            }
            else
            {
                int cnt=edge[i].size();
                double tmp=0,mx=0;
                for (int j = 0; j < cnt; j++)
                {
                    tmp+=dp[edge[i][j]]+1;
                    mx=max(mx,dp[edge[i][j]]+1);
                }
                tmp-=mx;
                tmp/=(cnt-1);
                dp[i]=tmp;
            }
            
        }
        ans=min(ans,dp[1]);
    }
    
    
    
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#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 <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    char c;
    cin >> c;
    if ('A' <= c && c <= 'Z') cout << 'A' << endl;
    else cout << 'a' << endl;

    return 0;
}

Measured memory_bytes: 2996
S=input()
m=int(input())
for i in range(m):
    C=input().split()
    a=int(C[1])
    b=int(C[2])+1
    if C[0]=="print":
        print(S[a:b])
    elif C[0]=="reverse":
        S=S[:a]+S[b-len(S)-1:a-len(S)-1:-1]+S[b:]
        
    elif C[0]=="replace":
        S=S[:a]+C[3]+S[b:]
        

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

#ifdef LOCAL
#define i64 "%lld"
#else
#define i64 "%I64d"
#endif

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int N = 1e5 + 10;

int n, l, a[N]; 

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

    cin >> n >> l;
    forn(i,n) cin >> a[i];

    int good = -1;
    forn(i,n-1) if(a[i] + a[i+1] >= l) {
        good = i;
        break;
    }
    if (good == -1) cout << "Impossible\n";
    else {
        good++;
        cout << "Possible\n";
        for (int i = 1; i < good; i++) cout << i << '\n';
        for (int i = n-1; i >= good; i--) cout << i << '\n'; 
    }

    return 0;
}


Measured memory_bytes: 1280
n = int(input())
a = input()
b = input()
c = input()
p = 0

for i in range(n):
    if a[i] == b[i] == c[i]:
        pass
    else:
        if a[i] == b[i]:
            p += 1
        elif b[i] == c[i]:
            p += 1
        elif a[i] == c[i]:
            p += 1
        else:
            p += 2

print(p)

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

int n, m;
vector<int> et[100000];

bool visit[100000];
int ord[100000];
int lowlink[100000];
int visit_cnt[100000];
vector<bool> isKotaihen[100000];

int dfs(int p, int v, int &t) {
	visit[v] = true;
	ord[v] = t;
	lowlink[v] = t;
	t++;
	
	for (int i = 0; i < et[v].size(); i++) {
		int nv = et[v][i];
		if (!visit[nv]) {
			int l = dfs(v, nv, t);
			lowlink[v] = min(lowlink[v], l);
			visit_cnt[v]++;
		}
		else if (nv != p) {	//辺(v -> nv)は後退辺
			lowlink[v] = min(lowlink[v], ord[nv]);
			isKotaihen[v][i] = true;
		}
	}
	return lowlink[v];
}

bool isKansetu(int v) {
	if (v == 0) {	//根
		if (visit_cnt[v] >= 2) return true;
		return false;
	}
	
	for (int i = 0; i < et[v].size(); i++) {
		int nv = et[v][i];
		if (!isKotaihen[v][i] && lowlink[nv] >= ord[v]) return true;
	}
	return false;
}

int main() {
	int i;
	
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		int s, t;
		cin >> s >> t;
		et[s].push_back(t);
		et[t].push_back(s);
	}
	
	for (i = 0; i < n; i++) {
		isKotaihen[i] = vector<bool>(et[i].size(), false);
	}
	
	int t = 0;
	dfs(0, 0, t);
	
	for (i = 0; i < n; i++) {
		if (isKansetu(i)) {
			cout << i << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 11084
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    cin>>str;
    if(str=="Sunny")
        cout<<"Cloudy"<<endl;
    else if(str=="Rainy")
        cout<<"Sunny"<<endl;
    else if(str=="Cloudy")
        cout<<"Rainy"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i,a,b) for(int i=(a);i<=(b);++i)
#define FD(i,b,a) for(int i=(b);i>=(a);--i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;
constexpr int inv(LL x, int m) { return x > m ? inv(x % m, m) : x > 1 ? inv(m % x, m) * (m - m / x) % m : x; }
constexpr int mpow(LL a, LL k, int m) { int r(1); for (a %= m; k; k >>= 1, a = a * a % m) if (k & 1)r = r * a % m; return r; }

int main() {
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n - h + 1) * (n - w + 1) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>


int main(void){
    int H=1, W=1, i, j;
   
    while(1){
        scanf("%d %d\n", &H, &W);
        if(H == 0 && W == 0){
            break;
        }

        for(i = 0; i < H; i++){
             for(j = 0; j < W; j++){
                if(i == 0 || i == H-1 || j == 0 || j == W-1){
                     printf("#");
                }else{
                     printf(".");
                }
             }
            printf("\n");
        }
        
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2032
#include <iostream>
#include <queue>
using namespace std;
int main(){
	int Px[12]={-1,0,1,2,2,2,1,0,-1,-2,-2,-2};
	int Py[12]={2,2,2,1,0,-1,-2,-2,-2,-1,0,1};
	int n;
	int x,y;
	int Sx[11],Sy[11];
	
	while(cin>>x>>y){
		if(x==0 && y==0)break;
		cin>>n;
		for(int i=1;i<=n;i++)cin>>Sx[i]>>Sy[i];
		queue<int>X;
		queue<int>Y;
		queue<int>time;
		X.push(x);
		Y.push(y);
		time.push(0);
		int flag=0;
		
		while(X.empty()==0){
			if(time.front()==n){
				flag=1;
				break;
			}
			for(int i=0;i<12;i++){
				int Tx=X.front()+Px[i];
				int Ty=Y.front()+Py[i];
				int F=0;
				for(int j=-1;j<=1;j++){
					for(int k=-1;k<=1;k++){
						if(Sx[time.front()+1]+k==Tx&&Sy[time.front()+1]+j==Ty){
							X.push(Tx);
							Y.push(Ty);
							time.push(time.front()+1);
						}
					}
				}
			}
			X.pop();
			Y.pop();
			time.pop();
		}
		if(flag)cout<<"OK"<<endl;
		else cout<<"NA"<<endl;
		
	}
	
	return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define FILE "taming"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const ull ULLINF = numeric_limits<ull>::max();
const double PI = acos(-1.0);

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

    #ifdef LOCAL
        assert(freopen("input.txt", "r", stdin));// assert(freopen("output.txt", "w", stdout));
    #else
        //assert(freopen(FILE".in", "r", stdin)); assert(freopen(FILE".out", "w", stdout));
    #endif
    long long a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    long long ans = 0;
    if(2 * c < a + b) {
        long long buy = min(x, y);
        ans += buy * 2 * c;
        x -= buy;
        y -= buy;
    }
    if(2 * c < a) {
        ans += x * 2 * c;
        y -= x;
        x = 0;
        y = max(0LL, y);
    }
    if(2 * c < b) {
        ans += y * 2 * c;
        x -= y;
        y = 0;
        x = max(0LL, x);
    }
    ans += x * a + y * b;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
 
    ll n,k,i,ans=0;
    cin>>n>>k;
    for(i=k;i<=(n+1);i++)
    {
    	ll lob = (i * (i-1))/2;
    	lob %= mod;
    	ll uob = ((n * (n+1))/2) - (((n-i) * (n-i+1))/2);
    	uob %= mod;
    	ans = (ans + uob - lob + 1 + mod)%mod;
    }
    cout<<ans;
}

Measured memory_bytes: 3652
package main

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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_D&lang=jp

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n, _ := strconv.Atoi(nextLine())
	var items []int
	for i := 0; i < n; i++ {
		item, _ := strconv.Atoi(nextLine())
		items = append(items, item)
	}
	ans := solve(n, items)
	fmt.Println(ans)
}

// Longest Increasing Subsequence
func solve(n int, items []int) int {
	l := len(items)
	dp := make([]int, 1, l)
	dp[0] = items[0]
	for i := 0; i < l; i++ {
		item := items[i]
		if dp[len(dp)-1] < item {
			dp = append(dp, item)
			continue
		}
		for j, d := range dp {
			if item <= d {
				dp[j] = item
				break
			}
		}
	}
	return len(dp)
}



Measured memory_bytes: 5800
N = int(input())
A = list(map(int,input().split()))
maxa = -float('inf')
mina = float('inf')
for i,a in enumerate(A):
    if maxa < a:
        maxa = a
        maxi = i
    if mina > a:
        mina = a
        mini = i

if abs(maxa) >= abs(mina):
    print(2*N-1)
    for i in range(N):
        print(maxi+1,i+1)
    for i in range(N-1):
        print(i+1,i+2)

else:
    print(2*N-1)
    for i in range(N):
        print(mini+1,i+1)
    for i in range(N,1,-1):
        print(i,i-1)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    string S;
    cin >> S;
    string T = "hi";
    while(true) {
        if(S == T) {
            cout << "Yes" << endl;
            break;
        }
        if(T.size() >= S.size()) {
            cout << "No" << endl;
            break;
        }
        T += "hi";
    }
}

Measured memory_bytes: 256
N = int(input())

count = {}
ans = 0

for i in range(N):
    a = int(input())
    v = count.get(a,0)
    v = v+1
    if(v%2 == 0):
        ans = ans - 1
    else:
        ans = ans + 1
    count[a] = v

print(ans)

Measured memory_bytes: 15068
import heapq
n, m, s, t = map(int, input().split())
edges_yen = [[]for _ in range(n)]
edges_snuuk = [[]for _ in range(n)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    edges_yen[u-1].append((a, v-1))
    edges_yen[v-1].append((a, u-1))
    edges_snuuk[u-1].append((b, v-1))
    edges_snuuk[v-1].append((b, u-1))


def dijkstra(init_v, edges):
    next_v = [(0, init_v)]
    INF = 10**18
    dist = [INF]*n
    dist[init_v] = 0
    while next_v:
        d, v = heapq.heappop(next_v)
        if dist[v] < d:
            continue
        for d, v2 in edges[v]:
            if dist[v2] <= dist[v]+d:
                continue
            dist[v2] = dist[v]+d
            heapq.heappush(next_v, (dist[v2], v2))
    return dist


dist_yen = dijkstra(s-1, edges_yen)
dist_snuuk = dijkstra(t-1, edges_snuuk)
dist = [x+y for x, y in zip(dist_yen, dist_snuuk)]
ans = []
INF = 10**18
MIN = INF
for x in dist[::-1]:
    if x < MIN:
        MIN = x
    ans.append(MIN)
for x in ans[::-1]:
    print(10**15-x)


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

/*他人のパクリ　アスキーコードの文字から数値への変換が出来なかった*/
int main() {
	string ac;
	while (getline(cin, ac)) {
		while ((ac.find("the") == -1) && (ac.find("this")==-1) && (ac.find("that") == -1)) {
			for (int i = 0; i < ac.size(); i++) {
				if ('a' <= ac[i] && ac[i] < 'z') {
					ac[i] += 1;
				}
				else if (ac[i]=='z'){
					ac[i] = 'a';
				}
			}

		}
		cout << ac << endl;
	}
	return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  int x, n;
  cin >> x >> n;
  set <int> st;
  REP(i, n) {
	int p;
	cin >> p;
	st.insert(p);
  }
  int ans;
  for (int i = 0;; i++) {
	  if (st.count(x - i) == 0) {
		  ans = x - i;
		  break;
		}
	  if (st.count(x + i) == 0) {
		  ans = x + i;
		  break;
		}
	}
  cout << ans << endl;
  return 0;
}


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

int a[5],cnt;

int main()
{
	scanf("%d %d %d",&a[1],&a[2],&a[3]);
	sort(a+1,a+4);
	cnt+=a[3]-a[2];
	a[1]+=cnt;
	cnt+=(a[3]-a[1])/2+((a[3]-a[1])&1)*2;
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

int N, M, Q, a[50], b[50], c[50], d[50];
int ans = 0;
int nums[11];

void dfs(int cur) {
  if(cur == N + 1) {
    int p = 0;
    rep(i, Q) {
      if(nums[b[i]] - nums[a[i]] == c[i]) {
        p += d[i];
      }
    }
    chmax(ans, p);
    return;
  }

  for(int i = nums[cur - 1]; i <= M; ++i) {
    nums[cur] = i;
    dfs(cur + 1);
  }
}

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

  cin >> N >> M >> Q;
  rep(i, Q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  nums[0] = 1;
  dfs(1);

  cout << ans << endl;
}


Measured memory_bytes: 3624
fn main() {
    let mut input: String = String::new();
    let stdin = std::io::stdin();
    let _ = stdin.read_line(&mut input);
    let rgbn = input
        .trim()
        .split_whitespace()
        .map(|n| n.parse().expect("parse"))
        .collect::<Vec<u32>>();
    println!("{}", solve(rgbn[0], rgbn[1], rgbn[2], rgbn[3]));
}

fn solve(r: u32, g: u32, b: u32, n: u32) -> u32 {
    // no brain
    let mut ans = 0;
    for buy_r in 0..=(n / r) {
        for buy_g in 0..=((n - r * buy_r) / g) {
            if (n - r * buy_r - g * buy_g) % b == 0 {
                ans += 1;
            }
        }
    }
    ans
}


Measured memory_bytes: 2136
#include<bits/stdc++.h>
#define upd(a,b) a=add(a,b)
#define rdc(a,b) a=sub(a,b)
#define inv(x) power(x,Mod-2)
using namespace std;
typedef long long ll;
const int Mod=1e9+7;
int add(int a,const int b){a+=b;if(a>=Mod)a-=Mod;return a;}
int sub(int a,const int b){a-=b;if(a<0)a+=Mod;return a;}
int mul(const int a,const int b){return (ll)a*b%Mod;}
int power(int x,int cs)
{
	int ras=1;
	while(cs)
	{
		if(cs&1) ras=mul(ras,x);
		x=mul(x,x);cs>>=1;
	}
	return ras;
}
int rd()
{
	int rx=0,fx=1;char c=getchar();
	while(c<48||c>57)
	{
		if(c=='-') fx=-1;
		c=getchar();
	}
	while(c>=48&&c<=57)
	{
		rx=rx*10+c-48;
		c=getchar();
	}
	return rx*fx;
}
const int N=4050,pn=4020;
int zp[N],fp[N];
void init()
{
	int i;
	zp[0]=fp[0]=1;
	for(i=1;i<=pn;i++) zp[i]=mul(zp[i-1],i);
	fp[pn]=inv(zp[pn]);
	for(i=pn-1;i>=1;i--) fp[i]=mul(fp[i+1],i+1);
}
int C(int a,int b)
{
	if(a<0||b<0||a<b) return 0;
	return mul(zp[a],mul(fp[b],fp[a-b])); 
}
int qry(int x,int y)
{
	return sub(C(x+y,x),C(x+y,x-1));
}
int n,K,ans;
int main()
{
	init();
	scanf("%d%d",&n,&K);
	ans=qry(K-1,n-1);
	if(K<n) ans=mul(ans,power(2,n-K-1));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define MAXN 110
using namespace std;
int N,a[110],ans;
int main()
{
	while(scanf("%d",&N)!=EOF)
	{
		ans=10000000;
		for(int i=1;i<=N;i++) scanf("%d",&a[i]);
		sort(a+1,a+N+1);
		for(int j=a[1];j<=a[N];j++)
		{
			int sum=0;
			for(int i=1;i<=N;i++) sum+=(j-a[i])*(j-a[i]);
			if(sum<ans) ans=sum;
		}
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 256
import Data.List
import Data.Int (Int64)

main = do
  [n, k] <- map read . words <$> getLine
  h <- map read . words <$> getLine
  print (solve k h)

solve :: Int64 -> [Int64] -> Int64
solve k h
  = sum $ map f $ zip [0..(length h)] $ reverse $ sort h
  where
    f :: (Int, Int64) -> Int64
    f (i, num)
      | fromIntegral i < k = 0
      | otherwise = num

Measured memory_bytes: 164220
from sys import exit
A,B,C = [int(n) for n in input().split()]
# N = int(input())
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())
# exit()
if( A<= C and C <=B) or (B <= C and C <= A):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
N = list(map(int,input().split()))
n = list(map(int,input().split()))
cnt = 0
for i in range(N[0]):
	sub = list(map(int,input().split()))
	sum = 0
	for j in range(N[1]):
		sum+=n[j]*sub[j]
	sum+=N[2]
	if(sum>0):
		cnt+=1
print(cnt)

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
	int a, b, c;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if(!((a==b && a==c && b==c)||(a!=b && a!=c && b!=c))){
		printf("Yes");
	}else {
		printf("No");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
using namespace std;
const long INF=1000000000000000;
const long MOD=1000000007;

int main() {
    long N;
    cin>>N;
    
    vector<long> s(N);
    for(int i=0;i<N;i++) cin>>s.at(i);
    
    
    long m=INF;
    
    for(int i=0;i<N;i++){
        if(s.at(i)%10!=0) m=min(m,s.at(i));
    }
    long sum=accumulate(s.begin(),s.end(),0);
    cout<<(m!=INF)*(sum-(sum%10==0)*m)<<endl;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500 * i + 100 * j + 50 * k == X:
                count += 1

print(count)

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

using namespace std;

using ll = long long;

const int N = 1e5;

int n;
int t;
int a;
int h[1005];

int main()
{
    while ( cin >> n >> t >> a)
    {
        int ans = 1;
        double gap = 0.0;
        double min_gap = 0.0;
        for (int i = 1; i <= n; i++)
        {
            cin >> h[i];
            gap = abs(a - (t-0.006*h[i]));
            if (i == 1)
            {
                min_gap = gap;
            }
            else
            {
                if (gap < min_gap)
                {
                    min_gap = gap;
                    ans = i;
                }
            }
        }

        cout << ans << endl;
    }

    return 0;
}


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

int main() {
    int K, R, r;
    cin >> K >> R;

    if(10 <= K) {
        r = R;
    } else {
        r = R + 100 * (10 - K);
    }

    cout << r << endl;
}

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

using namespace std;
#define t_step 0.5

void calc_area(float *v_now, float *t_now, const vector<int> v, const vector<int> t, double *area){
  float t_next = *t_now + t_step;
  float v_max = -1;
  for(int i=0; i<t.size(); i++){
    float v_max_tmp;
    if(t_next <= t[i]) v_max_tmp = v[i+1] + (t[i] - t_next) * 1.0;
    else if(t_next >= t[i] && t_next <= t[i+1]) v_max_tmp = v[i+1];
    else v_max_tmp = v[i+1] + (t_next - t[i+1]) * 1.0;

    if(v_max == -1 || v_max_tmp <= v_max) v_max = v_max_tmp;
  }

  double area_tmp;
  if(v_max > *v_now){
    area_tmp = (*v_now + *v_now + 0.5) * t_step / 2.0;
    *v_now += 0.5;
  }
  else if(v_max == *v_now){
    area_tmp = *v_now * t_step;
    *v_now += 0.0;
  }
  else{
    area_tmp = (*v_now + *v_now - 0.5) * t_step / 2.0;
    *v_now -= 0.5;
  }

  *area += area_tmp;
  *t_now += t_step;
}

int main(){
  int N;
  cin >> N;
  vector<int> t, v;
  double area = 0.0;
  for(int i=0; i<N; i++){
    int t_;
    cin >> t_;
    t.push_back(t_);
  }
  for(int i=0; i<N; i++){
    int v_;
    cin >> v_;
    v.push_back(v_);
  }

  vector<int> t_processed(N+1), v_processed(N+2);
  t_processed[0] = 0.0;
  v_processed[0] = 0.0; v_processed[N+1] = 0.0;
  for(int i=0; i<N; i++){
    t_processed[i+1] = t_processed[i] + t[i];
    v_processed[i+1] = v[i];
  }

  float v_now = 0.0; float t_now = 0.0;
  while(t_now < t_processed[N]){
    calc_area(&v_now, &t_now, v_processed, t_processed, &area);
    // cout << t_now << ' ' << area << endl;                                                                                                                                 
  }

  cout << fixed << area << endl;

  return 0;
}


Measured memory_bytes: 256
Ss = Array.new(3) { gets.chomp }

turn = 0
pos = Array.new(3, 0)
loop do
  if pos[turn] == Ss[turn].size
    puts ('A'.ord + turn).chr
    exit
  end
  card = Ss[turn][pos[turn]]
  pos[turn] += 1
  turn = card.ord - 'a'.ord
end


Measured memory_bytes: 1788
a,b,c,d = (int(i) for i in input().split())
s = []
s.append(a)
s.append(b)
s.append(c)
s.append(d)
if 1 in s and 9 in s and 7 in s and 4 in s:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;


namespace Atcoder01
{
    /*class Program
    {
        //ABC96B
        static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = int.Parse(Console.ReadLine());
            Array.Sort(input);
            int Ans = input[0] + input[1];
            var ans = input.Max();
            for (int i = 0; i < N; i++)
            {
                ans = ans * 2;
            }
            Console.WriteLine(ans + Ans);
        }
    }*/
    //ABC94B
    class Program
    {
        static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] gate = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];
            int X = input[2];
            int cost1 = 0;
            int cost2 = 0;
            for (int i = 0;i<X;i++)
            {
                if (gate.Contains(i))
                {
                    cost1++;
                }
            }
            for (int i = X;i<= N+1;i++)
            {
                if (gate.Contains(i))
                {
                    cost2++;
                }
            }
            List<int> Answer = new List<int>();
            Answer.Add(cost1);
            Answer.Add(cost2);
            Console.WriteLine(Answer.Min());
        }
    }
}



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

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	long long sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	cout << sum - n << endl;
	return 0;
}

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

typedef long long int ll;

int main()
{
    int n,m;
    cin>>n>>m;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];

    vector<vector<int> >v(n);
    while(m--)
    {
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        bool inside = true;
        int val = arr[i];
      //  cout<<i<<endl;
        for(int j=0;j<v[i].size();j++)
        {
            if(val<=arr[v[i][j]])
            {
                inside = false;
                break;
            }
        }
        if(inside)
            {
                cnt++;
            }
    }
    cout<<cnt<<endl;
}


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

int main()
{
    int X;
    cin >> X;
    int a = 0, b = 0;
    a = X / 500;
    b =  (X - (500 * a)) / 5;
    cout << (1000 * a) + (5 * b) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int answer = 0;
		
	    Scanner scanner = new Scanner(System.in);
	    int multiples = scanner.nextInt();
	    int units = scanner.nextInt();
	    int duration = scanner.nextInt();
		
		answer = (int) Math.floor((duration / multiples) * units);
		
		System.out.println(answer);
	}

}


Measured memory_bytes: 23508
#include <stdio.h>

int main(){
	int i;
	int n;
	scanf("%d", &n);
	int R[n];
	for(i=0;i<n;i++)
		scanf("%d",&R[i]);

	int minv = R[0], maxv=R[1]-R[0];
	for(i=1;i<n;i++){

		if(maxv < R[i]-minv)
			maxv = R[i]-minv;
		if(minv > R[i])
			minv = R[i];
	}
	printf("%d\n",maxv);
	return 0;
}

Measured memory_bytes: 2632
def solve(dp,u,t,d,i,tl)
    return dp[d][i] if dp[d][i] != -1
    return dp[d][i] = 0 if d == 100
    return dp[d][i] = Float::INFINITY if u[d] < t[i]
    return dp[d][i] = [solve(dp, u, t, d+1, (i+1)%tl, tl), 1 + solve(dp, u, t, d+1, 0, tl)].min
end
loop do
    tl = gets.to_i
    break if tl == 0
    t = gets.split.map(&:to_i)
    n = gets.to_i
    u = Array.new(100, Float::INFINITY)
    n.times do
        int = gets.split.map(&:to_i)
        u[int[0] - 1] = int[1] if int[1] < u[int[0] - 1]
    end
    dp = Array.new(101).map{Array.new(33,-1)}
    puts solve(dp,u,t,0,0,tl)
end

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

long long gcd(long long a,long long b){
    if (a<b){
        swap(a,b);
    }
    if (a%b == 0){
        return b;
    }
    return gcd(a%b,b);
}

int main(){
    long long k;
    cin >> k;
    long long ans = 0;
    for (long long i = 1; i <= k; i++){
        for (long long j = 1; j <= k; j++){
            for (long long l = 1; l <= k; l++){
                ans += gcd(i,gcd(j,l));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long [] ax = new long [n];
		
		long max =0;
		long min =0;
		long sum =0;
		
		int i = 0;
		while(i<n){
			ax[i] = sc.nextLong();
			if(i==0){
				max = ax[0];
				min = ax[0];
			}
			else{
				if(max < ax[i]){
					max = ax[i];
				}
				else if(min > ax[i]){
					min = ax[i];
				}
			}
			sum += ax[i];
			i++;
		}
		
		System.out.println(min+" "+max+" "+sum);
	}
}

Measured memory_bytes: 31844
N = gets.to_i
XYs = readlines.map{|l| l.split.map(&:to_i)}

d = ->(xys){Math.hypot(*xys.inject([0, 0]){|(xs, ys), (x, y)| [xs += x, ys += y]})}
xys = XYs.sort_by{|x, y| Math.atan2(y, x)} * 2
puts [*0 ... N].product([*1 .. N]).map{|i, n| d[xys[i, n]]}.max

Measured memory_bytes: 2808
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		if(a==2||b==2) {
			System.out.println("No");
			return;
		}
		if(a==1) {
			if(b==3||b==5||b==7||b==8||b==10||b==12) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
		if(a==3) {
			if(b==5||b==7||b==8||b==10||b==12) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
		if(a==4) {
			if(b==6||b==9||b==11) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
		if(a==5) {
			if(b==7||b==8||b==10||b==12) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
		if(a==6) {
			if(b==9||b==11) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
		if(a==7) {
			if(b==8||b==10||b==12) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
		if(a==8) {
			if(b==10||b==12) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
		if(a==9) {
		if(b==11) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		}
		if(a==10) {
			if(b==12) {
			System.out.println("Yes");
		}
			else {
				System.out.println("No");
			}
		}
		if(a==11) {
			System.out.println("No");
		}
		if(a==12) {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 24916
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define lld long double
#define F first
#define S second
#define f(i,a,b) for(int i=a;i<=b;i++)
#define g(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mh make_heap
#define ph push_heap
#define pq priority_queue
#define bits(x) __builtin_popcountll(x)
#define op(x) cout<<"Case #"<<x<<": "
#define op1(x) cout<<"Scenario #"<<x<<": "
#define endl "\n"
using namespace std;
const ll mod = 1000000007;
const ll INF = LLONG_MAX;
const ll NEGINF = LLONG_MIN;
const int N = 18;
const ll MAXN = 1000001;
#define MAX 5

ll n;
ll dp[2001];

ll foo(ll sum)
{
	if (sum > n) return 0;

	if (sum == n)
	{
		return 1;
	}

	if (dp[sum] != -1) return dp[sum];

	ll res = 0;

	for (int i = 3; i <= n; i++)
	{
		res = (res % mod + foo(sum + i) % mod) % mod;
	}

	return dp[sum] = res;


}

void solve(int t)
{

	cin >> n;

	memset(dp, -1, sizeof(dp));

	cout << foo(0) % mod << endl;





}


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





	int t = 1;
	//cin >> t;



	for (int i = 1; i <= t; i++)
	{
		solve(i);

	}
}

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

#define rep(i, n) for(int i = 0; i < int(n); i++)
#define repeat(i, j, n) for(int i = int(j); i < int(n); i++)
#define all(v) begin(v), end(v)

using namespace std;

map<int, int> compress(vector<int> X) {
  map<int, int> res;
  sort(all(X));
  int cnt = 0;
  for(int x : X) {
    for(int i : {-1, 0, 1}) 
      if(not res.count(x + i)) res[x + i] = cnt++;
  }
  return res;
}

int main() {
  while(true) {
    int N; cin >> N;
    if(N == 0) break;

    vector<int> L(N), T(N), R(N), B(N);
    vector<int> X, Y;
    rep(i, N) {
      cin >> L[i] >> T[i] >> R[i] >> B[i];
      L[i] *= 2;
      T[i] *= 2;
      R[i] *= 2;
      B[i] *= 2;
    }
    L.push_back(-2);
    R.push_back(1e6 * 2 + 2);
    B.push_back(-2);
    T.push_back(1e6 * 2 + 2);
    N++;
    rep(i, N) {
      X.push_back(L[i]);
      X.push_back(R[i]);
      Y.push_back(T[i]);
      Y.push_back(B[i]);
    }
    auto map_x = compress(X);
    auto map_y = compress(Y);
    rep(i, N) {
      L[i] = map_x[L[i]];
      R[i] = map_x[R[i]];
      T[i] = map_y[T[i]];
      B[i] = map_y[B[i]];
    }

    vector<vector<int>> G(map_y.size(), vector<int>(map_x.size()));

    rep(i, N) {      
      repeat(x, L[i], R[i] + 1) G[B[i]][x] = -1;
      repeat(x, L[i], R[i] + 1) G[T[i]][x] = -1;
      repeat(y, B[i], T[i] + 1) G[y][L[i]] = -1;
      repeat(y, B[i], T[i] + 1) G[y][R[i]] = -1;
    }

    //rep(i, G.size()) {
    //rep(j, G[i].size()) cerr << G[i][j] << " ";
    //cerr << endl;
    //}
    const int dy[] = {0, 1, 0, -1};
    const int dx[] = {1, 0, -1, 0};
    function<void(int, int, int)> fill = [&] (int y, int x, int c) {
      G[y][x] = c;
      rep(i, 4) {
	int ny = y + dy[i];
	int nx = x + dx[i];
	if(0 <= ny and ny < G.size() and 0 <= nx and nx <= G[ny].size()) {
	  if(G[ny][nx] == 0) fill(ny, nx, c);
	}
      }
    };
    
    int cnt = 0;
    rep(i, G.size()) {
      rep(j, G[i].size()) if(G[i][j] == 0) fill(i, j, ++cnt);
    }

    cout << cnt - 1 << endl;
    
  }
  return 0;
}



Measured memory_bytes: 6768
#include <stdio.h>

int s[1000001];
int p[1000001];

int main(void)
{
	int i, j, k;
	int n;
	
	for (i = 0; i <= 1000000; i++){
		s[i] = 1;
	}
	s[0] = s[1] = 0;
	
	for (i = 2; i * i <= 1000000; i++){
		if (s[i] == 0) continue;
		for (j = i * i; j <= 1000000; j += i){
			s[j] = 0;
		}
	}
	k = 2;
	p[1] = 2;
	for (i = 3; i <= 1000000; i++){
		if (s[i] == 1){
			p[k] = i + p[k - 1];
			k++;
		}
	}
	
	while (scanf("%d", &n), n != 0){
		printf("%d\n", p[n]);
	}
	return (0);
}

Measured memory_bytes: 7104
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        String s = sc.nextLine();
        int idx1 = s.indexOf('A');
        int idx2 = s.lastIndexOf('Z');
        _out.println((idx2 - idx1 + 1));
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 28220
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N,M;
int32_t X[100000];
int32_t diff[100000];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (int32_t i = 0; i < N; i++)
	{
		in >> X[i];
	}
	std::sort(X, X + N);
	int64_t sum = 0;
	for (int32_t i = 0; i < N-1; i++)
	{
		sum +=  X[i];
	}
	if (sum > X[N - 1]) {
		out << "Yes" << endl;
	}
	else {
		out << "No" << endl;
	}
	return 0;
}
#endif


Measured memory_bytes: 256
import math
N=int(input())
risuto=list(map(int,input().split()))
ans=1
kari=0
if 0 in risuto:
    print(0)
else:
    for j in range(N):
        kari+=math.log10(risuto[j])

    if kari<18:
        for i in range(N):
            ans*=risuto[i]
        print(ans) 
    elif kari==18:
        for i in range(N):
            ans*=risuto[i]
        if ans>10**18:
            print(-1)
        else:
            print(ans)
    else:
        print(-1)


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

bool huiwen(int x) {
	if(x<0)
	{
		return false;
	}
	
	int tmp=x,res=0;
	while(tmp)
	{
		res=res*10+tmp%10;
		tmp=tmp/10;
	}
	return x==res;
}

int main(){
	int a,b;
	cin>>a>>b;
	int s=0;
	for(int i=a;i<=b;i++){
		if(huiwen(i)){
			s++;
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  int a,b,d,x,y,count=0;
  cin>>a>>b>>d;
  x=__gcd(a,b);
  for(int i=x;i>0;i--){
    if(x%i==0){
      count++;
      y=i;
    }
    if(count==d)
      break;
  }
  cout<<y<<endl;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void count(int &k, int &d, vi &c, vii &s, vi &t) {
  vi p(k);
  vi lastday(k);
  ll ans = 0;
  rep(i,d) {
    ll today = t[i]-1;
    p[today] += s[i][today];
    lastday[today] = i+1;
    rep(j,k) {
      p[j] -= c[j] * (i+1 - lastday[j]);
    }
    rep(j,k) ans += p[j];
  }
  cout << ans << endl;
}

int main(){
  int d;
  cin >> d;
  int k = 26;
  vi c(k);
  rep(i,k) cin >> c[i];
  vii s(d,vi(k));
  rep(i,d)rep(j,k) cin >> s[i][j];
  vi lastday(k);
  vi t(d);
  rep(i,d) {
    P mx = make_pair(0,0); // min-point, index
    rep(j,k) {
      int m_p = c[j] * ((i+1) - lastday[j]);
      m_p += s[i][j];
      chmax(mx, make_pair(m_p, j));
    }
    int today = mx.se;
    cout << today + 1 << endl;
    t[i] = today + 1;
    lastday[today] = i+1;
  }
  // count(k, d, c, s, t);
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 1e18;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
// priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
// #define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
 
ll mod = 998244353;
//ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,a,b,c,d,e,h,r,l,q;
ll k;
ll x[500005], y[500005], z[500005];
// char s[500005];
string s, t, u;

int main(){
    cin >> n >> k;
    for(ll i=0;i<n;i++){
        cin >> x[i];
        x[i] ++;
    }
    for(ll i=0;i<n;i++){
        y[i+1] = y[i] + x[i];
    }
    ll ans = 0;
    for(ll i=0;i+k<=n;i++){
        ans = max(ans, y[k + i] - y[i]);
    }
    double real = ans / 2.0;
    ps(real);

    return 0;
}


















Measured memory_bytes: 8448
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<numeric>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(lli i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	string s; cin >> s;
	char c = 'a';
	vector<vector<int>> v(26);
	rep(i, s.size()) v[s[i]-'a'].push_back(i);
	
	int ans = IINF;
	rep(i, v.size()) if(v[i].size() > 0){		
		v[i].push_back(s.size());
		irep(j, v[i].size()-1) v[i][j+1] = v[i][j+1] - v[i][j] - 1;
		ans = min(ans, *max_element(v[i].begin(), v[i].end()));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from math import gcd 
import sys
sys.setrecursionlimit(10000000)

#const
dxdy=((1,0),(0,1))
# my functions here!
def pin(type=int):
    return map(type,input().rstrip().split())


def resolve():  
    N=int(input())
    r=range(1,N+1)#スニペットのようなもの
    ans=0
    for a in r:
        for b in r:
            for c in r:
                ans+= gcd(gcd(a,b),c)#3数のGCDを一気にとる
    print(ans)
resolve()




Measured memory_bytes: 9196
#include<cstdio>
#include<cstring>
#include<algorithm>
const int N=2e5+10;
int n,m,a[N],b[N];
int read(){
	int ans=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-48;c=getchar();}
	return ans*f;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	m=read();
	for(int i=1;i<=m;i++)b[i]=read();
	if(n<m)printf("NO");
	else{
		int h=1;
		std::sort(a+1,a+1+n);std::sort(b+1,b+1+m);
		for(int i=1;i<=m;i++){
			if(h>n||a[h]>b[i]){printf("NO");return 0;}
			while(h<=n&&a[h]!=b[i])h++;
			if(h>n){printf("NO");return 0;}
			h++;
		}
		printf("YES");
	}
	return 0;
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std; 

int main(void)
{
    string a;
    cin >> a;

    if(a[2] == a[3] && a[4] == a[5]) {
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}   
/** atcoder **/


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int l, a, b, c, d,cnt=0;
	cin >> l >> a >> b >> c >> d;
	while (a>0||b>0)
	{
		a -= c;
		b -= d;
		cnt++;
	}
	cout << l - cnt << endl;
	return 0;
}

Measured memory_bytes: 2988
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int m=0;
  int ans=0;
  REP(i,N){
    int H;
    cin>>H;
    if(H>=m)ans++;
    m=max(m,H);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<utility>
#include<algorithm>
#include<iomanip>
using namespace std;

string getNumber6digit(int i)
{
	ostringstream oss;
	oss << setfill('0') << setw(6) << i;

	return oss.str();
}

string getNumber(int i, int j)
{
	return getNumber6digit(i) + getNumber6digit(j);
}

int main(void)
{
	int N, M;
	cin >> N >> M;

	vector<vector<pair<int, int>>> city(N, vector<pair<int, int>>());
	for(int i=0; i<M; i++){
		int P, Y;
		cin >> P >> Y;

		P--;

		city[P].push_back(make_pair(Y, i));
	}

	for(int i=0; i<N; i++)
		sort(city[i].begin(), city[i].end());

	vector<pair<int, int>> id(M);
	for(int i=0; i<N; i++){
		for(int j=0; j<city[i].size(); j++){
			id[city[i][j].second] = make_pair(i, j);
		}
	}

	for(int i=0; i<M; i++)
		cout << getNumber(id[i].first+1, id[i].second+1) << endl;


	return 0;
}


Measured memory_bytes: 7808
#include<iostream>
using namespace std;
int main()
{
	int n=0;
	int max=0;
	char arr[101];
	int q;
	cin>>q>>arr;
	for(int i=0;i<q;i++)
	{
		if(arr[i]=='I')
		{
			n++;
			if(n>max)
			{
				max=n;
			}
		}
		else if(arr[i]=='D')
		{
			n--;
		}
	}
	cout<<max;
}


Measured memory_bytes: 256