akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  int N, X, T; cin >> N >> X >> T;
  int ans = 0; int res = 0;
  while(true) {
    res += X; ans += T;
    if(res >= N) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    unsigned long long x;
    cin >> x;
    unsigned long long a = 100;
    ll ans = 0;
    while(a < x) {
        a *= 1.01;
        ans ++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int p = 1000000007;
typedef pair<long long,long long> P;
typedef pair<P,bool> PP;
long long gcd(long long m, long long n)
{
  while (m>0&&n>0){
    n = n % m;
    if (n>0)
      m = m % n;
  }
  if (n==0)
    return m;
  else
    return n;
}
long long pow_rem_p(long long a, long long n)
{
  long long ff,f,nn;
  ff=a; f=1; nn=n;
  while(nn>0){
    if(nn%2==1){
      f*=ff;
      f%=p;
    }
    ff*=ff;
    ff%=p;
    nn/=2;
  }
  return f;
}
int main()
{
  int n,i,t=0,s=0,z=0;
  long long a,b,m,res=1;
  bool f;
  vector<PP> ab;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a >> b;
    if(a==0&&b==0){
      z++;
    }else if(a==0){
      ab.emplace_back(P(0,1),0);
    }else if(b==0){
      ab.emplace_back(P(0,1),1);
    }else{
      f=0;
      if(a<0){
        a=-a;
        f=1;
      }
      if(b<0){
        b=-b;
        f=1-f;
      }
      m=gcd(a,b);
      a/=m;
      b/=m;
      if(f==0){
        ab.emplace_back(P(a,b),0);
      }else{
        ab.emplace_back(P(b,a),1);
      }
    }
  }
  sort(ab.begin(),ab.end());
  for(i=0;i<ab.size();i++){
    if(i>0&&ab[i]==ab[i-1]){
      if(ab[i].second==0) s++;
      else t++;
    }else if(i>0&&ab[i].first==ab[i-1].first){
      t=1;
    }else{
      if(i>0){
        if(s==0||t==0)
          res*=pow_rem_p(2,s+t);
        else
          res*=pow_rem_p(2,s)+pow_rem_p(2,t)-1;
        res%=p;
        s=0;
        t=0;
      }
      if(ab[i].second==0) s++;
      else t++;
    }
  }
  if(s==0||t==0)
    res*=pow_rem_p(2,s+t);
  else
    res*=pow_rem_p(2,s)+pow_rem_p(2,t)-1;
  res+=p+z-1;
  res%=p;
  cout << res << endl;
  return 0;
}

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

using namespace std;
long long a,b,c;
int main()
{
	scanf("%lld%lld%lld",&a,&b,&c);
	if(a%2==0||b%2==0||c%2==0) puts("0");
	else printf("%lld",min(a*b,min(a*c,b*c)));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll N,P;


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

    if(N==1){
        cout << P << endl;
        return 0;
    }

    // PをN回割ることのできる最大の整数を見つける
    // 素数を考えれば良い

    assert(N>=2);
    // N>=2よりsqrt(P)以下の素数を考えれば良い
    // つまり1e6以下の素数を調べる
    vector<ll> ps;
    vector<bool> primes(sqrt(P)+10,true);
    primes[1] = false;
    for(ll i=2;i<=sqrt(P)+1;i++){
        if(!primes[i]) continue;
        ps.emplace_back(i);
        for(ll j=2;i*j<primes.size();j++){
            primes[i*j] = false;
        }
    }

    ll ans = 1;
    for(auto p: ps){
        ll cnt = 0;

        auto PP(P);

        while(PP%p==0){
            PP /= p;
            cnt++;
        }

        for(int i=0;i<cnt/N;i++) ans *= p;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
vector<int> days[3];
vector<int> cost[3];
int main()
{
    int i,n,a,b,c;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a>>b>>c;
        days[0].push_back(a);
        days[1].push_back(b);
        days[2].push_back(c);
        if(!i)
        {
            cost[0].push_back(a);
            cost[1].push_back(b);
            cost[2].push_back(c);
        }
        else
        {
            cost[0].push_back(0);
            cost[1].push_back(0);
            cost[2].push_back(0);
        }
    }
    for(int i=0;i<n-1;i++)
    {
        cost[0][i+1]=(cost[2][i]+days[0][i+1]<cost[1][i]+days[0][i+1])?cost[1][i]+days[0][i+1]:cost[2][i]+days[0][i+1];
        cost[1][i+1]=(cost[2][i]+days[1][i+1]<cost[0][i]+days[1][i+1])?cost[0][i]+days[1][i+1]:cost[2][i]+days[1][i+1];
        cost[2][i+1]=(cost[0][i]+days[2][i+1]<cost[1][i]+days[2][i+1])?cost[1][i]+days[2][i+1]:cost[0][i]+days[2][i+1];

    }
    cout<<max(cost[0][n-1],max(cost[1][n-1],cost[2][n-1]))<<endl;
    return 0;
}


Measured memory_bytes: 2920
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

long long int pow_mod(long long int p_a,long long int p_n,long long int p_p=1e9+7){
	//p_a^p_n mod p_p
	long long int p_b=1,p_t=1;
	for(;p_b<=p_n;p_b<<=1);
	for(p_b>>=1;p_b>0;p_b>>=1){
		p_t*=p_t;
		if(p_t>=p_p)p_t%=p_p;
		if(p_n&p_b)p_t*=p_a;
		if(p_t>=p_p)p_t%=p_p;
	}
	return p_t;
}

long long int gcd(long long int g_a,long long int g_b){
	if(g_a<g_b)gcd(g_b,g_a);
	if(g_b==0)return g_a;
	return gcd(g_b,g_a%g_b);
}

long long int divide(long long int d_a,long long int d_b,long long int d_p=1e9+7){
	// d_a/d_b mod d_p
	// prime:d_p is prime
	if(d_a>=d_p)d_a%=d_p;
	if(d_a<0)d_a+=d_p;
	if(d_b>=d_p)d_b%=d_p;
	if(d_b<0)d_b+=d_p;
	d_a*=pow_mod(d_b,d_p-2,d_p);
	return d_a%d_p;
}

LL pos[110000];
LL kai[110000];

int main(){
	LL n,m;
	int i,j,k;
	LL a,b,c;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>pos[i];
	}
	LL sd=0;
	LL s=0;
	kai[0]=1;
	for(i=1;i<=n;i++){
		kai[i]=kai[i-1]*i;
		if(kai[i]>=MAX)kai[i]%=MAX;
	}
	for(i=0;i<n-2;i++){
		sd+=pos[n-2-i]-pos[i];
		if(sd>=MAX)sd%=MAX;
		if(sd<0)sd+=MAX;
		a=divide(kai[n-1],i+1);
		a=divide(a,i+2);
		s+=sd*a;
		if(s>=MAX)s%=MAX;
	}
	for(i=0;i<n-1;i++){
		a=divide(kai[n-1],n-1-i);
		a*=pos[n-1]-pos[i];
		if(a>=MAX)a%=MAX;
		s+=a;
	}
	s%=MAX;
	cout<<s<<endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

long INF = 1;

// src, (dist, coin)
unordered_map<long, set<pair<long, long>>> connections;

// node, (score, walked_node)
unordered_map<long, pair<long, bitset<2510>>> score;

void solve() {
  INF <<= 60;
  long N, M, P;
  cin >> N >> M >> P;
  rep (i, M) {
    long a, b, c;
    cin >> a >> b >> c;
    c -= P;
    connections[a].insert(make_pair(b, c));
  }
  score[1] = make_pair(0, bitset<2510>());
  queue<long> q;
  q.push(1);
  while (q.size()) {
    long current = q.front();
    q.pop();
    auto current_score = score[current].first;
    auto walked = score[current].second;
    walked[current] = true;
    for (auto con: connections[current]) {
      long tmp_score = current_score;
      if (tmp_score < INF) tmp_score += con.second;
      if (score.count(con.first) == 0) {
        score[con.first] = make_pair(tmp_score, walked);
        q.push(con.first);
      } else if (score[con.first].first < tmp_score)  {
        if (walked[con.first] > 0) tmp_score = INF;
        score[con.first] = make_pair(tmp_score, walked);
        q.push(con.first);
      }
    }
  }
  long result = score[N].first;
  if (result < 0) result = 0;
  if (result == INF) result = -1;
  cout << result << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws IOException {
		int sum = 0;
		String str;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<String> arrayStr = new ArrayList<String>();
		ArrayList<Integer> arrayAns = new ArrayList<Integer>();
		while(true){ //??????????????\???????¶???????
			str = br.readLine();
			if(str.equals("0")){
				break; //0?????\??????????????¨?????\?????????
			}
			arrayStr.add(str); //??\?????????????????????????????????????´?
		}
		for(int k = 0; k < arrayStr.size(); ++k){ //????????????????´???????????????????????´????
			String tmp1 = arrayStr.get(k); //?????????????????????????????????
			for(int l = 0; l < tmp1.length(); ++l){ //?????????????????????????????????????????????
				int tmp2 = tmp1.charAt(l)-'0'; //??¢???????????????????????¨??????int????????????
				sum += tmp2;
			}
			arrayAns.add(sum);
			sum = 0;
		}
		for(int i = 0; i < arrayAns.size(); ++i){
			System.out.println(arrayAns.get(i));
		}
	}

}

Measured memory_bytes: 24424
#include<bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define pb push_back
#define popb pop_back
#define popf pop_front
#define pf push_front
#define si size()
#define mp make_pair 
#define mt make_tuple
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound

#define ask(i,m,n) for(lli i=m;i<n;i++)
#define anket ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
 
#define endl "\n"
#define o0(a) cout<<a<<" "
#define o1(a) cout<<a<<"\n"
#define o2(a,b) cout<<a<<" "<<b<<"\n"
#define o3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define o4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"
using namespace std;

#define prime1 1000000007
#define prime2 998244353

lli modadd(lli n,lli m , lli mod){
    lli sum = ((n+m)%mod+mod)%mod;
    return sum;
}

lli modsub(lli n,lli m,lli mod){
    lli diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}

lli modpro(lli n,lli m, lli mod){
    lli pro = ((n*m)%mod+mod)%mod;
    return pro;
}

lli powmod(lli x,lli y,lli mod){
    x %= mod;
    y %= mod;
    lli res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x,mod);
        y = y >> 1;
        x = modpro(x , x,mod);
    }
    return res;
}

