akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,s,n) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{
  cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;
}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
ll INF=10e12;
//------------------------------------------------------------
ll N,ans=0;
string S,T;
void solve() {
  cin>>S>>T;

  bool flag = true;

  rep(i,0,S.size())
  {
    if(S[i]!=T[i]) { flag=false; break;}
  }

  if(flag) print("Yes");
  else print("No");
  return;
}


Measured memory_bytes: 3656
import java.util.*;
import java.lang.Math;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        int sq = (int)Math.sqrt(N);
        long result = 0;
        for(int i = sq; i > 0; i--){
            if(N % i == 0){
                result = N / i + i - 2;
                break;
            }
        }
        System.out.println(result);
    }
}


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

int main(){
	int n;
	cin>>n;
	int ar[n];
	for(int i=0;i<n;i++){
		cin>>ar[i];
	}

	int dp[n];
	dp[0] = 0;
	dp[1] = abs(ar[1]-ar[0]);
	for(int i=2;i<n;i++){
		dp[i] =	min(dp[i-1]+abs(ar[i-1]-ar[i]),dp[i-2]+abs(ar[i-2]-ar[i])); 
	}
	cout<<dp[n-1];
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

// void func(int N, int Q, string S, vector<int> l, vector<int> r) {}

int main() {
    int N;
    cin >> N;
    int Q;
    cin >> Q;
    string S;
    cin >> S;
    vector<int> l(Q);
    vector<int> r(Q);
    rep(i, Q) {
        cin >> l[i];
        cin >> r[i];
    }

    // 累積和
    vi ac(N + 1);
    rep(i, N - 1) {
        if (S[i] == 'A' && S[i + 1] == 'C') {
            ac[i + 1] = ac[i] + 1;
        } else {
            ac[i + 1] = ac[i];
        }
    }
    rep(i, Q) { cout << ac[r[i] - 1] - ac[l[i] - 1] << endl; }

    // func(N, Q, S, std::move(l), std::move(r));
    return 0;
}


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

vector<int> to[200005];
vector<int> ans;

void dfs(int v, int p=-1) {
    for (int u : to[v]) {
        if (u == p) continue;
        ans[u] += ans[v];
        dfs(u,v);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    rep(i,n-1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    rep(i,q) {
        int p, x;
        cin >> p >> x;
        --p;
        ans[p] += x;
    }
    dfs(0);
    rep(i,n) {
        if (i != n-1) printf("%d ", ans[i]);
        else printf("%d\n", ans[i]);
    }
    return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;


int main() {
    int n; cin >> n;
    string s; cin >> s;
    V<int> w(n, 0), e(n, 0);
    if(s[0] == 'W') w[0] = 1;
    else e[0] = 1;
    for(int i = 1; i < n; i++){
        if(s[i] == 'W'){
            w[i] = w[i - 1] + 1;
            e[i] = e[i - 1];
        }else{
            e[i] = e[i - 1] + 1;
            w[i] = w[i - 1];
        }
    }

    int ans = INT_INF;
    for(int i = 0; i < n; i++){
        int l = 0, r = 0;
        if(0 < i) l = w[i];
        r = e[n - 1] - e[i + 1];
        ans = min(ans, l + r);
    }
    cout << ans << endl;

}


Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <cmath>
#include <algorithm>

using namespace std;

const int INF = 1e6;

int main(){
    int n;
    cin >> n;
    vector<int> c(n+10);
    for (int i=0; i<n; i++){
        cin >> c[i];
    }
    vector<int> dp(n+10, 1);
    vector<int> vb(200010, -1);
    vb[c[0]] = 0;
    for (int i=1; i<n; i++){
        if (vb[c[i]] != -1){
            int j = vb[c[i]];
            if (j==i-1){
                dp[i] = dp[i-1];
            }
            else {
                dp[i] = dp[i-1]+dp[j];
            }
            dp[i] = dp[i]%1000000007;
        }
        else{
            dp[i] = dp[i-1];
        }
        vb[c[i]] = i;
    }

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


Measured memory_bytes: 2560
a[10002],N,p,q,k,s,m;main(i,j,c,k){for(;scanf("%d",&N)*N;printf("%d\n",N-m)){for(i=N;*a=a[N+1]=m=i;)scanf("%d",a+i--);for(;i++<N;)for(j=3;j--;s-k>m?m=s-k:0)for(a[p=i]=a[i]%3+1,q=i+1,s=0,k=4;k>3;s+=k){c=a[p];for(k=1;c&&a[--p]==c;)k++;for(;c&&a[q]==c;q++)k++;}}}

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

int main(){
  string s;
  cin >> s;
  if(s.at(0) == s.at(1) && s.at(1) == s.at(2) && s.at(2) == s.at(3)) cout << "No" << endl;
  else if(s.at(0) == s.at(1)){
    if(s.at(2) == s.at(3)) cout << "Yes" << endl;
    else cout << "No" << endl;
  }else if(s.at(0) == s.at(2)){
    if(s.at(1) == s.at(3)) cout << "Yes" << endl;
    else cout << "No" << endl;
  }else if(s.at(0) == s.at(3)){
    if(s.at(1) == s.at(2)) cout << "Yes" << endl;
    else cout << "No" << endl;
  }else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second

typedef long long int lli;
//typedef pair<int,int> P_;

const int INF=1<<30;
const long long int INF_=1<<60;

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int M,N;
	cin >> M >> N;
	vector<int> P(M);
	vector<int> C(N);
	vector<int> E(N);
	REP(i,0,M) cin >> P[i];
	REP(i,0,N) cin >> C[i] >> E[i];
	sort(P.begin(),P.end(),greater<int>());
	vector<lli> dp(10001,-INF);
	dp[0]=0;
	REP(i,0,N){
		for(int j=10000; j>=0; --j){
			int idx=j-C[i];
			if(idx<0) idx=0;
			dp[j]=max(dp[j],dp[idx]-E[i]);
		}
	}
	lli ans=0;
	lli sum=0;
	REP(i,0,M+1){
		dp[i]+=sum;
		sum+=P[i];
		ans=max(ans,dp[i]);
		//cout << dp[i] << ' ';
	}
	//cout << endl;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1340
X,Y = list(map(int, input().split()))

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv
      
if (X+Y) % 3 > 0:
  print(0)
  exit(0)
  
K = (X+Y)//3

if X < K or Y < K:
  print(0)
  exit(0)

comb = Combination(K+10)
print(comb(K, X-K))

Measured memory_bytes: 116332
use std::fmt::Debug;
use std::str::FromStr;

#[allow(dead_code)]
#[allow(deprecated)]
fn read_line_from_stdin() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).unwrap();
    buffer.trim_right().to_owned()
}

#[allow(dead_code)]
#[allow(deprecated)]
fn parse_line_to_multiple<T>() -> Vec<T>
where
    T: FromStr,
    T::Err: Debug,
{
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).unwrap();
    buffer
        .trim_right()
        .split_whitespace()
        .flat_map(|s| T::from_str(s))
        .collect()
}

macro_rules! parse_line {
    [$( $x:tt : $t:ty ),+] => {
        //declare variables
        $( let $x: $t; )+
        {
            use std::str::FromStr;
            // read
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).unwrap();
            #[allow(deprecated)]
            let mut splits = buf.trim_right().split_whitespace();
            // assign each variable
            $(
                $x = splits.next().and_then(|s| <$t>::from_str(s).ok()).unwrap();
            )+
            // all strs should be used for assignment
            assert!(splits.next().is_none());
        }
    };
}

#[derive(Debug, Clone, Copy)]
struct Query {
    a: usize,
    b: usize,
    c: usize,
    d: usize,
}

fn main() {
    parse_line![n: usize, m: usize, q: usize];

    let queries = {
        let mut temp = vec![];
        for _ in 0..q {
            parse_line![a: usize, b: usize, c: usize, d: usize];
            temp.push(Query {
                a: a,
                b: b,
                c: c,
                d: d,
            });
        }
        temp
    };

    let mut max_score = 0;
    let mut nums = vec![1; n];

    loop {
        let mut score = 0;
        for &query in queries.iter() {
            if nums[query.b - 1] - nums[query.a - 1] == query.c {
                score += query.d;
            }
        }
        if max_score < score {
            max_score = score;
        }
        if next_nums(&mut nums, m).is_none() {
            break;
        }
    }

    println!("{} ", max_score);
}

fn next_nums(nums: &mut [usize], m: usize) -> Option<()> {
    let len = nums.len();
    // この位の値をカウントアップ
    nums[len - 1] += 1;
    if nums[len - 1] > m {
        // これ以上位上げができなければ終了
        if len - 1 == 0 {
            None
        } else {
            // 次の位をカウントアップ
            next_nums(&mut nums[..len - 1], m)?;
            // この数列は単調非減少だから
            // この位の値が次の位の値と同じになるようにする
            nums[len - 1] = nums[len - 2];
            Some(())
        }
    } else {
        Some(())
    }
}


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

int main(){
    int n; cin >> n;
    vector<string> w(n);
    set<string> chk;
    for(int i = 0; i < n; i++) {
        cin >> w[i];
        int chk_size0 = chk.size();
        chk.insert(w[i]);
        int chk_size1 = chk.size();
        if(chk_size0==chk_size1) {
            cout << "No" << endl;
            return 0;
        } else if(i > 0) {
            if(w[i-1].back()==w[i].front()) {
                continue;
            } else {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

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

    ll ans = 1e18;
    for(int bits = 0; bits <= (1<<n); bits++){
        vector<ll> rikai(m,0);
        ll cost = 0;
        for(int i=0;i<n;i++){
            if(!((bits >> i) & 1)) continue;
            cost += c[i];
            for(int j=0;j<m;j++){
                rikai[j] += a[i][j];
            }
        }
        bool ok = true;
        for(int i=0;i<m;i++){
            if(rikai[i] < x){
                ok = false;
                break;
            }
        }
        if(ok){
            ans = min(ans,cost);
        }
    }

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

Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main(){
    int n,i=1;
    while(true){
        cin>>n;
        if(n==0){
           break;
        }
        else{
        
        cout <<"Case "<<i<<": "<<n<<endl;
        i++;
        }
    }
    
    return 0;
}


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

using namespace std;

int main()
{
  string a;
  cin >> a;
  for (int i = 0; i < 3; i++)
    {
       if (a[i] == 'A' && a[i+1] == 'B')
         {
         cout << "Yes";
         return 0;
          }
       else
         {if (a[i] == 'B' && a[i+1] == 'A')
         {
         cout << "Yes";
         return 0;
          }}
    }
  cout << "No";
}


Measured memory_bytes: 384
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

struct Edge
{
    int a;
    int b;
};

struct Vertex
{
    int id;
    int parent;
    int root(vector<Vertex>& v)
    {
        if(parent == -1)
        {
            return id;
        }
        auto r = v[parent].root(v);
        parent = r;
        return r;
    }
};

int main(int, const char**)
{
    int n, m;
    cin >> n >> m;
    vector<Edge> e(m);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;
        e[i] = {a, b};
    }

    int count = 0;
    rep(i, m)
    {
        vector<Vertex> v(n);
        rep(j, n) v[j] = {j, -1};
        rep(j, m)
        {
            if(i == j)
            {
                continue;
            }
            auto& t = e[j];
            if(v[t.a].root(v) != v[t.b].root(v))
            {
                v[v[t.a].root(v)].parent = t.b;
            }
        }
        bool valid = true;
        rep(j, n - 1)
        {
            auto a = v[j].root(v);
            auto b = v[j + 1].root(v);
            if(!(a != -1 && b != -1 && a == b))
            {
                valid = false;
                break;
            }
        }
        if(!valid)
        {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0), cin.tie(0)
#define RI(x) x = rit()
#define RII(a,b) a = rit(), b = rit()
#define RIII(a,b,c) a = rit(), b = rit(), c = rit()
#define REP(I, N) for(int I=0;I<(N);I++)
#define REPP(I, N) for(int I=1;I<=(N);I++)
#define SZ(x) (int)(x).size()
#define P pair<int, int>
#define F first
#define S second
#define PB(x) push_back(x)
#define endl "\n"
#define ll long long
//#define int long long

//===================================================//

#define N 100000
#define modn 1000000007

using namespace std;
inline int rit(){
    int f=0,key=1;
    char ch;
    do{
        ch = getchar();
        if(ch=='-') key=-1;
    }while(ch<'0'||ch>'9');
    do{
        f = f*10+ch-'0';
        ch = getchar();
    }while(ch>='0'&&ch<='9');
    return f*key;
}
int n;
int32_t main(void){
    RI(n);
    while(n){
        if(n%10==9){
            puts("Yes");
            return 0;
        }
        n/=10;
    }
    puts("No");
	return 0;
}


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

def binary_search(l, target):
    left = 0
    right = len(l)
    while left<right:
        mid = (left+right)//2

        if target == l[mid]:
            return True
        elif target < l[mid]:
            right = mid
        else:
            left = mid+1

    return False

seki = [i*j for i in range(1, 10) for j in range(1, 10)]
seki.sort()

if binary_search(seki, n):
    print('Yes')
else:
    print('No')

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

int main(){
	while(1){
		int n;
		cin >>n;
		if(n==0)
			break;

		int h[n+1];
		for(int i=0; i<n+1; i++)
			cin >>h[i];
		
		for(int i=0; i<n+1; i++){
			int tmp[n];
			for(int j=0; j<i; j++)
				tmp[j]=h[j];
			for(int j=i+1; j<n+1; j++)
				tmp[j-1]=h[j];

			bool flg=true;

			int d=tmp[1]-tmp[0]; 
			for(int j=1; j<n-1; j++){
				if(tmp[j+1]-tmp[j]!=d){
					flg =false;
					break;
				}
			}

			if(flg){
				cout << h[i]<<endl;
				break;
			}
		}		

	}

	return 0;
}
				
				

Measured memory_bytes: 1160
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    char a[210];
    int i;
    int j;
    int length;
    int wr;
    int ans;
    
    cin >> a;
    
    length = strlen (a);
    for(i = 0; i < length/2; i++){
        wr = 0;
        for(j =0; j < i; j++){
            if(a[j] != a[j + i]){
                wr = 1;
            };
        };
            if(wr == 0){
                ans = 2*i;
            };
        };
    cout << ans << endl;
    

    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define L 100001

int main(){
  int N, min_sub = 0;
  int i, j, k, a, count = 0;
  int v[L] = {0};

  scanf("%d",&N);
  
  for(i=0;i<N;i++){
  	scanf("%d",&a);
    k = N;
    if(k >= L) k = 100000;
    if(k < a)
      min_sub++;
    else
      v[a] += 1;
  }
  
  for(i=1;i<=k;i++){
    if(v[i] > i)
      min_sub += v[i] - i;
    else if(v[i] < i)
      min_sub += v[i];
  }

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

  return 0;
}

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

#define    ll     long long int

int main( )
{
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
N,K,Q = map(int,input().split())

#正解数
A = [0] * N

#残るのに必要なline
line = Q - K + 1

#KがQよりおおきければ全員残れる
if line - 1 < 0:
    for i in range(N):
        print('Yes')
    exit()
#KがQより小さい時、K-Qの値より正解数が多くないと残れない

for i in range(Q):
    Ai = int(input())
    Ai -= 1
    A[Ai] += 1

for i in range(N):
    if A[i] >= line:
        print('Yes')
    else:
        print('No')



Measured memory_bytes: 50648
/**
 *    author:  ELEKI
 *    created: 16.03.2020 06:24:15       
**/
#include <iostream>

using namespace std;

typedef unsigned char uChar;
typedef unsigned int uInt;

constexpr uChar List[] = {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};

int main(){
  uInt K;
  cin >> K;
  cout << static_cast<uInt>(List[K-1]) << endl;
  return 0;
}

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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;i++)
#define rep2(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

ll dp[100005][13];

void Main() {
    int n;
    cin >> n;
    vector<double> a(n);
    double ans =0;
    for (int i = 0; i < n ; ++i) {
        cin >> a[i];
        ans += 1/a[i];
    }
    cout << 1/ans << endl;

}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int r;
    cin >> r;
    cout << r*r << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
neg = 0
sum_abs = 0
minn = float("inf")
for i in a:
    if i < 0:
        neg += 1
    sum_abs += abs(i)
    minn = min(abs(i),minn)
print(sum_abs - (neg%2)*minn*2)

Measured memory_bytes: 14412
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ll long long
#define len(v) (int)(v).size()

using namespace std;

struct RH{
    static ll mod[2], mul[2];
    static vector<ll> pm[2];
    string s; int sz; vector<ll> hs[2];
    void init(string& s){
        this->s = s, sz = len(s);
        rep(i,2){
            hs[i].resize(sz+1,0);
            if(pm[i].empty()) pm[i].push_back(1);
            rep(j,sz){
                hs[i][j+1] = (hs[i][j]*mul[i]+s[j])%mod[i];
            }
        }
    }
    pair<ll,ll> hash(int l,int r){
        if(l >= r) return make_pair(0,0);
        ll res[2];
        rep(i,2){
            while(len(pm[i]) <= r){
                pm[i].push_back(pm[i].back()*mul[i]%mod[i]);
            }
            res[i] = (hs[i][r] + mod[i] - hs[i][l] * pm[i][r-l] % mod[i]) % mod[i];
        }
        return make_pair(res[0],res[1]);
    }
};
vector<ll> RH::pm[2];
ll RH::mod[2] = {1000000007, 1000000009}, RH::mul[2] = {10009, 10007};

int main()
{
    int n,m;
    cin >> n >> m;
    string s;
    cin >> s;
    RH rh;
    rh.init(s);
    int l = 0, r = 1;
    set<pair<ll,ll> > st;
    rep(i,m){
        string t;
        cin >> t;
        if(t == "L++"){
            l++;
        }else if(t == "L--"){
            l--;
        }else if(t == "R++"){
            r++;
        }else{
            r--;
        }
        st.insert(rh.hash(l,r));
    }
    cout << len(st) << "\n";
}



Measured memory_bytes: 31740
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
// const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 1e6+1;
const int MOD = 1e9+7;

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;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

long long modpow(long long res,long long a, long long n, long long mod) {
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//sieve(MAX);でベクトルIsPrimeに「MAXまでの数値の素数の真偽」を格納する。
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
// ここから開始
int main(){
    ll x,y;
    cin>>x>>y;
    // case1
    ll ans = 2e9;
    if(x<=y) ans=lmin(ans,y-x);
    if(-x<=y) ans=lmin(ans,y+x+1);
    if(x<=-y) ans=lmin(ans,-y-x+1);
    if(-x<=-y) ans=lmin(ans,-y+x+2);
    cout<<ans<<endl;
    return 0;
}



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

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

prime_factors = collections.Counter(prime_factorize(N))

counter = 0
for p in prime_factors:
    e = 1
    while prime_factors[p] >= e:
        N //= p ** e
        prime_factors[p] -= e
        e += 1
        counter += 1

print(counter)

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

int main() {
  
  int x, y;
  cin >> x >> y;
  
  bool ans = false;
  
  if (x == 1 && y == 2 || y == 4) ans = true;
  else {
    REP(i,x+1) {
      if (i * 2 + (x - i) * 4 == y) ans = true;
    }
  }

  cout << (ans ? "Yes" : "No") << endl;
    
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
int t;
int n,m;
int dp[3005];
int c[3005];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i) scanf("%d",&c[i]);
    dp[0] = 0;
    ll ans = 0;
    for(int i=1;i<=n;++i)
    {
        ++dp[0];
        for(int j=m;j>=c[i];--j)
        {
            dp[j] = (dp[j] + dp[j-c[i]])%mod;
        }
        ans = (ans+dp[m])%mod;
    }
    printf("%lld\n",ans);
    return 0;
}


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

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

    int H[N];
    int ans = 0;
    int temp = 0;
    for (int i = 0; i < N; i++)
    {
        H[i] = 0;
        cin >> H[i];
        if (i > 0 && H[i - 1] >= H[i])
        {
            temp++;
        }
        if (i > 0 && H[i - 1] < H[i])
        {
            cerr << temp << endl;
            ans = max(ans, temp);
            temp = 0;
        }
        
    }
    cout << max(ans, temp) << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	long long int l, r;
	std::cin >> l >> r;
	long long int result = 2019;
	long long int temp;


	for (long long int i = l; i < r; i++) {
		for (long long int j = i + 1; j <= r; j++) {
			temp = i * j % 2019;
			if (temp == 0) {
				std::cout << 0 << std::endl;
				return 0;
			}
			else if (result > temp) {
				result = temp;
			}
		}
	}

	std::cout << result << std::endl;

	return 0;
}

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


struct UnionFind {
  vector<int> par; //par[i]:=iの親番号

  UnionFind(int N) : par(N) {
    rep(i, N) par[i]=i;
  }

  int root(int x) { //xが属する木の根を得る
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { //併合
    int rx=root(x);
    int ry=root(y);
    if (rx==ry) return;
    par[rx]=ry;
  }

  bool same(int x, int y) { //x, yが属する木が同じならtrue
    int rx=root(x);
    int ry=root(y);
    return rx==ry;
  }
};

int main() {
  int n,m; cin>>n>>m;
  vector<int> a(m),b(m);
  rep(i, m) {
    cin>>a[i]>>b[i];
    a[i]--; b[i]--;
  }

  int res=0;
  rep(i, m) {
    UnionFind uf(n);
    rep(j, m) {
      if (i==j) continue;
      uf.unite(a[j], b[j]);
    }
    if (!uf.same(a[i], b[i])) res++;
  }
  cout<<res<<endl;
}


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

#define iter(i, n) for (int i = 1; i <= n; ++i)
#define iter_r(i, n) for (int i = n; i >= 1; --i)

const int mod = 998244353;

#define NR 1010000
const int N = 1e6 + 10;
int n, m;

struct Int {
	int v;

	Int(int v = 0) : v(v) {}

	void operator+=(Int b) { v = (v + b.v) % mod; }
	void operator-=(Int b) { v = (v - b.v + mod) % mod; }
	void operator*=(Int b) { v = 1ll * v * b.v % mod; }
};

Int fac[NR], inv[NR];

Int operator+(Int a, Int b) { return (a.v + b.v) % mod; }
Int operator-(Int a, Int b) { return (a.v - b.v + mod) % mod; }
Int operator*(Int a, Int b) { return 1ll * a.v * b.v % mod; }

Int F(int n, int m) {
	return fac[n + m] * inv[n] * inv[m];
}

Int pr(Int a, int z) {
	Int s = 1;
	while (z > 0) {
		if (z % 2 == 1) s *= a;
		a *= a;
		z /= 2;
	}
	return s;
}

Int get_inv(Int a) { return pr(a, mod - 2); }

int main() {
	fac[0] = inv[0] = 1;
	iter(i, N) fac[i] = fac[i - 1] * i;
	inv[N] = get_inv(fac[N]);
	iter_r(i, N - 1) inv[i] = inv[i + 1] * (i + 1);

	scanf("%d%d", &n, &m); ++n; ++m;
	if (n > m) swap(n, m);
	Int last = 0, speed = 0, ans = 0;
	int _x = -1;
	const Int tot = F(n - 1, m - 1), tmp0 = F(n - 1, m - 2);
	iter(q, n + m - 2) {
	//	if (q > n - 1 && _x < n - 1) last -= n - 1;
	//	if (q > m - 1) last -= m - 1;		
		if (_x < n - 1) {
			if (q % 2 == 1) {
				++_x;
				int y = q - _x;

				if (_x == 0) {
					speed += F(n - 2, m - 1);
					speed += F(n - 1, m - 2);
				} else {
					//printf("!!\n");
					speed += F(_x, y - 2) * F(n - _x - 1, m - y - 1);
					speed += F(y - 2, _x) * F(m - _x - 1, n - y - 1);
				}
			} else {

				int y = q - _x;
			//	printf("c[%d %d]\n", _x, y);
				speed -= F(_x, y - 2) * F(n - _x - 2, m - y);
				speed -= F(y - 2, _x) * F(m - _x - 2, n - y);
			}
		} else speed = tmp0;
		last += speed;
	//	printf("c%d %d (%d %d %d %d)\n" ,last.v, speed.v, q, n, m, _x);



//		printf("[%d %d]\n", _x, q-_x);
//		printf("!%d %d\n", last.v, tot.v);
		ans += last * get_inv(q);
	}
	printf("%d\n", (ans * get_inv(tot)).v);
	return 0;
}

Measured memory_bytes: 8192
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const double eps = 1e-8;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

struct UnionFind {
	vector<ll> data;
	vector<set<ll>> edges;
	vector<ll> sum;
	UnionFind(ll size) : data(size, -1), edges(size), sum(size) { }
	bool unionSet(ll x, ll y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
			sum[x] += sum[y];
			for (auto &&tmp : edges[y])
				edges[x].insert(tmp);
		}
		return x != y;
	}
	bool findSet(ll x, ll y) {
		return root(x) == root(y);
	}
	int root(ll x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(ll x) {
		return -data[root(x)];
	}
};

typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
	Edge() :src(0), dst(0), weight(0) {}
	Edge(int src, int dst, Weight weight) :
		src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight < f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int main() {
	ll N, M;
	cin >> N >> M;
	vector<ll> node(N);
	for (int i = 0;i < N;i++)
		cin >> node[i];
	Graph g(N);
	map<Edge, ll> eid;
	Edges es(M);
	for (int i = 0;i < M;i++) {
		ll a, b, y;
		cin >> a >> b >> y;
		a--;
		b--;
		g[a].push_back(Edge(a, b, y));
		g[b].push_back(Edge(b, a, y));
		eid[Edge(a, b, y)] = i;
		eid[Edge(b, a, y)] = i;
		es[i] = Edge(a, b, y);
	}
	UnionFind uf(N);
	for (int i = 0;i < N;i++)
		uf.sum[i] = node[i];
	set<ll> ans;
	sort(es.begin(), es.end());
	for (auto &&edge : es) {
		ll from, to, cost;
		from = edge.src;
		to = edge.dst;
		cost = edge.weight;
		uf.unionSet(from, to);
		ll nownode = uf.root(from);
		uf.edges[nownode].insert(eid[edge]);
		if (uf.sum[nownode] >= cost) {
			for (auto &&tmp : uf.edges[nownode])
				ans.insert(tmp);
			uf.edges[nownode].clear();
		}
	}
	cout << M - (ll)ans.size() << endl;
	return 0;
}

Measured memory_bytes: 52480
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
#define ll long long
#define pb push_back
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const double PI  =3.141592653589793238463;
long long MOD = 1000000007;

int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}

ll f[2000001];



ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}

/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}

bool prime[100005];
void seive()
{  memset(prime,true,sizeof(prime));
    for(int i=2;i*i<=100005;i++)
    {
         if(prime[i]==true) {
        for(int j=2*i;j<=(100005);j+=i)
           { prime[j]=false;}
           }

    }
}
bool in(float x1,float y1,float x,float y,float r )
{
    if(abs(x1-x)*abs(x1-x)+abs(y1-y)*abs(y1-y)<=r*r) return true;
    return false;


}


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

	ll T;
   T=1;
	while(T--)
	{
    double n,t,a;
    cin>>n>>t>>a;
    vector<double>v(n);
    for(int i=0;i<n;i++) { cin>>v[i]; v[i]=t-(v[i]*0.006);}
    double mm = INT_MAX;
    int ans=-1;
    for(int i=0;i<n;i++)
    {
        if(abs(a-v[i])<mm) {mm=abs(a-v[i]); ans = i+1; }
    }
    cout<<ans<<endl;
}
}


Measured memory_bytes: 256
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()

f = 0
ff = 0
num = 12
if int(s[:2]) > num or int(s[:2]) == 0:
    f = 1
if int(s[2:]) > num or int(s[2:]) == 0:
    ff = 1

if f == 0 and ff == 0:
    print("AMBIGUOUS")
elif f == 1 and ff == 0:
    print("YYMM")
elif f == 0 and ff == 1:
    print("MMYY")
elif f == 1 and ff == 1:
    print("NA")

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

struct UnionFind {
  vector<int> par, rank;

  UnionFind(int n){
    par.resize(n);
    fill(par.begin(), par.end(), -1);
    rank.resize(n);
  }

  int root(int x){
    if(par[x] < 0){
      return x;
    }

    par[x] = root(par[x]);

    return par[x];
  }

  void unite(int x, int y){
    int rx=root(x);
    int ry=root(y);

    if(rx!=ry){
      if(rank[rx] >= rank[ry]){
        par[ry]=rx;

        if(rank[rx]==rank[ry]){
          rank[rx] += 1;          
        }
      }else{
        par[rx] = ry;
      }
    }
  }

  bool is_same(int x, int y){
    return root(x)==root(y);
  }

  int count(int x){
    return -par[root(x)];
  }
};

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

  UnionFind roads = UnionFind(n+1);
  UnionFind rails = UnionFind(n+1);

  for(int i=0;i<k;i++){
    int p,q;
    cin>>p>>q;
    roads.unite(p,q);
  }
  for(int i=0;i<l;i++){
    int r, s;
    cin>>r>>s;
    rails.unite(r,s);
  }

  map<pair<int, int>, int> counter;

  for(int i=1;i<=n;i++){
    counter[make_pair(roads.root(i), rails.root(i))]++;
  }

  for(int i=1;i<=n;i++){
    cout<<counter[make_pair(roads.root(i), rails.root(i))]<<' ';
  }
  cout<<endl;

  return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a > b) {
        cout << "a > b" << endl;
    }
    else if (a < b) {
        cout << "a < b" << endl;
    }
    else {
        cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define ll long long
const ll mod=1e9+7;
const int maxn=10000;
using namespace std;

int main()
//int found; found=chaine.find(cara); if (found!=std::string::npos) how to verify if a caracter exists in a chaine
// toupper(caractere) ==> return the majuscule of a caractere
//floor(x) Returns the largest integer smaller than x
//ceil(x) returns  Returns the smallest integer greater
/* #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
    #endif */
{

	int x;
	cin>>x;
	if(x>=30)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	
	
}




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

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

int N, C;
int D[30][30];
int c[3][500] = {0};

int main() {
  scanf("%d%d", &N, &C);
  
  REP(i,C) REP(j,C) scanf("%d", &D[i][j]);
  
  int buf;
  REP(i,N) REP(j,N) {
    scanf("%d", &buf);
    REP(k,C) c[((i+1)+(j+1))%3][k] += D[buf-1][k];
  }

  int minval = numeric_limits<int>::max();
  REP(i,C) REP(j,C) if(i!=j) REP(k,C) if(i!=k && j!=k) {
    int val = c[0][i] + c[1][j] + c[2][k];
    if (val < minval) minval = val;
  }

  printf("%d\n", minval);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	long long int n,m,nd;
    cin>>n>>m;
    nd=2*n;
    if(nd>m)
	cout<<m/2<<endl;
    else 
	if(nd==m)cout<<n<<endl;
    else
	{
        m-=nd;
        m/=4;
        cout<<n+m<<endl;
    }
    return 0;
}

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

int main(void) {
    long long K, A, B;
    cin >> K >> A >> B;
    long long ans = 1;
    if (B > A + 2 && A + 1 <= K) {
        long long remain = K;
        ans              = B;
        remain -= (A + 1);
        ans += (remain / 2) * (B - A) + remain % 2;
    } else {
        ans += K;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
// be name khoda
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
const ll maxn=100009;
vector <ll> adj[maxn];
ll p[maxn];
int main()
{
	ios_base::sync_with_stdio(false);
	ll n;	cin >> n; 
	ll cnt=0;
	for (ll i=0;i<n;i++)	{cin >> p[i];p[i]--;}
	for(ll i=0;i<n-1;i++)
	{
		if (p[i]==i)
		{	
			swap(p[i],p[i+1]);
			cnt++;
		}
	}
	if (p[n-1]==n-1) cnt++;
	cout<<cnt;
}


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

#define INF INT32_MAX

int main()
{
	int N;
	cin >> N;
	vector<int> H( N );
	for( int i = 0; i < N; i++) {
		cin >> H[i];
	}

	int last = H[0];
	int ans = 0;
	int ans1 = 0;
	for( int i = 1; i < N; i++ ) {
		if( H[i] <= last ) ans1++;
		else ans1 = 0;
		last = H[i];
		ans = max( ans, ans1 );
	}

	cout << ans << endl;
}


Measured memory_bytes: 640
from collections import deque

n,q=map(int,input().split())
que=deque([])
for _ in range(n):
    p,t=input().split()
    que.append((p,int(t)))
tm=0
while len(que):
    n1,n2=que.popleft()
    if n2>q:
        n2-=q
        que.append((n1,n2))
        tm+=q
    elif n2==q:
        print(n1,tm+q)
        tm+=q
    else:
        print(n1,tm+n2)
        tm+=n2


Measured memory_bytes: 12528
# by the authority of GOD   author: manhar singh sachdev #

import os,sys
from io import BytesIO, IOBase

def main():
    s,t = input().strip(),input().strip()
    fin = 10**10
    for i in range(len(s)-len(t)+1):
        ans = 0
        for j in range(len(t)):
            if s[i+j] != t[j]:
                ans += 1
        fin = min(fin,ans)
    print(fin)

#Fast IO Region
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == '__main__':
    main()

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

using namespace std;

int main(){
    int a,b;
    cin >>a >>b;
    for(int i= ceil( a/0.08);i<(a+1)/0.08;i++){
       // cout <<i <<endl;
        if(static_cast<int>(i*0.1)==b){
            cout << i <<endl;
            return 0;
        }
    }
    cout << -1 <<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;

signed main(){
    int n;
    cin >> n;
    double ans = 0;
    rep(i,n){
        double x;
        string s;
        cin >> x >> s;
        if(s == "JPY")ans += x;
        else ans += 380000*x;
    }
    cout << ans << endl;
    return 0;   
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://abc119.contest.atcoder.jp/tasks/abc119_a
// rm -r -f test;oj dl http://yahoo-procon2017-qual.contest.atcoder.jp/tasks/yahoo_procon2017_qual_c

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		var R = GetLongs(N);

		long ans = long.MinValue;
		long min = R[0];
		for(long i = 1; i < N; i++)
		{
			chmax(ref ans, R[i] - min);
			chmin(ref min, R[i]);
		}
		WriteLine(ans);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}


Measured memory_bytes: 27604
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl;
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

const int mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0) :x(x%mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
};

long long N, K;

mint dp[110][111000];
mint sdp[111000];
long long num[111000];

mint solve() {
	int iter = 0;
	for (int i = 1; i <= N;) {
		int j = N / i;
		if (i <= j) num[iter++] = 1, ++i;
		else num[iter++] = N / j - i + 1, i = N / j + 1; 
	}

	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for (int k = 0; k < K; ++k) {
		memset(sdp, 0, sizeof(sdp));
		for (int j = 0; j <= iter; ++j) sdp[j + 1] = sdp[j] + dp[k][j];
		for (int j = 0; j < iter; ++j) dp[k + 1][j] = sdp[iter - j] * mint(num[j]);
	}

	mint res = 0;
	for (int j = 0; j <= iter; ++j) res += dp[K][j];
	return res;
}


int main() {
	cin >> N >> K;
	puts(solve().x);

	return 0;
}


Measured memory_bytes: 97024