akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <stack>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int h[100001];
int main(int argc, char *argv[]) {
    ios_base::sync_with_stdio(false);//bugs with `printf'
    cin.tie(NULL);//incompatible with `while (cin >> ...)'
    int N,K;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    sort(h, h + N);
    int mn = 1 << 30;
    for (int i = 0, j = K - 1; j < N; j++, i++) {
        int tmp = h[j] - h[i];
        if (mn > tmp) {
            mn = tmp;
        }
    }
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n;
    cin >> n;
    vvi g(n);
    vi o(n, 0);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
        o[a]++;
        o[b]++;
    }
    vi c(n);
    ll sum = 0;

    for (int i = 0; i < n; ++i) {
        cin >> c[i];
        sum += c[i];
    }
    sort(c.begin(), c.end(), greater<int>());
    sum -= c[0];
    int s = 0;
    vi ret(n, -1);
    deque<int> qu;
    qu.push_back(s);
    ret[s] = c[0];
    int cpos = 1;
    while (qu.size() != 0) {
        int i = qu.front();
        qu.pop_front();
        for (auto &t : g[i]) {
            if (ret[t] == -1) {
                ret[t] = c[cpos++];
                qu.push_back(t);
            }
        }
    }
    cout << sum << "\n";
    for (int i = 0; i < n; ++i) {
        cout << ret[i];
        if (i == n - 1)
            cout << endl;
        else
            cout << " ";
    }

    return 0;
}

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

flag=0
for x in A:
    if x==0:
        print('0')
        exit()

    if flag==0:
        ans=x
        flag=1
        continue

    ans = ans * x
    if ans > 10**18:
        print('-1')
        exit()

print(ans)

Measured memory_bytes: 21652
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = scan.next();
        if (s.endsWith("s")) {
            s = s + "es";            
        } else {
            s = s + "s";
        }
        System.out.println(s);
    }
}


Measured memory_bytes: 38664
n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)

left, right = -1, a[-1] * f[0]

