akhauriyash/Code-Regression huggingface dataset:
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_3_C
  * 2 ????????°?????????
  * ???????????´??° x, y ?????????????????????????????????????°?????????????????????????????????°?????????????????????????????????
  * ??\???????????°????????????????????????????§?????????????????????????????????????????????????????????§??????????????????????????´??° x, y ??????????????????????§?????????????????????????
  * x ??¨ y ?????¨?????? 0 ?????¨?????\?????????????????????????????????????????????????????????????????????????????£????????????????????????
  */
object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).map(_.split(" +").map(_.toInt).sorted)
      .map { case Array(x, y) => (x, y) }
      .takeWhile { case (x, y) => x != 0 || y != 0 }
      .foreach { case (x, y) => println(s"$x $y") }
  }
}

Measured memory_bytes: 52552
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x;
    int e=0;
    scanf("%d",&x);
    if(x>=500){
        e+=(x/500)*1000;
        x=x%500;
    }
    if(x>=5){
        e+=(x/5)*5;
    }
    printf("%d",e);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
template<typename T> inline void debug(const vector<T> &xs){
#ifdef DEBUG
	pr(xs);
#endif
}

int main(){
	int D, G;
	cin >> D >> G;
	vector<int> P(D), C(D);
	for(int i=0; i<D; i++) cin >> P[i] >> C[i];

	int ans = 1e9;
	for(int k=0; k<1<<D; k++){
		int x = 0;
		int n = 0;
		for(int d=D-1; d>=0; d--){
			if((k>>d)&1){
				x += 100*(d+1)*P[d] + C[d];
				n += P[d];
			}
		}
		debug(any({k, x, n}));
		if(x>=G){
			ans = min(ans, n);
			continue;
		}
		int d=D-1;
		while((k>>d)&1) d--;
		if(d<0) continue;
		int l = (G-x+100*(d+1)-1)/(100*(d+1));
		if(0<=l&&l<P[d]) ans = min(ans, n+l);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
ls = []
counter = 0
for i in range(n):
	ls.append(int(input()))
for k in ls:
	s = 2
	ms = k
	if k == 2:
		counter += 1
	else:
		while ms >= s:
			if k % s == 0:
				break
			ms = k // s + 1
			s += 1
		else:
			counter += 1
print(counter)


Measured memory_bytes: 5976
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;




int main() {
int N,M,s,c;
cin>>N>>M;
vector<pair<int,int>> trans;
bool fin=false;
rep(i,M){
  cin>>s>>c;
  
  trans.push_back(make_pair(s,c));
  

}
rep(i,1000){
  string S;
  fin=false;
  S=to_string(i);
  if(S.size()!=N)continue;
  rep(j,trans.size()){
    if(S[trans[j].first-1]!=(char)(trans[j].second+'0')){
      fin=true;
    }
  }
  if(fin)continue;
  cout<<i<<endl;
  return 0;
}
cout<<-1<<endl;
return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
void debug(vector<T> &vec) {
    for (auto x : vec) {
        cout << x << " ";
    }
    cout << endl;
    return;
}

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

template <typename T>
int getFormer(const vector<T> &vec, T x) {
    return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}

template <typename T>
int getLatter(const vector<T> &vec, T x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

void solve(int N, int M) {
    vector<pair<long long, int>> maxs(N, make_pair(0, 0)),
        mins(N, make_pair(0, 0));
    REP(i, N) {
        maxs[i].second = i;
        mins[i].second = i;
    }

    REP(i, M) {
        int S, k;
        cin >> S >> k;
        REP(j, k) {
            int c;
            cin >> c;
            maxs[c - 1].first += S;
            if (k == 1) mins[c - 1].first += S;
        }
    }

    sort(ALL(mins));
    sort(ALL(maxs), greater<pair<long long, int>>());

    if (maxs[0].second == mins[0].second) {
        cout << max(maxs[0].first - mins[1].first,
                    maxs[1].first - mins[0].first) +
                    1
             << endl;
    } else {
        cout << maxs[0].first - mins[0].first + 1 << endl;
    }

    return;
}

int main() {
    int N, M;
    while (cin >> N >> M && N) {
        solve(N, M);
    }
    return 0;
}


Measured memory_bytes: 3316
# -*- coding: utf-8 -*-

"""
参考：http://tutuz.hateblo.jp/entry/2018/08/06/074104
・別解
・予め必要なA,C,?の個数は集めておく。
・Bの位置を決めて、4つの選び方パターンを全部数え上げる。
"""

MOD = 10 ** 9 + 7
S = input()

# あるBの位置よりも左にあるAと?の個数
A, LQ = [0] * len(S), [0] * len(S)
for i in range(len(S)-1):
    a = lq = 0
    if S[i] == 'A':
        a += 1
    if S[i] == '?':
        lq += 1
    A[i+1] = A[i] + a
    LQ[i+1] = LQ[i] + lq
# あるBの位置よりも右にあるCと?の個数
C, RQ = [0] * len(S), [0] * len(S)
for i in range(len(S)-1, 0, -1):
    c = rq = 0
    if S[i] == 'C':
        c += 1
    if S[i] == '?':
        rq += 1
    C[i-1] = C[i] + c
    RQ[i-1] = RQ[i] + rq

ans = 0
for i in range(len(S)):
    if S[i] == '?' or S[i] == 'B':
        # (A,B,C) と選ぶ場合(後ろの3べきは使わなかった?の分)
        case1 = (A[i] * C[i] * pow(3, LQ[i] + RQ[i], MOD)) % MOD
        # (A,B,?) と選ぶ場合
        case2 = (A[i] * RQ[i] * pow(3, max(LQ[i] + RQ[i] - 1, 0), MOD)) % MOD
        # (?,B,C) と選ぶ場合
        case3 = (LQ[i] * C[i] * pow(3, max(LQ[i] + RQ[i] - 1, 0), MOD)) % MOD
        # (?,B,?) と選ぶ場合
        case4 = (LQ[i] * RQ[i] * pow(3, max(LQ[i] + RQ[i] - 2, 0), MOD)) % MOD
        # 全部足し合わせてMOD
        ans = (ans + case1 + case2 + case3 + case4) % MOD

print(int(ans))


Measured memory_bytes: 18992
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int N, C, K;
	vector<int> V;
	cin >> N >> C >> K;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		V.push_back(tmp);
	}

	sort(V.begin(), V.end());

	int ans = 0;
	while (!V.empty()) {
		// cout << V[0] << " ";
		ans++;
		int latest = V[0] + K;
		V.erase(V.begin());
		int cap = C - 1;
		while (cap > 0 && !V.empty() && V[0] <= latest) {
			V.erase(V.begin());
			cap--;
		}
	}

	cout << ans << endl;




	return 0;
}

Measured memory_bytes: 892
#include<iostream>
using namespace std;
int main()
{
  int x, n, i, min, minin;
  cin >> x >> n;
  
  if(n == 0)
  {
      cout << x << "\n";
      return 0;
  }
  
  int a[n], test[101]={0}, flag=0;
  for(i=0; i<n; i++)
  {
      cin >> a[i];
      test[a[i]]++;
      if(a[i] == x)
        flag = 1;
  }
  if(!flag)
    cout << x << "\n";
  else
  {
      i = 1;
      while(test[x-i]!=0 && test[x+i]!=0)
        i++;
        
      if(test[x-i] == 0)
      {
          min = i;
          minin = x - i;
      }
      else
      {
          min = i;
          minin = x + i;
      }
      
      if(min >= x)
        cout << 0 << "\n";
      else
        cout << minin << "\n";
  }
  
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int n;
int main(void){
    cin>>n;
    if(1<=n&&n<=9)cout<<n<<endl;
    else if(10<=n&&n<=99)cout<<9<<endl;
    else if(100<=n&&n<=999)cout<<9+n-99<<endl;
    else if(1000<=n&&n<=9999)cout<<9+900<<endl;
    else if(10000<=n&&n<=99999)cout<<9+900+n-9999<<endl;
    else if(n==100000)cout<<9+900+90000<<endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1000000000;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

set<int> divisors(int n){
  set<int> div;
  for (int i = 1; i * i <= n; i++){
	   if (n % i == 0){
		   div.insert(i);
		   if (n / i != i) div.insert(n / i);  
		 }  
	 }
  return div;	
}

void solve(){
	int n;
	cin >> n;
	int ret = INT_MAX;
	set<int> v = divisors(n);

	for(auto it : v){
	  int x = n / it;
	  string a = to_string(it);
	  string b = to_string(x);
	  ret = min(ret, max((int)a.size(), (int)b.size()));	
	}
   cout << ret << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 384
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for B - Break Number
	var N int
	fmt.Scanf("%d", &N)

	var A int = 1
	var temp int
	for i := 0; i < 8; i++ {
		temp = int(math.Pow(2, float64(i)))
		if N < temp {
			fmt.Println(A)
			break
		}
		A = temp
	}
}


Measured memory_bytes: 1840
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main(){
	fast;
	ll n;
	cin>>n;
	ll sum=0,l,m;
	for(int i=0;i<n;i++)
	{
		cin>>l>>m;
		sum+=(m-l+1);
	}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3596
from itertools import permutations

S=input()
cand=["".join(t) for t in list(permutations(["a","b","c"],3))] # "a","b","c"を並び替えてできる文字列の候補

if S in cand: # ありえる場合
    print("Yes")
else: # ありえない場合
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int d, n;
    cin >> d >> n;
    int ans;
    
    if (d == 2) {
        ans = 100 * 100;
        ans = ans * n;
        if (n == 100) {
            ans += 100 * 100;
        }
    }else if(d == 1){
        ans = 100;
        ans *= n;
        if (n == 100) {
            ans += 100;
        }
    }else{
        ans = n;
        if (n == 100) {
            ans++;
        }
    }
        cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    double d;
    cin >> n >> d;
    int ctr=0;
    rp(i,n){
        double x,y;
        cin >> x >> y;
        if(x*x+y*y<=d*d) ctr++;
    }
    print(ctr);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3768
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long int;

int n;
vector<int> d;

int main(void) {
	cin >> n;
	for (size_t i = 0; i < n; i++) {
		int di;
		cin >> di;
		d.push_back(di);
	}
	sort(d.begin(), d.end());
	int ret = d[n / 2] - d[n / 2 - 1];
	cout << ret << endl;
	return 0;
}

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

int main(){
  long long N;
  cin >> N;
  string S="";
  while(N){
    N--;
    int A=N%26;
    N/=26;
    char a='a'+A;
    S.push_back(a);
  }
  reverse(S.begin(),S.end());
  cout << S << endl;
}

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

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define scn(var)         cin >> var;
#define pYes()           prt("Yes")
#define pNo()            prt("No")
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------


int main(){
    string s; cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;

}

Measured memory_bytes: 3624
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

void selectionSort(vector<int> &V, int N)
{
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        int min_idx = i;
        for (int j = i + 1; j < N; j++)
        {
            if (V[j] < V[min_idx])
            {
                min_idx = j;
            }
        }

        if (min_idx != i)
        {
            cnt++;
            swap(V[i], V[min_idx]);
        }
    }

    for (int i = 0; i < N; i++)
    {
        cout << V[i];
        if (i != N - 1)
        {
            cout << " ";
        }
    }
    cout << endl;
    cout << cnt << endl;
}

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

    selectionSort(A, N);

    return 0;
}


Measured memory_bytes: 3104
import numpy as np
from math import ceil

n = int(input())
a = [int(input()) for _ in range(n)]
modulo = 998244353

s = sum(a)

dp = np.zeros(s + 1, dtype=np.int)
dp[0] = 1
for ai in a:
    dp[ai:] = 2 * dp[ai:] + dp[:-ai]
    dp[:ai] = 2 * dp[:ai]
    dp %= modulo
sol = 3 ** n % modulo
sol -= 3 * dp[ceil(s / 2) :].sum()


if s % 2 == 0:
    dp = np.zeros(s + 1, dtype=np.int)
    dp[0] = 1
    for ai in a:
        dp[ai:] = dp[ai:] + dp[:-ai]
        dp %= modulo

    sol += 3 * dp[s // 2]

sol %= modulo

print(sol)


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

p = list(map(int, input().split()))

ans = [x + 1 for x in range(n)]
ans = sorted(ans)

count = 0

for i in range(n):
    if ans[i] != p[i]:
        count += 1
if count <= 2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
	int n;
	string s;
	int ans = 0;

	cin >> s;
	int len = s.length();
	int cpos = 999;
	int fpos = 0;

	for(int i = 0; i < len; i++){
		if(s[i] == 'C'){
			cpos = i;
		}
	}
	for(int i = cpos; i < len; i++){
		if(s[i] == 'F'){
			fpos = i;
		}
	}

	if(cpos < fpos){  
			cout << "Yes" << endl;
	}else{
			cout << "No" << endl;
	}


	return 0;
}


Measured memory_bytes: 256
#

import sys
input=sys.stdin.readline

def main():
    D=int(input())
    C=list(map(int,input().split()))
    S=[list(map(int,input().split())) for i in range(D)]
    last=[[0]*27 for i in range(D+1)]
    for day in range(1,D+1):
        maxt=0
        maxx=0
        sat=0
        for t in range(1,27):
            for j in range(day,D+1):
                    last[j][t]=day
            sat+=S[day-1][t-1]
            for j in range(1,27):
                sat-=C[j-1]*(day-last[day][j])
            if maxx<sat:
                maxt=t
                maxx=sat
        print(maxt)
    
if __name__=="__main__":
    main()


Measured memory_bytes: 68796
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN) = readLine.split(" ").map(_.toInt)
    val aryA = for(i <- 1 to datN) yield {
      val aryD = readLine.split(" ").map(_.toInt)
      aryD(0) == aryD(1)
    }

    var ans = false
    for(i <- 0 until (datN - 2)) {
      ans = ans || (aryA(i) && aryA(i + 1) && aryA(i + 2))
    }

    println(if(ans) "Yes" else "No")
  }
}


