akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep2(i,a,n) for(int i = (a);i < (n);i++)
#define rep(i,n) rep2(i,0,n)

int main(void){
    int n;cin >> n;
    string s[n];rep(i,n)cin >> s[i];
    int num[4] = {};
    string t[4] = {"AC","WA","TLE","RE"};
    rep(i,n){
        rep(j,4){
            if(t[j] == s[i])num[j]++;
        }
    }
    rep(i,4){
        cout << t[i] << " x " << num[i] << endl;
    }
    
}

Measured memory_bytes: 6756
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] a = new Integer[n];
        int[] max = new int[2];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            if (a[i] >= max[1]) {
                max[0] = i;
                max[1] = a[i];
            }
        }

        for (int i = 0; i < n; i++) {
            if (i == max[0]) {
                int result = 0;
                for (int j = 0; j < n; j++) {
                    if (a[j] >= result && max[0] != j) {
                        result = a[j];
                    }
                }
                System.out.println(result);
            } else {
                System.out.println(max[1]);
            }
        }
    }
}


Measured memory_bytes: 95484
#include <bits/stdc++.h>
//F6編譯，右上三角形執行，ctrl+c強制停止執行  F5開啟exe
#define ll long long
#define maxn 10005
#define mod 1000000007
using namespace std;

typedef pair<int, int> P;

int n;
string s;
int k;
ll ans = 0;

int main()
{
    cin >> s;
    cin >> k;
    n = s.length();
    if (k == 1)
    {
        for (int i = n - 1; i >= 0; i--)
        {
            if (i > 0)
                ans += 9;
            else
                ans += s[i] - '0';
        }
        printf("%lld\n", ans);
    }
    else if (k == 2)
    {
        for (int i = n - 1; i >= 0; i--)
        {
            for (int j = i - 1; j >= 0; j--)
            {
                if (j > 0)
                    ans += 81;
                else
                {
                    ans += (s[j] - '1') * 9;
                    bool ok = 0;
                    for (int w = 1; w < i; w++)
                        if (s[w] > '0')
                            ok = 1;
                    if (ok)
                        ans += 9;
                    else
                        ans += s[i] - '0';
                }
            }
        }
        printf("%lld\n", ans);
    }
    else
    {
        for (int i = n - 1; i >= 0; i--)
        {
            for (int j = i - 1; j >= 0; j--)
            {
                for (int w = j - 1; w >= 0; w--)
                {
                    if (w > 0)
                        ans += 9ll * 9 * 9;
                    else
                    {
                        ans += (s[w] - '1') * 9ll * 9;
                        bool ok = 0;
                        for (int z = 1; z < j; z++)
                            if (s[z] > '0')
                                ok = 1;
                        if (ok)
                            ans += 81ll;
                        else
                        {
                            if (s[j] == '0')
                                continue;
                            ans += (s[j] - '1') * 9ll;
                            for (int z = j + 1; z < i; z++)
                                if (s[z] > '0')
                                    ok = 1;
                            if (ok)
                                ans += 9ll;
                            else
                                ans += (ll)(s[i] - '0');
                        }
                    }
                }
            }
        }
        printf("%lld\n", ans);
    }

    return 0;
}


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

const int N = 605;


char mx[N][N];
int dep[N][N];

int ant, n;