while right - left > 1:#2分探索で探す。
    mid = (left + right) // 2
    ck = 0#修行回数
    for i in range(n): 
      ck += max(0, a[i] - mid // f[i])# (a[i] - ck) * f[i] = midを解いて左記になる。
    if ck <= k: right = mid
    else: left = mid

print(right)


Measured memory_bytes: 119500
#include <iostream>
#include <cstring>
using namespace std;
char c[100],s[100];
void solve(void)
{
    int l=strlen(c);
    for(int i=0;i<l;i++)
    {
        if(c[i]!=s[i])
        {
            cout<<"No\n";
            return;
        }
    }
    cout<<"Yes\n";
    return;
}
int main(void)
{
    cin>>c>>s;
    solve();
    return 0;
}


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

int main() {
    /*
	cin >> a >> b >> c;
	cout << a << " " << b << " " << c <<endl
	*/
	int a[4][3][10];
	int b,f,r,v,x;
	cin >> x;
	for(int bb=0;bb<4;bb++){
    	for(int ff=0;ff<3;ff++){
        	for(int rr=0;rr<10;rr++){
    	        a[bb][ff][rr]=0;
        	}
    	}
	}
	for(int i=0;i<x;i++){
	    cin >> b>> f>> r>> v;
	    a[b-1][f-1][r-1]+=v;
	}
	for(int bb=0;bb<4;bb++){
    	for(int ff=0;ff<3;ff++){
        	for(int rr=0;rr<10;rr++){
    	        cout << " "<< a[bb][ff][rr];
    	      //  if(rr!=9)cout << " ";
        	}
    	    cout << '\n';
    	}
        if(bb!=3)cout << "####################" << endl;
	}
}

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

int main() {
    string s;
    cin >> s;
    for (int i = 1; i < s.size()+1; i++){
        if(i == 1){
            if(s.at(i-1) == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }else if(i % 2 == 0){
            if(s.at(i-1) == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(s.at(i-1) == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

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

    int x = x2-x1;
    int y = y2-y1;

    cout << x2-y << " " << y2+x << " " << x1-y << " " << y1+x << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long K = sc.nextLong();
		double sm = 100;
		long count = 0;
		while(sm < K) {
			sm = Math.floor(sm * 1.01);
			
			count++;
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 35844
#include <iostream>

using namespace std;

int main(void){

  int month[13] ={0,31,29,31,30,31,30,31,31,30,31,30,31};
  int m,d;

  while( cin >> m >> d ){
    if( m == d && d == 0 )break;

    int sum = 0;
    for( int i = 1 ; i < m ; i++ ){
      sum += month[i];
    }

    sum += d; 
    sum %= 7;

    switch(sum){
    case 0:
      cout << "Wednesday" << endl;
      break;
    case 1:
      cout << "Thursday" << endl;
      break;
    case 2:
      cout << "Friday" << endl;
      break;
    case 3:
      cout << "Saturday" << endl;
      break;
    case 4:
      cout << "Sunday" << endl;
      break;
    case 5:
      cout << "Monday" << endl;
      break;
    case 6:
      cout << "Tuesday" << endl;
      break;
    }
  }
  return 0;
}

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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

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

#define sortAl(v) sort(all(v))
#define sortAlr(v)                                                             \
  sort(v.begin(), v.end());                                                    \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

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

template <class T> inline void chmax(T &a, T b) { a = std::max(a, b); }
template <class T> inline void chmin(T &a, T b) { a = std::min(a, b); }

#define mod (int)(1e9 + 7)
#define INF LLONG_MAX

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

  ll n, m, q;
  cin >> n >> m >> q;

  vector<pair<ll, ll>> train(m);
  rep(i, m) { cin >> train[i].first >> train[i].second; }

  vector<pair<ll, ll>> question(q);
  rep(i, q) { cin >> question[i].first >> question[i].second; }

  ll dp[510][510] = {};
  FORm(itr, train) { dp[itr->first][itr->second]++; }

  // i駅を出発地してk駅以前までを終点とする電車の数
  rep(i, n + 1) {
    REP(k, n + 1) { dp[i][k] += dp[i][k - 1]; }
  }

  // i駅以降を出発地してk駅以前までを終点とする電車の数
  for (ll i = n; i >= 0; i--) {
    rep(k, n + 1) { dp[i][k] += dp[i + 1][k]; }
  }

  FORm(itr, question) { cout << dp[itr->first][itr->second] << endl; }

  return 0;
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i = a; i<n; i++)
#define per(i,a,n) for (int i = n-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define all(now) (now).begin(),(now).end()
#define fi first
#define se second
#define SZ(now) ((int)(now).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod = 1000000007;
inline int read(int &n){char c=getchar();int x=0,f=1;while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+(c-'0');c=getchar();}return n = x*f;}
ll powmod(ll a,ll b,ll mod) {ll res = 1; a%=mod; assert(b>=0); for(;b; b>>=1){if(b&1)res = res*a%mod; a = a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int N = 1e5+7;
int T,n,m;
int a[N];
ll b[N];
int main()
{
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    rep(i,1,n+1){
        cin >> a[i];
    }
    sort(a + 1, a + 1 + n);
    rep(i,1,n+1){
        b[i] = b[i - 1] + a[i];
        if(b[i]==m){
            cout << i << endl;
            return 0;
        }
        else if(b[i]>m){
            cout << i - 1 << endl;
            return 0;
        }
    }
    cout << n - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;


    void main()
    {
        int m1=qread(),d1=qread(),m2=qread(),d2=qread();
        bool is=0;if(m1+1==m2 and d2==1) is=1;write(is);
    }
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

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

int main() {
  int a, b, m;
  cin >> a >> b >> m;
  vector<ll> va(a);
  vector<ll> vb(b);
  for (int i = 0; i < a; i++) {
    cin >> va[i];
  }
  for (int i = 0; i < b; i++) {
    cin >> vb[i];
  }
  ll ans = INFL;
  for (int i = 0; i < m; i++) {
    ll x, y, c;
    cin >> x >> y >> c;
    ans = min(ans, va[x - 1] + vb[y - 1] - c);
  }
  sort(va.begin(), va.end());
  sort(vb.begin(), vb.end());
  ans = min(ans, va[0] + vb[0]);
  cout << ans << endl;
}


Measured memory_bytes: 1792
N, A, B, C, D = map(int, input().split())
A -= 1
B -= 1
C -= 1
D -= 1
S = input()

if C < D:
    for i in range(A, D):
        if S[i] == '#' and S[i + 1] == '#':
            print("No")
            break
        elif i + 1 == D: print("Yes")
else:
    for i in range(B, D + 1):
        if S[i] == '#' and S[i + 1] == '#':
            print("No")
            break
        elif S[i - 1] == '.' and S[i] == '.' and S[i + 1] == '.':
            for j in range(A, C):
                if S[j] == '#' and S[j + 1] == '#':
                    print("No")
                    break
                elif j + 1 == C: print("Yes")
            break
        elif i + 1 == D + 1: print("No")


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
using namespace  std;

void fnBubbleSort(vector<string> &a_rvsSortBbl)
{
  int ixSorting = 0;
  bool bSorting = true;

  while (bSorting)
  {
    bSorting = false;
    for (int j = a_rvsSortBbl.size() - 1; j > ixSorting; j--)
    {
      if (a_rvsSortBbl[j].at(1) < a_rvsSortBbl[j - 1].at(1))
      {
        swap(a_rvsSortBbl[j], a_rvsSortBbl[j - 1]);
        bSorting = true;
      }
    }
    ixSorting++;
  }
}

void fnOutputBbl(const vector<string> &a_cnrvsSortBbl)
{
  for (int i = 0; i < a_cnrvsSortBbl.size(); i++)
  {
    if (i) cout << " ";
    cout << a_cnrvsSortBbl[i];
  }
  cout << endl;
  cout << "Stable" << endl;
}

void fnSelectionSort(vector<string> &a_rvsSortSel)
{
  for (int ixSorting = 0; ixSorting < a_rvsSortSel.size() - 1; ixSorting++)
  {
    int ixMinimum = ixSorting;
    bool bSorting = false;
    for (int j = ixSorting + 1; j < a_rvsSortSel.size(); j++)
    {
      if (a_rvsSortSel[j].at(1) < a_rvsSortSel[ixMinimum].at(1))
      {
        ixMinimum = j;
        bSorting = true;
      }
    }
    if (bSorting == true)  swap(a_rvsSortSel[ixSorting], a_rvsSortSel[ixMinimum]);
  }
}

void fnOutputSel(const vector<string> &a_cnrvsSortSel, const vector<string> &a_cnrvsSortBbl)
{
  string sSortEnd = "Stable";

  for (int i = 0; i < a_cnrvsSortSel.size(); i++)
  {
    if (i) cout << " ";
    cout << a_cnrvsSortSel[i];
    
    if (a_cnrvsSortSel[i] != a_cnrvsSortBbl[i]) sSortEnd = "Not stable";
  }
  cout << endl;
  cout << sSortEnd << endl;
}

int main()
{
  vector<string> vsSortBbl, vsSortSel;
  int iMaxSize;
  
  cin >> iMaxSize;
  for (int i = 0; i < iMaxSize; i++)
  {
    string sCard;
    cin >> sCard;
    vsSortBbl.push_back(sCard);
    vsSortSel.push_back(sCard);
  }

  fnBubbleSort(vsSortBbl);
  fnOutputBbl(vsSortBbl); 

  fnSelectionSort(vsSortSel);
  fnOutputSel(vsSortSel, vsSortBbl);

  return 0;
}

Measured memory_bytes: 1216
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

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

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

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	ll x, k, d; cin >> x >> k >> d;
	x = abs(x);
	if (to_string(k).size()+to_string(d).size() > 17 || x < k*d)
	{
		k -= x / d;
		x %= d;
		if (k % 2 == 0)cout << x << endl;
		else cout << d - x << endl;
	}
	else
	{
		cout << x - k * d << endl;
	}
}

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

int main(){

    long long x,k,d,ans;
    cin >> x >> k >> d;
    x = abs(x);
    if(x / d >= k){
        ans = x - k * d;
    }else{
        if((k - x / d) % 2 == 0){
           ans = x % d;
        }else{
           ans = abs(x % d - d); 
        }

    } 
    cout << ans << endl;
    
}

Measured memory_bytes: 3620
import math
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()

ans = MAX_INT
for i in range(1, int(math.sqrt(N))+1):
  if N%i == 0:
    tmp = N//i
    ans = min(ans, i + tmp -2)
print(ans)

Measured memory_bytes: 40556
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 601; int n, m;
vector<int> graph[maxN];

ldouble memo[maxN];
ldouble solve(int blocked)
{
  memo[n] = 0;
  for (int u = n - 1; u >= 1; u --)
  {
    ldouble sum = 0, maximum = 0;
    for (int v: graph[u])
      sum += memo[v], maximum = max(maximum, memo[v]);
    if (u == blocked && graph[u].size() >= 2)
      sum -= maximum;
    memo[u] = 1 + sum / (graph[u].size() - (u == blocked));
  }
  return memo[1];
}

int main()
{
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i ++)
  {
    int u, v; scanf("%d %d", &u, &v);
    graph[u].push_back(v);
  }

  ldouble ans = 1e18;
  for (int blocked = 0; blocked < n; blocked ++)
    ans = min(ans, solve(blocked));
  printf("%.7Lf\n", ans);

  return 0;
}

Measured memory_bytes: 1408
// https://atcoder.jp/contests/abc177/tasks/abc177_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const int SZ = 1e6;

// エラトステネスの篩
template <int N> struct Prime {
    bitset<N + 1> b;
    Prime() : b() {
        // trueで初期化
        b.flip();
        b[0] = b[1] = false;
        for (int i = 2; i <= N; ++i) {
            if (b[i]) {
                for (int j = i * i; j <= N; j += i) {
                    b[j] = false;
                }
            }
        }
    }
};
Prime<SZ> prime;

void solve() {
    int N;
    cin >> N;
    vector<int> A(N), D(SZ + 1);
    for (auto &x : A) {
        cin >> x;
        // 同じ数が重複するケースを考慮
        D[x]++;
    }
    // trueなら "pairwise coprime"
    bool pc = true;

    REP(i, SZ) {
        // 素数の場合
        if (prime.b[i]) {
            int cnt = 0;
            for (int now = i; now <= SZ; now += i) {
                cnt += D[now];
                if (cnt >= 2) {
                    break;
                }
            }
            // 共通の素数を含むのでgcd(ALL) >= i
            if (cnt >= 2) {
                pc = false;
                break;
            }
        }
    }
    if (pc) {
        cout << "pairwise coprime" << endl;
    } else {
        int g = A[0];
        for (auto &x : A) {
            g = gcd(g, x);
            if (g == 1) {
                break;
            }
        }
        if (g == 1)
            cout << "setwise coprime" << endl;
        else
            cout << "not coprime" << endl;
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 18952
<?php
$line = trim(fgets(STDIN));
// $flag = false;
for($i = 1; $i < 10; $i++) {
    for($j = 1; $j < 10; $j++) {
        if ($i * $j == $line) {
            echo "Yes";
            // $flag = true;
            exit;
        }
    }
}
echo "No";
?>

Measured memory_bytes: 4856
#include<cstdio>
const int MOD=1e9+7;
struct mint{int x;mint(int x=0):x(x){}};
inline mint operator+  (mint a,mint b){return a.x+b.x<MOD?a.x+b.x:a.x+b.x-MOD;}
inline mint operator-  (mint a){return MOD-a.x;}
inline mint operator-  (mint a,mint b){return a+-b;}
inline mint operator*  (mint a,mint b){return 1LL*a.x*b.x%MOD;}
inline mint operator<< (mint x,int y){mint r=1;for(;y;y>>=1,x=x*x)if(y&1)r=r*x;return r;}
inline mint operator~  (mint x){return x<<MOD-2;}
inline mint operator/  (mint a,mint b){return a*~b;}
inline mint&operator+= (mint&a,mint b){return a=a+b;}
inline mint&operator-= (mint&a,mint b){return a=a-b;}
inline mint&operator*= (mint&a,mint b){return a=a*b;}
inline mint&operator<<=(mint&x,int y){return x=x<<y;}
inline mint&operator/= (mint&a,mint b){return a=a/b;}
#define MN 2000000
int x1[2],y1[2],x2[2],y2[2],xl,xr,yl,yr;
mint ans,f[MN+5],rf[MN+5];
inline mint F(int n,int m){return f[n+m]*rf[n]*rf[m];}
struct P{int x,y;P(int x,int y):x(x),y(y){}};
inline mint F(const P&a,const P&b){return F(b.x-a.x,b.y-a.y);}
mint cal(int x1,int y1,int x2,int y2)
{
	P s(x1,y1),t(x2,y2),l(xl,yl),r(xr,yr);
	mint res=F(s,r)*F(r,t)*(xr+yr+1)-F(s,l)*F(l,t)*(xl+yl);int i;
	for(i=yl;++i<=yr;)res-=F(s,P(xl-1,i))*F(P(xl,i),t)*(xl+i);
	for(i=xl;++i<=xr;)res-=F(s,P(i,yl-1))*F(P(i,yl),t)*(i+yl);
	for(i=yl;i<yr;++i)res+=F(s,P(xr,i))*F(P(xr+1,i),t)*(xr+i+1);
	for(i=xl;i<xr;++i)res+=F(s,P(i,yr))*F(P(i,yr+1),t)*(i+yr+1);
	return res;
}
int main()
{
	int i;
	for(f[0]=i=1;i<=MN;++i)f[i]=f[i-1]*i;
	for(rf[i=MN]=~f[MN];i--;)rf[i]=rf[i+1]*(i+1);
	scanf("%d%d%d%d%d%d",&x1[0],&x1[1],&xl,&xr,&x2[1],&x2[0]);
	scanf("%d%d%d%d%d%d",&y1[0],&y1[1],&yl,&yr,&y2[1],&y2[0]);
	#define rep(i) for(int i=0;i<2;++i)
	rep(a)rep(b)rep(c)rep(d)ans+=cal(x1[a]-!a,y1[b]-!b,x2[c]+!c,y2[d]+!d)*(a^b^c^d?MOD-1:1);
	printf("%d",ans);
}

Measured memory_bytes: 15872
// HowManyDivisors.cc
// ３つの整数 a、b、cを読み込み、aからbまでの整数の中に、
// cの約数がいくつあるかを求めるプログラムを作成してください。
// 【入力】
// a、b、cが１つの空白区切りで１行に与えられます。
// 【出力】
// 約数の数を１行に出力してください。
// 【制約】
// ・1≤a,b,c≤10000
// ・a≤b
// 【例】
// 入力：5 14 80
// 出力：3
#include<iostream>
using namespace std;

int main( void) {
  int a, b, c;
  int counter = 0;

  cin >> a >> b >> c;

  for ( int i = a; i <= b; i++) {
    if ( c % i == 0) counter++;
  }

  cout << counter << endl;

  return 0;
}



Measured memory_bytes: 3112
#include <stdio.h>
#include <string.h>

void rotate(char str[][9])
{
	int i, j;
	char temp[8][9];
	
	memset(temp, '\0', sizeof(temp));
	
	for (i = 0; i < 8; i++){
		for (j = 0; j < 8; j++){
			temp[i][j] = str[7 - j][i];
		}
	}
	
	memcpy(str, temp, sizeof(temp));
	
	for (i = 0; i < 8; i++){
		printf("%s\n", temp[i]);
	}
}

int main(void)
{
	char str[8][9];
	int i;
	
	for (i = 0; i < 8; i++){
		scanf("%s", str[i]);
	}
	
	for (i = 1; i <= 3; i++){
		printf("%d\n", 90 * i);
		rotate(str);
	}
	
	return (0);
}

Measured memory_bytes: 548
#include <stdio.h>
#define s 1000000000
#define q 50000 

int binarySearch(int);

int num,A[s];

int main(){


  int i,num2,a,count=0;       

  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d",&A[i]);
  }
    
  scanf("%d",&num2);
  for(i=0;i<num2;i++){
    scanf("%d",&a);
    count+=binarySearch(a);
  }
  printf("%d\n",count);
  return 0;
}
    
int  binarySearch(int key)
{
  int mid,left,right;
  left=0;
  right= num;
  while(left<right){
    mid = (left + right)/2;
    if(A[mid]==key){
      return 1;
    }
    else if(key<A[mid]){
      right=mid;
    }
    else left = mid + 1;
  }
  return 0;
    }



Measured memory_bytes: 2108
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);
	int n; cin >> n;
	string s; cin >> s;
	map<string, map<string, ll>> cntLeft, cntRight;
	int maxMask = 1 << n;
	for (int mask = 0; mask < maxMask; mask++)
	{
		string strLeftRed, strLeftBlue, strRightRed, strRightBlue;
		for (int i = 0; i < n; i++)
		{
			if ((mask & (1 << i)) != 0)
			{
				strLeftRed += s[i];
				strRightRed += s[n + i];
			}
			else
			{
				strLeftBlue += s[i];
				strRightBlue += s[n + i];
			}
		}
		reverse(strLeftBlue.begin(), strLeftBlue.end());
		reverse(strRightBlue.begin(), strRightBlue.end());
		cntLeft[strLeftRed][strLeftBlue]++;
		cntRight[strRightRed][strRightBlue]++;
	}

	ll result = 0;
	for (auto& p1 : cntLeft)
	{
		for (auto& p2 : p1.second)
		{
			if (cntRight.count(p2.first) == 0)
				continue;
			if (cntRight[p2.first].count(p1.first) == 0)
				continue;
			result += p2.second * cntRight[p2.first][p1.first];
		}
	}
	cout << result << endl;
}

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

template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}
template<typename T>
void deb(T a){
  //cout<<a<<endl;
  a=a;
}
const int INF=1e9;
int k[36];
typedef pair<int,int> P;
typedef pair<P,int> PI;

signed main(){
  int n;cin>>n;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)cin>>b[i];
  map<int,int> m;
  for(int i=0;i<n;i++)m[a[i]],m[b[i]];
  int cnt=0;
  for(auto &p:m)p.second=cnt++;
  for(int i=0;i<n;i++)a[i]=m[a[i]],b[i]=m[b[i]];

  int ans=INF;
  vector<PI> v(n);
  vector<int> q(n);
  vector<int> c(n);

  for(int i=0;i<(1<<n);i++){
    //cout<<i<<endl;
    for(int j=0;j<n;j++){
      if((i>>j)&1)v[j]=PI(P(a[j],0),j);
      else v[j]=PI(P(b[j],1),j);
    }
    memset(k,0,sizeof(k));
    int now=0;
    deb("B");
    //for(int j=0;j<n;j++)cout<<v[j].first.first<<" ";cout<<endl;
    for(int j=0;j<n;j++){
      q[j]=k[v[j].first.first];
      c[j]=j-q[j];
      for(int l=v[j].first.first-1;l>=0;l--)k[l]++;
      for(int kk=0;kk<j;kk++)if(v[kk].first.first>v[j].first.first)c[kk]++;
    }
    //for(int j=0;j<n;j++)cout<<c[j]<<" ";cout<<endl;
    deb("C");
    vector<P> aa;
    for(int j=0;j<n;j++){
      if(((j+c[j])&1)!=v[j].first.second){
        aa.push_back(P(v[j].first.first,c[j]));
      }
    }
    deb("D");
    //cout<<aa.size()<<endl;
    if(aa.size()){
      if(aa.size()&1)continue;
      sort(aa.begin(),aa.end());
      bool out=false;
      for(int j=0;j<aa.size();j++){
        if(aa[j].first==aa[j+1].first){
          if((aa[j+1].second-aa[j].second)&1){
            now+=(aa[j+1].second-aa[j].second);
            j++;
            continue;
          }
        }
        out=1;break;
      }
      if(out)continue;
    }
    for(int j=0;j<n;j++)now+=q[j];
    //cout<<i<<" "<<now<<" "<<ans<<endl;
    chmin(ans,now);
  }
  deb("A");
  if(ans==INF)cout<<-1<<endl;
  else cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
//	cut here before submit 
//	freopen ("testcase.RL", "r", stdin );
	string str = "";
	while (getline (cin, str ) ){
		if (str.empty() ) break;
		int n = str.length();
		rep (i, n ){
			if (str[i] == ',' ) str[i] = ' ';
		} // end rep
		vector<int> l (12, 0 ), sum (12, 0 );
		int v1, v2;
		stringstream ss (str );
		for (int i = 1; i <= 10; i++ ){
			ss >> l[i];
		} // end rep
		l[11] = 100000;
		ss >> v1 >> v2;
		for (int i = 1; i <= 11; i++ ){
			sum[i] = sum[i-1] + l[i];
		} // end for
/*
		cerr << "sum: " << endl;
		rep (i, 10+1 ){
			cerr << sum[i] << (i != 10 ? ' ' : '\n' );
		} // end rep
*/
		double t = (double)sum[10]/(double)(v1 + v2 );
//		cerr << "t: " << t << endl;
		double cl = (double)v1*t;
//		cerr << "cl: " << cl << endl;
		int res = 0;
		for (int i = 1; i <= 10; i++ ){
			if ((double)sum[i-1] < cl && cl <= (double)sum[i] ){
				res = i;
				break;
			} // end if
		} // end for
		printf ("%d\n", res );

	} // end loop

		
	return 0;
}

Measured memory_bytes: 1232
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def f(x):
    res = 0
    for i in range(1,x+1):
        if x % i == 0:
            res += 1
    return res
 
n = I()
ans = 0
for i in range(1,n+1):
    if i % 2:
        if f(i) == 8:
            ans += 1
print(ans)

Measured memory_bytes: 38384
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long answer = 0;
    for(int i = 0; i < n-2; i++)
    {
      if(nums[i] > nums[i+1] && nums[i+1] > nums[i+2]) answer++;
      else if(nums[i] < nums[i+1] && nums[i+1] < nums[i+2]) answer++;
    }
    
		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;
 
using ll = long long;
 
const ll inf = 1e18;
const int N = 2 * 1e5 + 10;

ll res;
ll a[N];

void solve(){
    string s;
    cin >> s;
    std::vector<char> v;
    for (int i = 0; i < s.size() - 1; ++i){
        if(!v.size()){
            v.push_back(s[i]);
            continue;
        }else{
            v.push_back(s[i]);
            while(v.size() >= 2 && s[i + 1] != v[v.size() - 2]){
                v.pop_back();
                res++;
            }
        }
    }
    if(res & 1) cout << "First\n";
    else cout << "Second\n";
}
 
int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
// Radhe Radhe

Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


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

  vector<long long> h(N);
  for(int i = 0;i < N;i++) {
    cin >> h.at(i);
  } 

  long long dp[100100];

  dp[0] = 0;
  dp[1] = abs(h.at(0) - h.at(1));

  for(int i = 2;i < N;i++) {

    dp[i] = min(dp[i - 1] + abs(h.at(i) - h.at(i - 1)),dp[i - 2] + abs(h.at(i) - h.at(i - 2)));


  }

  cout << dp[N - 1] << endl;

  }



Measured memory_bytes: 1792
def solve(diagram)
  area = 0
  froms = []
  layers = []
  (0...diagram.size).each do |x|
    c = diagram[x]
    case c
    when '\\' then
      froms.push x
    when '/' then
      next if froms.empty?
      from = froms.pop
      area += 1
      area += x - from - 1
      layers << [from, x]
    end
  end
  return area, layers
end

diagram = STDIN.readline
area, layers = solve(diagram)

puts area

area = 0
areas = []
last = diagram.size
layers.reverse.each do |layer|
  if last < layer[0]
    areas[-1] += (layer[1] - layer[0])
  else
    areas << layer[1] - layer[0]
    last = layer[0]
  end
end
print areas.size
print " " if areas.size != 0
puts areas.reverse.join(' ')

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

class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			int choice = sc.nextInt();
			int max = (int)Math.pow(2,n) - 1;
			for (int i = 1; i<=max; i++) {
				ArrayList<Integer> ans = new ArrayList<Integer>();
				ans.clear();
				String binary = Integer.toBinaryString(i);
				for (int j=0; j<binary.length(); j++) {
					char c =  binary.charAt(binary.length()-j-1);
					if (c == '1') {
						ans.add(j);  //部分集合をキープ
					}
				}
				if (ans.size() == choice) {
					System.out.print(i+":");
					for (int j=0; j<ans.size(); j++) System.out.print(" " + ans.get(j));
					System.out.print('\n');
				}
			}
		}
	}
}