lli moddiv(lli n,lli m,lli mod){
    //return n/m mod (mod) or n*(m)^-1 mod (mod)
    lli a = powmod(m,mod-2,mod);
    //this is because of fermats thm i.e. a^-1 = a^p-2 mod(p) check
    //multiplying p on both sides
    lli res = modpro(a,n,mod);
    return res;
}

vector<lli> prefix_function(string s) {
    lli n = (lli)s.length();
    vector<lli> pi(n);
    for (lli i = 1; i < n; i++) {
        lli j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}


int main() {
	anket;
	string s;
	cin>>s;
	if(s[0]=='7' ||s[1]=='7' ||s[2]=='7' ){
	    o1("Yes");
	}
	else{
	    o1("No");
	}
	return 0;
}




Measured memory_bytes: 3656
#include "bits/stdc++.h"

using namespace std;

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

  string N;

  cin>>N;
  
  char tmp=N[0];
  int count=0;
  int count_max=0;
  
  for(int i=0;i<N.size();i++){
    if(tmp==N[i]){
      count++;
    }else{
      tmp=N[i];
      count=1;
    }
    if(count_max<count){
      count_max=count;
    }
  }
  
  if(count_max>=3){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  long long n, a, b;
  cin >> n >> a >> b;
  a--;
  b--;
  if (a % 2 == b % 2) {
    cout << abs(a - b) / 2 << '\n';
  } else {
    if (a > b) swap(a, b);
    cout << min((b - a - 1) / 2 + a + 1, (n - (a + (n - b))) / 2 + n - b);
  }
  return 0;
}


Measured memory_bytes: 256
import fractions
N=int(input())
T,A=map(int,input().split())
for i in range(1,N):
    nT,nA=map(int,input().split())
    if(nT>=T and nA>=A):
        T,A=nT,nA
        continue
    pT,pA=T//nT,A//nA
    if(T%nT!=0):
        pT+=1
    if(A%nA!=0):
        pA+=1
    T,A=nT*max(pT,pA),nA*max(pT,pA)
print(T+A)

Measured memory_bytes: 64492
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long cash = 1000;
        long stocks = 0;

        long[] future = new long[n];
        for (int i = 0; i < n; i++) {
            future[i] = sc.nextLong();
        }

        int currentDay = 1;
        boolean isBuy = true;
        int next;
        while (currentDay <= n && (next = nextDay(future, currentDay, isBuy)) != -1) {
            long price = future[next - 1];

            if (isBuy) {
                long number = cash / price;
                cash -= price * number;
                stocks += number;
            } else {
                cash += price * stocks;
                stocks = 0;
            }

            isBuy = !isBuy;
            currentDay = next + 1;
        }

        System.out.println(cash);
    }

    private static int nextDay(long[] future, int currentDay, boolean isBuy) {
        long current = future[currentDay - 1];
        int nextDay = currentDay;

        for (int i = currentDay; i < future.length; i++) {
            long next = future[i];
            if (isBuy) {
                if (current >= next) {
                    current = next;
                    nextDay = i + 1;
                } else {
                    break;
                }
            } else {
                if (current <= next) {
                    current = next;
                    nextDay = i + 1;
                } else {
                    break;
                }
            }
        }

        if (isBuy && nextDay == future.length) return -1;
        else return nextDay;
    }
}


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