int main() {
#ifdef HOME
	freopen("agc23b.in", "r", stdin);
	freopen("agc23b.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	bool flag;

	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> mx[i];

	for (int shift = 0; shift < n; ++shift) {
		flag = true;
		for (int i = 0; i < n && flag; ++i)
		for (int j = 0; j < n && flag; ++j)
			flag&= mx[i][(j + shift) % n] == mx[j][(i + shift) % n];
		if (flag)
			ant+= n; }

	cout << ant << endl;

	return 0; }


Measured memory_bytes: 384
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    double n, m, d;
    cin >> n >> m >> d;
    double res;
    if (d == 0)
        res = (m - 1) / n;
    else
        res = 2 * (m - 1) * (n - d) / n / n;
    cout << fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=2e5;
int N,a[MAX_N],b[MAX_N],temp[MAX_N];
ll ans[29];
int main(){
	cin>>N;
	REP(i,N){
		cin>>a[i];
	}
	REP(i,N){
		cin>>b[i];
	}
	REP(k,29){
		REP(i,N){
			temp[i]=b[i]%(1<<(k+1));
		}
		sort(temp,temp+N);
		REP(i,N){
			int a2=a[i]%(1<<(k+1));
			ans[k]+=lower_bound(temp,temp+N,(1<<(k+1))-a2)-lower_bound(temp,temp+N,(1<<k)-a2);
			ans[k]+=lower_bound(temp,temp+N,(1<<(k+2))-a2)-lower_bound(temp,temp+N,(1<<k)*3-a2);
		}
	}
	ll ans2=0;
	REP(i,29){
		ans2+=ans[i]%2*(1<<i);
	}
	cout<<ans2<<endl;
	return 0;
}

Measured memory_bytes: 2560
# C - Forbidden List
def main():
    X, _, *P = map(int, open(0).read().split())
    P = set(P)
    for i in range(100):
        if X - i not in P:
            print(X - i)
            return
        if X + i not in P:
            print(X + i)
            return


if __name__ == "__main__":
    main()


Measured memory_bytes: 9188
open Printf
open Scanf

let () =
  let n, q = scanf "%d %d " (fun x y -> (x, y)) in
  let st = Array.make (4*n) 0 in
  let add s t x =
    let rec iter k l r =
      if t <= l || r <= s then ()
      else if s <= l && r <= t then
        st.(k) <- st.(k) + x
      else
        let m = (l + r) / 2 in
        iter (2*k) l m;
        iter (2*k+1) m r in
    iter 1 0 n in
  let get i =
    let rec iter k l r s =
      if i = l && i+1 = r then s + st.(k)
      else
        let m = (l + r) / 2 in
        if i < m then iter (2*k) l m (s + st.(k))
        else iter (2*k+1) m r (s + st.(k))
    in
    iter 1 0 n 0 in
  let rec loop c =
    if c = 0 then ()
    else
      begin
        begin
          let com = scanf "%d " (fun a -> a) in
          if com = 0 then
            let s, t, x = scanf "%d %d %d " (fun a b c -> (a-1, b, c)) in
            add s t x
          else
            let i = scanf "%d " (fun a -> a-1) in
            get i |> printf "%d\n"
        end;
        loop (c-1)
      end
  in loop q

Measured memory_bytes: 7768
n, k = [int(x) for x in input().split()]
hs = [int(x) for x in input().split()]
dp = {}
dp[0] = 0 # start

for i in range(n):
    for j in range(1, k + 1):
        to = i + j
        if to >= n:
            break
        cost = abs(hs[to] - hs [i]) + dp[i]
        if to in dp:
            if dp[to] > cost:
                dp[to] = cost
        else:
            dp[to] = cost

print(dp[n-1])


Measured memory_bytes: 62816
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*/
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it){   cout << endl ;}

template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}
int ini(){int x; scanf("%d",&x);return x;}
long long inl(){ long long x;scanf("%lld",&x); return x;}
double ind(){double x; scanf("%lf",&x);return x;}
#define Iin ini();
#define Lin inl();
#define Din ind();

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);

int a[N];

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //ios_base::sync_with_stdio(false); 
    //cin.tie(NULL);  

    int t=1,te=0;
    while(t--){
        int n;
        cin>>n;

        for(int i=1;i<=n;i++)a[i]=ini();
        int res=0,cur=0;

        for(int i=2;i<=n;i++){
            if(a[i]<=a[i-1]){
                cur++;
            }
            else{
                res=max(res,cur);
                cur=0;
            }
        }
        res=max(res,cur);

        cout<<res<<endl;

        //printf("Case %d: ",++te);
    }
    return 0;
}


