akhauriyash/Code-Regression huggingface dataset:
from collections import deque

X = int(input())
N = 10**5+4
N_sq=N**(1/2)

check = deque(range(2,N+1))
search = deque([])

for n in range(N):
    if len(check)<=0:
        break
        
    c = check.popleft()
    search.append(c)

    check = deque([ _ for _ in check if _%c != 0])
    
    if c > N_sq:
        search.extend(check)
        break
        
for s in search:
    if X <= s:
        print(s)
        break


Measured memory_bytes: 80300
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <queue>
#include <cmath>
#include <cfloat>
#include <set>
#include <map>

// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, n);
	auto ok = [&](string s) {
		bool res = true;
		for (int i=0; i<s.size()-1; ++i){
			res &= (s[i] == s[i+1]);
		}
		return res;
	};
	
	for (int i=n; i<1000; ++i) {
		if (ok(to_string(i))) {
			OUT(i)BR;
			return 0;
		}
	}
  
  return 0;
}


Measured memory_bytes: 256
if __name__ == "__main__":
    v = map( int, raw_input().split())
    a = v[0]
    b = v[1]

    d = a / b
    r = a - ( d * b )
    s = (0.0 + a) / b
    print "{0:d} {1:d} {2:.5f}".format( d, r, s)

Measured memory_bytes: 4228
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String w = scan.nextLine();
		String[] wArray = new String[w.length()];
		
		for(int i = 0; i < w.length(); i++) {
			wArray[i] = w.substring(i, i + 1);
		}
		
		List<String> wList = new ArrayList<String>(Arrays.asList(wArray));
		List<String> wHashList = new ArrayList<String>(new HashSet<>(wList));
		int sum = 0;
		
		for(int i = 0; i < wHashList.size(); i++) {
			for(int j = 0; j < w.length(); j++) {
				if(wHashList.get(i).equals(w.substring(j, j + 1))) {
					sum++;
				}
			}
			if(sum % 2 == 1) {
				break;
			} else {
				sum = 0;
			}
		}
		
		if(sum % 2 == 1) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
		
		scan.close();
	}

}


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

int main() {
	// your code goes here
    int n,k;
    cin >> n >> k;
    int dp[n];
    for (int i = 0; i < n;i++) {
        dp[i] = INT_MAX;
    }
    int h[n];
    for (int i = 0; i < n;i++) {
        cin >> h[i];
    }
    for (int i = 0; i < min (k,n);i++) {
        dp[i] = abs (h[i] - h[0]);
    }
    //dp[1] = abs (h[1] - h[0]);
    //dp[0] = 0;
    for (int i = k; i < n;i++) {
        for (int j = max (i - k,0);j <= i;j++)
            dp[i] = min (dp[j] + abs(h[i] - h[j]),dp[i]);
    }
    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 4344
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main()
{
    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2])
        cout << "No";
    else
    {
        cout << "Yes";
    }
    
}

Measured memory_bytes: 888
N,M=map(int,input().split())
AB=[]
for _ in range(N):
    AB.append(list(map(int,input().split())))
AB.sort()
ans=0
n=0

while M>0:
    ans+=AB[n][0]*AB[n][1]
    M-=AB[n][1]
    if M<0:
        ans+=M*AB[n][0]
    n+=1
    
print(ans)

Measured memory_bytes: 27760
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ss second
#define ff first
#define mk make_pair
#define vec vector<int> 
#define finput ifstream cin;cin.open("in.txt")
#define foutput ofstream cout;cout.open("out.txt") 