Measured memory_bytes: 80648
#include <bits/stdc++.h>
using namespace std;
int ans=0;
string s;
int main()
{
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        int j=i;
        while(j<s.size() && s[j]=='R')
        {
            j++;
        }
        ans=max(ans,j-i);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3596
N, = map(int, raw_input().split())
r = "No"
for l in range(1,1000):
  if 2*N==l*(l+1):
    r = "Yes"
    break
print r
if r=="Yes":
  k = l+1
  S = []
  for i in range(k):
    S.append([])
  x = 1
  for i in range(k-1):
    for j in range(l-i):
      S[i].append(x)
      S[i+1+j].append(x)
      x += 1
  print k
  for i in range(k):
    print " ".join([str(l)] + map(str, S[i]))

Measured memory_bytes: 8068
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
int N;
int main() {
	scanf("%d", &N);
	vector<ll> A(N + 1);
	rep(i, 0, N)scanf("%lld", &A[i]);
	rep(i, 1, N)A[i] += A[i - 1];
	sort(A.begin(), A.end());
	A.push_back(0);
	ll count = 0, ans = 0;
	rep(i, 1, N + 1) {
		if (A[i] == A[i - 1]) {
			count++;
		}
		else {
			ans += count * (count + 1) / 2;
			count = 0;
		}
	}
	printf("%lld",ans += count * (count + 1) / 2);
	return 0;
}

Measured memory_bytes: 4608
#include<cstdio>
using namespace std;
typedef long long ll;

ll n, m, t, p, d, c, x, y, data[32][32], cp[32][32];

int main() {
  while (scanf("%lld%lld%lld%lld", &n, &m, &t, &p), n) {
    for (ll i = 0; i < m; i++) for (ll j = 0; j < n; j++) data[i][j] = 1;
    for (ll i = 0; i < t; i++) {
      scanf("%lld%lld", &d, &c);
      for (ll i = 0; i < m; i++) for (ll j = 0; j < n; j++) cp[i][j] = data[i][j];
      if (d == 1) {
        for (ll i = 0; i < m; i++) for (ll j = 0; j < n; j++) {
          data[i][j] = (c+j<n?cp[i][c+j]:0) + (c-j-1<0?0:cp[i][c-j-1]);
        }
      } else {
        for (ll i = 0; i < m; i++) for (ll j = 0; j < n; j++) {
          data[i][j] = (c+i<m?cp[c+i][j]:0) + (c-i-1<0?0:cp[c-i-1][j]);
        }
      }
      /*
      for (ll i = 0; i < m; i++) for (ll j = 0; j < n; j++) printf("%lld%c", data[i][j], j==n-1?'\n':' ');
      printf("\n");
      */
    }
    for (ll i = 0; i < p; i++) {
      scanf("%lld%lld", &x, &y);
      printf("%lld\n", data[y][x]);
    }
  }
}



Measured memory_bytes: 2712
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    long A = sc.nextLong();
    long B = sc.nextLong();
    System.out.println(func(A, B));
  }
  
  static long func(long A, long B){
    if(A == B) return A;
    if(A%2 == 1) return A^func(A+1, B);
    if(B%2 == 0) return func(A, B-1)^B;
    long C = (B-A+1)/2;
    return C%2 == 0 ? 0 : 1;
  }
}

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