Measured memory_bytes: 640
import java.util.*;

 class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();
		String[] inputArray = input.split(" ");

		if(inputArray.length == 3){
			int a = Integer.parseInt(inputArray[0]);
			int b = Integer.parseInt(inputArray[1]);			
			int c = Integer.parseInt(inputArray[2]);
			if(a < b&&b<c){
			
				System.out.println("Yes");
					
			}
			else{

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

Measured memory_bytes: 26060
#include<stdio.h>
int main()
{
    int A,B,C;
    scanf("%d%d%d",&A,&B,&C);
    if(A==5 && B==7 && C==5)
        printf("YES\n");
    else if(A==5 && B==5 && C==7)
        printf("YES\n");
    else if(A==7 && B==5 && C==5)
        printf("YES\n");
    else
        printf("NO\n");

}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int f(int x) {
  int res = 0;
  while(x % 2 == 0) {
    x /= 2;
    res++;
  }
  return res;
}

ll gcd(ll m, ll n) {
  if(m < n) swap(m, n);
  if(n == 0) return abs(m);
  else return gcd(n, m % n);
}

ll lcm(ll m, ll n) {
  return abs(m*n) / gcd(m, n);
}

int main() {
  int n, m; cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  // a -> a'
  rep(i, n) a[i] /= 2;

  // a' -> a''
  int t = f(a[0]);
  rep(i, n) {
    if(f(a[i]) != t) {
      cout << 0 << endl;
      return 0;
    }
    a[i] >>= t; // a[i] /= 2^t
  }
  m >>= t;
  ll l = 1;
  rep(i, n) {
    l = lcm(l, a[i]);
    if(l > m) {
      cout << 0 << endl;
      return 0;
    }
  }

  m /= l;
  int ans = (m+1)/2;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <functional>
#include <iomanip>
using namespace std;

#define rep(p,q) for(int i = p;i < q;i++)

#define LL long long int

#define inf 10000000000

LL insertSort(vector<int>& ar,int n,int g) {
	LL count = 0;
	rep(g, n) {
		int v = ar[i];
		for (int j = i - g; -1 < j && v < ar[j]; j -= g) {
			ar[j + g] = ar[j];
			ar[j] = v;
			count++;
		}
	}
	return count;
}

int main(void) {
	int n;
	LL count = 0;
	cin >> n;
	vector<int> v = vector<int>();
	rep(0, n) {
		int a;
		cin >> a;
		v.push_back(a);
	}
	vector<int> g = vector<int>();
	int h = 1;
	g.push_back(h);
	//最も効率がいいらしい O(n^1.25)
	while (3 * h + 1 < n) {
		h = 3 * h + 1;
		g.push_back(h);
	}
	reverse(g.begin(),g.end());
	if (n == 1) {
		cout << 1 << endl << 1 << endl << 0 << endl;
		cout << v[0] << endl;
	}
	else {
		rep(0, g.size()) {
			count += insertSort(v, n, g[i]);
		}
		cout << g.size() << endl;
		rep(0, g.size() - 1) {
			cout << g[i] << " " ;
		}
		cout << g[g.size() - 1] << endl;
		cout << count << endl;
		rep(0, n) {
			cout << v[i] << endl;
		}
	}
}



Measured memory_bytes: 7072
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
using namespace std;
using ll = long long;
#define rep(i,n) for(decltype(n) i=0; i<n; ++i)
inline constexpr ll Inf = (1ULL << 62) -1;

template <class T>
void updatemax(T& a, T b) { if (b > a) a = b; }

int main() {
    ll N;
    cin >> N;
    vector<ll> v(N);
    rep(i,N) cin >> v[i];
    sort(v.begin(), v.end());
    ll ans=0;
    rep(i,N-2) {
        for(ll j=i+1; j < N-1; ++j) {
            if (v[i] == v[j])
                continue;
            ll len = v[i] + v[j];
            for (ll k=j+1; k<N; ++k) {
                if (v[j] == v[k])
                    continue;
                if (v[k] < len) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3196
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<ll> dijkstra(vector<vector<pair<ll,ll>>> const& edge, ll start){
    ll N = edge.size();
    vector<ll> dist(N,INF);
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>, greater<pair<ll,ll>> > q;
    q.push(mp(0, start));
    vector<bool> visited(N,false);
    
    ll from,d;
    ll to,cost;
    while(!q.empty()){
        tie(d,from) = q.top(); q.pop();
        if (visited[from]) continue;
        visited[from] = true;
        dist[from] = d;
        for(auto e:edge[from]){
            tie(to,cost) = e;
            if (visited[to]) continue;
            q.push(mp(d+cost, to));
        }
    }

    return dist;
}
//fixed<<setprecision(10)<<ans<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    vector<vector<pair<ll,ll>>> edge(N);
    int l,r,c;
    REP(i,M){
        cin >> l >> r >> c;
        l--;r--;
        edge[l].push_back(mp(r,c)); 
    }
    REP(i,N-1) edge[i+1].push_back(mp(i,0)); //重み0の辺
    auto dist = dijkstra(edge, 0);

    if (dist[N-1]>=INF) cout << -1 << endl;
    else cout << dist[N-1]<< endl;
}


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << " : " << x << endl;
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

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

    if (n == m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

///////////////////////////////////////////
const long long int INF = 1000000000000000000LL;
using ll = long long int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return 1; } return 0; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return 1; } return 0; }
template<class T>T sqar(T x){ return x*x; }
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
///////////////////////////////////////////

int main(){
    int n;
    string s;
    cin>>n>>s;
    int ck[3*100000+1]={0};
    rep(i,n){
        if(s[i]=='E'){
            if(i==0){ ck[i]++; }else{ ck[i]=ck[i-1]+1; }
        }else{
            if(i!=0){ ck[i]=ck[i-1]; }
        }
    }
    int ans = 3*100000+1;
    rep(i,n){
        if(i==0)ans=ck[n-1]-ck[0];
        ans = min(ans,i - ck[i-1]  + ck[n-1] - ck[i]);
    }
    cout<<ans<<endl;
}






















Measured memory_bytes: 1796
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

void call(int n) {
    for (int i = 1; i <= n; ++i) {
        if (i % 3 == 0) {
            cout << " " << i;
        } else {
            int x = i;
            while (x) {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
}

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

    int n;
    cin >> n;
    call(n);
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<string>S(N);
  for(int i=0;i<N;i++){
    cin>>S.at(i);
  }
  sort(S.begin(),S.end());
  vector<pair<int,string>>SS;
  SS.push_back(make_pair(1,S[0]));
  for(int i=1;i<N;i++){
    if(S.at(i)==S.at(i-1)){
      SS.at(SS.size()-1).first=SS.at(SS.size()-1).first+1;
    }
    else{
      SS.push_back(make_pair(1,S[i]));
    }
  }
  sort(SS.begin(),SS.end());
  reverse(SS.begin(),SS.end());
  int M=SS.at(0).first;
  vector<string>T;
  for(int i=0;i<SS.size();i++){
    if(SS.at(i).first==M){
      T.push_back(SS.at(i).second);
    }
  }
  sort(T.begin(),T.end());
  for(int i=0;i<T.size();i++){
    cout<<T.at(i)<<endl;
  }
}


Measured memory_bytes: 21488
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		for(int i=0;i<=s.length()-2;i++) {
			if(s.substring(i, i+2).equals("AC")) {
				System.out.println("Yes");
				System.exit(0);
			}
		}
		System.out.println("No");
	}
}



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

// main
int main(){

    string S; cin >> S;
    int n = S.size();

    ll sum = 0;

    for(int bit = 0; bit < (1<<(n-1)); ++bit){
        string num_str("");
        for(int i = 0; i < n; ++i){
            num_str += S[i];
            if(bit & (1<<i)){
                sum += stoll(num_str);
                num_str = string();
            }
        }
        sum += stoll(num_str);
    }

    cout << sum << endl;

    return 0;
}

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

int main() {
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << fixed << setprecision(8) << sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1)) << endl;
}

Measured memory_bytes: 3264
use std::io::{self, Read};

fn main() {
    //io::stdin().read_line(&mut line).ok();
    let mut buffer = String::new();
    let stdin = io::stdin();
    stdin.lock().read_to_string(&mut buffer).ok();

    let s = buffer.trim().to_lowercase();

    let alphabets = (b'a'..b'z'+1).map(|c| c as char);
    let nums = alphabets.map(|a| (a, s.chars().filter(|&c| c == a).count()));
    for num in nums {
        println!("{} : {}", num.0, num.1);
    }
}



Measured memory_bytes: 5040
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const long double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a = 0, b = 0, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> n;
  a = 2;
  b = 1;
  ans = 2;
  vlli d;
  d.pb(a);
  d.pb(b);
  rep(i, 0, n)
  {
    ans = a + b;
    a = b;
    b = ans;
    d.pb(ans);
  }
  cout << d[n] << endl;
}

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

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;
        

        static void Main(string[] args)
        {
            var x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var ans = 0;

            for(int i = 0; i < 5; i++)
            {
                if (x[i] == 0) ans = i + 1;
            }

            Console.WriteLine(ans);


        }

        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }

        /*static public void DFS(int h, int w, bool[][] _visited)
        {
            
            if (w < 0 || h < 0 || h > _visited.Length - 1 || w > _visited[h].Length-1 || map[h][w]=='x')
                return;
            if (_visited[h][w])
                return;
            //Console.WriteLine(h + " " + w+" "+ _visited[h].Length + " " + _visited.Length);
            _visited[h][w] = true;

            DFS(h + 1, w,_visited);
            DFS(h - 1, w,_visited);
            DFS(h, w + 1,_visited);
            DFS(h, w - 1,_visited);

        }*/
        
        
        
    }
}