int main(){
	//finput;
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int t=n/2;
	int a1[t],a2[t];
	for(int i=0;i<t;i++){
		a1[i]=a[2*i];
	}
	for(int i=0;i<t;i++){
		a2[i]=a[2*i+1];
	}
	sort(a1,a1+t);
	sort(a2,a2+t);
	int count=0,i=0,temp,mx1=0,ans=0,mx2=0,val1=0,val2=0;
	while(i<t){
		temp=a1[i];
		while(temp==a1[i]){
			count++;
			i++;
		}
		if(count>mx2){
			mx1=mx2;
			mx2=count;
			val1=val2;
			val2=temp;
		}
		else if(count<=mx2 && count>mx1){
			mx1=count;
			val1=temp;
		}
		count=0;
	}
	count=0,i=0,temp;
	int mx3=0,mx4=0,val3=0,val4=0;
	while(i<t){
		temp=a2[i];
		//cout<<temp<<endl;
		while(temp==a2[i]){
			count++;
			i++;
		}
		if(count>mx4){
			mx3=mx4;
			mx4=count;
			val3=val4;
			val4=temp;
		}
		else if(count<=mx4 && count>mx3){
			mx3=count;
			val3=temp;
		}
		count=0;
		//cout<<val3<<endl;
	}
	//cout<<val3<<" "<<val4<<endl;
	if(val2!=val4){
		cout<<n-mx2-mx4;
	}
	else{
		cout<<min(n-mx2-mx3,n-mx4-mx1);
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 99999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;

int main() {
  int n, d;
  int cnt = 0;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> x[i][j];
    }
  }

  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      int dis = 0;
      for (int k = 0; k < d; k++)
        dis += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);

      bool flag = false;
      for (int k = 1; k <= dis; k++) {
        if (k * k == dis) flag = true;
      }

      if (flag) cnt++;
    }
  }

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


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<algorithm>
using namespace std;
int st[4];
string st1;
int shu;
int main()
{
cin>>st1;
for(int i=0; i<4; i++)st[i]=int(st1[i])-48;
shu=st[0];
for(int i=1; i<=2; i++)
{
    if(i==1)shu+=st[1];
    else shu-=st[1];
    for(int j=1; j<=2; j++)
    {
        if(j==1)shu+=st[2]; 
        else shu-=st[2];
        for(int k=1; k<=2; k++)
        {
            if(k==1)shu+=st[3];
            else shu-=st[3];
            if(shu==7)
            {
                cout<<st[0]; 
                if(i==1)cout<<'+';
                else cout<<'-'; 
                cout<<st[1]; 
                if(j==1)cout<<'+'; 
                else cout<<'-'; 
                cout<<st[2]; 
                if(k==1)cout<<'+'; 
                else cout<<'-'; 
                cout<<st[3]; 
                cout<<"=7"; 
                cout<<endl; 
                return 0; 
            }
            if(k==1)shu-=st[3];
            else shu+=st[3]; 
        }
        if(j==1)shu-=st[2];
        else shu+=st[2]; 
    }
    if(i==1)shu-=st[1];
    else shu+=st[1];//恢复原样 
}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>

using namespace std;

long long N;

int main()
{
    cin >> N;
    vector<long long> a;
    vector<pair<double, long long> > b;

    double sum = 0;
    for (int i = 0; i < N;i++)
    {
        long long t;
        cin >> t;
        sum += t;
        a.push_back(t);
    }

    double ave = sum / N;
    int ans = 0;
    double min_dif = 1000000000;
    for (int i = 0; i < N; i++)
    {
        double dif = abs(a[i] - ave);
        if(min_dif > dif)
        {
            min_dif = dif;
            ans = i;
        }
    }

    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>

int main(void)
{
    int a, b;
    char op;

    while (1) {
        scanf("%d %c %d", &a, &op, &b);
        if (op == '?')
            break;
        else if (op == '+')
            printf("%d\n", a + b);
        else if (op == '-')
            printf("%d\n", a - b);
        else if (op == '*')
            printf("%d\n", a * b);
        else if (op == '/')
            printf("%d\n", a / b);
    }

    return 0;
}


Measured memory_bytes: 2140
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		long[] a = new long[N+2];
		long sum = 0;
		a[0]=0;
		for (int i = 1; i <= N; i++) a[i] = I.nextLong();
		a[N+1]=0;
		for (int i = 1; i < N+2; i++) {
			sum+=Math.abs(a[i]-a[i-1]);
		}
		for (int rm = 1; rm <= N; rm++) {
			long cursum = sum;
			cursum-=Math.abs(a[rm]-a[rm-1]);
			cursum-=Math.abs(a[rm]-a[rm+1]);
			cursum+=Math.abs(a[rm-1]-a[rm+1]);
			O.pln(cursum);
		}
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 53964
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 200000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	ll cost;
	edge(int _t, ll _cost) : t(_t)
		, cost(_cost) {
	}
};
bool isPrime(int n) {

	if (n == 1) return false;
	for (ll i = 2; i * i <= n; i++)
	{
		if (n % i == 0) return false;
	}
	return true;
}
int anyDigitSum(int n) {
	int res = 0;
	while (n > 0)
	{
		res += n % 10;
		n /= 10;
	}
	return res;
}

void Solve() {

	int h, w,a,b;
	cin >> h >> w >> a >> b;
	COMinit();

	ll res = 0;
	for (int i = b; i < w; i++)
	{
		res += (COM(h - (a + 1) + i,i) * COM((a - 1) + w - (i + 1), a - 1)) % MOD;
		res %= MOD;
	}
	cout << res << endl;
}
int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 4992
#include <iostream>

using namespace std;

double compute_e(int n, int m, int v[], double r[]) {
    double e = 0;
    double normalizing = 0;
    for (int i = 0; i < m; ++i) {
        e += v[i] * r[i];
        normalizing += r[i];
    }
    e /= normalizing;
    return e;
}

int main() {
    int t, n, m, p, q;
    int v[100];
    double r[100];
    double e_leader = 0;
    double e_max = -1;
    cin >> t;
    for (int i = 0; i < t; ++i) {
        cin >> n >> m;
        for (int j = 0; j < m; ++j) {
            cin >> v[j] >> r[j];
        }
        e_max = max(e_max, compute_e(n, m, v, r));
    }
    cin >> p >> q;
    for (int i = 0; i < q; ++i) {
        cin >> v[i] >> r[i];
    }
    e_leader = compute_e(p, q, v, r);
    if (e_max > e_leader + 0.0000001) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << " = " << x << endl;
#define debugV(x,n) for(int i = 0;i < n;i++) cerr << x[i] << " "; cerr<<endl;
#define rep(i,a,b) for(int i = (int)a;i < (int)b;i++)
#define F first
#define S second
#define pb push_back
typedef pair<int,int> ii;
typedef long long int ll;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-5;

int v[(int)(2*1e5+3)],pd[(int)(2*1e5+3)];
int n;
bool ok;

ll solve(int i, int a)
{
	if(i==n)
		return 0;
	if(pd[i]!=-1)
		return pd[i];
	ll ans=0;
	if(v[i]==a+1)
		ans=solve(i+1,v[i])+1;
	ans=max(ans,solve(i+1,a));
	return pd[i]=ans;
}
int main(){
	cin>>n;
	rep(i,0,n)
		cin>>v[i];
	
	ok=false;
	ll ans=0;
	memset(pd,-1,sizeof pd);
	rep(i,0,n)
	{
		if(v[i]==1){
			ok=true;
			ans=max(solve(i+1,1)+1,ans);
		}
	}
	//debug(ans)
	if(!ok)
		puts("-1");
	else
		printf("%lld\n",n-ans);

	return 0;
}

Measured memory_bytes: 11264
<?php
/**
 * AGC034
 * A - Kenken Race
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

fscanf(STDIN, "%d %d %d %d %d", $n, $a, $b, $c, $d);
$s = trim(fgets(STDIN));

$dp_funuke[$b - 1] = true;
$dp_funuke[$b] = true;
for ($i = $b + 1; $i <= $d; $i++) {
    if (($s[$i - 1] ?? '#') !== '.') {
        $dp_funuke[$i] = false;
        continue;
    }
    $dp_funuke[$i] = ($dp_funuke[$i - 1] or $dp_funuke[$i - 2]);
}

if (! $dp_funuke[$d]) {
    echo 'No', PHP_EOL;
    exit;
}

$dp_sunuke[$a - 1] = true;
$dp_sunuke[$a] = true;
for ($i = $a + 1; $i <= $c; $i++) {
    if (($s[$i - 1] ?? '#') !== '.') {
        $dp_sunuke[$i] = false;
        continue;
    }
    $dp_sunuke[$i] = ($dp_sunuke[$i - 1] or $dp_sunuke[$i - 2]);
}

if (! $dp_sunuke[$c]) {
    echo 'No', PHP_EOL;
    exit;
}

/*
if (! is_reachable($b, $d, $s) || is_reachable($a, $c, $s)) {
    echo 'No', PHP_EOL;
    exit;
}
*/

if ($c > $d) {
    $no_flag = true;
    for ($i = max($a, $b); $i <= min($c, $d); $i++) {
        if (($s[$i - 2] ?? '#') === '.' and $s[$i - 1] === '.' and ($s[$i] ?? '#') === '.') {
            $no_flag = false;
            break;
        }
    }
    if ($no_flag) {
        echo 'No', PHP_EOL;
        exit;
    } 
}

echo 'Yes', PHP_EOL;

/*
function is_reachable($start, $end, $s) {
    for ($i = $start; $i <= $end; $i++) {
        if ($s[$i] === '#' and $s[$i + 1] === '#') {
            return false;
        }
    }
    return true;
}*/


Measured memory_bytes: 17656
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main() {
	string s; cin >> s;
	map<int, int> cnt;
	cnt[0] = 1;
	int now = 0;
	int p = 1;
	for (int i = s.length() - 1; i >= 0; --i) {
		int d = s[i] - '0';
		now = (now + p * d) % 2019;
		p = p * 10 % 2019;
		++cnt[now];
	}
	ll res = 0;
	for (auto& e : cnt)
		res += (ll)e.second * (e.second - 1LL) / 2;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  string s;
  cin >> s;
  int c = 0, len = s.length();
  REP(i, len / 2) {
    if (s[i] != s[len - i - 1]) c++;
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n);++i)
const int INF =1001001001;
using ll=long long;
using P = pair<int,int>;
using Graph =vector<string>;
Graph field;
queue<P> q;

int main() {
  ll n,a,b,c,d;
  a=0;
  b=0;
  c=0;
  d=0;
  cin>>n;
  rep(i,n){
    string ab;
    cin>>ab;
    if(ab=="AC"){
      a++;
    }
    if(ab=="WA"){
      b++;
    }
    if(ab=="TLE"){
      c++;
    }
    if(ab=="RE"){
      d++;
    }
  }
  cout<<"AC x "<<a<<endl;
  cout<<"WA x "<<b<<endl;
  cout<<"TLE x "<<c<<endl;
  cout<<"RE x "<<d<<endl;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

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

  int n;
  cin >> n;
  const auto x = 800 * n;
  const int y = 200 * (n / 15);
  cout << x - y << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){

int n;
cin>>n;
int num[4][3][10] = {};
for(int i=0;i<n;i++){
int b, f, r, v;
cin>>b>>f>>r>>v;
num[b-1][f-1][r-1] += v;
}

for(int i=0;i<4;i++){
if(i) cout<<"####################"<<endl;

for(int j=0;j<3;j++){
for(int k=0;k<10;k++){
cout<<" "<<num[i][j][k];
}
cout<<endl;
}
}

return 0;
}


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

int main()
{
        int a,b,c;
        int sum;
	cin>>a>>b>>c;
	sum=b/a;
	if(sum>c)
                printf("%d\n",c);
        else
                printf("%d\n",sum);
        return 0;
}


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

public class Main{
    public static void main(String[] args) {
        int i,sum,ave,j=0;
        int d[] = new int[1000];
        String c[] = new String[100];
    try{  BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        while(true){
        String line = in.readLine();
        int b = Integer.parseInt(line);
        if(b==0){
            break;
        }
        sum = 0;
        int a[] = new int[b];
      for(i=0;i<b;i++){
         c[i] = in.readLine();
         a[i] = Integer.parseInt(c[i]);
      }
     Arrays.sort(a);
      for(i=1;i<b-1;i++){
         sum += a[i];
      }
      ave = sum/(b-2);
      d[j] = ave;
      j++;
    }
    for(i=0;i<j;i++){
        System.out.println(d[i]);
    }
    } catch(IOException e) {
        System.out.println(e);
    } catch(NumberFormatException e){
        System.out.println(e);
    }
    }
  }
  



Measured memory_bytes: 24440
N,K = map(int,input().split())
A = list(map(int,input().split()))
pos = 0
visit = [0] * N
move = []
roop = []
while visit[pos]!=2:
    if visit[pos]==0:
        move.append(pos)
    else:
        roop.append(pos)
    visit[pos] += 1
    pos = A[pos] - 1
if len(move)>K:
    print(move[K]+1)
else:
    print(roop[(K-(len(move)-len(roop)))%len(roop)]+1)

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF =1000000000000000;

string search8(int p,int q,int r,int s){
  string x = "";
  string smp = "";
  if(p + q + r + s == 7)smp="+++";
  if(p + q + r - s == 7)smp="++-";
  if(p + q - r + s == 7)smp="+-+";
  if(p + q - r - s == 7)smp="+--";
  if(p - q + r + s == 7)smp="-++";
  if(p - q + r - s == 7)smp="-+-";
  if(p - q - r + s == 7)smp="--+";
  if(p - q - r - s == 7)smp="---";
  
  x+=to_string(p);
  x+=smp.at(0);
  x+=to_string(q);
  x+=smp.at(1);
  x+=to_string(r);
  x+=smp.at(2);
  x+=to_string(s);
  x+="=7";
    
  return x;
}

int main(){
  char x1,x2,x3,x4;
  cin >> x1 >> x2 >> x3 >> x4;
  
  int a = x1-'0';
  int b = x2-'0';
  int c = x3-'0';
  int d = x4-'0';
  
  cout << search8(a,b,c,d) << endl;
}


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 bit = 0;
        for(int i = 0; i<N; i++) {
            bit |= sc.nextInt();
        }
        System.out.println(Integer.numberOfTrailingZeros(bit));
    }



}


