akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//
#include<cmath>
#include<iomanip>

using namespace std;

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

typedef long long ll;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0}; //次に行くところ
int dx[] = {0,1}; //s上に同じ

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

  int c = 0,ans = INT_MAX;
  vector<int> a(5);

  for (int i = 0; i < 5; i++){
    cin >> a[i];
  }
  
  sort(a.begin(),a.end());

  do{
    c = 0;
    for (int i = 0; i < 5; i++){
      c += a[i];
      if (c % 10 != 0 && i != 4){
        c += 10 - c % 10;
      }
    }
    chmin(ans,c);
  } while (next_permutation(a.begin(),a.end()));
  
  cout << ans << '\n';
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  return 0;
}

Measured memory_bytes: 3700
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::prelude::BufRead;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufReader, BufWriter, Write};
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::str::FromStr;


fn main() {
    let param = read_vector::<usize>();
    let (n, m) = (param[0], param[1]);
	let mut adj = vec![vec![]; n];
    for _ in 0..m {
        let line = read_vector::<usize>();
        let (a, b, _) = (line[0] - 1, line[1] - 1, line[2]);
        adj[a].push(b);
        adj[b].push(a);
    }
    let num = dfs(&adj);
    println!("{}", num);
}

fn dfs(adj: &[Vec<usize>]) -> usize {
    let mut num = 0;
    let mut stack = vec![];
    let mut used = vec![false; adj.len()];
    for i in 0..adj.len() {
        if used[i] {
            continue;
        }
        num += 1;
        stack.push(i);
        while stack.len() > 0 {
            let crt = stack.pop().unwrap();
            if used[crt] {
                continue;
            }
            used[crt] = true;
            for &nxt in adj[crt].iter() {
                if used[nxt] {
                    continue;
                }
                stack.push(nxt);
            }
        }
    }
    num
}

#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err: std::fmt::Debug {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf
        .trim()
        .parse()
        .unwrap();
}

#[allow(dead_code)]
fn read_vector<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();
}

#[allow(dead_code)]
fn read_matrix<T>() -> Vec<Vec<T>> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    use std::io::prelude::*;
    let stdin = stdin();
    return stdin
        .lock()
        .lines()
        .map(|line| line
            .unwrap()
            .split_whitespace()
            .map(|s| s.parse().unwrap())
            .collect())
        .collect();
}

Measured memory_bytes: 12540
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let s: String = read();
    let s: Vec<u8> = s.into_bytes();

    let mut total: i64 = 0;
    for i in 0..s.len() {
        let d = (s[i] - '0' as u8) as i64;
        let mut p10 = 1;
        for j in i..s.len() {
            let right = max(1, s.len()-j-1)-1;
            total += d * p10 * (1<<(i+right));
            p10 *= 10;
        }
    }
    println!("{}", total);
}