Measured memory_bytes: 28268
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}
//void chmin(ll &a,ll b){if(a>b) a = b ;}

int main(){
	ll n ; cin >> n ;
	vvll g(n,vll(n)) ;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			char c ;
			cin >> c ;
			c -= '0' ;
			g.at(i).at(j) = c ;
		}
	}
	ll ans = -1 ;
	queue<ll> q ;
	for(int i=0;i<n;i++){
		vll d(n,INF) ;
		d.at(i) = 1 ;
		q.push(i) ;
		while(!q.empty()){
			ll p = q.front() ;
			q.pop() ;
			for(int i=0;i<n;i++){
				if(g.at(p).at(i)&&d.at(i)>d.at(p)+1){
					d.at(i) = d.at(p)+1 ;
					q.push(i) ;
				}
			}
		}
		bool ok = true ;
		for(int i=0;i<n;i++){
			if(!ok) break ;
			for(int j=i;j<n;j++){
				if(g.at(i).at(j)&&d.at(i)==d.at(j)){
					ok = false ;
					break ;
				}
			}
		}
		if(ok){
			for(int i=0;i<n;i++) ans = max(ans,d.at(i)) ;
		}
	}
	cout << ans << endl ;
}


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

using namespace std;

int main()
{
	int n;
	string s;
	cin >> n >> s;
	int x = 0;
	int maxx = 0;
	for (auto&& si : s)
	{
		if (si == 'I') x++;
		else x--;
		maxx = max(maxx, x);
	}
	cout << maxx << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	
	while(true){
		
		int n;
		
		cin >> n;
		
		if(n == 0){
			break;
		}
		
		int first = 100000;
		int second = 100000;
		int boobee = -1;
		int last = -1;
		
		string fir = "";
		string sec = "";
		string boo = "";
		string las = "";
		
		for(int loop = 0; loop < n; loop++){
			string str;
			int a, b;
			cin >> str;
			int sum = 0;
			for(int i = 0; i < 4; i++){
				cin >> a >> b;
				sum += a * 60 + b;
			}
			if(sum < first){
				second = first;
				first = sum;
				sec = fir;
				fir = str;
			}else if(sum < second){
				second = sum;
				sec = str;
			}
			if(sum > last){
				boobee = last;
				last = sum;
				boo = las;
				las = str;
			}else if(sum > boobee){
				boobee = sum;
				boo = str;
			}
		}
		
		cout << fir << endl << sec << endl << boo << endl;
		
	}
	return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){ 
  int n,k,q; cin >> n >> k >> q;
  vector<int>x(n,k-q);

  rep(i,q){
    int a;
    cin >> a;
    x[a-1]++;
  }
  rep(i,n){
    if(x[i]<=0){
      cout << "No" << endl;
    }else{
      cout << "Yes" <<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <string>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template<class T> using vv=vector<vector<T>>;
typedef deque<int> di;
typedef deque<deque<int>> ddi;


int main() {
    int q;
    cin >> q;
    rep(i,q) {
        string x,y;
        cin >> x >> y;
        int dp[1050][1050] = {};
        rep(i,(int)x.length()) {
            rep(j,(int)y.length()) {
                if(i == 0 && j == 0) {
                    if(x[i] == y[j]) {
                        dp[i][j] = 1;
                    } 
                } else if(i == 0) {
                    if(x[i] == y[j]) {
                        dp[i][j] = 1;
                    } else { 
                        dp[i][j] = dp[i][j-1];
                    }
                } else if(j == 0) {
                    if(x[i] == y[j]) {
                        dp[i][j] = 1;
                    } else { 
                        dp[i][j] = dp[i-1][j];
                    }
                } else if(x[i] == y[j]) {
                    dp[i][j] = dp[i-1][j-1] +1;
                } else {
                    dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
                }
            }
        }
        cout << dp[x.length()-1][y.length()-1] << endl;
    }
	return 0;
}

Measured memory_bytes: 7532
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int p = 13331;
map<ll,int>has1;
long long hh[5005]={0};
long long aa[5005]={0};
char s[5005]={0};
ll gethashcode(int i,int j){
    if(i==0)
        return hh[j];
    else
    return hh[j]-hh[i-1]*aa[j-i+1];
}
int n;
bool check(int m){
        has1.clear();
        ll num;
        for(int i=1;i+m-2<=n;i++){
        num=gethashcode(i,i+m-1);
        if(has1[num]){
            if(has1[num]<=i-m)
                return 1;
            //cout << i << " " << has1[num] << endl;
        }
        else
            has1[num]=i;
    }
    return 0;
}
int main()
{
    cin >> n;
    cin >> s;
    ll num;
    aa[0]=0;
    for(int i=0;i<n;i++){
        hh[i+1]=hh[i]*p+s[i]-'a';
    }
    aa[0]=1;
    for(int i=1;i<=n;i++)
        aa[i]=aa[i-1]*p;
    int res=0;
    int l=0,r=n;
    int mid;
    int flag=0;
    //cout << check(5) << endl;
    while(l<r){
        mid=(l+r)/2;
        if(check(mid)){
            res=mid;
            l=mid+1;
        }
        else
            r=mid;
    }
    printf("%d\n",res);
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,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 ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;cin>>n>>k;
    ll a = n/k;
    ll ans = a*a*a;
    if(k%2==0){
        a = (n+k/2)/k;
        ans += a*a*a;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

vector<int> enum_div(int n) {
    vector<int> result;
    for (int i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            result.push_back(i);
            if (i*i != n) {
                result.push_back(n/i);
            }
        }
    }
    return result;
}

long long gcd(long long a, long long b) { return b?gcd(b,a%b):a;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, k;
    cin >> a >> b >> k;
    auto v = enum_div(gcd(a, b));
    sort(v.rbegin(), v.rend());
    cout << v[k-1] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<math.h>
#include<queue>
#include<stack>
#include<map>
using namespace std;
int main(){
  int n;
  cin >> n;int i;
  for(i=1; i<=n; i++){
    if(pow(2,i)>n)break;
  }
  if(n<i)i=n;
  cout << pow(2,i-1) << endl;
  return 0;
}


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

using namespace std;

template <class T>inline T updmax(T &a, T b) { return a = max(a, b); }
template <class T>inline T updmin(T &a, T b) { return a = min(a, b); }

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	int r = 0;
	for(int i=1; i <= n; i++){
		if(0 <= i && i < 10){
			r++;
		}
		else if(100 <= i && i < 1000){
			r++;
		}
		else if(10000 <= i && i < 100000){
			r++;
		}
	}
	cout << r << "\n";
	return 0;
}

Measured memory_bytes: 256
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Thu Jan 16 11:50:34 2020
//
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	was := make([]int, n)
	acs := make([]bool, n)
	for i := 0; i < m; i++ {
		var p int
		var s string
		fmt.Scan(&p, &s)
		if s == "AC" {
			acs[p-1] = true
		} else if !acs[p-1] {
			was[p-1]++
		}
	}

	nac := 0
	for i := range acs {
		if acs[i] {
			nac++
		}
	}
	nwa := 0
	for i := range was {
		if acs[i] {
			nwa += was[i]
		}
	}
	fmt.Println(nac, nwa)
}


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

#define int long long
const int N = 1000005;

int n,a[N];

void dfs(int p,int lim) {
    if(p==n+1) {
        for(int i=1;i<=n;i++) cout<<(char)(a[i]+'a'-1);
        cout<<endl;
    }
    else for(int i=1;i<=lim;i++) {
        a[p]=i;
        dfs(p+1,lim+(i==lim));
    }
}

signed main() {
    cin>>n;
    dfs(1,1);
}

Measured memory_bytes: 1536
package main

import (
	"fmt"
)

func main() {

	var n, m int
	fmt.Scanf("%d %d", &n, &m)

	broken := map[int]struct{}{}
	for i := 0; i < m; i++ {
		var a int
		fmt.Scanf("%d", &a)
		broken[a] = struct{}{}
	}

	mod := 1000000007
	step := make([]int, n+1)
	step[0] = 1
	if _, isHole := broken[1]; isHole {
		step[1] = 0
	} else {
		step[1] = 1
	}
	for i := 2; i <= n; i++ {
		if _, isHole := broken[i]; isHole {
			step[i] = 0
		} else {
			step[i] = (step[i-1] + step[i-2]) % mod
		}
	}

	fmt.Printf("%d\n", step[n])
}


Measured memory_bytes: 7832
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

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

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

ll a, b;

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> a >> b;
	cout << a * b / __gcd(a, b);













	return 0;
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n,t; cin >> n >> t;
	vector<int> a(n);
	
	int la=0, ans=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		ans+=min(t,a[i]-la);
		la=a[i];
	}
	ans+=t;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
//by sdfzchy
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL inf=(1ll<<50);
inline LL in()
{
	char ch=getchar();
	LL f=1,tmp=0;
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {tmp=(tmp<<1)+(tmp<<3)+(ch-'0');ch=getchar();}
	return tmp*f;
}

const int N=100010;
LL A,B,C,x,y;
int main()
{
    A=in(),B=in(),C=in();
    x=in(),y=in();
    LL ans=inf;
    for(int i=0;i<=max(x,y)*2;i+=2)
    {
    	LL curx=max(0ll,x-i/2),cury=max(0ll,y-i/2);
		LL cos=curx*A+cury*B+i*C;
		ans=min(ans,cos);
	}
	cout<<ans<<endl;
	return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, T, c[100], t[100];

int main() {
	cin >> n >> T;
	inc(i, n) { cin >> c[i] >> t[i]; }
	
	int ans = 12345;
	inc(i, n) {
		if(t[i] <= T) { setmin(ans, c[i]); }
	}
	
	if(ans == 12345) {
		cout << "TLE" << endl;
	} else {
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<ll> dqll;

int main() {
  ll N;
  cin >> N;
  vll lst;

  for (ll i = 1; i * i <= N; i++) {
    if(N % i == 0){
      ll qq = N / i;
      lst.push_back(i + qq - 2);
    }
  }

  ll ans = LONG_LONG_MAX;
  for (size_t i = 0; i < lst.size(); i++) {
    ans = min(lst[i], ans);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import unittest


class TestE(unittest.TestCase):
    def test_1(self):
        self.assertEqual(
                think(2, [1, 1, 3, 4]),
                11
        )

    def test_2(self):
        self.assertEqual(
                think(3, [10, 10, 10, -10, -10, -10]),
                360
        )

    def test_3(self):
        self.assertEqual(
                think(1, [1, 1, 1]),
                0
        )

    def test_4(self):
        self.assertEqual(
                think(6, [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 0, 0, 0, 0, 0]),
                999998537
        )


def solve():
    k, a = read()
    result = think(k, a)
    write(result)


def read():
    n, k = read_int(2)
    return k, read_int(n)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(k, a):
    mode = 10 ** 9 + 7
    n = len(a)

    fact_table, inverse_fact_table = prepare_fact_table(n, mode)
    a.sort()

    sum_of_max = 0
    sum_of_min = 0

    for i, x in enumerate(a):
        if i >= k - 1:
            sum_of_max += x * combination(i, k - 1, fact_table, inverse_fact_table, mode)
            sum_of_max %= mode
        if n - i >= k:
            sum_of_min += x * combination(n - i - 1, k - 1, fact_table, inverse_fact_table, mode)
            sum_of_min %= mode

    return (sum_of_max - sum_of_min) % mode


def write(result):
    print(result)


def prepare_fact_table(n, mode):
    fact_table = [1 for i in range(n + 1)]
    inverse_fact_table = [1 for i in range(n + 1)]
    for i in range(2, len(fact_table)):
        fact_table[i] = fact_table[i - 1] * i % mode
        inverse_fact_table[i] = divmod(fact_table[i], mode)
    return fact_table, inverse_fact_table


def divmod(x, mode):
    return pow(x, mode - 2, mode)


def combination(n, k, fact_table, inverse_fact_table, mode):
    return fact_table[n] * inverse_fact_table[k] * inverse_fact_table[n - k] % mode


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 82008
def main():
  K, N = map(int, input().split())
  A = [int(a) for a in input().split()]
  maxK=0
  for i in range(1,N):
    maxK = max(maxK, A[i]-A[i-1])
  maxK = max(maxK, K+A[0]-A[N-1])
  print(K-maxK)

if __name__=='__main__':
  main()

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

    int N, K;
    cin >> N >> K;
    vector<int> P(N);
    for(int i = 0; i < N; i++) {
        cin >> P.at(i);
    }

    ll max_sum = 0;
    for(int i=0; i<K; i++){
        max_sum += P.at(i);
    }

    ll sum = max_sum;
    int max_index = 0;
    for(int i=1; i<=N-K; i++){
        sum = sum - P.at(i-1) + P.at(i + K - 1);
        if(sum > max_sum){
            max_sum = sum;
            max_index = i;
        }
    }

    double ans = 0;
    for(int i=max_index; i<(max_index+K); i++){
        ans += (P.at(i) + 1) / 2.0;
    }

    printf("%.10f\n", ans);
    return 0;
}


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

int main() {
  int x1, y1, x2, y2;

  cin >> x1 >> y1 >> x2 >> y2;
  int a = x2 - x1;
  int b = y2 - y1;

  cout << x2 - b << " " <<  y2 + a << " " << x1 - b << " " << y1 + a << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main (){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	int64_t sol=0;
	int64_t maxi=0;
	cin>>maxi;
	for (int i=1;i<n;i++){
		int64_t tmp;
		cin>>tmp;
		sol+=max(maxi-tmp,(int64_t)0);
		maxi=max(maxi,tmp);
	}
	cout<<sol;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		int[] a = new int[n];
		int[] b = new int[n];
		for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		long[] number = new long[100010];
		for(int i = 0 ; i < n ; i++) number[a[i]] += b[i];
		for(int i = 0 ; i < 100010 ; i++) {
			k -= number[i];
			if(k <= 0) {
				System.out.println(i);
				return;
			}
		}
	}
}


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

bool match(const string &s, const string &t) {
  // cerr << t << endl;
  int idx = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (t[idx] == s[i]) idx++;

    if (idx == t.size()) return true;
  }

  return false;
}

int main() {
  string s, t;
  cin >> s >> t;

  int ans = 0;
  string T = t;
  while (match(s, T)) {
    ans++;
    if ((int64_t)T.size() * (t.size() + 1) + t.size() > s.size()) break;
    string nT = T;
    for (int i = 0; i < t.size(); ++i) {
      nT += t[i] + T;
    }

    T = nT;
  }

  cout << ans << endl;
}



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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int n, cnt = 0, ans = 0;
    int a, b, c;
    cin >> a >> b >> c;
    set<int> s;

    s.insert(a);
    s.insert(b);
    s.insert(c);

    if (s.size() == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<cctype>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
int main(){
    string alpha;
    int numOfShuffle;
    int n;
    string result;
    
    while(1) {
        cin >> alpha;
        if(alpha == "-") break;
        cin >> numOfShuffle;
        for (int i = 0; i < numOfShuffle; i++) {
            cin >> n;
            alpha = alpha.substr(n,alpha.size()) +  alpha.substr(0,n);
           
        }
        cout << alpha << endl;
        
    }
    
    
    
    return 0;
}

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

int main() {
	int n;
	while (cin >> n, n) {
		bool ok = false;
		int cnt = 1;
		rep(i, n) {
			int k; cin >> k;
			if (2 <= k)ok = true;
			if (0 < k)cnt++;
		}
		if (ok)cout << cnt << endl;
		else puts("NA");
	}
}

Measured memory_bytes: 3120
local function getsqrt(a, b)
  local min, max = a, b + 1
  local dst = a * b
  while 1 < max - min do
    local mid = (min + max) // 2
    if mid * mid <= dst then
      min = mid
    else
      max = mid
    end
  end
  return min
end

local q = io.read("*n")
for iq = 1, q do
  local a, b = io.read("*n", "*n")
  local c = 0
  if b < a then a, b = b, a end
  local dst = a * b
  local sql = getsqrt(a, b)
  if sql * sql == dst then
    if sql == a then
      c = 2 * (sql - 1)
    else
      c = 2 * (sql - 1) - 1
    end
  elseif sql * (sql + 1) < dst then
    c = 2 * sql - 1
  else
    c = 2 * (sql - 1)
  end
  print(c)
end


Measured memory_bytes: 752