Measured memory_bytes: 21844
h,w=map(int,input().split())
s=[["."]*(w+2)]
for i in range(h):
  temp=list(map(str,input()))
  temp.insert(0,".")
  temp.append(".")
  s.append(temp)
s.append(["."]*(w+2))
count=0
for i in range(1,h+1):
  for j in range(1,w+1):
    if s[i][j]=="#":
      if s[i+1][j]=="." and s[i-1][j]=="." and s[i][j+1]=="." and s[i][j-1]==".":
        count=count+1
if count>0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
	int q=0;char ch=' ';
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q;
}
typedef long long LL;
const int N=100005;
int n,ans,a[N],b[N];
int main()
{
	n=read();
	for(RI i=1;i<=n;++i) a[i]=b[i]=read();
	sort(b+1,b+1+n);
	for(RI i=1;i<=n;++i) {
		a[i]=lower_bound(b+1,b+1+n,a[i])-b;
		if(abs(i-a[i])&1) ++ans;
	}
	printf("%d\n",ans/2);
	return 0;
}
//必要性：一个元素离目标位置的距离奇偶性不会变
//充分性：将1挪回去，再将2挪回去......

Measured memory_bytes: 1024
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int a=0;
    cin>>s;
    rep(i,3){
        if(s[i]=='R')a++;
    }
    if(s[0]==s[2]&&a==2){
        a=1;
    }
    cout<<a<<"\n";
}



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

