akhauriyash/Code-Regression huggingface dataset:
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();

		// 文字列を分割する
		// 4文字の前提
		char[] c = new char[4];

		for (int i = 0; i < 4; i++) {
			c[i] = str.charAt(i);
		}

		// 組み合わせを調べる
		int[] x = { 0, 0, 0, 0 };

		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (i != j) {
					if (c[i] == c[j]) {
						x[i]++;
					}
				}
			}
		}

		// 全て他の1つの文字と同じ値であればOKそれ以外はNG
		boolean chk = true;

		for (int i = 0; i < 4; i++) {
			if (x[i] != 1) {
				chk = false;
			}
		}

		// 結果出力
		if (chk) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 21588
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

// priceをキーに降順でソート
//sort(fruits.begin(), fruits.end(),
//     [](const fruit& x, const fruit& y) { return x.price > y.price;});

int main() {
    int A,B;
    std:cin >> A >> B;
    if((A+B)%2==1){
        std::cout << "IMPOSSIBLE" <<std::endl;
    }
    else{
        std::cout << (A+B)/2 << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string.h>
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
    int a,b,c,d,i,n;
    int arr[100]={0};
    cin>>a>>b;
    for(i = 0;i < b;i++){
        cin>>c>>d;
        arr[c]++;
        arr[d]++;
    }
    for(i = 1;i <=a ;i++){
        cout<<arr[i]<<endl;
    }
}


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

#define f(i, q) for(int i = 0; i < q; i++)  

typedef long long ll;

int main() {

    int n;
    vector<pair< int, int> > v(50);
    vector<int> c;
    
    cin >> n;
    f(i, n) 
        cin >> v.at(i).first;
    f(i, n) 
        cin >> v.at(i).second;
    
    f(i,n) 
        if( (v.at(i).first - v.at(i).second) > 0)
            c.push_back(v.at(i).first - v.at(i).second);
    
    sort(c.begin(), c.end(), greater<int>());

    cout << accumulate(c.begin(), c.end(), 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    string str;
    list<char> s;
    int q, tf;
    char c;
    bool flg = true;

    cin >> str >> q;

    for (int i = 0; i < str.size(); i++) {
        s.push_back(str[i]);
    }

    for (int i = 0; i < q; i++) {
        cin >> tf;
        if (tf == 1) {
            flg = !flg;
        } else {
            cin >> tf >> c;
            if (flg) {
                if (tf == 1) {
                    s.push_front(c);
                } else {
                    s.push_back(c);
                }
            } else {
                if (tf == 1) {
                    s.push_back(c);
                } else {
                    s.push_front(c);
                }
            }
        }
    }

    if (!flg) {
        reverse(s.begin(), s.end());
    }

    for (auto itr = s.begin(); itr != s.end(); itr++) {
        cout << *itr;
    }
    cout << endl;

    return 0;
}


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

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;


const ll MOD = 998244353;

int main() {
    int n, s; cin >> n >> s;
    vvll f(n + 1, vll (s + 1));
    vll a(n + 1);
    FOR(i, 1, n) cin >> a[i];
    f[0][0] = 1;
    FOR(i, 1, n) {
        FOR(j, 0, s) {
            f[i][j] = 2 * f[i - 1][j];
            if (j >= a[i]) f[i][j] += f[i - 1][j - a[i]];
            f[i][j] %= MOD;
        }
    }
    cout << f[n][s] << endl;
}

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

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int p[102];
    int d[3] {0};
    for(int i = 0; i < n; i++){
        cin >> p[i];
        if(p[i] <= a) d[0]++;
        else if(p[i] <= b) d[1]++;
        else d[2]++;
    }
    cout << min(d[0], min(d[1], d[2])) << endl;
}

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

typedef long long ll;
#define f first
#define s second
#define pb push_back

using namespace std;
int arr[100001];

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

    if(n == 1){
        cout << "0"<<"\n";
        return 0;
    }
    int val = arr[0], lc = 0, gc = 0;
    for(int i = 0; i < n-1; i++){
        if(arr[i] >= arr[i+1]){
            lc++;
        } else{
            if(gc < lc){gc = lc;}
            lc = 0;
        }
    }
    if(lc > gc){gc = lc;}
    cout << gc<<"\n";
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int A, B;
    cin >> A >> B;
    cout << ((A + B) / 2) << endl;
}