int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin >> L.at(i);
  }
  sort(L.begin(),L.end());
  if(L.at(N-1) >= accumulate(L.begin(), L.end(), 0)-L.at(N-1)){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def kaibunnsuu(n):
	s = str(n)
	for i in range(len(s)//2):
		if s[i] != s[-i-1]:
			return False
	return True


a,b = map(int, input().split())

cnt = 0
for i in range(a, b+1):
	if kaibunnsuu(i) == True:
		cnt += 1
		#print(i)
print(cnt)

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

using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define ull unsigned long long
#define rep(i,a,b) for(int i = a; i < b; i++)
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define oset tree < int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update >


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

    int t = 1;
    // cin>>t;
    while(t--){
      string s,t;
      cin>>s>>t;
      bool f = true;
      if(t.size() ==s.size()+1){

        rep(i,0,s.size()){
          if(s[i]!= t[i]){
            f = false;
            break;
          }
        }

        if(f){
          cout<<"Yes\n";

        }
        else{
          cout<<"No\n";
        }
      }
      else{
        cout<<"No\n";
      }
    }
    return 0;
  }


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

# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "<stdin>"

using namespace std;

# 1 "../Algo/NumberTheory/modulo.h" 1
class ModuloOps {
public:
    ModuloOps(long long mod): MOD(mod) {
    }

    long long binPow(long long a, long long b) {
        if (b == 0) {
            return 1;
        }
        auto prev = binPow(a, b/2);
        return mul(mul(prev, prev), b % 2 == 1 ? a : 1);
    }

    long long inv(long long a) {
        return binPow(a, MOD - 2);
    }

    inline long long add(long long a, long long b) {
        return (a + b) % MOD;
    }

    inline long long sub(long long a, long long b) {
        return (a - b + MOD) % MOD;
    }

    inline void inc(long long &a, long long b) {
        a = add(a, b);
    }

    inline long long mul(long long a, long long b) {
        return (a * b) % MOD;
    }

    inline long long div(long long a, long long b) {
        return mul(a, inv(b));
    }

private:
    long long MOD;
};
# 5 "<stdin>" 2

ModuloOps OPS(1e9 + 7);

long long calc(int n, int m) {
    long long v = 1;
    long long div = 1;
    for (int i = n+1; i <= n+m; i++) {
        v = OPS.mul(v, i);
    }
    for (int i = 1; i <= m; i++) {
        div = OPS.mul(div, i);
    }
    return OPS.mul(v, OPS.inv(div));
}

long long sum(int n, int m) {
    return OPS.sub(calc(n+1, m+1), 1);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    long long ans = OPS.sub(
        OPS.add(sum(r2, c2), sum(r1-1, c1-1)),
        OPS.add(sum(r2, c1-1), sum(r1-1, c2)));
    cout << ans << endl;
}


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

#define pb push_back
#define INF 1e9
#define mod 998244353
#define mod2 1000000007
#define dbg(x) cout << (#x) << " --> " << x << "\n";
#define dbgarr(y)                                                                                            \
  cout << (#y) << " --> " << '\n';                                                                           \
  for(auto& x : y) cout << x << '\n';
#define dbgparr(y)                                                                                           \
  cout << (#y) << " --> " << '\n';                                                                           \
  for(auto& x : y) cout << x.first << ", " << x.second << '\n';
using namespace std;

typedef priority_queue<int, vector<int>, greater<int>> minPq;
typedef priority_queue<int> maxPq;
typedef long long ll;

void goodLuckHaveFun() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
/* clang-format off */
  #ifdef _DEBUG
  freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
  #endif
  /* clang-format on */
}

int main() {
  goodLuckHaveFun();
  int k,n;
  cin >> k >> n;
  vector<int> nums(n);
  for(int i = 0; i < n; ++i){
    cin >> nums[i];
  }
  int maxx = -1;
  for(int i = 0; i < n-1; ++i){
    maxx = max(maxx, nums[i+1]-nums[i]);
  }
  maxx = max(maxx,nums[0]+k-nums[nums.size()-1]);
  cout << k - maxx << '\n';
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
public class Main{
	static int mod = 1000000007;
   public static void main(String[] main) throws Exception{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st = new StringTokenizer(br.readLine());
      PrintWriter out = new PrintWriter(System.out);
      int k = Integer.parseInt(st.nextToken());
      st = new StringTokenizer(br.readLine());
      String s = st.nextToken();
      long[] fact = new long[2000001];
      fact[0] = 1;
      for(int i = 1; i < 2000001; i++)
    	  fact[i] = (fact[i-1]*i)%mod;
      long ans = pow(26,k);
      long prev = ans;
      long inv = pow(26, mod-2);
      for(int i = 1; i <= k; i++) {
    	  prev = (multiply(prev,inv)*multiply(25*(s.length()+i-1),pow(i,mod-2)))%mod;
    	  ans = (ans + prev)%mod;
      }
      out.println(ans);
      out.close();
   }
   static long multiply(long a, long b) {
	   return (a*b)%mod;
   }
   static long pow(long l, int p) {
	   if(p == 0)
		   return 1;
	   if(p == 1 || l == 1)
		   return l;
	   long temp = pow(l, p/2);
	   long temp1 = (temp*temp)%mod;
	   if(p%2 == 1)
		   temp1 = (temp1*l)%mod;
	   return temp1;
   }
}

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

int main(){
    string a , m ,n;
    int b , c;
    cin >> b >> a;
    c= 0;
    if(b % 2 == 0){
        while(c  != b/2){
            n = a.at(c);
            m += n;
            c = c + 1;
        }
        if(a == m + m){
            cout << "Yes" <<endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
-- modules to import --

import Data.ByteString.Char8
import Prelude

-- functions for this task --

convert_sign :: ByteString -> Int
convert_sign string_given
        | Data.ByteString.Char8.head string_given == '+' =  1
        | Data.ByteString.Char8.head string_given == '-' = -1

task_A :: ByteString -> Int
task_A string_given
        | Data.ByteString.Char8.length string_given > 0 = (convert_sign $ string_given) + (task_A $ Data.ByteString.Char8.tail $ string_given)
        | otherwise                                     = 0

-- main process is below --

main :: IO ()
main = do

        -- STEP.01
        -- read out the given string
        string_given <- Data.ByteString.Char8.getLine

        -- STEP.02
        -- output the answer of this task
        Prelude.print $ task_A $ string_given

-- End of this source code --

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

using namespace std;

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

Measured memory_bytes: 256
S = input()
A = 'abcdefghijklmnopqrstuvwxyz'
if len(S) <= 25:
    for i in range(26):
        if A[i] not in S:
            print(S+A[i])
            break
else:
    for i in range(25):
        if S[-1-i] > S[-2-i]:
            for j in range(i+1):
                if S[-2-i] < S[-1-j]:
                    print(S[:-2-i]+S[-1-j])
                    break
            break
    else:
        print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std; 
int n;
long long a[85];
int main() {
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	long long nw=1000;
	long long cnt=0;
	for(int i=0;i<n-1;i++){
		//cout<<nw<<' '<<cnt<<endl;
		nw+=cnt*a[i];
		cnt=0;
		if(a[i]>=a[i+1])continue;
		cnt+=nw/a[i];
		nw%=a[i];
	}
	nw+=cnt*a[n-1];
	cout<<nw<<endl;
    return 0; 
}/*
*/

Measured memory_bytes: 3672
from collections import Counter,defaultdict,deque
from heapq import heapify,heappop,heappush
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b = inpl()
if n == 0 or a > b or (n == 1 and a != b):
    print(0)
else:
    print((b-a)*(n-2)+1)



Measured memory_bytes: 38636
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	double xa1, ya1, xa2, ya2;
	double xb1, yb1, xb2, yb2;

	boolean inA(double x, double y){
//		return (x>xa1-EPS)&&(x<xa2+EPS)&&(y>ya1-EPS)&&(y<ya2+EPS);
		return (x>xa1)&&(x<xa2)&&(y>ya1)&&(y<ya2);
	}

	boolean inB(double x, double y){
//		return (x>xb1-EPS)&&(x<xb2+EPS)&&(y>yb1-EPS)&&(y<yb2+EPS);
		return (x>xb1)&&(x<xb2)&&(y>yb1)&&(y<yb2);
	}

	void run(){
		sc=new Scanner(System.in);
		for(; sc.hasNext();){
			xa1=sc.nextDouble();
			ya1=sc.nextDouble();
			xa2=sc.nextDouble();
			ya2=sc.nextDouble();
			xb1=sc.nextDouble();
			yb1=sc.nextDouble();
			xb2=sc.nextDouble();
			yb2=sc.nextDouble();

			boolean f=false;
			f|=inA(xb1, yb1);
			f|=inA(xb1, yb2);
			f|=inA(xb2, yb1);
			f|=inA(xb2, yb2);
			f|=inB(xa1, ya1);
			f|=inB(xa1, ya2);
			f|=inB(xa2, ya1);
			f|=inB(xa2, ya2);

			f=(xa1<=xb2)&&(xb1<=xa2)&&(ya1<=yb2)&&(yb1<=ya2);
			
			println(f?"YES":"NO");

		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
n,m=map(int,input().split())
l=[list(map(int, input().split())) for i in range(m)]
l.sort()
r=[]
q=[]
for i in range(m):
    if l[i][0]==1:
        r.append(l[i][1])
    elif l[i][1]==n:
        q.append(l[i][0])
if set(r)&set(q):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
    

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

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

    map<ll, ll> ma;

    for (ll i = 0; i < n; i++) {
        ll tmp; cin >> tmp;
        ma[tmp] = -1;
    }

    if (ma.size() == n) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 12800
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final long S = sc.nextLong();
		final long C = sc.nextLong();
		
		final long S_pair_C = S * 2;
		//System.out.println((C - S_pair_C));
		if(S_pair_C >= C){
			System.out.println(C / 2);
		}else{
			System.out.println(S + ((C - S_pair_C) / 4));
		}
		
		
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
		
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21076