class Program{
    static void Main(){
        (long h, long w) = OdamaKit.Cin<long, long>();
        
        Console.WriteLine(h*w);
        return;
    }

    
}
static class OdamaKit
{
    public static List<T> Initialize<T>(this List<T> list, T value){
        for(int i=0; i<list.Capacity; ++i) list.Add(value);
        return list;
    }
    public static List<List<T>> InitializeByList<T>(this List<List<T>> lists){
        for(int i=0; i<lists.Capacity; ++i) lists.Add(new List<T>());
        return lists;
    }
    private static Queue<string> InputLine()
    {
        var inputLine = new Queue<string>();
        foreach(var s in Console.ReadLine().Split(' ')){
            inputLine.Enqueue(s);
        }
        return inputLine;
    }
    private static object Match<T>(string s){
        object a = default(T) as object;
        return a switch
        {
            long _=> long.Parse(s),
            double _=> double.Parse(s),
            string _=> s,
            int _=> int.Parse(s),
            float _=> float.Parse(s),
            _=> s
        };
    }
    public static T Cin<T>(){
        var line = InputLine();
        return (T)Match<T>(line.Dequeue());
    }
    public static (T1, T2) Cin<T1, T2>(){
        var line = InputLine();
        return ((T1)Match<T1>(line.Dequeue()), (T2)Match<T2>(line.Dequeue()));
    }
    public static (T1, T2, T3) Cin<T1, T2, T3>(){
        var line = InputLine();
        return ((T1)Match<T1>(line.Dequeue()), (T2)Match<T2>(line.Dequeue()), (T3)Match<T3>(line.Dequeue()));
    }
    public static (T1, T2, T3, T4) Cin<T1, T2, T3, T4>(){
        var line = InputLine();
        return ((T1)Match<T1>(line.Dequeue()), (T2)Match<T2>(line.Dequeue()), (T3)Match<T3>(line.Dequeue()), (T4)Match<T4>(line.Dequeue()));
    }
    public static Queue<string> Cin<T>(out T a){
        a = default(T);
        var line = InputLine();
        a = (T)Match<T>(line.Dequeue());
        return line;
    }
    public static Queue<string> Cin<T>(this Queue<string> line, out T a){
        a = default(T);
        a = (T)Match<T>(line.Dequeue());
        return line;
    }
}