Measured memory_bytes: 4352
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer x = sc.nextInt();
        Integer y = sc.nextInt();
        Integer group1[] = { 1, 3, 5, 7, 8, 10, 12 };
        Integer group2[] = { 4, 6, 9, 11 };
        Integer group3[] = { 2 };
        if (Arrays.asList(group1).contains(x) && Arrays.asList(group1).contains(y)) {
            System.out.println("Yes");
        } else if (Arrays.asList(group2).contains(x) && Arrays.asList(group2).contains(y)) {
            System.out.println("Yes");

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

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

int main()
{
     ll q , h , s , d  , n ;  // q = 0.25 , h = 0.5 , 1 = s , 2 = D
     cin  >> q >> h >> s >> d  >> n;
     q*=4 ;
     h*=2 ;
     ll d1 ;
     ll x = min( q  ,  min (h , s ) ) ;

         d1 = d/2  ;

         if( n%2==0 )
         {
             if( d1 < x )
             {
                 cout << d*(n/2) << endl;
             }
             else
             {
                 cout << x*n << endl;
             }
         }
         else
         {

             if( d1 < x )
             {
                 cout << d* (n/2) + x << endl;
             }
             else
             {
                 cout << x*n <<endl;
             }
         }



}


Measured memory_bytes: 256
inf = input().split()
W = int(inf[0])
H = int(inf[1])
x = int(inf[2])
y = int(inf[3])
 
s=W*H
if not s%2==0:
  s = s//2+0.5
else:
  s = s/2
st = "{0:.9f}".format(s)
if W%2==0 and H%2==0:
  gx = W//2
  gy = H//2
  if gx==x and gy==y:
    print(st, 1)
  else:
    print(st, 0)
else:
  print(st, 0)


Measured memory_bytes: 3064
// Solution by ** Abhishek Mittal **
#include<iostream>
#include<fstream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>

#define FIO ios_base::sync_with_stdio(0);  cin.tie(0);
#define PI 3.14159265358979323846
#define mod 1000000007
#define ll long long
#define vll vector<long long>  

#define all(c) c.begin(), c.end()

// Used to traverse in any STL container with iterators
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

// Find whether element is present in given container or not
#define present(container, element) (container.find(element) != container.end())

// Finds whether element in present container is present in vector or not
#define cpresent(container, element) (find(all(container),element) != container.end())

using namespace std;

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    FIO
    
    int a,b,c,k;
    cin>>a>>b>>c;
    cin>>k;
    while(k--){
        if(b<=a)b*=2;
        else {
            if(c<=b)c*= 2;
        }
    }
    if(a<b && b<c)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    


    return 0;

}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define lli long long int 
int main()
{
    lli n,i,d=0,m;
    cin>>n;
    lli a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    m=a[0];
    for(i=1;i<n;i++)
    {
    	if(a[i]>m)
    	m=a[i];
    	else
    	d=d+m-a[i];
	}
	cout<<d;
	return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int n;
    ll k;
    cin>>n>>k;
    vi a(n);
    rep(i,n){
        cin>>a[i];
        a[i]--;
    }

    int pos=0,cnt=0,roop;
    vc<pi> visited(n);
    while(true){
        if(visited[pos].first){
            roop=cnt-visited[pos].second;
            // cerr<<"roop="<<roop<<"\n";
            break;
        }
        visited[pos].first=1;
        visited[pos].second=cnt;
        // cerr<<pos<<" "<<visited[pos].second<<"\n";
        pos=a[pos];
        cnt++;
    }

    if(k<visited[pos].second){
        rep(i,n){
            if(visited[i].second==k){
                cout<<i+1<<"\n";
                return 0;
            }
        }
    }

    k-=visited[pos].second;
    k%=roop;
    int ans=pos;

    rep(i,k){
        ans=a[ans];
    }

    cout<<ans+1<<"\n";
    
    return 0;
}

Measured memory_bytes: 5640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

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

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a[33] = {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 k;
    cin >> k;
    cout << a[k-1] << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define rep(i,n) for(int i=0;(i)<(n);i++)
typedef long long ll;
using namespace std;
int main(void){
    int n; cin >> n;
    int inv [100003];
    int x[100003];
    rep(i,n) cin >> x[i];
    int ans = 0;
    inv[1] = 1;
    for (int i = 2; i <= n; ++i)
        inv[i] = -1ll * (mod / i) * inv[mod % i] % mod;
    int tmp = 0;
    rep(i,n-1){
        tmp = (tmp + inv[i+1])%mod;
        ans = (1ll*(x[i+1]-x[i])*tmp + ans)%mod;
    }
    rep(i,n-1) ans = 1ll*ans*(i+1)%mod;
    cout << (ans+mod)%mod << endl;
}



Measured memory_bytes: 1024
#include <stdio.h>

int main() {
	int n, debt;
	scanf("%d", &n);
	debt = 100000;
	for (; n>0; n--) {
		int interest;
		interest = debt / 20;
		interest = (interest+999) / 1000 * 1000;
		debt += interest;
	}
	printf("%d\n", debt);
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, X, T;
  cin >> N >> X >> T;
  cout << (N + X - 1) / X * T << "\n";
}


Measured memory_bytes: 3604
import math
a,b,x=map(int,input().split())
c=b-(x/(a*a))
k=math.sqrt(c**2+(a*a/4))
if x<=a*a*b/2:
  o=(x*2/b)/a
  k=math.sqrt(o**2+b*b)
  print(math.degrees(math.acos(o/k)))
else:
  print(math.degrees(math.acos(a/(2*k))))

Measured memory_bytes: 3060
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);

    	int R=sc.nextInt();
    	int G=sc.nextInt();

    	int result=2*G-R;

    	System.out.println(result);

    }
}