Measured memory_bytes: 3128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			s.nextInt();
			final int K = s.nextInt();
			s.nextLine();
			final String S = s.nextLine();

			char[] cs = S.toCharArray();
			switch (cs[K - 1]) {
			case 'A':
				cs[K - 1] = 'a';
				break;
			case 'B':
				cs[K - 1] = 'b';
				break;
			default:
				cs[K - 1] = 'c';
				break;
			}
			System.out.println(new String(cs));
		}
	}
}


Measured memory_bytes: 19796
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val n  = inputs(0).toInt
  val ai = inputs(1).split(" ").map(_.toInt)

  println(solve(n, ai))

  def solve(n: Int, ai: Seq[Int]): Long = {
    var start = ai(0).toLong
    val size  = ai.size
    var money = 1000L
    var stock = 0L
    (1 until size).foreach { i =>
      val currentStockPrice = ai(i).toLong

      if(start < currentStockPrice) {
    
        stock = money / start 
        money = money % start
    
        money = money + (stock * currentStockPrice) 
        stock = 0
        start = currentStockPrice
      } else if (start > currentStockPrice) {
        start = currentStockPrice
      }
      // println(s"仕入れ値: $start")
    }

    money
  }
}

Measured memory_bytes: 54956
def gcd(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    m = b % a
    while m:
        a, b = m, a
        m = b % a
    return a


k = int(input())
ans = 0

for a in range(1, k+1):
    for b in range(1, k+1):
        ab = gcd(a, b)
        for c in range(1, k+1):
            ans += gcd(ab, c)
print(ans)


Measured memory_bytes: 9204
#include<iostream>
#include<cstdio>
#include<algorithm>
#define LL long long

using namespace std;
const int N = 1e5+7;

int main()
{
	ios :: sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	int n,x,ans;
	cin>>n;
	cin>>x;
	ans=x;
	for(int i=1;i<n;i++){
		cin>>x;
		ans=__gcd(ans,x);
	}
	cout<<ans<<endl;
	return 0;
 } 

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

// #define MOD 1000000007

using namespace std;
// typedef unsigned long long ull;

// void p() {
//     cout << "\n";
// }
// template<class Head, class... Body>
// void p(Head head, Body... body) {
//     cout << head << ",";
//     p(body...);
// }

int main(int argc, char const *argv[]) {
    unsigned int X;
    cin >> X;
    unsigned int count = 0;
    unsigned int position = 0;
    while (position < X) {
        count += 1;
        position += count;
        // cout << count << " " << position << endl;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
import glob
import numpy as np


# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\137\\B'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class B(Common):

    def resolve(self):

        tmp = [int(i) for i in self.input_data().split()]
        K = tmp[0]
        X = tmp[1]

        start = X - (K-1)
        if start < -1000000:
            start = -1000000
        end = X + (K-1)
        if end > 1000000:
            end = 1000000

        for i in range(start, end + 1):
            if i == end:
                print(str(i))
            else:
                print(str(i), end=' ')


solver = B(REL_PATH)
solver.exec_resolve()

Measured memory_bytes: 13732
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
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(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}
template<class T>istream&operator>(istream&i,T&t){return i>>t;}
#ifndef LOCAL
struct ostdmy{
template<class T>ostdmy&operator<<(const T&t){return*this;}
template<class T>ostdmy&operator<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int a,b;
    cin>a>b;
    int c=0;
    if(a>b)c+=a--;
    else c+=b--;
    if(a>b)c+=a--;
    else c+=b--;
    cout<c<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
	char data[100];
	int i;
	gets(data);
	for(i=0;i<strlen(data);i++){
		if(isalpha(data[i])!=0){
			data[i]=toupper(data[i]);
		}
	}
	printf("%s\n",data);
	
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using Int = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define PB push_back
#define MP make_pair
#define PUTS(x) cout << (x) << endl;
vector<Int> IntsIn(int n) {
    auto v = vector<Int>(0);
    for (int i = 0; i < n; i++) {
        Int a;
        cin >> a;
        v.push_back(a);
    }
    return v;
}

int main() {
    int n;
    cin >> n;
    rep(i, n) {
        int a;
        cin >> a;
        if (a % 2 == 0) {
            if (a % 3 != 0 && a % 5 != 0) {
                puts("DENIED");
                return 0;
            }
        }
    }
    puts("APPROVED");
}

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

void fail(){
	cout<<"NO"<<endl;
	exit(0);
}
int a[100001];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	a[n]=a[0];
	long long int tot=0;
	for(int i=0;i<n;i++)
		tot+=a[i];
	long long int sum=1LL*n*(n+1)/2;
	if(tot%sum!=0){
		cout<<"NO"<<endl;
		return 0;
	}
	long long int k=tot/sum;
	for(int i=0;i<n;i++){
		long long int x=k-a[i+1]+a[i];
		if(x<0||x%n!=0)
			fail();
	}
	cout<<"YES"<<endl;
}


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

int main(){
  long long A,B,ans,a,b,c;
  cin>>A>>B;
  if(2*A>=B){
    cout<<B/2<<endl;
    return 0;
  }
  else{
    B-=2*A;
    B/=4;
              cout<<A+B<<endl;
    return 0;
  }
}


Measured memory_bytes: 256
import numpy as np

N=int(input())
X = [int(i) for i in input().split()]
X=np.array(X)

minval = 1000000000000
ans=0
for candidate in range(101):
    tmp = sum((X-candidate)**2)
    if tmp < minval:
        minval=tmp
        ans = candidate

print(minval)


Measured memory_bytes: 21672
#include<bits/stdc++.h>
using namespace std;
int32_t main()
{
  // #ifndef ONLINE_JUDGE
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  //#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  pair<string,int> p[10000];
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  {
  	cin>>p[i].first>>p[i].second;
  }
  string x;
  cin>>x;
  int sum=0;
  int t;
  for(int i=0;i<n;i++)
  	{
  		if(p[i].first==x)
  			{
              t=i;
              break;
  			}
  	}

  	for(int i=t+1;i<n;i++)
  	{
  		sum=sum+p[i].second;
  	}
  	cout<<sum;


}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define float long double
#define foi(i,n) for(int i = 0 ;i < n ; i++)
using namespace std;
float dp[301][301][301];



// dp[i][j][k] = we remove the Ith index ka element and graph has j non zero components currently having k elements

float solve(int i,int j,int k,float n){
    if(i == 0 && j == 0 && k == 0) return 0;
    if(i<0 || j <0 || k <0) return 0;
    if(dp[i][j][k]!=-1) return dp[i][j][k];
    int zero = n - i - j - k ;
    float p0 = zero/n;
    float p1 = i/n; // one
    float p2 = j/n; // two
    float p3 = k/n; // three

    float a,b,c;
    a = p1*solve(i-1,j,k,n);
    b = p2*solve(i+1,j-1,k,n);
    c = p3*solve(i,j+1,k-1,n);

    return dp[i][j][k] = (1+a+b+c)/(1-p0);

}


int32_t  main(){
    int n;
    cin >> n;
    foi(i,301){
        foi(j,301){
            foi(k,301) dp[i][j][k] = -1;
        }
    }
    int one,two,three;
    one =two = three = 0;
    foi(i,n){
        int x;
        cin >> x;
        if(x == 1) one++;
        else if(x == 2) two++;
        else if(x == 3) three++;
    }
    cout << fixed << setprecision(10);
    cout << solve(one,two,three,n);
}


Measured memory_bytes: 426496
#include <iostream>
#include <math.h>
using namespace std;
 
int main (){
	int m[3],t[3],ans=100000;
  	for(int i = 0;i<3;i++){
    	cin >> m[i];
      	//cout << i << "番" << m[i] <<endl;
    }
  	for(int i = 0;i<3;i++){
    	t[i] = m[i] + m[i + 1];
      	if(i == 2){
        t[i] = m[0] + m[2];
        }
      	if(ans>t[i]){
        	ans = t[i];
        }
    }
  	cout << ans;
  	
}	


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

int main()
{
    int a, b, c, sum=0, login=0, bonus=0;
    cin >> a >> b >> c;
    while(sum < c)
    {
        sum += a;
        login++;
        bonus++;
        if(bonus == 7)
        {
            sum += b;
            bonus = 0;
        }
    }
    cout << login << endl;
}


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

void solve()
{
    int n; cin >> n;
    int ans = n - 1; // a = 1
    ans += n - 1; // b = 1;
    for (int i = 2; i < n; ++i) {
        for (int j = 2; i < n; ++j) {
            if (i * j < n) {
                ++ans;
            } else break;
        }
    }
    cout << ans - 1 << '\n';
}

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

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const int INF = 1001001001;

int main(){
    int h, w;
    cin >> h >> w;
    int a[h][w], b[h][w];
    int dif[h][w];
    rep(i, h) rep(j, w) cin >> a[i][j];
    rep(i, h) rep(j, w) cin >> b[i][j];
    rep(i, h) rep(j, w) dif[i][j] = abs(a[i][j] - b[i][j]);
    vec<vec<vec<bool>>> dp(h, vec<vec<bool>>(w, vec<bool>(160*160, false)));
    dp[0][0][dif[0][0]] = true;
    rep(i, h) rep(j, w) rep(k, 160*160) {
        if (dp[i][j][k] == true) {
            if (i+1<h) {
                dp[i+1][j][k+dif[i+1][j]] = true;
                dp[i+1][j][abs(k-dif[i+1][j])] = true;
            }
            if (j+1<w) {
                dp[i][j+1][k+dif[i][j+1]] = true;
                dp[i][j+1][abs(k-dif[i][j+1])] = true;
            }
            //cout << i << " " << j << " " << k << endl;
        }
    }
    int ans = 0;
    while(true) {
        if (dp[h-1][w-1][ans] == true) break;
        ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

bool CompareMin(int a, int b) {
	return a > b;  
}
typedef long long ll;
int main(){
    int a,b,c;
    cin >>a >> b;
    if(a <=5){
        cout << 0 << endl;
    }else if(a<=12){
        cout << b/2 << endl;
    }
    else if(a>=13){
        cout <<b << endl;
    }

    return 0;
    
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String a=sc.nextLine();
		int sum = 0;
		for(int i=0;i<a.length();i++){
			if(a.charAt(i)=='1'){
				sum++;
			}
		}
		System.out.println(sum);
	}
}


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

using namespace std;

#define ll long long
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef set<int> si;
typedef set<vi> svi;
typedef set<ll> sll;
typedef set<vll> svll;
typedef set<pii> spii;
typedef set<vpii> svpii;
typedef set<pll> spll;
typedef set<vpll> svpll;
typedef vector<si> vsi;
typedef vector<sll> vsll;
typedef vector<spii> vspii;
typedef vector<spll> vspll;
#define ft first
#define sc second
#define pb push_back
#define ins insert
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define sortarr(a,n) sort(a,a+n)
#define tt ll tc; cin >> tc; while(tc--)
#define rep(var,start,end,interval) for(ll var=start;(interval>0 and var<end) or (interval<0 and var>end);var+=interval)
#define each(x,v) for(auto x : v)
#define takearr0(a,n) rep(z,0,n,1) cin >> a[z];
#define takearr1(a,n) rep(z,1,n+1,1) cin >> a[z];

const ll max_n = 5000;

ll n,k;

int main()
{
	io;
	cin >> n >> k;
	vll p(n),c(n);
	takearr0(p,n);
	takearr0(c,n);
	vvll cycles;
	rep(i,0,n,1) --p[i];
	vb v(n,false);
	rep(i,0,n,1)
	{
		if(!v[i])
		{
			v[i] = true;
			vll vec;
			vec.pb(c[i]);
			ll rt = p[i];
			while(!v[rt])
			{
				vec.pb(c[rt]);
				v[rt] = true;
				rt = p[rt];
			}
			cycles.pb(vec);
		}
	}
	ll ans = -1e15;
	each(vec,cycles)
	{
		ll full = 0;
		each(x,vec) full += x;
		n = vec.size();
		rep(i,0,n,1) vec.pb(vec[i]);
		rep(i,0,n,1)
		{
			ll val = 0;
			rep(j,i+1,i+min(n,k)+1,1)
			{
				val += vec[j];
				ans = max(ans,val);
			}
		}
		if(k > n)
		{
			ans = max(ans,full*((k/n)-1));
			rep(i,0,n,1)
			{
				ll val = 0;
				rep(j,i+1,i+min(n,k-n)+1,1)
				{
					val += vec[j];
					ans = max(ans,full*((k/n)-1)+val);
				}
			}
			ans = max(ans,full*(k/n));
			rep(i,0,n,1)
			{
				ll val = 0;
				rep(j,i+1,i+k%n+1,1)
				{
					val += vec[j];
					ans = max(ans,(full*(k/n))+val);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3812
#!/usr/bin/env python3
from collections import Counter
import sys


def solve(N: int, S: "List[str]"):
    c = Counter(S)
    words = []
    w, m = c.most_common()[0]
    words.append(w)
    for _w, _c in c.most_common()[1:]:
        if _c==m:
            words.append(_w)
        else:
            break
    print('\n'.join(sorted(words)))
    # return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 45108
b = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = []; dp[0] = 0
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
(0..n).map{|i| a.each{|j| dp[i+b[j]] = dp[i+b[j]].nil? ? dp[i]*10+j : [dp[i+b[j]], dp[i]*10+j].max } if !dp[i].nil?}
p dp[n]

Measured memory_bytes: 29948
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807/5;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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 dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

Measured memory_bytes: 512
#--- Battle

A, B, C, D = map(int, input().split())

i = 0
j = 0
while (A > 0):
  i = i + 1
  A = A - D
#  print(A)

while (C > 0):
  j = j + 1
  C = C - B
#  print(C)

#print(i, j)
if (i >= j):
  print("Yes")
else:
  print("No")



Measured memory_bytes: 9184
#pragma GCC optimize("O1")
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
}
int main()
{
    vok();
    ll n,k;
    IN n>>k;
    vll a(n);
    bitset<50> b[n];
    loop(i,0,n)
    {
        IN a[i];
        bitset<50> temp(a[i]);
        b[i]=temp;
    }
    bitset<50> ans(0);
    rloop(i,49,0)
    {
        int countt=0;
        loop(j,0,n)
        {
            if(b[j][i])
            {
                countt++;
            }
          	cout<<"";
        }
        ans[i]=1;
        if((countt*2)<n && ans.to_ullong()<=k)
        {
            //Do Nothing
        }
        else
        {
            ans[i]=0;
        }
    }
    ll fans=0LL;
    ll X=ans.to_ullong();
    loop(i,0,n)
    {
      	cout<<"";
        fans+=(X^a[i]);
    }
    OUT fans<<endl
    return 0;
}


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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

const int mod=1000000007;

int *fact=NULL;
int *invFact=NULL;

int inv(int a,int p){
  if(a==1) return 1;
  return p-(int64)(p/a)*inv(p%a,p)%p;
}

void init(int n){
  fact=(int *)malloc(sizeof(int)*(n+1));
  invFact=(int *)malloc(sizeof(int)*(n+1));
  fact[0]=1;
  int i;
  for(i=1;i<=n;i++) fact[i]=(int64)fact[i-1]*i%mod;
  invFact[n]=inv(fact[n],mod);
  for(i=n-1;i>=0;i--){
    invFact[i]=(int64)invFact[i+1]*(i+1)%mod;
  }
  return;
}

int comb(int n,int k){
  int res=(int64)fact[n]*invFact[k]%mod*invFact[n-k]%mod;
  return res;
}

void run(void){
  int h,w,a,b;
  scanf("%d%d%d%d",&h,&w,&a,&b);
  init(h+w);
  int ans=0;
  int x,y;
  for(x=h-a-1,y=b;x>=0 && y<w;x--,y++){
    ans=(ans+(int64)comb(x+y,x)*comb(h-x-1+w-y-1,h-x-1))%mod;
  }
  printf("%d\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 1792
package main

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

func main() {
	sc := NewScanner()
	N, C, K := sc.NextInt(), sc.NextInt(), sc.NextInt()

	T := make([]int, N)
	for i := 0; i < N; i++ {
		T[i] = sc.NextInt()
	}

	sort.Ints(T)

	bus := 0
	current := 0
	start := 0
	for i := 0; i < N; i++ {
		if current == 0 {
			bus++
			start = T[i]
		}
		if T[i]-start <= K {
			current++
		}
		if current == C {
			current = 0
		} else if T[i]-start > K {
			current = 0
			i--
			continue
		}

	}
	fmt.Println(bus)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 4480
#include <stdio.h>

int main(void)
{
        int A,B,C,ans = 0;
        scanf("%d %d %d",&A,&B,&C);


        if(A + B + 1 >= C) {
                ans = C + B;
        } else {
                ans = B * 2 + A + 1;
        }

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

        return 0;
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')


def factorize(n):
    res = []
    for i in range(2, int(pow(n, 0.5))+1):
        if n % i: continue
        res.append([i, 0])
        while n % i == 0:
            n = n // i
            res[-1][-1] += 1
    if n != 1:
        res.append([n, 1])
    return res

from fractions import gcd
def solve():
    a, b = MI()
    p = gcd(a, b)
    f = factorize(p)
    print(len(f) + 1)






if __name__ == '__main__':
    solve()


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

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0);
 
    ll a, b, c ,d;
    cin >> a >> b >> c >> d;

    // a <= x <= b and c <= y <= d
    ll a1 = a * c;
    ll a2 = a * d;
    ll a3 = b * c;
    ll a4 = b * d;
    cout << max({a1, a2, a3, a4});
}



Measured memory_bytes: 3660
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

N, A, B = [int(x) for x in input().split()]
ans = min(A * N, B)
print(ans)


Measured memory_bytes: 3828
import java.io.*;
public class Main {

	static int[] dx = {0,0,-1,1};
	static int[] dy = {-1,1,0,0};
	static int[][] map;
	static int n, m;
	static boolean[][] check;

	public static void main(String[] args) throws IOException {
		BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		while (true) {
			m = Integer.valueOf(s.readLine());
			n = Integer.valueOf(s.readLine());
			if (m == 0 && n == 0) break;
			map = new int[n][m];
			for (int i = 0 ; i < n ; i++) {
				String[] data = s.readLine().split(" ");
				for (int j = 0 ; j < m ; j++)
					map[i][j] = Integer.valueOf(data[j]);
			}
			int max = 0;
			for (int i = 0 ; i < n ; i++) {
				for (int j = 0 ; j < m ; j++) {
					if (map[i][j] == 1) {
						check = new boolean[n][m];
						max = Math.max(max, dfs(i, j));
					}
				}
			}
			out.println(max);
		}
		out.flush();
	}

	private static int dfs(int y, int x) {
		int ret = 0;
		for (int d = 0 ; d < 4 ; d++) {
			int tx = x + dx[d];
			int ty = y + dy[d];
			if (tx < 0 || ty < 0 || tx >= m || ty >= n || map[ty][tx] == 0 || check[ty][tx]) {
				continue;
			}
			check[ty][tx] = true;
			ret = Math.max(ret, 1 + dfs(ty, tx));
			check[ty][tx] = false;
		}
		return ret;
	}
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
long long dp[100005];
int n, c, w[105], v[105];
int main() {
    for (int i=1; i<=100000; i++) dp[i] = INT_MAX;
    scanf("%d %d", &n, &c);
    for (int i=1; i<=n; i++) {
        scanf("%d %d", &w[i], &v[i]);
    }
    for (int i=1; i<=n; i++) {
        for (int j=100000; j>=v[i]; j--) {
            dp[j] = min(dp[j], dp[j-v[i]] + w[i]);
        }
    }
    int ans = 0;
    for (int i=100000; i>=1; i--) {
        if (dp[i] <= c) {
            ans = i;
            break;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C){
    set<ll> mp;
    mp.insert(A); mp.insert(B); mp.insert(C); 
    if(mp.size()==2){
        cout<<YES<<endl;
    }
    else{cout<<NO<<endl;}
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
  

n, m, k = map(int, input().split())

uf = UnionFind(n)

friends = [[] for i in range(n)]
blocks = [[] for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)
    friends[a-1].append(b-1)
    friends[b-1].append(a-1)    
    
for i in range(k):
    c, d = map(int, input().split())
    blocks[c-1].append(d-1)
    blocks[d-1].append(c-1)     
    
for i in range(n):
    tmp = uf.size(i) - len(friends[i]) -1

    for v in blocks[i]:
        if uf.same(i, v):
            tmp -= 1
        
    print(tmp, end=' ')
    





Measured memory_bytes: 44440
N, M = [int(a) for a in input().strip().split()]
P = []
Y = []
prefs = {}
YtoIdx = {}
results = ['' for i in range(0, M)]
for i in range(0, M):
    pk, yk = [int(a) for a in input().strip().split()]
    if not pk in prefs:
        prefs[pk] = []
    prefs[pk].append(yk)
    P.append(pk)
    Y.append(yk)
    YtoIdx[yk] = i

for p in prefs.keys():
    prefs[p].sort()
    for i, y in enumerate(prefs[p]):
        pre = str(p).zfill(6)
        suf = str(i+1).zfill(6)
        results[YtoIdx[y]] = pre + suf

for res in results:
    print(res)


Measured memory_bytes: 46732
#include<cstdio>
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

const int CMax = 100002;

int n;
long long A[CMax], sk, e;

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

    sort(A, A+n);
    sk = A[n-1];
    e = A[n-1];
    for (int i = n-2; i >= 0; i--){
        while (sk % A[i] != 0){
            sk += e;
        }
        e = sk;
    }

    cout << sk << endl;
}


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

int main(){
    int n;
    string s;
    cin>>n>>s;
    if(n%2) cout<<"No"<<endl;
    else{
        int x = n/2;
        for(int i=0;i<x;i++)
        {
            if(s[i]!=s[i+x])
            {
                cout<<"No"<<endl;
                return 0 ;
            }
        }
        cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

x = [-1] * N
sa = sum(A)
sx = sa // 2

t = 0
for i in range(0, N, 2):
    t += A[i]
x[0] = t - sx

for i in range(N-1):
    x[i+1] = A[i] - x[i]

print(*[2 * xx for xx in x], sep=" ")

Measured memory_bytes: 70884
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define INF 1000000000001
#define DIM 100001
#define mod 1000000007
#define PI 3.1415926535897932384626433
#define se second
#define fi first
#define pb push_back
#define T true
#define F false
#define endl "\n"
#define gg cout<<"OPS"<<endl;
#define qwe return 0;
#define amen exit(0);
typedef char ch;
typedef bool boll;
typedef string st;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef set < string > sst;
typedef set < long long > sll;
typedef queue < long long > que;
typedef deque < long long > deq;
typedef vector < long long > vec;
typedef map < long long, long long > mll;
typedef pair < long long, long long > pll;
typedef vector < pair < long long, long long > > vpl;
typedef pair < long long, unsigned long long > pul;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> sat_set;
ll t,n;
int main()
{
     fast;
     ll k=0;
     cin>>k;
     st s;
     cin>>s;
     if(s.size()<=k)return cout<<s<<endl,0;
     for(int i=0;i<k;i++)cout<<s[i];
     for(int i=k;i<s.size();){cout<<"..."; break;}
     //cout<<endl;

}


Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)
#define MAX 8

int path[MAX][MAX];

int dfs(bool* flags, int n, int now){
    bool flag = true;
    int res = 0;
    rep(n, i) flag = flag && flags[i];
    if (flag) return 1;
    rep(n, i) {
        if (!flags[i] && path[now][i]) {
            flags[i] = true;
            res += dfs(flags, n, i);
            flags[i] = false;
        }
    }
    return res;
}

void solve(void){
    int n, m;
    scanf("%d%d\n",&n, &m);
    rep(m, i){
        int a, b; scanf("%d%d\n", &a, &b);
        path[a-1][b-1] = 1;
        path[b-1][a-1] = 1;
    }
    bool flags[n];
    flags[0] = true;

    cout << dfs(flags, n, 0) << '\n';
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 256
use std::io;


fn main() {
    let (n, k) = {
        let i = read::<f64>();
        (i[0], i[1])
    };
    let _ = read::<usize>();
    println!("{}", ((n - 1.0) / (k - 1.0)).ceil());
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int main(){
  int n,a,b,c,d;
  string s;
  cin>>n>>a>>b>>c>>d>>s;
  a--;b--;c--;d--;
  for(int i=a+1;i<d;i++){
    if(s[i]==s[i+1] && s[i]=='#'){
      cout<<"No"<<endl;
      return 0;
    }
  }
  if(d<c){
    int c=0;
    for(int i=b-1;i<=min(d+1,n-1);i++){
      if(s[i]=='.') c++;
      else c=0;
      if(c==3){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int list[n];
    int i,difference=0;
    for (i=0;i<n;i++){
        scanf("%d",&list[i]);
    }
    int min = list[0];
    int ans = list[1] - list[0];
    for (i=1;i<n;i++){
        if (min>list[i]){
            min = list[i];
        }else if (ans<list[i]-min){
            ans = list[i] - min;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 2520
using System;

class Atcoder76
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int a = int.Parse(Console.ReadLine());

        int oneyen = n % 500;

        if (oneyen <= a)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
int judge(char x)
{
	if(x=='\0')
	{
		return 3;
	}
	if(x=='a')
	{
		return 0;
	}
	if(x=='b')
	{
		return 1;
	}
	return 2;
}
int main()
{
	char sa[102],sb[102],sc[102];
	scanf("%s%s%s",&sa,&sb,&sc);
	int x=0,v;
	int a=0,b=0,c=0;
	while(1)
	{
		switch(x)
		{
			case 0:
			x=judge(sa[a]);
			a++;
			v=0;
			break;
			case 1:
			x=judge(sb[b]);
			b++;
			v=1;
			break;
			case 2:
			x=judge(sc[c]);
			c++;
			v=2;
			break;
			case 3:
			switch(v)
			{
				case 0:
				printf("A\n");
				break;
				case 1:
				printf("B\n");
				break;
				case 2:
				printf("C\n");
				break;
			}
			return 0;
			break;
		}
	}
}

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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a, b, c) for(int a = b; a >= c; --a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 2e5 + 100;
const int maxN = 6e6;
const int oo = 1e18;
const int mod  = 1e9 + 7;


signed main()  {
//    freopen("test.inp", "r", stdin);
//    freopen("spm.out", "w", stdout);
    ios_base::sync_with_stdio(false); cout.tie(0);
    int n, m, d; cin >> n >> m >> d;
    double ans = (double) (m - 1.00) * 2.00 * (n - d) * 1.00 / (n * 1.00 * n);
    if(d == 0) ans /= 2.00;
    cout << fixed << setprecision(10) << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;
const int MAX_N = 1e5 * 2;
ll ifact[MAX_N];
ll fact[MAX_N];

ll comb(int n, int k){
  return fact[n] * ifact[k] % MOD * ifact[n-k] % MOD;
}
ll mod_pow(ll n, ll x){
  ll res = 1;
  while(n > 0){
    if(n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}

void inv_fact(int M){
  fact[0] = ifact[0] = 1;
  for(int i = 1; i <= M; i++){
    fact[i] = fact[i-1] * i % MOD;
  }
  ifact[M] = mod_pow(MOD - 2, fact[M]);
  for(int i = M - 1; i >= 1; i--){
    ifact[i] = ifact[i + 1] * (i + 1) % MOD;
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  inv_fact(H + W - 2);
  ll ans = 0;
  REP(i,H-A){
    ans = (comb(B - 1 + i, i) * comb(H-i+W-B-2, W-B-1) + ans) % MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,d,i,c=0;
    scanf("%lld %lld",&n,&d);
    ll x[n],y[n];
    for(i=0;i<n;i++)
    {
        scanf("%lld %lld",&x[i],&y[i]);
        if(sqrt(x[i]*x[i]+y[i]*y[i])<=d)
        {
            ++c;
        }
    }
    printf("%lld\n",c);





   
}

Measured memory_bytes: 6836
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int n = sc.nextInt();
		ArrayList<String> ss = new ArrayList<String>();

		String[] strs = str.split("");

		for(int i=0; i<strs.length; i++) {
			if(i%n == 0) {
				ss.add(strs[i]);
			}
		}

		String res = "";
		for(int i=0; i<ss.size(); i++) {
			res += ss.get(i);
		}

		System.out.println(res);
	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;

//i*2^X>=K
//2^X>=
int main() {
	int N,t;
	cin >> N;
	vector<int>A(N);
	for (size_t i = 0; i < N-1; i++)
	{
		cin >> t;
		t--;
		A.at(t)++;
	}
	for (size_t i = 0; i < N; i++)
	{
		cout << A.at(i)<<endl;
	}
}

Measured memory_bytes: 4052
#include <iostream>
using namespace std;
int main()
{
	int w, h, i, j, c, x, y;
	char f[100][100];
	bool b;
	while (cin >> w >> h)
	{
		if (w == 0 && h == 0) break;
		x = y = 0;
		b = false;
		c = 0;
		for (i = 0; i < w; i++)
			for (j = 0; j < h; j++)
				cin >> f[i][j];
		while (c <= w*h)
		{
			switch (f[y][x])
			{
			case '>':
				x++;
				break;
			case '^':
				y--;
				break;
			case '<':
				x--;
				break;
			case 'v':
				y++;
				break;
			default:
				cout << x << " " << y << endl;
				b = true;
				break;
			}
			if (b) break;
			c++;
		}
		if (!b) cout << "LOOP" << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  string s,t; cin >> s >> t;
  ll N = s.size();
  ll M = t.size();

  vector<vector<ll>> data(26);// a~z(0~25)のj+1番目の文字がSの何文字目(1<=n<=N)にあるか
  
  rep(i,26) data[i].push_back(-1);
  rep(i,N) data[s[i] - 'a'].push_back(i+1);
  rep(i,26) data[i].push_back(1e8);
  
  bool flag = true;
  int last = 0; // 最初からn(1 <= n <= N)文字目
  ll ans = 0;
  rep(i,M) {
    int k = t[i] - 'a';
    if (data[k].size() == 2) {
      flag = false;
      break;
    } else {
      int l = upper_bound(all(data[k]),last) - data[k].begin();
      if (l == data[k].size() - 1) {
        ans += (N - last);
        l = upper_bound(all(data[k]),0) - data[k].begin();
        ans += data[k][l];
        last = data[k][l];
      } else {
       ans += data[k][l] - last;
       last = data[k][l];
      }
    }
  }

  if (flag) cout << ans << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 1724