Measured memory_bytes: 27916
def resolve():
    a = [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]
    k = int(input())
    print(a[k-1])

resolve()


Measured memory_bytes: 2940
def resolve():
    N, K = list(map(int, input().split()))
    TD = sorted([list(map(int, input().split())) for _ in range(N)], reverse=True, key=lambda x: x[1])
    eat_types = set()
    eat_dups = []
    total = 0
    for i in range(K):
        typ, point = TD[i]
        total += point
        if typ in eat_types:
            eat_dups.append(TD[i])
        else:
            eat_types.add(typ)
    ans = total + len(eat_types)**2

    didx = len(eat_dups)-1
    for i in range(K, N):
        typ, point = TD[i]
        if typ in eat_types:
            continue
        if didx < 0:
            break
        total -= eat_dups[didx][1]
        total += point
        didx -= 1
        eat_types.add(typ)
        ans = max(ans, total+len(eat_types)**2)
    print(ans)
    
    
    
    

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 30116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll a,b; cin >> a >> b;
    ll ans=(a*b)/2;
    if(a%2==1 && b%2==1) ans++;
    if(a==1 || b==1) ans=1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[][] max = new int[2][2];
    int tmp;
    int N = sc.nextInt();
    for (int i = 0; i < N; i++) {
      tmp = sc.nextInt();
      if (max[0][0] < tmp) {
        max[0][0] = tmp;
        max[0][1] = i;
      } else if (max[1][0] < tmp) {
        max[1][0] = tmp;
        max[1][1] = i;
      }
    }
    for (int i = 0; i < N; i++)
      if (i == max[0][1])
	    System.out.println(max[1][0]);
      else
        System.out.println(max[0][0]);
  }
}

Measured memory_bytes: 83192
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int PS(int x) {
  int a=1;
  repl(i,0,x) {
    a*=100;
  }
  return a;
}
int main() {
  int D;
  int N;
  cin >>D>>N;
  
  int g=PS(D);
  if(N<=99) {
  cout<<g*N<< endl;
}
  else if(N==100) {
    if(D==0) {
      cout << 101<< endl;
    }
    else if (D==1) {
      cout << 10100<< endl;
    }
    else if (D==2) {
cout <<1010000<< endl;
    }
  }
}
  
  
 


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

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

    if((c-a-b)*(c-a-b) > 4 * a * b && c - a - b > 0) PR("Yes");
    else PR("No");


    /*ll H, W;
    cin >> H >> W;

    ll C;
    if(W == 1 || H == 1) C = 1;
    else {
        if(H % 2 == 0) C = W * (H / 2);
        else C = W * ((H - 1) / 2) + (W + 1) / 2;
    }
    PR(C);

    return 0;*/
}