//g=a+b/2→2g-r
//(2002+x)/2=2017

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define PI atan(1)*4
typedef long long int ll;
using namespace std;
char s[15];
char t[15]; 
int main()
{
	io;
	int a,b,c,k;
	int ans = 0;
	cin >> a >> b >> c >> k;
	if(k <= a){
		ans += k*1;
	}
	else{
		k-=a;
		ans += a;
		if(k > b){
			k -= b;
			ans -= k; 
		} 
	}
	cout << ans;
    return 0;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int solve(int x,int y ,int s){
    vector<int>kouhoX;
    vector<int>kouhoY;
    vector<int>ans;
    int index=0;
    for(int i =1;i<s;i++){
        for(int j =1;j<s;j++){
            if((int)(i*(100+x)/100)+(int)(j*(100+x)/100)==s){
                kouhoX.push_back(i);
                kouhoY.push_back(j);
                index++;
            }
        }
    }

    for(int i=0;i<index;i++){
        ans.push_back((int)(kouhoX[i]*(100+y)/100)+(int)(kouhoY[i]*(100+y)/100));
    }
    sort(ans.begin(),ans.end());
    return ans[ans.size()-1];
}

int main(int argc, char const *argv[]) {
    cin.tie(0);
    int x, y, s;
    vector<int> ans;
    while (1) {
        cin >> x >> y >> s;
        if (x == 0 && y == 0 && s == 0) break;
        ans.push_back(solve(x, y, s));
    }
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3180
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
bool cmp(int x,int y)
{
    return x>y;
}
const int N=200005;
const int mod=1e9+7;
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int flag=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size()-1;i++){
        if(s[i]==s[i+1]){
            cout<<i+1<<" "<<i+2<<endl;
            flag=1;
            break;
        }
        else if(i<s.size()-2&&s[i]==s[i+2]){
            cout<<i+1<<" "<<i+3<<endl;
            flag=1;
            break;
        }
    }
    if(!flag)
    cout<<-1<<" "<<-1<<endl;
    return 0;
}


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

for i in range(1,n+1):
    if i%3 == 0:
        print(" ",end="")
        print(i, end="")
    else:
        i_str = str(i)
        for j in range(len(i_str)):
            if i_str[j] == "3":
                print(" ",end="")
                print(i, end="")
                break
print("")


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

template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int n, m;
    cin >> n >> m;

    vector<int> a(m);
    rep(i, m) cin >> a[i];

    const int MOD = 1e9+7;

    ll dp[100100];
    for(int i = 0; i < 100100; ++i) {
        dp[i] = 0;
    }
    for(int i = 0; i < m; ++i) {
        dp[a[i]] = -1;
    }
    dp[n] = 1;
    for(int i = n-1; i >= 0; --i) {
        if(dp[i] == -1) {
            dp[i] = 0;
            continue;
        }

        dp[i] = (dp[i+1] + dp[i+2]) % MOD;
    }

    ll ans = dp[0];

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4436
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

long long fact(long long n) {
    long long ret = 1;
    loop(i, 1, n + 1) {
        ret *= i;
    }
    return ret;
}
int main() {
    int n; cin >> n;
    vector<pair<int, int>> v(n);

    rep(i, n) {
        int x, y; cin >> x >> y;
        v[i] = {x, y};
    }

    sort(v.begin(), v.end());
    double sum = 0.;
    int cnt = 0;
    do {
        auto prev = v[0];

        loop(i, 1, n) {
            auto cur = v[i];
            double dist = (prev.first - cur.first) *  (prev.first - cur.first)
                + (prev.second - cur.second) * (prev.second - cur.second);
            dist = sqrt(dist);

            sum += dist;
            prev = cur;
            cnt++;
        }
    } while(next_permutation(v.begin(), v.end()));

    double ans = sum / (double)fact(n);
    printf("%.8lf\n", ans);
}


Measured memory_bytes: 888
#include<iostream>
using namespace std;
int main() {
	int a, b, max;
	cin >> a >> b ;
	max = a + b;
	if (max < a - b) {
		max = a - b;
	}
	if (max < a*b) {
		max = a * b;
	 }
	cout << max << endl;

}

Measured memory_bytes: 256
//package manju;

import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double d = scan.nextDouble();
		double t = scan.nextDouble();
		double s = scan.nextDouble();
		if(d/s <= t) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
	}
}


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