Measured memory_bytes: 54812
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define FOR(i,n) for(int i=0;i<(int)N;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

inline int getint(){
    int n;
    scanf("%d",&n);
    return n;
}

inline vector<int> getints(int n){
    vector<int> a(n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    return a;
}

void dumpints(vector<int> a){
  cout<<"[";
  for(int i=0;i<a.size()-1;i++){
    cout<<a[i]<<",";
  }
  cout<<a[a.size()-1]<<"]"<<endl;
}

template<class T> bool ifinclude(vector<T> a,T x){
    auto itr=find(a.begin(),a.end(),x);
    return distance(a.begin(),itr)!=a.size();
}

int main(void){
  lli N=getint();
  lli A=getint();
  lli B=getint();
  lli ans;
  if(A>B){
    ans=0;
  }else if(A<B){
    if(N==1){
      ans=0;
    }else{
      ans=(B-A)*(N-2)+1;
    }
  }else{
    ans=1;
  }
  cout<<ans<<endl;
  return 0;
}


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


int main(void)
{
    int n;
    int h[100];
    int count;
    int maxH = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
        maxH = max(maxH, h[i]);
    }

    do {
        int maxIdx = 0;
        int endConditionCount = 0;
        for (int i = 0; i < n; i++) {
            endConditionCount += h[i];
            if (h[maxIdx] == h[i]) {
                continue;
            }
            if (max(h[maxIdx], h[i]) == h[i]) {
                maxIdx = i;
            }
        }
        if (endConditionCount == 0) {
            break;
        }
        // 隣のやつは同じ値か？
        int maxGroupCount = 0;
        for (int i = 0; i < n - maxIdx - 1; i++) {
            if (h[maxIdx + (i + 1)] == h[maxIdx]) {
                maxGroupCount++;
            } else {
                break;
            }
        }

        for (int i = 0; i < maxGroupCount + 1; i++) {
            h[maxIdx + i]--;
        }
        count++;
    } while (1);
    cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
typedef long long lint;
using namespace std;
const int N=5005;
const int mod=1e9+7;
int n,wans[N],dp[N][N];

namespace utils{
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x>y?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

namespace G{
	int cnt,fir[N],sz[N];
	struct edge{
		int to,nx;
	}eg[N<<1];

	inline void add(const int a,const int b){
		eg[++cnt]=(edge){b,fir[a]};
		fir[a]=cnt;
	}

	void dfs(const int x){
		dp[x][1]=sz[x]=1;
		for(int i=fir[x]; i; i=eg[i].nx){
			const int y=eg[i].to;
			if(sz[y]) continue;
			dfs(y);
			int tot=sz[x]+sz[y];
			for(int j=tot; j; --j){
				int res=(mod-(lint)dp[x][j]*dp[y][0]%mod)%mod;
				for(int k=min(sz[y],j-1); k&&j-k<=sz[x]; --k){
					res=(res+(lint)dp[x][j-k]*dp[y][k])%mod;
				}
				dp[x][j]=res;
			}
			sz[x]+=sz[y];
		}
		assert(!dp[x][0]);
		for(int i=2; i<=sz[x]; i+=2){
			dp[x][0]=(dp[x][0]+(lint)dp[x][i]*wans[i])%mod;
		}
	}
}

int main(){
	n=nxi();
	for(int i=1; i<n; ++i){
		const int a=nxi(),b=nxi();
		G::add(a,b),G::add(b,a);
	}
	wans[0]=1;
	for(int i=2; i<=n; i+=2){
		wans[i]=(lint)wans[i-2]*(i-1)%mod;
	}
	G::dfs(1);
	printf("%d\n",dp[1][0]);
	return 0;
}


Measured memory_bytes: 58312
#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<string> W(N);
    for(int i=0; i<N; i++) {
        cin >> W.at(i);
    }
    set<string> st;
    st.insert(W.at(0));
    for(int i=1; i<N; i++) {
        if(W.at(i-1).at(W.at(i-1).size()-1) != W.at(i).at(0)) {
            cout << "No" << endl;
            return 0;
        } else {
            st.insert(W.at(i));
        }
    }
    if(st.size() == N) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
c=[list(map(int,input().split()))for i in range(3)]
a=[c[0][i]-0 for i in range(3)]
b=[c[i][0]-a[0]for i in range(3)]
d=[[a[i]+b[j] for i in range(3)]for j in range(3)]
print('Yes' if c==d else 'No')

Measured memory_bytes: 9056
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

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

string str[1000];
string emb[2];
char c[3] = {'J', 'O', 'I'};
int m, n;

bool isInMap(int x, int y) {
	return x >= 0 && x < n && y >= 0 && y < m;
}

bool check(int x, int y) {
	if (!isInMap(x, y) || !isInMap(x + 1, y + 1)) return false;
	if (str[y][x] == emb[0][0] && str[y][x + 1] == emb[0][1]
		&& str[y + 1][x] == emb[1][0] && str[y + 1][x + 1] == emb[1][1])
		return true;
	
	return false;
}

int solve(int x, int y) {
	int res = 0;
	
	int dx[4] = {-1,0,-1,0};
	int dy[4] = {-1,-1,0,0};
	
	REP(i, 4) if (check(x + dx[i], y + dy[i])) res++;
	return res;
}

int main() {
	cin >> m >> n;
	REP(i, m) cin >> str[i];
	REP(i, 2) cin >> emb[i];
	
	int base = 0;
	REP(i, m) {
		REP(j, n) {
			if (check(j, i)) base++;
		}
	}
	
	int ans = 0;
	REP(i, m) {
		REP(j, n) {
			int pos = 0;
			while (c[pos] != str[i][j]) pos++;
			
			bool nowC = check(j, i);
			FOR(k, 1, 3) {
				str[i][j] = c[(pos + k) % 3];
				
				int sub = solve(j, i);
				if (nowC) sub--;
				ans = max(ans, base + sub);
			}
			str[i][j] = c[pos];
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 4136
N = int(input())
A = input().split()
for i in range(N):
  if int(A[i])%2 != 0:
    ans = "APPROVED"
  if int(A[i])%2 == 0:
    if int(A[i])%3==0 or int(A[i])%5==0:
      ans = "APPROVED"
    if int(A[i])%3!=0 and int(A[i])%5!=0:
      ans = "DENIED"
      break
print(ans)

Measured memory_bytes: 3060
n = int(input())
n_list = list(map(int, input().split()))
q = int(input())

n_dic = {}
for i in n_list:
    n_dic.setdefault(i, 0)
    n_dic[i] += 1

result = 0
for k in n_dic:
    result += k * n_dic[k]

for i in range(q):
    b, c = map(int, input().split())
    if b in n_dic:
        n_dic.setdefault(c, 0)
        n_dic[c] += n_dic[b]
        result = result + (c-b)*n_dic[b]
        del n_dic[b]

    print(result)


Measured memory_bytes: 20956
#include <stdio.h>
#include <math.h>
 
int main(void){
    int a, b, c;
    char op;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?')break;
        if(op=='+')c=a+b;
        if(op=='-')c=a-b;
        if(op=='*')c=a*b;
        if(op=='/')c=a/b;
        printf("%d\n",c);
    }
    return 0;
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

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

const int inf=100000000;



int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int c[3][3];
    for(int i=0; i<3; i++)
    {
        for(int j=0; j<3; j++)
        {
            cin>>c[i][j];
        }
    }
    if((c[0][0]+c[1][1]==c[0][1]+c[1][0])&&(c[0][0]+c[2][2]==c[2][0]+c[0][2])&&(c[1][1]+c[2][2]==c[2][1]+c[1][2])&&(c[1][0]+c[2][1]==c[2][0]+c[1][1])&&(c[0][1]+c[1][2]==c[1][1]+c[0][2])) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;

}

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



int main(int argc, char const *argv[])
{
    int n, a, b;
    int num5, num4, num3,num2,num1;
    int temp = 0;
    cin >> n >> a >> b;
    long sum = 0;
    for(int i = 1; i <= n; i++){
        num5 = i / 10000;//5桁目
        num4 = i / 1000 - num5 * 10;//4桁目
        num3 = i / 100 - num4 * 10 - num5 * 100;//3桁目
        num2 = i / 10 - num3 * 10 - num4 * 100 - num5 * 1000;//2桁目
        num1 = i % 10;//1桁目
        temp = num5 + num4 + num3 + num2 + num1;
        /*cout << "num5 = " << num5;
        cout << " num4 = " << num4;
        cout << " num3 = " << num3;
        cout << " num2 = " << num2;
        cout << " num1 = " << num1 << endl;*/
        if(temp >= a && temp <= b){
//            cout << "temp = " << temp << endl;
            sum+=i;
        }
    }
    cout<<sum<<endl;
    return 0;
}


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

int main(){
	string S;
	cin >> S;
	int yen = 700;
	for(int i=0;i<3;i++){
		if(S[i] == 'o'){
			yen += 100;
		}
	}
	cout << yen << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int w[100]={},i,n,j,k,sum=0;
	while(1){
		scanf("%d",&w[i]);
		if(w[i]<0) break;
		i++;
	}

	n=i;

	for(i=0;i<n;i++){
		if(30<=w[i]){
			w[i]-=30;
			sum=160*w[i]+1400+1250;
		}else if(20<=w[i]&&30>w[i]){
			w[i]-=20;
			sum=140*w[i]+1250;
		}else if(10<w[i]&&w[i]<=20){
			w[i]-=10;
			sum=125*w[i];
		}
		printf("%d\n",3130-sum);
		sum=0;

	}


	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
  int n,x,L[110];
  cin >> n >> x;
  for(int i = 0; i < n; i++)
    cin >> L[i];
  
  int sum = 0;
  for(int i = 0; i < n; i++) {
    sum += L[i];
    if(sum > x) {
      cout << i+1 << endl;
      return 0;
    }
  }
  cout << n+1 << endl;
}

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

int main()
{
	int n,a,b,m;
	cin>>n;
	vector<int>v(n);
	int aux,sum=0;
	for(int i=1;i<n+1;i++)
	{
		cin>>aux;
		v[i]=aux;
		sum+=aux;
	}
	cin>>m;
	while(m--)
	{
		cin>>a>>b;
		cout<<sum-v[a]+b<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cctype>
#include<algorithm>
#include <stdio.h>

using namespace std;

int main() {
 
	int a, b,coun,ans;
	cin >> a >> b;
	ans = a * 100 + b * 1800;
	coun = 1;
	for (int x = 0; x < b; x++) {
		coun = coun * 2;
	}
	ans = ans*coun;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#coding:utf-8

def main():
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())
    k = int(input())

    flag = True

    if b-a > k:
        flag = False
    elif c-a > k:
        flag = False
    elif d-a > k:
        flag = False
    elif e-a > k:
        flag = False
    elif c-b > k:
        flag = False
    elif d-b > k:
        flag = False
    elif e-b > k:
        flag = False
    elif d-c > k:
        flag = False
    elif e-c > k:
        flag = False
    elif d-e > k:
        flag = False

    if flag:
        print('Yay!')
    else:
        print(':(')


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define pb push_back
#define bp __builtin_popcount
#define sz size()
#define ff first
#define ss second
#define vll vector<ll>
#define vbool vector<bool>
#define vpll vector<pair<ll,ll>>
#define pll pair<ll,ll>
#define vllv vector<vector<ll>>
#define setpri(x) cout<<setprecision(x)<<fixed;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){if(n%x==0)return n/x; else return (n/x)+1;}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll modinv(ll n,ll mod){
    return pow1(n,mod-2,mod);
}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
    if(a.ff != b.ff)return a.ff < b.ff;
    return a.ss > b.ss;
}

void solve(){
    ll i,j,k,l,n,m,x,y,z,r;
	string s;
	cin>>s;
	if(s=="ABC"){
		cout<<"ARC";
	}else{
		cout<<"ABC";
	}
  
}
int main(){
    FS;
    ll i,j,k,n,m,x,y,z,q;
    q=1;
    // cin>>q;
    while(q--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3660
#include<iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	int a[100];
	cin >> a[0];
	if (N==1) {
		cout << 0<<endl;
	}
	else if (N==2) {
		cin >> a[1];
		cout << abs(a[1] - a[0])<<endl;
	}
	else {
		int temp[2];
		cin >> a[1];
		if (a[0] == a[1]) {
			temp[1] = a[0];
		}
		else if (a[0] > a[1]) {
			temp[1] = a[0];
			temp[0] = a[1];

		}
		else {
			temp[1] = a[1];
			temp[0] = a[0];
		}
		for (int i = 3; i <= N; i++) {
			cin >> a[i];
			if (temp[0] > a[i]) {
				temp[0] = a[i];
			}
			if (temp[1]<a[i]) {
				temp[1] = a[i];

			}
		}
		cout << temp[1] - temp[0] << endl;

	}
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a, b, k int
	var p []int
	fmt.Scan(&a, &b, &k)
	if a > b {
		for i := 1; i <= a; i++ {
			if a%i == 0 && b%i == 0 {
				p = append(p, i)
			}
		}
	} else {
		for i := 1; i <= b; i++ {
			if a%i == 0 && b%i == 0 {
				p = append(p, i)
			}
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(p)))
	fmt.Println(p[k-1])
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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; }

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ll n;
    cin >> n;
    vll a(n);
    rep(i,n) cin >> a[i];
    if(n==2){
        cout << max(a[0], a[1]);
        return 0;
    }
    ll dp[n+1][2];
    dp[3][0] = __gcd(a[0], __gcd(a[1], a[2]));
    dp[3][1] = max({__gcd(a[0], a[1]), __gcd(a[1], a[2]), __gcd(a[0], a[2])});
    srep(i,3,n){
        dp[i+1][0] = __gcd(dp[i][0], a[i]);
        dp[i+1][1] = max(__gcd(dp[i][1], a[i]), dp[i][0]);
         
    }
    cout << max(dp[n][1], dp[n][0]) << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n;
    cin >> n;
    if(n % 2 == 1)
	{
        cout << 0 << endl;
        return 0;
    }
    ll five = 5;
    ll sum = 0;
    while (five < n)
    {
      sum += n / five / 2;
      five *= 5;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int N;

int A[210];

int main(){

	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> A[i];

	int res = 0;

	while (true) {
		bool exist_odd = false;

		for (int i = 0; i < N; i++) {
			if (A[i] % 2 != 0) 
				exist_odd = true;
		}
	
		if (exist_odd)
			break;

		for (int i = 0; i < N; i++) {
			A[i] /= 2;
		}
		res++;
	}

	cout << res << endl;
	}

Measured memory_bytes: 256
// CODING BEAST
/*******************************************************************************************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define Precision(a) cout << fixed << setprecision(a)

using ll = long long;
#define INF
using vb = vector<bool>; using vc = vector<char>; using vd = vector<double>; using vi = vector<int>; using vvi = vector<vi>;
using vll = vector<ll>; using vvll = vector<vll>; using pi = pair<int, int>; using pll = pair<ll, ll>;
#define endl "\n"
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i = 0; i < n; i++)
#define repc(i,a,n) for(ll i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define pow2(x) (1ll<<(x))
#define Blazing_fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trav(a,v) for(auto &a:v)
int a[8] = { -1, -1, -1, 0, 0, 1, 1, 1};
int b[8] = { -1, 0, 1, -1, 1, -1, 0, 1};
inline ll power(ll x, ll y)
{
    ll temp;
    if ( y == 0)
        return 1;
    temp = power(x, y / 2) ;
    if (y % 2 == 0)
        return (temp * temp) ;
    else
        return (x * temp * temp) ;
}
bool sortbysec(pll & a, pll & b) {
    return (a.second < b.second);
}
/*
ll fact(ll n)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
        res = (res * i) ;
    return res;
}

ll ncr(ll n, ll r)
{
    return fact(n) / (fact(r) * fact(n - r));
}
bool isprime(ll n) {
    if (n <= 1) return false;
    if (n <= 3) return true;
    if ((n % 2 == 0) || (n % 3 == 0)) return false;
    for (ll i = 5; i * i <= n; i = i + 6)
        if ((n % i == 0) || (n % (i + 2) == 0)) return false;

    return true;
}*/
/*********************************************************************************************************************************************************/

signed main() {
    ll n; cin >> n;
    vll v(n);
    vll dp(n);

    rep(i, n) {
        cin >> v[i];
    }
    ll mod = 1000000007;
    dp[n - 1] = v[n - 1];
    for (ll i = n - 2; i >= 0; i--) {
        dp[i] = (dp[i + 1] + v[i]) % mod;
    }
    ll ans = 0;

    for (ll i = 1; i < n; i++) {
        ll x = (v[i - 1] * dp[i]) % mod;
        // cout << x << endl;
        ans = (ans + x) % mod;
    }
    cout << ans  << endl;
}



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

using namespace std;

#define int long long

const int inf = 1e18;

signed main() {
    int n;
    cin >> n;
    int res = 1;
    bool ok = true;
    for(int i=0;i<n;++i){
        int x;
        cin >> x;
        if(x==0){
            cout << 0;
            return 0;
        }
        if(res>inf/x){
            ok = false;
            continue;
        }
        else res*=x;
    }
    if(!ok) cout << -1;
    else cout << res;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(){
	int W = 0;
	int H = 0;
	int x = 0;
	int y = 0;
	int r = 0;
	cin >> W >> H >> x >> y >> r;
	if (x + r > W){
		cout << "No" << endl;
	}
	else if (x - r < 0){
		cout << "No" << endl;
	}
	else if (y + r>H){
		cout << "No" << endl;
	}
	else if (y - r < 0){
		cout << "No" << endl;
	}
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
 
using namespace std;
using LL = long long int; 

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.st <<","<<P.nd <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAXN = 1e6+6;

int n, k;
int t[MAXN];

int main() {
  cin >> k >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> t[i];
  }

  LL res = 1 << 30;
  LL maks = 0;
  for (int i = 2; i <= n; ++i) {
    maks = max(maks, (LL)t[i] - (LL)t[i - 1]);
  }

  maks = max(maks, (LL)k - (LL)t[n] + t[1]);

  cout << k - maks;
}


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

bool hantei(int a,  int b, int c) {
  vector<int> tmp = {a,b,c};
  sort(tmp.begin(), tmp.end());
  if(tmp[1] == b)
    return true;
  else
    return false;
}

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  int ans = 0;
  for(int i = 1; i<n-1; i++){
    if(hantei(v[i-1], v[i], v[i+1])) ans ++;
  }
  cout << ans << endl;  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       int A = sc.nextInt();
        int arr[] = new int[1000100];
        for (int i = 0; i < A; i++) {
            int num = sc.nextInt();
            if (num != 0) {
            	arr[num - 1]++;} 
            arr[num]++;
            arr[num + 1]++;}
        int best = 0;
          for (int i = 0; i < arr.length; i++) {
            if (arr[i] > best) {
            	best = arr[i];}}
           System.out.println(best);
        sc.close();}}
 
    

Measured memory_bytes: 61312
#include<bits/stdc++.h>
using namespace std;
const int N=4e3+5;
char s[N];
int main(){
	int n,a=0,b=0,c=0;scanf("%d%s",&n,s);
	for(int i=0;s[i];i++){
		if(s[i]=='R')a++;
		else if(s[i]=='G')b++;
		else c++;
	}
	long long ans=1ll*a*b*c;
	for(int i=n/2;i;i--){
		for(int j=0;j+i*2<n;j++){
			if(s[j]!=s[j+i]&&s[j+i]!=s[j+2*i]&&s[j]!=s[j+2*i])ans--;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
// #include <iostream>
// #include <cstdio>
// #include <cstdlib>
// #include <algorithm>
// #include <cmath>
// #include <vector>
// #include <set>
// #include <map>
// #include <queue>
// #include <ctime>
// #include <cassert>
// #include <complex>
// #include <string>
// #include <cstring>
// #include <queue>
// #include <bitset>

using namespace std;

// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")


#define ll              long long int
#define vi              vector< int >
#define vll             vector< ll >
#define pii             pair< int, int >
#define vpii            vector< pii >

#define sc              scanf
#define pf              printf
#define cspf(i)         pf("Case %d: ", i)
#define spc             pf(" ")
#define line            pf("\n")

#define ff              first
#define ss              second
#define mp              make_pair
#define pb              push_back
#define tp(v,j)         get<j>(v)
#define Log(b,x)        (log(x)/log(b))

#define FOR(i,x,y)      for(int i = int(x); i < int(y); i++)
#define ROF(i,x,y)      for(int i = int(x)-1; i >= int(y); i--)
#define clr(arr,x)      memset(arr, x, sizeof arr)
#define vout(v,sz)      for(int w=0;w<sz;w++){if(w) spc; cout<<v[w];}
#define all(v)          v.begin(), v.end()
#define rall(v)         v.rbegin(), v.rend()
#define unq(v)          sort(all(v)),(v).resize(unique(all(v))-v.begin())
#define fastIO          ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

#define sc1(x)          sc("%d",&x);
#define sc2(x,y)        sc("%d %d", &x, &y)
#define sc3(x,y,z)      sc("%d %d %d", &x, &y, &z)
#define scl1(x)         sc("%lld",&x);
#define scl2(x,y)       sc("%lld %lld", &x, &y)
#define scf1(x)         sc("%lf",&x);
#define scf2(x,y)       sc("%lf %lf", &x, &y)

#define pf1(x)          pf("%d",x);
#define pf2(x,y)        pf("%d %d", x, y)
#define pfl1(x)         pf("%lld",x);
#define pfl2(x,y)       pf("%lld %lld", x, y)
 
#define MOD             (int)(998244353)
#define MaxN            100005
#define inf             0x3f3f3f3f
#define PI              acos(-1.0)  // 3.1415926535897932
#define eps             1e-9

template <class T> inline T bigMod(T p,T e,T M){T ret=1; for(;e>0;e>>=1){ if(e&1) ret=(ret*p)%M; p=(p*p)%M;} return (T)ret;}
template <class T> inline T modInverse(T a,T M){return bigMod(a,M-2,M);}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/gcd(a,b))*b;}


int main()
{
    // #ifndef ONLINE_JUDGE
    //     clock_t tStart = clock();
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif

    ll x;
    cin>>x;
    ll ans = (x/500) * 1000;
    ans += ((x%500)/5) * 5;
    cout<<ans<<endl;


    // #ifndef ONLINE_JUDGE
    //     fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    // #endif
 
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m, way[N];
string s;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> m >> s;
	set < int > st;
	st.insert(0); 
	for(int i = 1; i <= n; i++){
		if(s[i] == '1')continue;
		if(st.lower_bound(i - m) == st.end()){
			cout << "-1\n";
			return 0; 
		}
		way[i] = *st.lower_bound(i - m);
		st.insert(i);
	}
	vector < int > inds;
	for(int i = n; i >= 1; i = way[i]){
		inds.push_back(i);
	}inds.push_back(0);
	reverse(inds.begin(), inds.end());
	for(int i = 1; i < inds.size(); i++){
		cout << inds[i] - inds[i - 1] << ' ';
	}
}

Measured memory_bytes: 6216
/* ex3_4 melo */
#include <stdio.h>
int main(void){
    int N, n, i, j;
    int a=0;
    scanf("%d",&N);
        for(i=1;i<10;i++){
            for(j=1;j<10;j++){
                n=i*j;
                if(N==n){
                    a=1;
                }
            }
        }
        if(a==1){
            printf("Yes\n");
        }else{
            printf("No\n");
        }

        return 0;
    }

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

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(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);
  while(N>0){
    if(N%10==7){
      OUT("Yes");
      return 0;
    }
    N/=10;
  }

  OUT("No");

  return 0;
}


Measured memory_bytes: 3588