/*

a + 2sqrt(ab) + b < c
2sqrt(ab) < c - a - b


*/

Measured memory_bytes: 3608
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop, heapify
import copy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    a, b, c, d = LI()

    print(int(max([a * c, a * d, b * c, b * d])))


if __name__ == "__main__":
    main()


Measured memory_bytes: 68044
while True:
    n=input()
    if n==0:break
    L=[list(raw_input()) for i in range(n)]
    dp=[[0]*n for i in range(n)]
    maxInt=0
    for i in range(n):
        for j in range(n):
            if i==0 and L[i][j]==".":
                dp[i][j]=1
            if j==0 and L[i][j]==".":
                dp[i][j]=1
            if L[i][j]==".":
                dp[i][j]=1+min(dp[i-1][j],dp[i][j-1],dp[i-1][j-1])
            maxInt=max(maxInt,dp[i][j])
    print maxInt

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

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int[] xs) {
    // |A[1] - (b+1)| + |A[2] - (b+2)| + ... + |A[n] - (b+n)| を以下に変形
    // |(A[1]-1) - b| + |(A[2]-2) - b| + ... + |(A[n]-n) - b|
    int[] ys;
    for (int i = 0; i < xs.length; i++) {
        ys ~= xs[i] - (i+1);
    }
    ys.sort();
    long mid = ys[ys.length / 2];
    return ys.map!(e => abs(e - mid)).sum;
}

void main() {
    readint;
    auto xs = readints;
    writeln(calc(xs));
}


Measured memory_bytes: 11120
#include<bits/stdc++.h>
#define int long long
#define rep(i,m,n) for(int i=m;i<n;i++)
#define repr(i,n,m) for(int i=n;i>=m ;i--)
#define mod 1000000007
#define float long double
#define pb push_back
#define pi pair<int,int>
#define mp make_pair
#define do int n; cin>>n; vector<int>v1(n); rep(i,0,n) cin>>v1[i];
#define print(v1) rep(i,0,v1.size()){cout<<v1[i]<<" ";} cout<<"\n";
using namespace std;
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
int modulo(int n,int m=1000000007){
    if(n<0){
        return (m-abs(n)%m)%m;
    }
    else return n%m;
}
bool isPrime(int n){
  for(int i=2;i*i<=n;i++){
    if(n%i==0)
      return false;
  }
  return true;
}
int power(int a,int n){
    if(n==0) return 1;
    if(n==1) return a;
    if(n==2) return (a*a)%mod;
    if(n&1){
        n--;
        return (a*power(power(a,2),n/2))%mod;
    }
    else return (power(power(a,2),n/2))%mod;
}
int fact(int n){
  int total=1;
  rep(i,2,n+1){
    total=(total*i)%mod;
    cout<<total+mod<<"\n";
  }
  return (total)%mod;
}
int find(int n){
  int x=n,sum=1;
  while(x>0){
    sum*=(x%10);
    x=x/10;
  }
  return sum;
}
void solve()
{   
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    vector<int>v1;
    v1.pb(a*c);
    v1.pb(a*d);
    v1.pb(b*c);
    v1.pb(b*d);
    sort(v1.begin(), v1.end(),greater<int>());
    cout<<v1[0];
}
 
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
   // #ifndef ONLINE_JUDGE
   // freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
   // #endif
   int t=1;
   //cin>>t;
   while(t--)
   {
      solve();
      cout<<"\n";
   }
   cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
  return 0;
 }

Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

struct P {
    int x, y;
};

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

    double s = 0;
    int k = 0;
    vector<P> p(n);

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

        for (int j = 0; j < i; j++) {
            int dx = x - p[j].x;
            int dy = y - p[j].y;
            s += sqrt(dx * dx + dy * dy);
            k++;
        }
    }

    printf("%.10f\n", s / k * (n - 1));

    return 0;
}

Measured memory_bytes: 256
#import <stdio.h>
#import <stdlib.h>
#import <string.h>
#define M 1000000007
typedef long long Int;

void init(Int *A, int L) {
    for (int i = 0; i <= 9; i++) A[i] = 1;
    for (int i = 10; i <= 12; i++) A[i] = 0;
    for (int n = 1; n <= L + 1; n++) {
        for (int i = 0; i <= 12; i++) A[13 * n + i] = 0;
        for (int i = 0; i <= 12; i++) {
            for (int j = 0; j <= 9; j++) {
                A[13 * n + ((i + j) % 13)] += A[13 * (n - 1) + i];
                A[13 * n + ((i + j) % 13)] %= M;
            }
        }
    }
}

Int f(Int *A, int n, int k) {
    return A[13 * (n - 1) + k] % M;
}