int main() {
  int n;
  while (cin >> n) {
    if (n == 0) break;
    int mat[n+1][n+1];
    for (int i = 0; i < n; i++) {
      mat[i][n] = 0;
      for (int j = 0; j < n; j++) {
	cin >> mat[i][j];
	mat[i][n] += mat[i][j];
      }
    }
    for (int i = 0; i < n+1; i++) {
      mat[n][i] = 0;
      for (int j = 0; j < n; j++) {
	mat[n][i] += mat[j][i];
      }
    }
    for (int i = 0; i < n+1; i++) {
      for (int j = 0; j < n+1; j++) {
	cout << right << setw(5) << mat[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    int n;
    cin >> n;
    map<string, int> mp;
    string s;
    rep(i, n)
    {
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    ll tmp;
    ll res = 0;
    for (auto itr = mp.begin(); itr != mp.end(); itr++)
    {
        ll f = itr->second;
        tmp = f * (f - 1) / 2;
        res += tmp;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 11276
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
		if((1<=i && i<=9) || (100<=i && i<=999) || (10000<=i && i<=99999)) ans++;
	cout<<ans<<'\n';
	
	return 0;
}

Measured memory_bytes: 256
// Problem : C - Traveling Salesman around Lake
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

int a[200000];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    int k, n;
    cin >> k >> n;
    for (int i=0; i<n; i++)
        cin >> a[i];
    
    int ret = a[n-1] - a[0];
    for (int i=1; i<n; i++)
        ret = min(ret, k + a[i-1] - a[i]);
    
    cout << ret << "\n";

    return 0;
}


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

int main(){
  long long int n;
  cin >> n;
  vector<long long int> a(n),b(n),c(n);
  for(int i=0;i<n;i++)cin >>a.at(i);
  for(int i=0;i<n;i++)cin >>b.at(i);
  for(int i=0;i<n;i++)cin >>c.at(i);
  sort(a.begin(),a.end());
  sort(c.begin(),c.end());
  long long int ans=0;
  for(int i=0;i<n;i++){
    long long int ansa,ansb;
    auto iter1=lower_bound(a.begin(),a.end(),b.at(i));
    auto iter2=upper_bound(c.begin(),c.end(),b.at(i));
    ansa=iter1-a.begin();
    ansb=c.end()-iter2;
    ans+=ansa*ansb;
 }
  cout << ans <<endl;
}


Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main(void){

	int a, b, output;

	cin >> a >> b;

	if(a == 1){
		if(b == 2)
			output = 3;
		else if(b == 3)
			output = 2;
	}else if(a == 2){
		if(b == 1)
			output = 3;
		else if(b == 3)
			output = 1;
	}else if(a == 3){
		if(b == 1)
			output = 2;
		else if(b == 2)
			output = 1;
	}

	cout << output << endl;

return 0;
}

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

// ll extended_gcd(ll a, ll b, ll &x, ll &y)
// {
//     if(a==0)
//     {
//         x = 0;
//         y = 1;
//         return b;
//     }
    
//     ll x1,y1;
//     ll g = extended_gcd(b%a, a, x1, y1);
    
//     x = y1-(b/a)*x1;
//     y = x1;
//     return g;
// }

// ll powe(ll x,ll n) {
//   if(x==0) return 0;
//   if(n==0) return 1;
//   ll val = powe(x,n/2);
//   if(n%2) return (((val*val)%N)*x)%N;
//   return (val*val)%N;
// }

// ll comb(ll n, ll k) { 
//     if(k==0) return 1;
//     if(k==n) return 1;
//     return (((mods[n]*invmods[n-k])%N)*invmods[k])%N;
// }

// ll cofac(vector<vector<ll> > &adj) {
//   ll tot = 1, idx;
//   ll res = 1;

//   for(ll i=1;i<adj.size();i++) {
//     idx = i;

//     while(idx<adj.size() && !adj[idx][i])
//       idx++;

//     if(idx==adj.size())
//       return 0;

//     if(idx!=i) {
//       swap(adj[i],adj[idx]);
//       if((idx-i)%2)
//         res = -res;
//     }

//     vector<ll> temp(adj[i].begin(),adj[i].end());

//     ll val = temp[i];
//     for(ll j=i+1;j<adj.size();j++) {
//       ll ids[b] = adj[j][i];

//       for(ll k=i+1;k<adj.size();k++) {
//         adj[j][k] = ((val*adj[j][k])%N - (ids[b]*temp[k])%N + 2*N)%N;
//       }

//       tot = (tot*val)%N;
//     } 
//   }

//   for(ll i=1;i<adj.size();i++)
//     res = (res * adj[i][i])%N;
  
//   ll x,y;
//   extended_gcd(tot,N,x,y);
//   // cout<<(res*x)%N<<endl;
//   return (2*N+(res*x)%N)%N;
// }


int main() {

  string s,t;
  cin>>s>>t;

  ll n = s.length(), m = t.length();

  vector<vector<ll> > ids(26,vector<ll>());

  for(ll i=0;i<n;i++) {
    ids[s[i]-'a'].push_back(i);
  }

  ll prev = -1, ans=-1, count=0;

  for(ll i=0;i<m;i++) {

    char a = t[i];

    if(!ids[a-'a'].size()) {
      cout<<-1<<endl;
      return 0;
    }
    else {
      int b = a-'a';
      ll low = 0, high = ((ll)ids[b].size())-1, res=-1;
      // cout<<1<<endl;
      if(prev<=ids[b][0])
        res = ids[b][0];
      else if(prev>ids[b][high])
        res = -1;
      else {
        while(low<=high) {
          ll mid = low+(high-low)/2;
          if(ids[b][mid]==prev){
            res = ids[b][mid];
            break;
          }
          else if(ids[b][mid]<prev) {
            low = mid+1;
            res = ids[b][low];
          }
          else {
            high = mid-1;
          }
        }
      }
        
      if(res==-1) {
        count++;
        ans = count*n + ids[b][0];
        prev = ids[b][0]+1;
      }
      else{
        ans = count*n + res;
        prev = res+1;
      }
    }
  }

  cout<<ans+1<<endl;

  return 0;
} 


Measured memory_bytes: 1724
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define inf 1013161010
#define ninf -1013161010
#define mod 1000000007
#define ll long long
#define lf long double
#define in(x) scanf("%d",&x);
#define sz(x) ((int)x.size())
#define lld l64d
#define rep(i,n) for(i=0;i<n;i++)
#define rrep(i,n) for(i=n-1;i>=0;i--)
#define rep1(i,a,b) for(i=a;i<=b;i++)
#define rrep1(i,a,b) for(i=a;i>=b;i--)
#define stlfor(i,t) for(auto i =t.begin();i!=t.end();i++)
#define fr freopen("x.txt","r",stdin)
#define frc freopen("y.txt","w",stdout)
#define all(x) x.begin(),x.end()
#define set0(x) memset(x,0,sizeof(x))
#define dbg cout<<"yo "<<endl;
#define pset(n) fixed<<showpoint<<setprecision(n)

#define pii pair<int,int>
#define pll pair<ll,ll>
#define min_pq priority_queue<pll, vector<pll>, greater<pll> >
#define vpii vector<pair<int,int> >
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define mii map<int,int>
#define umii unordered_map<int,int>
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define modulo %
#define moduloe %=

typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> OST;

ll toint(const string &s) { stringstream ss; ss << s; ll x; ss >> x; return x; }
ll add(ll a, ll b) {a+=b; while(a >= mod) a-= mod; while(a<0) a+= mod;}
ll mul(ll a, ll b) {return (a * 1LL *b % mod);}
string tostring ( ll number ){  stringstream ss; ss<< number; return ss.str();}

const lf pi = 2*acos(0);
const int nn = 500006;
const lf EPS = 0.000000001;

ll gcd(ll a,ll b){return (b==0)? a:gcd(b,a%b); }
void nope(int num = 0){ if(num==0) cout<<"NO"; else cout<<"-1"; exit(0); }

int ans[nn], a[nn];
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll i,j,n,tt;
    tt=1;
    //cin>>tt;
    while(tt--)
    {
        int k;
        cin>>n>>k;
        rep(i, n)
            cin>>a[i];

        for(i=0;i<k;i++)
        {
            if(ans[i] == 0)
            {
                ans[i] = -1;
                for(j=0;j<n;j++)
                    if(a[j] + i <= k)
                        ans[a[j] + i] = 1;
            }
        }

        if(ans[k] == 1)
            cout<<"First"<<endl;
        else
            cout<<"Second"<<endl;


    }
    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


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

namespace ABC155C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var sDict = new SortedDictionary<string, int>(new Comparer());

            for (var i = 0; i < N; i++)
            {
                var s = Console.ReadLine();
                int value;
                if (!sDict.TryGetValue(s, out value))
                    sDict.Add(s, 1);
                else
                    sDict[s] = value + 1;
            }

            var ansList = new List<string>();
            foreach (var kvp in sDict.OrderByDescending(x => x.Value))
            {
                if (ansList.Any() && kvp.Value != sDict[ansList.First()])
                    break;

                ansList.Add(kvp.Key);
            }
            //Console.WriteLine();
            Console.WriteLine(string.Join(Environment.NewLine, ansList));
        }

        class Comparer : IComparer<string>
        {
            public int Compare(string x, string y) => string.Compare(x, y, StringComparison.OrdinalIgnoreCase);
        }
    }
}


Measured memory_bytes: 57412
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi
def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    # n, m = [int(x) for x in input().split()]  
    k, t = [int(x) for x in input().split()]  
    a = [int(x) for x in input().split()]  

    mx = max(a)
    el = k - mx
    print(max(0, mx - el - 1))
    
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""
a b a
d c d
a b a
"""


Measured memory_bytes: 9880
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------

signed main() {
	int a, b;
	char c;
	while (cin >> a >> c >> b && c != '?') {
		if (c == '+') cout << a + b << endl;
		if (c == '-') cout << a - b << endl;
		if (c == '*') cout << a * b << endl;
		if (c == '/') cout << a / b << endl;
	}
}


Measured memory_bytes: 3112
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String c = sc.next();

    if (c.equals("a") || c.equals("e") || c.equals("i") || c.equals("o") || c.equals("u")) {
      System.out.println("vowel");
    } else {
      System.out.println("consonant");
    }


  }

}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		int w = sc.nextInt();
		if (w >= s) {
			System.out.println("unsafe");
		} else {
			System.out.println("safe");
		}

	}

}

Measured memory_bytes: 35652
#include <bits/stdc++.h>
#define rep(i,n) for (int i=1;i<=(n);i++)
using namespace std;
typedef long long ll; //long longをllとして簡略
 
int main(){
  int n,k;
  cin >> n >> k;
  double ans=0;

  rep(i,n){
    double p=1;
    int x=i;

    while(x<k){
      p *=0.5;
      x *=2;
    }
    ans += p/n;
  }
  cout << setprecision(10)<< ans <<endl;
  return 0;
}

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

#define ll long long 
#define inf 1000000007

int main () {
  int n;
  cin >> n;
  if (n == 7 || n == 5 || n == 3) {
    cout << "YES" << endl;  
  }
  else {
    cout << "NO" << endl;  
  }

}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include <random>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll h,w,n;
    cin>>h>>w>>n;
    ll x,y;
    cin>>x>>y;
    string s,t;
    cin>>s>>t;
    ll nowx=x,nowy=y;
    rep(i,n){
        if(s[i]=='R'){
            nowy++;
            if(nowy>w){
                cout<<"NO"<<endl;
                return 0;
            }
        }
        if(t[i]=='L'){
            if(nowy>1) nowy--;
        }
    }
    nowy=y;
    rep(i,n){
        if(s[i]=='L'){
            nowy--;
            if(nowy<1){
                cout<<"NO"<<endl;
                return 0;
            }
        }
        if(t[i]=='R'){
            if(nowy<w) nowy++;
        }
    }
    rep(i,n){
        if(s[i]=='D'){
            nowx++;
            if(nowx>h){
                cout<<"NO"<<endl;
                return 0;
            }
        }
        if(t[i]=='U'){
            if(nowx>1) nowx--;
        }
    }
    nowx=x;
    rep(i,n){
        if(s[i]=='U'){
            nowx--;
            if(nowx<1){
                cout<<"NO"<<endl;
                return 0;
            }
        }
        if(t[i]=='D'){
            if(nowx<h) nowx++;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 920
#include<stdio.h>
#include<string.h>
int main() {

	int result = 0;
	char s[150][15];
	char s2[150][15];
	int s3[300];
	int m, n,i,j,max=0;
	scanf("%d", &n);

	for (i = 0; i < 200; i++) {
		s3[i] = 0;
	}
	for (i = 0; i < n; i++) {
		scanf("%s", &s[i]);
	}
	scanf("%d", &m);
	for (i = 0; i < m; i++) {
		scanf("%s", &s2[i]);
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			if (strcmp(s[i],s[j])==0) {
				s3[i]++;
			}
		}
		for (j = 0; j < m; j++) {
			if (strcmp(s[i], s2[j]) == 0) {
				s3[i]--;
			}
		}
	}

	for (i = 0; i < 150; i++) {
		if (s3[i] > max) {
			max = s3[i];
		}
	}
	printf("%d", max);

	return 0;
}

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int a, b, ans = 0;
	cin >> a >> b;
	for (int i = a; i <= b; i++) {
		string s = to_string(i), r(rbegin(s), rend(s));
		ans += r == s;
	}
	cout << ans << "\n";
}


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


Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInts(n)

	cnt := map[int]int{}

	for i := 0; i < n; i++ {
		cnt[a[i]]++
	}

	memo := 0
	for _, e := range cnt {
		memo += e*(e-1)/2
	}

	for i := 0; i < n; i++ {
		c := cnt[a[i]]
		fmt.Fprintln(wr, memo-(c*(c-1)/2)+(c-1)*(c-2)/2)
	}
}


Measured memory_bytes: 14464
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;

int inf  = 1e9;
int A[1005], B[1005];

int dp[10005];

int main() {
  fill(dp, dp+10005, inf);
  dp[0] = 0;
  int H,N; 
  cin >> H>>N;
  rep(i,N) {
    cin >> A[i] >> B[i];
  }
// dp[i] := min total magic power used to decrease the monster's life by i
  for (int i=0; i<N; ++i) {
    for (int j=0; j<H; j++) {

      int nj = min(j+A[i], H);
      dp[nj] = min(dp[nj], dp[j]+B[i]);
    }
  }
  // rep(i,H) cout << dp[i] << endl;
  cout << dp[H] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
using namespace std;
#define ll long long
#define int ll
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define TOAD
#ifdef TOAD
#define bug(x) cerr<<__LINE__<<": "<<#x<<" is "<<x<<endl
#define IOS() 
#else
#define bug(...)
#define IOS() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#endif
const ll inf = 1ll<<60;
const int iinf=2147483647;
const ll mod = 1e9+7;
const int maxn=500005;

signed main (){
  IOS();
  int N; cin>>N;
  string str, t; cin>>str>>t;
  int ans=0;
  REP(i,N){
    bool can=true;
    REP(j,N-i){
      if (str[i+j]!=t[j]){
        can=false;
      }
    }
    if (can){
      ans=i*2+(N-i);
      break;
    }
  }
  if (ans==0) ans=N*2;
  cout<<ans<<endl;

}/*
3 3 1
0 0 1
1 1 1
*/

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int a;
  cin>>a;
  vector<int> v(a);
  for(int i=0;i<a;i++){
  	cin>>v[i];
  }
  for(int i=0;i<a;i++){
  	if(v[i]%2==0){if(v[i]%3!=0){if(v[i]%5!=0){cout<<"DENIED"<<endl;return 0;}}}
  }
  cout<<"APPROVED"<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
K = int(input())
S = list(input())[: -1]
N = len(S)
mod = 10 ** 9 + 7

class Factorial:
  def __init__(self, n, mod):
    self.f = [1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i = [pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % mod * self.i[k] % mod

f = Factorial(N + K + 1, mod)

res = 0
for l in range(K + 1):
  r = K - l
  res += f.combi(l + N - 1, l) * pow(25, l, mod) % mod * pow(26, r, mod) % mod
  res %= mod
print(res)

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

using namespace std;
using ll=long long;

const int N=1e5+10;

int main(){
    int n;
    int ma=0;
    cin>>n;
    string a[n];
    map<string, int> t;
    for(string &i:a){
        cin>>i;
        if(t.count(i)){
            t[i]++;
        }
        else t.insert({i, 1});
        ma=max(ma, t[i]);
    }
    sort(a, a+n);
    int p=unique(a, a+n)-a;
    for(int i=0; i<p; i++){
        if(t[a[i]]==ma) cout<<a[i]<<endl;
    }
}


Measured memory_bytes: 26752
#include<iostream>
#include<string>

std::string x,y;
int lcs[1000][1000];

int max(int k,int l){
  if(k>l){
    return k;
  }else{
    return l;
  }
}

void LCS(int i,int j){
  if(x[i] == y[j]){
    lcs[i][j] = lcs[i-1][j-1]+1;
  }else{
    lcs[i][j] = max(lcs[i-1][j],lcs[i][j-1]);
  }
}

void pre(){
  for(int i=0;i<(int)y.size();i++){
    if(x[0] == y[i]){
      for(int j=i;j<(int)y.size();j++){
	lcs[0][j] = 1;
      }
      break;
    }else{
      lcs[0][i] = 0;
    }
  }

  for(int i=0;i<(int)x.size();i++){
    if(x[i] == y[0]){
      for(int j=i;j<(int)x.size();j++){
	lcs[j][0] = 1;
      }
      break;
    }else{
      lcs[i][0] = 0;
    }
  }

}

int main(){
  int q;
  std::cin >> q;
  for(int k=0;k<q;k++){
    std::cin >> x;
    std::cin >> y;
    int size_x=x.size(),size_y=y.size();
    pre();
    for(int i=1;i<size_x;i++){
      for(int j=1;j<size_y;j++){
	LCS(i,j);
      }
    }

    /*for(int i=0;i<size_x;i++){
      for(int j=0;j<size_y;j++){
	std::cout << lcs[i][j] << ' ';
      }
      std::cout << '\n';
    }
    */
    
    std::cout << lcs[size_x-1][size_y-1] << '\n'; 

  }
  return 0;
}



Measured memory_bytes: 7092
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {

    let op: String = read();
    let iter = op.chars();

    let mut ans: i32 = 0;

    for c in iter {

        if c == '+' {
            ans += 1;
        } else {
            ans -= 1;
        }
    }

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


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<functional>
using namespace std;
int main() {
	int a, b,c;
	cin >> a >> b>>c;
	if (a < b &&b< c) cout << "Yes" << endl;
	else cout << "No" << endl;
	cin >> a;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

string str[2020];

int main() {
    int n;
    while (cin >> n, n) {
        rep(i, n) cin >> str[i];
        rep(i, n) {
            int a = 0;
            while (a < str[i].size() and str[i][a] == '.') str[i][a++] = ' ';
            if (!a) continue;
            str[i][--a] = '+';
            int b = i-1;
            while (b >= 0 and a < str[b].size() and str[b][a] == ' ') str[b--][a] = '|';
        }
        rep(i, n) {
            cout << str[i] << endl;
        }
    }
}



Measured memory_bytes: 3864
import sys
import bisect

def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = [int(readline()) for _ in range(n)]
    res = []
    for i in range(n-1, -1, -1):
        p = bisect.bisect_right(res, a[i])
        if len(res) == p:
            res.append(a[i])
        else:
            res[p] = a[i]
    print(len(res))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 47580
def gcd(a, b):
  while(b > 0):
    a %= b
    a, b = b, a
  return a
def lcm(a, b):
  return a * b // gcd(a,b)
n = int(input())
md = int(1e9 + 7)
a = [int(e) for e in input().split()]
x = 1
for j in range(n):
  x = lcm(x, a[j])
ans = 0
for i in range(n):
  ans += x // a[i]
ans %= md
print(ans)


Measured memory_bytes: 4084
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from collections import deque
A = S()
Down = deque([])
S = deque([])

for i in range(len(A)):
    if A[i] == '\\':
        Down.append(i)
    elif A[i] == '/' and len(Down) != 0:
        j = Down.pop()
        a = i - j
        while len(S) > 0 and S[-1][0] > j:
            a += S.pop()[1]
        S.append((j, a))
ans = []
for i in range(len(S)):
    ans.append(S[i][1])
print(sum(ans))
ans.insert(0, len(ans))
print(' '.join(map(str, ans)))


Measured memory_bytes: 7300
N, M, X = map(int, input().split())
charge_list = list(map(int, input().split()))

count_up = 0
for i in range(M):
    if X < charge_list[i]:
        count_up += 1
    else:
        pass


count_down = 0
for i in range(M):
    if charge_list[i] < X:
        count_down += 1
    else:
        pass


print(min(count_up, count_down))


Measured memory_bytes: 3060