int main(){
  int n; // 駅数
  cin >> n;

  vector<int> c(n+1, 0); // 所要時間
  vector<int> s(n+1, 0); // 始発時間
  vector<int> f(n+1, 0); // 運行間隔
  for(int i = 1; i < n; i++){
    cin >> c[i] >> s[i] >> f[i];
  }

  int time;
  for(int i = 1; i < n; i++){
    time = s[i] + c[i];
    for(int j = i+1; j < n; j++){
      if(time < s[j]){
        time = s[j] + c[j]; 
      }else{
        int wait = time % f[j];
        if(wait == 0){
          time += c[j];
        }else{
          time += f[j] - wait + c[j];
        }
      }
    }
    cout << time << endl;
  }

  cout << 0 << endl;

  return 0;
}

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

#define vd vector<double>
 
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define vc vector<char>
#define vcc vector< vector<char> >
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
//#define endl '\n'
 
int main() {
    string s;
    cin >> s;
    s += "EEEEE";
    int n = int(s.length());
    ll ans = 0, a_count = 0;
    int i = 0;
    while(i < n){
        if(s[i] == 'E') break;
        if(s[i] == 'A'){
            a_count++;
            i++;
        }
        else if(s[i] == 'B' && s[i+1] == 'C'){
            ans += a_count;
            i += 2;
        }
        else{
            a_count = 0;
            i++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
  int n;
  int s[100];
  int sum=0;
  cin >> n;
  for (int i=0; i<n; i++) {
    cin >> s[i];
    sum += s[i];
  }
  sort(s,s+n);
  for(int i=0; i<n; i++){
    if(sum%10 != 0){
      cout << sum << endl;
      return 0;
    }
    if(s[i]%10 != 0) sum -= s[i];
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

const long long INF = 1LL << 60;

struct Edge {
    long long from;
    long long to;
    long long cost;
    Edge(int s, int d) : to(s),cost(d) {}
};

using Graph = vector<vector<Edge>>;
using Edges = vector<Edge>;
 
/* dijkstra(G,s,dis)
    入力：グラフ G, 開始点 s, 距離を格納する dis
    計算量：O(|E|log|V|)
    副作用：dis が書き換えられる
*/
void dijkstra(const Graph &G, int s, vector<long long> &dis) {
    int N = G.size();
    dis.resize(N, INF);
    priority_queue<P, vector<P>, greater<P>> pq;  // 「仮の最短距離, 頂点」が小さい順に並ぶ
    dis[s] = 0;
    pq.emplace(dis[s], s);
    while (!pq.empty()) {
        P p = pq.top();
        pq.pop();
        int v = p.second;
        if (dis[v] < p.first) {  // 最短距離で無ければ無視
            continue;
        }
        for (auto &e : G[v]) {
            if (dis[e.to] > dis[v] + e.cost) {  // 最短距離候補なら priority_queue に追加
                dis[e.to] = dis[v] + e.cost;
                pq.emplace(dis[e.to], e.to);
            }
        }
    }
}    
 
/* bellman_ford(Es,s,t,dis)
    入力: 全ての辺Es, 頂点数V, 開始点 s, 最短経路を記録するdis
    出力: 負の閉路が存在するなら ture
    計算量：O(|E||V|)
    副作用：dis が書き換えられる
*/
bool bellman_ford(const Edges &Es, int V, int s, vector<long long> &dis) {
    dis.resize(V, INF);
    dis[s] = 0;
    int cnt = 0;
    while (cnt < V) {
        bool end = true;
        for (auto e : Es) {
            if (dis[e.from] != INF && dis[e.from] + e.cost < dis[e.to]) {
                dis[e.to] = dis[e.from] + e.cost;
                end = false;
            }
        }
        if (end) break;
        cnt++;
    }
    return (cnt == V);
}


int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    int s = 0;
    rep(i,n) s ^= a[i];
    rep(i,n) a[i] ^= s;
    rep(i,n) cout << a[i] << endl;
}


Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n,a,b;
  cin >> n >> a >> b;
  int ans=0;
  for (int i = 1; i <= n; i++) {
    int x = i;
    int sum = 0;
    while(x > 0) { sum += x%10; x/=10; }
    if (a <= sum && sum <= b) ans+=i;
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

    int N,i,j,d[101],ans = 0;

    scanf("%d",&N);
    for(i = 0;i < N;i++){
        scanf("%d",&d[i]);
    }

    for(i = 0;i < N;i++){
        for(j = i + 1;j < N;j++){
            ans += d[i] * d[j];
        }
    }

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

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()
#define arr array

template<typename T> void umin(T& a,T b){a = min(a,b);}
template<typename T> void umax(T& a,T b){a = max(a,b);}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;


void pre(){

    

}

int n,m;
int p[maxs];
int sz[maxs];
int r[maxs];

int fn(int x){
    if(p[x] == x)
        return x;
    return p[x] = fn(p[x]);
}

bool add(int x,int y){
    x = fn(x);
    y = fn(y);
    if(x==y)
        return false;
    if(r[x] < r[y])
        swap(x,y);
    p[y] = x;
    sz[x] += sz[y];
    if(r[x]  == r[y])
        r[x]++;
    return true;
}

void solve(){

    cin >> n >> m;
    for(int i=1;i<=n;i++){
        p[i] = i;
        sz[i] = 1;
    }
    while(m--){
        int s,d;
        cin >> s >>d;
        add(s,d);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        int p = fn(i);
        umax(ans,sz[p]);
    }
    cout << ans << endl;

}


int32_t main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 5992
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)

c = 0
N.times do |i|
  b = B[i]
  n = [b, A[i]].min
  b -= n
  c += n
  b = [b, A[i+1]].min
  A[i+1] -= b
  c += b
end
puts c


Measured memory_bytes: 19596
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 1000;
int N;
int A[MAX_N][MAX_N-1];
int status[MAX_N][MAX_N];
int nextMatch[MAX_N];

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

  cin >> N;
  rep(i, N) {
    rep(j, N-1) {
      cin >> A[i][j];
      --A[i][j];
    }
  }


  int ans = 0;
  int totalMatchNum = N * (N-1) / 2;
  int currentMathNum = 0;
  while (true) {
    ++ans;
    // その日できる試合を列挙
    vector<int> matches;
    for (int i = 0; i < N; ++i) {
      if (nextMatch[i] == N-1) continue;
      int nextOpponent = A[i][nextMatch[i]];
      if (nextOpponent >= 0) {
        int mi = min(nextOpponent, i);
        int ma = max(nextOpponent, i);
        ++status[mi][ma];
        if (status[mi][ma] == 2) {
          matches.push_back(mi*N+ma);
        }
        A[i][nextMatch[i]] = -1;
      }
    }

    // 試合ができない場合
    if (len(matches) == 0) {
      ans = -1;
      break;
    }

    // すべての試合が終わった場合
    currentMathNum += len(matches);
    if (currentMathNum == totalMatchNum) {
      break;
    }

    // 更新
    for (int matchId : matches) {
      int p1 = matchId%N;
      int p2 = (matchId-p1)/N;
      ++nextMatch[p1];
      ++nextMatch[p2];
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
    int V, E;
    cin >> V >> E;
    vector<pair<int, int> > edge(E);
    for (int i = 0; i < E; i++) {
        cin >> edge[i].first >> edge[i].second;
    }
    vector<int> ans;
    vector<int> state(V, 0);

    for (int i = 0; i < E; i++) {
        state[edge[i].second]++;
    }

    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            if (state[i] == 0) {
                ans.push_back(i);
                for (int j = 0; j < edge.size(); j++) {
                    if (edge[j].first == i) {
                        state[edge[j].second]--;
                        edge[j] = edge.back();
                        edge.pop_back();
                        j--;
                    }
                }
                state[i]--;
                break;
            }
        }
    }
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3436
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    if(A >= 13) cout << B << endl;
    else if (A >= 6) cout << B / 2 << endl;
    else cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const ll INF = 1E+18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vl a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    ll high = 0;
    rep(i, n) {
        if (i==0) {
            chmax(high, a[i]);
            continue;
        }
        if (a[i]<high) {
            ans += high-a[i];
        }
        else {
            high = a[i];
        }
    }
    
    pr(ans);
    return 0;
}


Measured memory_bytes: 4780
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  string s;cin>>s;
  if(s=="AAA"||s=="BBB"){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=110;
int num[maxn];
int main()
{
    int n,x;
    while(~scanf("%d%d",&n,&x))
    {
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&num[i]);
        }
        sort(num+1,num+1+n);
        int sum=0;
        for(int i=1;i<=n;i++)
        {
            x-=num[i];
            if(x>=0)
            {
                if(i!=n)sum++;
                else if(x==0) sum++;
            }
            else break;
        }
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

int n;

struct card
{
	char suit;
	int value;
};

struct card L[MAX/2+2],R[MAX/2+2];

void merge(struct card A[],int left,int mid,int right){
	int n1,n2,i,j,k;
	struct card s,t;
	n1=mid-left;
	n2=right-mid;
	for(i=0;i<n1;i++)
		L[i]=A[left+i];
	for(i=0;i<n2;i++)
		R[i]=A[mid+i];
	L[n1].value=2000000000;
	R[n2].value=2000000000;
	i=j=0;
	for(k=left;k<right;k++){
		if(L[i].value<=R[j].value){
			A[k]=L[i];
			i=i+1;
		}
		else{
			A[k]=R[j];
			j=j+1;
		}
	}
}

void mergeSort(struct card A[],int left,int right){
	int mid;
	if(left+1<right){
		mid=(left+right)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
}

int partition(struct card A[],int p,int r){
	int i,j;
	struct card t,s,x;
	x=A[r];
	i=p-1;
	for(j=p;j<r;j++){
		if(A[j].value<=x.value){
			i=i+1;
			s=A[i];
			A[i]=A[j];
			A[j]=s;
		}	
	}
	t=A[i+1];
	A[i+1]=A[r];
	A[r]=t;
	return i+1;
}

void quicksort(struct card A[],int p,int r){
	int q;
	if(p<r){
		q=partition(A,p,r);
		quicksort(A,p,q-1);
		quicksort(A,q+1,r);
	}
}

int main(){
	int i,v,stable=1;
	struct card A[MAX],B[MAX];
	char S[10];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s%d",S,&v);
		B[i].suit=A[i].suit=S[0];
		B[i].value=A[i].value=v;
	}
	mergeSort(A,0,n);
	quicksort(B,0,n-1);
	for(i=0;i<n;i++){
		if(A[i].suit!=B[i].suit)
			stable=0;
	}
	if(stable==1)
		printf("Stable\n");
	else
		printf("Not stable\n");
	for(i=0;i<n;i++)
		printf("%c %d\n",B[i].suit,B[i].value);
	return 0;
}


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

int main() {
    ll a, b, n, x;
    cin >> a >> b >> n;
    x = min(n, b-1);
    ll ans = (a*x/b) - a*(x/b);
    cout << ans << endl;
    return 0;
}

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

int main(){
  int h,w;
  string s[50];
  cin>>h>>w;
  for(int i=0;i<h;++i)cin>>s[i];
  int x[8]={1,1,0,-1,-1,-1,0,1},
      y[8]={0,1,1,1,0,-1,-1,-1};
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
      if(s[i][j]!='#'){
      int cnt=0;
      for(int k=0;k<8;++k){
        if(i+y[k]>=0&&i+y[k]<h&&j+x[k]>=0&&j+x[k]<w&&s[i+y[k]][j+x[k]]=='#')cnt++;
      }
      cout << cnt;
      }else cout << '#';
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let r1: usize = scan(tokens);
    let c1: usize = scan(tokens);
    let r2: usize = scan(tokens);
    let c2: usize = scan(tokens);
    fn f(i: usize, j: usize) -> F {
        let (i, j) = if i < j { (i, j) } else { (j, i) };
        let mut numer = F(1);
        let mut denom = F(1);
        for k in 0..i {
            numer = numer * F(i + j - k);
            denom = denom * F(i - k);
        }
        numer / denom
    }
    fn g(i: usize, j: usize) -> F {
        f(i + 1, j + 1) - F(1)
    }
    println!(
        "{}",
        (g(r2, c2) - g(r2, c1 - 1) - g(r1 - 1, c2) + g(r1 - 1, c1 - 1)).value()
    );
}

const MODULO: usize = 1_000_000_007;

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
struct F(usize);

impl F {
    fn value(self) -> usize {
        self.0
    }
    fn pow(self, e: usize) -> F {
        let mut a = F(1);
        let mut b = self;
        let mut e = e;
        while e != 0 {
            if e & 1 != 0 {
                a = a * b;
            }
            b = b * b;
            e >>= 1;
        }
        a
    }
    fn inverse(self) -> F {
        self.pow(MODULO - 2)
    }
}

impl std::ops::Add for F {
    type Output = F;
    fn add(self, other: F) -> F {
        F((self.value() + other.value()) % MODULO)
    }
}

impl std::ops::Sub for F {
    type Output = F;
    fn sub(self, other: F) -> F {
        F((self.value() + MODULO - other.value()) % MODULO)
    }
}

impl std::ops::Mul for F {
    type Output = F;
    fn mul(self, other: F) -> F {
        F((self.value() * other.value()) % MODULO)
    }
}

impl std::ops::Div for F {
    type Output = F;
    fn div(self, other: F) -> F {
        self * other.inverse()
    }
}


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

int main() {
  int K,A,B;
  cin >> K >> A >> B;
  int c,d;
  c = A/K;
  d = B/K;
  if((d-c)>0 || A%K==0 || B%K==0){
    cout << "OK" << endl;
  }
  else{
    cout << "NG" << endl;
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll a, b, c;
  cin >> a >> b >> c;

  string ans = "No";

  ll d = c - a - b;

  if (d > 0 && d * d > 4 * a * b) {
    ans = "Yes";
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
s = list(str(input()))
t = list(str(input()))
ls = len(s)
lt = len(t)
m0  = lt
for i in range(ls - lt + 1):
  stemp = s[i:i +lt]
  k = 0
  for j in range(lt):
    if t[j] != stemp[j]:
      k += 1
  if k < m0:
    m0 = k
print(m0)    

Measured memory_bytes: 9060
#include <stdio.h>
#define N 100

typedef struct{
  int u;
  int k;
  int v[N];
}DFS;

DFS data[N];
int  time, n;
int color[N], d[N], f[N];

void visit(int u){
  int i, l, j;
  color[u] = 1;
  d[u] = ++time;
  for(i = 0; i < data[u].k; i++){
    l = data[u].v[i];
    for(j = 0; j < n; j++){
      if(data[j].u == l){
	if(color[j] == 0){
	  visit(j);
	}
      }
    }
  }
  color[u] = 2;
  f[u] = ++time;
}

int main(){
  int i, j;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d%d", &data[i].u, &data[i].k);
    for(j = 0; j < data[i].k; j++){
      scanf("%d", &data[i].v[j]);
    }
  }

  for(i = 0; i < n; i++){
    color[i] = 0;
  }
  time = 0;
  for(i = 0; i < n; i++){
    if(color[i] == 0){
      visit(i);
    }
  }

  for(i = 0; i < n; i++){
    printf("%d %d %d\n", data[i].u, d[i], f[i]);
  }

  return 0;
}
  



Measured memory_bytes: 2128
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> K >> N;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	A.push_back(A[0] + K);
	vector< int > B(N);
	rep(i, N) B[i] = A[i + 1] - A[i];
	sort(B.begin(), B.end());
	int ans = 0;
	rep(i, N - 1) ans += B[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4964
#include<iostream>
using namespace std;
int main(){
  while(1){
    int x,y,s,max=0;
    cin>>x>>y>>s;
    if(x+y+s==0)break;
    for(int i=1;i<s;i++){
      for(int j=1;j<s;j++){
	if(i+j>s)break;
	if(i*(100+x)/100+j*(100+x)/100==s){
	  if(i*(100+y)/100+j*(100+y)/100>max)max=i*(100+y)/100+j*(100+y)/100;
	}
      }
    }
    cout<<max<<endl;
  }
  return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
#define MOD (ll)(998244353)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	cout<<3*n*n<<"\n";
	return 0;
}

















Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CFiveTransportations solver = new CFiveTransportations();
        solver.solve(1, in, out);
        out.close();
    }

    static class CFiveTransportations {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            long n = sc.nextLong();
            long[] tab = new long[5];
            for (int i = 0; i < 5; i++) {
                tab[i] = sc.nextLong();
            }
            long min = Long.MAX_VALUE;
            for (int i = 0; i < 5; i++) {
                min = Math.min(min, tab[i]);
            }
            long ans = n / min + (n % min == 0 ? 0 : 1) + 4;
            out.println(ans);
        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  string s; std::cin >> s;
  int c0 = 0, c1 = 0, ans = 0;
  rep(i, s.size()) {
    if (s[i] == '0' && c1)
      ans += 2, c1--;
    else if (s[i] == '1' && c0)
      ans += 2, c0--;
    else if (s[i] == '0')
      c0++;
    else if (s[i] == '1')
      c1++;
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n;
    while(1){
        cin>>n;
        if(n==0)break;
        vector<int> s(n);
        for(int i=0;i<n;i++){
            cin>>s[i];
        }
        sort(s.begin(),s.end());
        long long ans=0;
        for(int i=1;i<n-1;i++){
            ans+=s[i];
        }
        cout<<ans/(n-2)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3040
use whiteread::parse_line;

fn main() {
    let n: usize = parse_line().unwrap();
    let mut i: usize = 1;
    let mut p: usize = 1;
    while i <= n {
        p = p*i % 1000000007;
        i = i+1;
    }
    println!("{}", (p % 1000000007));
}


Measured memory_bytes: 2180
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int N;
vector<ll> A;

int F(ll M0)
{
    vector<ll> M(N);
    M[0] = M0;

    rep(i, 0, N - 1)
    {
        M[i + 1] = 2 * A[i] - M[i];
    }

    if (M[N - 1] + M[0] >= 2 * A[N - 1])
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

void _main()
{
    cin >> N;
    A.resize(N);
    rep(i, 0, N) cin >> A[i];

    ll ng = -1;
    ll ok = 2000000000;
    while (abs(ok - ng) > 1)
    {
        const ll mid = (ok + ng) / 2;
        if (F(mid * 2))
        {
            ok = mid;
        }
        else
        {
            ng = mid;
        }
    }

    vector<ll> M(N);
    M[0] = ok * 2;
    rep(i, 0, N - 1)
    {
        M[i + 1] = 2 * A[i] - M[i];
    }
    rep(i, 0, N)
    {
        cout << M[i] << " ";
    }
    cout << endl;
}


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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

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

    double a, b, c, d, e, f;
    
    while(cin >> a >> b >> c >> d >> e >> f)
    {  
        double x = (c * e - b * f) / (a * e - b * d);
        double y = (a * f - d * c) / (a * e - b * d);

        if(x == 0)
            x = 0;
        
        if(y == 0)
            y = 0;
            
        printf("%.3lf %.3lf\n", x, y);
    }

    
    return 0;
}


Measured memory_bytes: 3204