int main() {
    char S[100002];
    scanf("%s", S);
    int L = strlen(S);
    int r[6] = {1, 10, 9, 12, 3, 4};
    int var_counts[6] = {0};
    int R = 0;
    for (int i = L - 1; i >= 0; i--) {
        int j = L - 1 - i;
        char c = S[i];
        if (c == '?') {
            var_counts[j % 6]++;
        } else {
            int d = c - '0';
            R += d * r[j % 6];
        }
    }

    Int *A = (Int *)malloc(sizeof(Int) * 13 * (L + 2));
    init(A, L);

    int c = R - 5;
    Int ans = 0;
    Int x[6] = {0};
    for (x[0] = 0; x[0] < 13; x[0]++) {
        for (x[1] = 0; x[1] < 13; x[1]++) {
            for (x[2] = 0; x[2] < 13; x[2]++) {
                for (x[3] = 0; x[3] < 13; x[3]++) {
                    for (x[4] = 0; x[4] < 13; x[4]++) {
                        for (x[5] = 0; x[5] < 13; x[5]++) {
                            int d = r[0] * x[0] + r[1] * x[1] + r[2] * x[2] + r[3] * x[3] + r[4] * x[4] + r[5] * x[5] + c;
                            if (d % 13 == 0) {
                                Int result = 1;
                                for (Int k = 0; k < 6; k++) {
                                    int v = var_counts[k];
                                    if (v > 0) {
                                        result *= f(A, v, x[k]);
                                        result %= M;
                                    }
                                }
                                ans += result;
                                ans %= M;
                            }
                            if (var_counts[5] == 0) break;
                        }
                        if (var_counts[4] == 0) break;
                    }
                    if (var_counts[3] == 0) break;
                }
                if (var_counts[2] == 0) break;
            }
            if (var_counts[1] == 0) break;
        }
        if (var_counts[0] == 0) break;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 12404
$N = gets.to_i
$H = gets.split.map(&:to_i)
$INF = 1 << 100

class Node
  attr_accessor :min_cost, :hight

  def initialize(h)
    @hight = h
    @min_cost = $INF

    #p @hight
  end
end

dp = Array.new($N){|i| Node.new($H[i])}
dp[0].min_cost = 0
dp[1].min_cost = (dp[1].hight - dp[0].hight).abs

i = 0
while i+2 < $N
  dp[i+2].min_cost = [(dp[i+2].hight - dp[i+1].hight).abs+dp[i+1].min_cost, (dp[i+2].hight - dp[i].hight).abs+dp[i].min_cost].min
  i += 1
end

puts dp[$N-1].min_cost

Measured memory_bytes: 17172
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define debug(x) cout<<#x<<": "<<x<<endl
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

ull modpow(ull x, ull n)
{
    ull ret = 1;
    while (n > 0) {
        if (n & 1) {
            ret = (ret * x) % MOD;
        }
        x = (x * x) % MOD;
        n >>= 1;
    }
    return ret;
}

ull modinv(ull x)
{
    return modpow(x, MOD - 2);
}

int main(void)
{
    ull H, W, A, B;
    const int N = 200001;
    cin >> H >> W >> A >> B;
    ull ret = 0;
    ull fac[N];
    fac[0] = 1;
    FOR(i, 1, N) {
        fac[i] = (i * fac[i - 1]) % MOD;
    }
    for (ull i = 0; i < H - A; i++) {
        ull x = fac[B - 1 + i] * fac[W - B + H - i - 2] % MOD;
        ull y = fac[B - 1] * fac[i] % MOD;
        y = y * fac[W - B - 1] % MOD;
        y = y * fac[H - i - 1] % MOD;
        x = x * modinv(y) % MOD;
        ret = (ret + x) % MOD;
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << # x << "; "<< x << endl


int main() {
	int K;
	string S;
	cin >> K >> S;
	vector<string> vec(K);
	if (S.size() <= K) {
		cout << S << endl;
	}
	else if (S.size() > K) {
		for (int i = 0; i < K; i++) {
			cout <<S.at(i);
		}
		cout << "..." << endl;
	}
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <iostream>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <algorithm>
#include <math.h>
#include <queue>
#include <vector>
#include <string.h>
#define mem(x,b) memset(x,b,sizeof(x))
#define mp(a,b) make_pair(a,b)
#define debug(a) cout<<a<<endl
#define maxn 200005
using namespace std;
typedef long long ll;
typedef double db;
const int mod=1e9+7;
int a[maxn];
int ans[maxn];
int vis[maxn];
int main()
{
    int n;
    ll k;
    scanf("%d",&n);
    scanf("%lld",&k);
	for(int i=1;i<=n;i++){
	    scanf("%d",&a[i]);
	}
	ans[0]=1;
	vis[1]=1;
	int j=0;
	for(int i=a[1];;i=a[i]){
	    j++;
	    if(vis[i]){
	    	if(k>=vis[i]-1){
	    		printf("%d\n",ans[(k-vis[i]+1)%(j+1-vis[i])+vis[i]-1]);
	    	}else{
	    		printf("%d\n",ans[k]);
	    	}
	    	break;
	    }
	    ans[j]=i;
	    vis[i]=j+1;
	}
    return 0;
}


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

using namespace std;

int main() {
    long long x;
    cin >> x;
    unordered_map<long long, int> d;
    for (long long i = -1000; i <= 1000; ++i) {
        auto p5 = i * i * i * i * i;
        d[p5] = i;
    }
    for (auto p : d) if (d.find(p.first - x) != d.end()) {
        auto b = d[p.first - x];
        cout << p.second << ' ' << b << '\n';
        return 0;
    }
    return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * 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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int a, b, c, d; cin >> a >> b >> c >> d;
    if (a == 12) {
        if (c == 1) {puts("1"); return 0;}
    } else {
        if (c == a+1) {puts("1"); return 0;}
    }
    puts("0");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int k,a,b,large;

    scanf("%d",&k);
    scanf("%d %d",&a,&b);
    large = ((b / k) * k);
    if ( a <= large ){
        printf("OK\n");
    }else{
        printf("NG\n");
    }
	return 0;
}

Measured memory_bytes: 1644
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
typedef long long ll;
#define rep(i,n) for(int i,i < (n);++i)
using namespace std;

int main() {
	ll h, n;
	cin >> h >> n;
	vector<int> s(n);
	ll damage = 0;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		damage += s[i];
      if(damage >=h) {
        printf("Yes");
        break;
	 }
    }
  	if(damage < h){
      printf("No");
    }
	
	return 0;
}

Measured memory_bytes: 640
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
using namespace std;
// clang-format on

using Weight = int;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(const int &s = 0, const int &d = 0, const Weight &w = 0) : src(s), dst(d), weight(w) {}
};

using Edges = std::vector<Edge>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

class Graph {
  std::vector<Edges> g;

public:
  Graph(const int &size = 0) : g(size) {}

  void addArc(const int &src, const int &dst, const Weight &w = 1) { g[src].emplace_back(src, dst, w); }

  void addEdge(const int &node1, const int &node2, const Weight &w = 1) {
    addArc(node1, node2, w);
    addArc(node2, node1, w);
  }

  const Edges &operator[](const int &i) const { return g[i]; }

  Graph toRootedTree(int r);
  std::pair<std::vector<Weight>, std::vector<int>> dijkstra(const int &src, const int &inf);
  Matrix warshallFloyd(const int &inf);
  std::pair<Weight, Edges> prim(const int &r);
  template<typename UnionFind> std::pair<Weight, Edges> kruskal();
  Weight solveTSP(const int &inf);
};

main {
  int n;
  cin >> n;
  cout << "ABC" << n << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
   string n;
    cin>>n;
     if(n=="hi"||n=="hihi"||n=="hihihi"||n=="hihihihi"||n=="hihihihihi"||n=="hihihihihihi"||n=="hihihihihihi"){
        cout<<"Yes";
    }
    else cout<<"No";

return 0;}

Measured memory_bytes: 256
n,x,m=map(int,input().split())
i=int(2)
a=[x]
q=int(0)
while (i <= n) and (q == 0):
	x=(x**2)%m
	if x in a:
		q=1
	else:
		a.append(x)
	i=i+1

if len(a) == n:
	print(sum(a))	
else:
	j=a.index(x)
	b=a[0:j]
	c=a[j:]
	lb=len(b)
	lc=len(c)
	k=(n-lb)%lc
	l=(n-lb)//lc
	d=c[0:k]
	print(sum(b)+sum(c)*l+sum(d))

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

using namespace std;

#define REP(i,x,y) for (int i=x;i<y;i++)
const int MAXN=2e5;
const int MOD=1e9+7;
int cnt[MAXN][26];
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i=1;i<=n;i++)
    {
        for (int j=0;j<26;j++)
        {
            cnt[i][j]=cnt[i-1][j];
        }
        cnt[i][s[i-1]-'a']++;
    }
    long long ans=0;
    for (int i=1;i<=n;i++)
    {
        long long tmp=1;
        for (int j=0;j<26;j++)
        {
            if (s[i-1]!=j+'a')
            {
                tmp=tmp*(cnt[i][j]+1)%MOD;
            }
        }
        ans=(ans+tmp)%MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10752
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void) {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	int cost12 = abs(a-b);
	int cost23 = abs(b - c);
	int cost13 = abs(a - c);
	int c1 = cost12 + cost23;
	int c2 = cost23 + cost13;
	int c3 = cost12 + cost13;
	if (c1 <= c2 && c1 <= c3) {
		printf("%d\n", c1);
	}
	else if (c2 <= c3) {

		printf("%d\n", c2);
	}
	else {
		printf("%d\n", c3);

	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int N,K,Min = 1000000000;
  cin >> N >> K;
  vector<int> h(N);
  for(int i=0;i<N;i++)cin >> h[i];
  
  sort(h.begin(),h.end());
  for(int i=0;i<=N-K;i++){
    Min=min(Min,h[i+K-1]-h[i]);
  }
  
  cout << Min << endl;
  
  return 0;
}


Measured memory_bytes: 640