akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli power(lli x, lli y){
    lli res = 1;
    x = x ;
    while (y > 0) {
        if (y & 1)
            res = (res*x) ;
        y = y>>1;
        x = (x*x);
    }
    return res;
}
lli dp[2][10005][105];
lli M = 1e9 + 7 ;
lli d;
string k;
lli calc(lli e, lli dig, lli sum){
	lli n = k.length();
	if(dig <= 0)
		return sum == 0;
	if(dp[e][dig][sum] != -1)
		return dp[e][dig][sum];
	lli res = 0;
	lli c = (e == 1 ? k[n-dig]-'0' + 1: 10);
	loop(i, 0, c){
		lli ne = (e & (i == k[n-dig]-'0'));
		res += calc(ne, dig-1, (sum+i)%d);
		res = res%M;
	}
	res = res%M;
	dp[e][dig][sum] = res;
	return res;
}
lli solve(){
	cin>>k>>d;
	lli n = k.length();
	lli res = 0;
	memset(dp, -1, sizeof(dp));
	calc(1, n, 0);
	cout<<(dp[1][n][0] - 1 + M)%M<<"\n";
	return 0;
}
int main(){
	fastio;
	lli t;
//	cin>>t;
	t = 1;
	while(t>0){
		t--;
		solve();
	}
}

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

int main() {
  int n, base_cost, topp_cost, base_cal;

  cin >> n;
  cin >> base_cost >> topp_cost;
  cin >> base_cal;

  int* topp_cal = new int[n];

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

  sort(topp_cal, topp_cal + n, greater<int>());

  int density = 0;

  for (int i = 0; i < n; i++) {
    int sum_cal = 0;
    for (int j = 0; j < i; j++)
      sum_cal += topp_cal[j];

    int dens = (sum_cal + base_cal) / (base_cost + i * topp_cost);
    
    if (dens > density)
      density = dens;
  }

  cout << density << endl;
}

Measured memory_bytes: 1204
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);

		double a=sc.nextDouble();
		double b=sc.nextDouble();
		
		BigDecimal a1 = new BigDecimal(String.valueOf(a));
		BigDecimal b1 = new BigDecimal(String.valueOf(b));
		
		BigDecimal c= a1.multiply(b1);
		BigDecimal value =c.setScale(0, RoundingMode.DOWN);
		
		long l = value.longValueExact();
		
		System.out.println(l);	
	}

}

Measured memory_bytes: 29008
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using ll = long long;
//typedef long long ll;

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

#define INF ((1LL << 31) - 1)
#define INFLL ((1LL << 62) - 1)
#define MOD (ll)(1e9+7)
#define EPS 1e-10
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()

int vx[4] = {-1, 0, 1, 0}, vy[4] = {0, -1, 0, 1};
//int vx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, vy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

// [sx, se), [sy, ey)であることに注意
inline bool check(int sx, int ex, int sy, int ey, int x, int y) {
  return (sx <= x and x < ex and sy <= y and y < ey);
}

inline bool check(int ex, int ey, int x, int y) {
  return check(0, ex, 0, ey, x, y);
}

std::vector<std::string> split(const std::string& s, char delim) {
  std::vector<std::string> ret;
  std::stringstream ss(s);
  std::string tmp;

  while (std::getline(ss, tmp, delim)) {
    ret.push_back(tmp);
  }

  return ret;
}

inline void init() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
}

int main() {
  int a, b;
  std::string s;

  cin >> a >> b;
  cin >> s;

  for (int i = 0; i < s.size(); ++i) {
    if (i == a) {
      if (s[i] != '-') {
        cout << "No" << endl;
        return 0;
      }
    } else {
      if (s[i] == '-') {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
  return 0;
}

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

int main(void)
{
                       //A  B  C  D  E  F  G  H  I 
    int table[][9] = {  {0, 1, 0, 1, 0, 0, 0, 0, 0}, // A
                        {1, 0, 1, 0, 1, 0, 0, 0, 0}, // B
                        {0, 1, 0, 0, 0, 1, 0, 0, 0}, // C
                        {1, 0, 0, 0, 1, 0, 1, 0, 0}, // D
                        {0, 1, 0, 1, 0, 1, 0, 1, 0}, // E
                        {0, 0, 1, 0, 1, 0, 0, 0, 1}, // F
                        {0, 0, 0, 1, 0, 0, 0, 1, 0}, // G
                        {0, 0, 0, 0, 1, 0, 1, 0, 1}, // H
                        {0, 0, 0, 0, 0, 1, 0, 1, 0}, // I
                    };
    char password[20];
    int i, j;
    
    for (i = 0; i < 1000; i++){
        scanf("%s", password);
        
        if (strlen(password) == 1){
            printf("%s\n", password);
            continue;
        }

        for (j = 0; j < strlen(password) - 1; j++){
//printf("<%c %c %d>", password[j], password[j + 1], table[password[j] - 'A'][password[j + 1] - 'A']);
            if (table[password[j] - 'A'][password[j + 1] - 'A'] == 0){
                break;
            }
        }
        if (j == strlen(password) - 1){
            printf("%s\n", password);
        }
    }
    
    return (0);
}
 

Measured memory_bytes: 524
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Numerics;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var K = ReadLong();

            if (K % 2 == 0) return -1;
            if (K % 2 == 0 || K % 5 == 0) return -1;

            if (K % 7 == 0) K /= 7;

            var count = 0L;
            var ones = 1L;
            while (true)
            {
                count++;
                if (ones % K == 0)
                {
                    return count;
                }

                ones = ones % K * 10 + 1;
            }
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27536
N,M = map(int, input().split())

# Mの約数dのうち、Nd <= Mとなるものの最大

divisors = []
for d in range(1, M+1):
    if d*d > M:
        break
    if M%d == 0:
        divisors.append(d)
        divisors.append(M//d)

ans = 1

divisors.sort()

for d in divisors:
    if N*d <= M:
        ans = d

print(ans)

Measured memory_bytes: 3060
public class Main {
	public static void main(String args[]) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();

		int s[] = new int[N];
		boolean b = false;
		int x = 0;
		for (int i = 0; i < N; i++) {
			char c = S.charAt(i);
			if (c == 'A') {
				s[i] = x;
				b = true;
			} else if (b && (c == 'C')) {
				x += 1;
				s[i] = x;
				b = false;
			} else {
				s[i] = x;
				b = false;
			}
		}

		int l = 0;
		int r = 0;

		for (int i = 0; i < Q; i++) {
			l = sc.nextInt();
			r = sc.nextInt();
			System.out.println(s[r - 1] - s[l - 1]);
		}

	}
}


Measured memory_bytes: 72400
function Main(input) {
  // 数字
  var N = parseInt(input[0], 10);
  var S = input[1];
  var K = parseInt(input[2], 10);
  // 文字

  var changeStr = S.charAt(K - 1);

  const regex = new RegExp(`[^${changeStr}]`, 'g')
  console.log(S.replace(regex, '*' ));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 7372
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <memory>
#include <functional>
#include <iomanip>
#include <random>
#include <map>
#include <string.h>
#include <set>

using namespace std;

using ULL = decltype(0ull);
constexpr auto DIV = 1000000007ull;
constexpr auto MAX = numeric_limits<ULL>::max();

int main() {
  int N;
  int minimum = std::numeric_limits<int>::max();
  cin >> N;
  vector<int> data(N);
  for (auto&& val : data) {
    cin >> val;
  }
  {
    int totalcost = 0;
    for (int cost = -100; cost <= 100; ++cost) {
      totalcost = 0;
      for (auto&& val : data) {
        int c = val - cost;
        totalcost += c*c;
      }
      minimum = min(totalcost, minimum);
    }
  }
  cout << minimum << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#define ll long long
#define inf  999999999
#define pa pair<int,int>
using namespace std;

int main(){
int h,w,a;
cin>>h>>w;
static int dp[1500][1500];
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
cin>>a;
if(a==1) dp[i][j]=0;
else dp[i][j]=inf;
if(i==0 && dp[i][j]!=0) dp[i][j]=1;
if(j==0 && dp[i][j]!=0) dp[i][j]=1;
}
}
int ans=0;
for(int i=1;i<h;i++){
for(int j=1;j<w;j++){
if(dp[i][j]!=0){
dp[i][j]=min(min(dp[i-1][j-1],dp[i][j-1]),dp[i-1][j])+1;

}
}
}
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){

if(dp[i][j]>ans) ans=dp[i][j];

}
}

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

Measured memory_bytes: 9360
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    char m[12][12];
    int cnt = 0;

    cin >> a >> b;

    for (int i = 0; i < a; i++) {
        cin >> m[i];
    }

    for (int i = 0; i < a; i++) {
        for (int j = 0; j < b; j++) {
            if (m[i][j] == '#') cnt++;
        }
    }

    if (cnt == a+b-1) {
        cout << "Possible" << endl;
    }
    else {
        cout << "Impossible" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007

int main() {
	string S;
	cin >> S;
	if (S[2] == S[3] && S[4] == S[5])cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import itertools


def main():
    N, C = list(map(int, input().split(' ')))
    D = [list(map(int, input().split(' '))) for _ in range(C)]
    grids = [list(map(lambda c: int(c) - 1, input().split(' '))) for _ in range(N)]
    color_counts = [[0 for _ in range(C)] for _ in range(3)]
    for i in range(N):
        for j in range(N):
            g = ((i + 1) + (j + 1)) % 3
            c = grids[i][j]
            color_counts[g][c] += 1
    min_d = 1000 * 500 * 500
    for dest_colors in itertools.permutations(range(C), 3):
        d = 0
        for g in range(3):
            for c in range(C):
                d += color_counts[g][c] * D[c][dest_colors[g]]
        min_d = min([min_d, d])
    print(min_d)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5620
#include<iostream>
#include<math.h>
using namespace std;

int main(){
	int N,M;
	cin>>N>>M;
	int res=0,tmp;
	tmp=pow(2,M);
	res+=1900*M;
	res*=tmp;
	for(int i=0;i<tmp;i++){
		res+=100*(N-M);
	}
	cout<<res<<endl;


}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n, m;
	while (scanf("%d", &n), n)
	{
		map<char, char> table;
		while (n--)
		{
			char a, b;
			scanf(" %c %c", &a, &b);
			table[a] = b;
		}
		scanf("%d", &m);
		while (m--)
		{
			char c;
			scanf(" %c", &c);
			putchar(table.count(c) ? table[c] : c);
		}
		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <vector>

int N,M,Q;
using namespace std;
vector<int> ed[100008];
int col[100008];
int dp[100008][11];
int main() {
	scanf("%d%d",&N,&M);
	for(int i=0;i<M;i++) {
		int va,vb;
		scanf("%d%d",&va,&vb);
		ed[va].push_back(vb);
		ed[vb].push_back(va);
	}
	scanf("%d",&Q);
	for(int i=1;i<=N;i++) {
		for(int j=0;j<11;j++) dp[i][j]=-1;
	}
	for(int i=0;i<Q;i++) {
		int va,vb;
		scanf("%d%d%d",&va,&vb,&col[i]);
		dp[va][vb]=i;
	}
	for(int j=10;j>0;j--) {
		for(int i=1;i<=N;i++) {
			for(int k=0;k<ed[i].size();k++) {
				int to=ed[i][k];
				if(dp[to][j-1]<dp[i][j]) dp[to][j-1]=dp[i][j];
			}
		}
	}
	for(int i=1;i<=N;i++) {
		int maxv=dp[i][0];
		for(int j=10;j>0;j--) if(maxv<dp[i][j]) maxv=dp[i][j];
		if(maxv>=0) {
			printf("%d\n",col[maxv]);
		} else {
			printf("0\n");
		}
	}
	return 0;
}


Measured memory_bytes: 11128
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
using namespace std;
int main(){
  string s;
  cin >> s;
  rep(i,19){
    if(i == 5 || i == 13) cout << ' ';
    else cout << s[i];
  }
  cout << '\n';
  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 long long ll;
typedef pair<int,int> P;
const int MAX_NA = 200005;
ll A[MAX_NA],num1[MAX_NA],num2[MAX_NA];
ll sum[MAX_NA];

ll f(ll X, ll N)
{
	ll res = 0;
	rep(i,N)
	{
		if (X-A[i] >= 0)
		{
			res += num2[X-A[i]];
		}
		else
		{
			res += N;
		}
	}
	return res;
}

int main()
{
	ll N,M;
	cin >> N >> M;
	rep(i,N)
	{
		cin >> A[i];
		num1[A[i]]++;
	}

	sort(A,A+N);
	reverse(A,A+N);
	rep(i,N)
	{
		sum[i+1] = sum[i] + A[i]; 
	}
	num2[0] = N;
	rep(i,MAX_NA-1)
	{
		num2[i+1] = num2[i] - num1[i];
	}

	ll l = 0, r = 200004;
	while(r - l > 1)
	{
		ll m = (l+r)/2;
		if (f(m,N) >= M)
		{
			l = m;
		}
		else
		{
			r = m;
		}
	}

	//cout << l << endl;

	ll ans = 0,temp = 0;
	ll x,p;
	rep(i,N)
	{
		if (l-A[i] < 0) p = 0;
		else p = l-A[i];
		//cout << A[i] << " " << num2[p] << endl;
		/*
		if (num2[p] < M) x = num2[p];
		else x = M; 
		*/
		x = num2[p];
		ans += A[i] * x + sum[x];
		temp += x;
	}
	//cout << temp << endl;
	ans -= l * (temp - M);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5632
#include <stdio.h>

int main (){
    
    int a,b,t,m=1,bis=0,i=0;
    
    scanf("%d %d %d",&a,&b,&t);
    
    for(i=1;i <= t;i++){
        if(m % a == 0 && m != 0){
            bis += b;
        }   
        m++;
    }
    
    printf("%d",bis);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void pr(A a){cout << a << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {}

int main(void) {
  int n,d;cin>>n>>d;
  int X[n+10][d+10];
  for(int i=0;i<n;++i) {
    for(int j=0;j<d;++j) {
      cin>>X[i][j];
    }
  }
  int res=0;
  for(int i=0;i<n;++i) {
    for(int j=i+1;j<n;++j) {
      double r=0;
      for(int k=0;k<d;++k) {
        r+=pow((X[i][k]-X[j][k]),2.0);
      }
      r=sqrt(r);
      if(floor(r)==r) res+=1;
    }
  }
  pr(res);
  return 0;
}


Measured memory_bytes: 256
g=->{gets.split.map &:to_i};n,C=g[];d=(1..C).map{g[]};c=(1..n).map{g[]};a=eval ([[0]*C]*3).to_s;C.times{|u|n.times{|i|n.times{|j|a[(i+j)%3][u]+=d[c[i][j]-1][u]}}};p [*0...C].permutation(3).map{|x,y,z|a[0][x]+a[1][y]+a[2][z]}.min

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

int main(void) {
  long long Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;
  long long one = min({Q * 4, H * 2, S});
  long long ans;
  if (2 * one <= D) {
    ans = N * one;
  } else {
    ans = D * (N / 2) + one * (N % 2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
INF = 10**20
MAX_INT = 10**6
a = [INF] * MAX_INT
b = [INF] * MAX_INT
a[0],b[0] = 0,0
for i in range(1, 200):
  t = i*(i+1)*(i+2)//6
  mm = min(t*5, MAX_INT)
  for j in range(t, mm):
    if a[j] > a[j-t]+1:
      a[j] = a[j-t]+1

  if t%2==0: continue

  for j in range(t, MAX_INT):
    if b[j] > b[j-t]+1:
      b[j] = b[j-t]+1

while True:
  N = int(input())
  if N==0: exit()
  print(a[N], b[N])


Measured memory_bytes: 52828
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>

using namespace std;

int main()
{
    char s[1000001];
    cin >> s;
    int num[26];
    memset(num, 0, sizeof(num));
    for(int i=0; i<strlen(s); i++){
        num[int(s[i])-97]++;
    }
    int flag=0;
    for(int i=0; i<26; i++){
        if(num[i]==0){
            cout << char(i+97);
            flag=1;
            break;
        }
    }
    if(flag==0){
        cout << "None";
    }
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int A, P;
  cin >> A >> P;

  cout << (3*A+P)/2 << endl;
  
  return 0;
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
r = Array.new(n, 1)
m.times do
  a, b = gets.split.map(&:to_i)
  r[a - 1] = 0 if h[a - 1] <= h[b - 1]
  r[b - 1] = 0 if h[a - 1] >= h[b - 1]
end
puts r.inject(:+)


Measured memory_bytes: 22636
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N ; i++) A[i] = sc.nextInt();
		int max = (K - A[N-1]) + A[0];
		for (int i = 0; i < A.length; i++) {
			if (i == 0) continue;
			else {
				int m = A[i] - A[i-1];
				if (max < m) max = m;
			}
		}
		System.out.println(K - max);
	}
}

Measured memory_bytes: 79672
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
ll x,a,b;
bool Main(){
    cin>>x>>a>>b;
    if(a-b>=0) cout<<"delicious"<<endl;
    else if(a+x-b>=0) cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
}
int main(){
    Main();
    return 0;
}

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

#define ll long long
#define mp make_pair
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)

using namespace std;

typedef pair<int, int> pii;
typedef double db;
const int N = 1e6 + 50;
int n, a[N], ans;
inline int read(){
	int x = 0, f = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar();}
	while(ch >='0' && ch <='9') { x = (x<<3)+(x<<1)+(ch^48); ch = getchar();}
	return x*f;
}
void init(){
	n = read();
	rep(i, 1, n) a[i] = read();
	rep(i, 1, n) rep(j, i+1, n) {
		ans += a[i]*a[j]; 
	}
	printf("%d\n", ans);
}
int main(){
//	freopen("input.in","r",stdin);
//	freopen("output.out","w",stdout);
	init();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll LIM = 1e9;

ll s;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> s;
    string ss = to_string(s);
    int n = ss.length();
    // cout << n << endl;

    if (n == 19) {
        cout << "0 0 1000000000 1 0 1000000000";
        return 0;
    } 

    ll si = 0;
    for (int i = 0; i < n / 2; i++) {
        if (ss[n - i - 1] == '0') continue;
        si += (10 - (ss[n - i - 1] - '0')) * powl(10, i);
        s += (10 - (ss[n - i - 1] - '0')) * powl(10, i);
        ss = to_string(s);
    }

    // cout << "SI" << si << '\n';

    n = ss.length();
    
    // x2 * y3 - x3 - y2
    ll x3 = si, y2 = 1;
    int uhalf = ceil((double)n / 2);
    string x2 = ss.substr(0, uhalf) , y3 = "1" + ss.substr(uhalf, n - uhalf);
    cout << "0 0 " << x2 << ' ' << y2 << ' ' << x3 << ' ' << y3;
}


Measured memory_bytes: 640
import java.util.ArrayDeque

fun main(args: Array<String>){
    val  ss = readLine()!!.split(" ")
    val stack = ArrayDeque<Int>()
    for (s in ss){
        if (s == "+"){ stack.addLast(stack.removeLast() + stack.removeLast() ) }
        else if (s == "-"){ stack.addLast(-stack.removeLast() + stack.removeLast() ) }
        else if (s == "*"){ stack.addLast(stack.removeLast() * stack.removeLast() ) }
        else if (s == "/"){ stack.addLast(stack.removeLast() / stack.removeLast() ) }
        else stack.addLast(s.toInt())
    }
    println(stack.removeLast())
}



Measured memory_bytes: 31996
#!python3

# input
A, B, C, D = list(map(int, input().split()))


def main():
    a = A // D if A % D == 0 else A // D + 1
    b = C // B if C % B == 0 else C // B + 1
    ans = "No" if a < b else "Yes"
    print(ans)
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 9180
use std::io::{Read, stdin};
use std::str::FromStr;


fn main() {
    let abcd: i32 = read();
    let a = abcd / 1000;
    let b = (abcd - a * 1000) / 100;
    let c = (abcd - a * 1000 - b * 100) / 10;
    let d = abcd - a * 1000 - b * 100 - c * 10;
    let mut s = String::new();
    for i in 0..8 {
        let mut ans = a;
        if i % 2 == 0 { ans += b; } else { ans -= b; }
        let op2i = i / 2;
        if op2i % 2 == 0 { ans += c; } else { ans -= c; }
        let op3i = op2i / 2;
        if op3i % 2 == 0 { ans += d; } else { ans -= d; }
        if ans == 7 {
            s.push_str(a.to_string().as_ref());
            if i % 2 == 0 {s.push('+');} else { s.push('-'); }
            s.push_str(b.to_string().as_ref());
            if op2i % 2 == 0 {s.push('+');} else { s.push('-'); }
            s.push_str(c.to_string().as_ref());
            if op3i % 2 == 0 {s.push('+');} else { s.push('-'); }
            s.push_str(d.to_string().as_ref());
            s.push_str("=7");
            break;
        }
    }
    println!("{}", s);
}


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

Measured memory_bytes: 4352
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 __shangu__
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DAllYourPathsAreDifferentLengths solver = new DAllYourPathsAreDifferentLengths();
        solver.solve(1, in, out);
        out.close();
    }

    static class DAllYourPathsAreDifferentLengths {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), bitn = 0;
            bitn = Integer.toBinaryString(n).length();
            out.printf("%d %d\n", bitn, bitn * 2 + Integer.bitCount(n) - 3);

            for (int i = 0; i < bitn - 1; ++i) {
                out.printf("%d %d %d\n", i + 1, i + 2, 0);
                out.printf("%d %d %d\n", i + 1, i + 2, 1 << i);

                if ((n >> i & 1) == 1) {
                    out.printf("%d %d %d\n", i + 1, bitn, (-1 << i + 1) & n);
                }
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main(){
	int n, x, m;
	int mem[11][3];

	cin >> n >> x >> m;
	for(int i=0; i<m; i++){
		cin >> mem[i][0] >> mem[i][1] >> mem[i][2];
	}
	int max=-1, maxans[10];
	for(int i=0; i<=x; i++){
		for(int i2=0; i2<=x; i2++){
			for(int i3=0; i3<=x; i3++){
				for(int i4=0; i4<=x; i4++){
					for(int i5=0; i5<=x; i5++){
						for(int i6=0; i6<=x; i6++){
							int ans[11];
							ans[1]=i;
							ans[2]=i2;
							ans[3]=i3;
							ans[4]=i4;
							ans[5]=i5;
							ans[6]=i6;
							int anssum=0;
							for(int j2=1; j2<=n; j2++){
								anssum += ans[j2];
							}
							
							int flag = 1;
							for(int j2=0; j2<m; j2++){
								int sum=0;
								for(int j3=mem[j2][0]; j3<=mem[j2][1]; j3++){
									sum += ans[j3];
								}
								if(sum != mem[j2][2]){
									flag=0;
									break;
								}
							}
							if(flag == 1 && max < anssum){
								max=anssum;
								for(int q=1; q<=n; q++){
									maxans[q] = ans[q];
								}
							}
						}
					}
				}
			}
		}
	}
	if(max == -1){
		cout << -1 << endl;
	}else{
		cout << maxans[1];
		for(int i=2; i<=n; i++){
			cout << ' ' << maxans[i];
		}
		cout << endl;
	}
}

Measured memory_bytes: 1164
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	ll n,p; cin>>n>>p;
	if(n == 1){cout<<p<<endl; return 0;}
	ll ans = 0;
	for(ll i = 1; i*i<=p; ++i){
		if(p%i == 0){
			if(p % (ll)pow(i,n) == 0){
				ans = i;
			}
			if(pow(i,n) > p){
				break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
N = int(input())
a = list(map(int, input().split()))
x = [0] * N
x[0] = sum([a[i] for i in range(N) if i % 2 == 0]) - sum([a[i] for i in range(N) if i % 2 != 0])
for i in range(N - 1):
    x[i + 1] = 2 * a[i] - x[i]
print(*x)


Measured memory_bytes: 14028
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <array>
#include <algorithm>
#include <set>
#include <iomanip>
#include <cstdio>
#include <queue>

using namespace std;

#define int long long

int in[4];
char op[3];

void func(int value, int deep)
{
    if (deep == 4)
    {
        if (value != 7)
        {
            return;
        }

        for (int i = 0; i < 3; ++i)
        {
            cout << in[i] << op[i];
        }
        cout << in[3] << "=7" << endl;
        
        exit(0);
    }

    op[deep - 1] = '+';
    func(value + in[deep], deep + 1);

    op[deep - 1] = '-';
    func(value - in[deep], deep + 1);


}

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

    string s;
    cin >> s;
    for (int i = 0; i < 4; ++i)
    {
        in[i] = (int)s[i] - '0';
    }

    func(in[0], 1);
    
}

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

lst = []
for i in A:
    if i % 2 == 0:
        lst.append(i)
lst2 = []
if lst:
    for j in lst:
        if j % 3 == 0 or j % 5 == 0:
            lst2.append(j)
    if lst == lst2:
        print('APPROVED')
    else:
        print('DENIED')
else:
    print('APPROVED')

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
    int n,m,c;cin>>n>>m>>c;
    V b(m);rep(i,m)cin>>b[i];
    int ans=0;
    rep(i,n){
        int sum=0;
        rep(j,m){
            int tmp;
            cin>>tmp;
            sum+=tmp*b[j];
        }
        sum+=c;
        if(sum>0)ans++;
    }
    cout<<ans<<endl;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    sort(S.begin(), S.end());
    sort(T.begin(), T.end(), greater<>());
    if (S < T)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()

A = S.count('a')
B = S.count('b')
C = S.count('c')
M = max(A, B, C)
if (A == M or A == M - 1) and (B == M or B == M - 1) and (C == M or C == M - 1):
    print('YES')
else:
    print('NO')

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

using namespace std;

int main()
{
    char s[7];

    scanf("%s", s);

    if(s[0] != s[1] && s[0] != s[2] && s[0] != s[4] && s[1] != s[2] && s[1] != s[4] && s[2] == s[3] && s[4] == s[5]){
        cout<< "Yes" << endl;
    }
    else
        cout<< "No" << endl;



    return 0;
}


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

int main(){
	int n,x,i,j,k,c;
	while(n!=0||x!=0){
		c=0;
		cin >> n >> x;
		if(n!=0||x!=0){
			for(i=1;i<=n;i++){
				for(j=i+1;j<=n;j++){
					for(k=j+1;k<=n;k++){
						if(i+j+k==x) c++;
					}
				}
			}
			cout << c << endl;
		}
	}
}

Measured memory_bytes: 1160
a = int(input())
ans = 0
if a < 105:
    print(0)
else:
    for i in range(105,a+1,2):
        count = 0
        for j in range(1,a+1,2):
            if i % j == 0:
                count += 1
        if count == 8:
            ans += 1
    print(ans)

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 100005

string s , t;

int main()
{
    _FastIO;
    cin >> s;
    cin >> t;
    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] != t[i])
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3812
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#include<set>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
int n;
ll a[10010];
ll gcd(ll x,ll y){//最大公約数
  if(x<0) x=-x;
  if(y<0) y=-y;
  if(y==0) return x;
  else return gcd(y,x%y);
}
bool prime[10010];
vector<ll> sieve(ll x){//エラストテネスの篩
  prime[0]=prime[1]=false;
  for(ll i=2;i<=x;i++) prime[i]=true;
  vector<ll> res;
  for(ll i=2;i<=x;i++){
    if(prime[i]){
      res.push_back(i);
      ll b=i;
      while(b<=x){
	prime[b]=false;
	b+=i;
      }
    }
  }
  return res;
}
map<ll,int> prime_factor(ll x){
  map<ll,int> res;
  for(ll i=2;i*i<=x;i++){
    while(x%i==0){
      res[i]++;
      x/=i;
    }
  }
  if(x!=1) res[x]=1;
  return res;
}

void solve(){
  set<ll> res;
  ll g=0;
  rep(i,n+1){
    g=gcd(g,a[i]);
  }
  map<ll,int> m=prime_factor(g);
  for(auto ite=m.begin();ite!=m.end();ite++){
    res.insert(ite->first);
  }
  vector<ll> pr=sieve(n);
  int ps=pr.size();
  rep(i,ps){
    ll p=pr[i];
    ll box[p+1];
    fill(box,0);
    box[0]=a[0];
    rep1(i,n){
      ll r=i%(p-1);
      if(r==0) r=p-1;
      box[r]+=a[i];
    }
    bool f=true;
    rep(i,p){
      if(box[i]%p!=0){
	f=false;
	break;
      }
    }
    if(f) res.insert(p);
  }
  for(auto ite=res.begin();ite!=res.end();ite++){
    prin(*ite);
  }
}
void reverse(){
  rep(i,(n+1)/2){
    ll temp=a[i];
    a[i]=a[n-i];
    a[n-i]=temp;
  }
}
int main(){
  cin>>n;
  rep(i,n+1) cin>>a[i];
  reverse();
  solve();
  

  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,29)-1;


int main() {
  int N, D; cin >> N >> D;
  int result = (N+2*D)/(2*D+1);
  cout << result << endl;
  return 0;
}

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

struct E{
    int to,co;
};

using graph = vector<vector<E>>;
graph G(100005);

void dfs(vector<ll> &dist,const int v){
    for(E e:G[v]){
        if(dist[e.to] != -1) continue;
        dist[e.to] = dist[v] + e.co;
        dfs(dist,e.to);
    }
    return;
}

int main(){
    int n;cin >> n;
    rep(i,n-1){
        int a,b,c;cin >> a >> b >> c;
        --a;--b;
        G[a].emplace_back((E){b,c});
        G[b].emplace_back((E){a,c});
    }

    int q,k; cin >> q >> k;
    --k;
    vector<ll> dist(n,-1);
    dist[k] = 0;
    dfs(dist,k);
    vector<ll> ans(q);
    rep(i,q){
        int x,y; cin >> x >> y;
        --x;--y;
        ans[i] = dist[x] + dist[y];
    }
    
    rep(i,q) cout << ans[i] << endl;
}

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

int main() {
    int N; cin>>N;
    for (int i = 0; i < N; i++){
        int A; cin>>A;
        if(A%2==0 && A%3!=0 && A%5!=0){
            cout<<"DENIED"<<endl;
            return 0;
        }
    }
    cout<<"APPROVED"<<endl;
}

Measured memory_bytes: 3600
## デバッグ用
GBN_DEBUG = False
def dprn(s, i):
    if GBN_DEBUG: print(", " + s + " = " + str(i), end = "")
def dprns(s):
    if GBN_DEBUG: print(", " + s, end = "")
def dprni(i):
    if GBN_DEBUG: print(i, end=" ")
def endl(): 
    if GBN_DEBUG: print('')
def puts(s): print(s)

#本体ここから

#S = input()
#N = int(input())
#S, T = input().split()
N, K = map(int, input().split())
#W = [input() for _ in range(N)]
A = list(map(int, input().split()))

#GBN_DEBUG = True

pos1 = 0 # 1の位置
for i in range(N):
    if A[i] == 1:
        pos1 = i
        break

numReplace = K - 1 # 1度に置き換えれる数

left = pos1 // numReplace # １より左を全て１にするのに必要な回数
if pos1 % numReplace != 0:
    left += 1
    pos1 = left * numReplace # 左を全て1にした場合に取り得る1の右端位置
                             # 元の1の位置より右にずれる（場合がある）

N_P_1 = N - pos1 - 1 
right = N_P_1 // numReplace # 1より右を全て１にするのに必要な回数
if N_P_1 % numReplace != 0:
    right += 1

print(left + right)


Measured memory_bytes: 14008
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
    int a, b;
    double c, C, s, l, h;
    scanf("%d%d%lf", &a, &b, &C);
    C *= M_PI/180;
    s = a*b*sin(C)/2;
    c = sqrt(a*a + b*b -2*a*b*cos(C));
    l = a+b+c;
    h = 2*s/a;
    printf("%lf\n%lf\n%lf\n", s, l, h);
    return 0;

}


Measured memory_bytes: 2932
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int a,b,c; 
int main() {
	cin>>a>>b>>c;
	if(a==b+c||b==a+c||c==a+b)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <math.h>
double pi(void);
int main(void)
{
	double r;
	scanf("%lf", &r);
	printf("%f %f\n", pi()*r*r, pi()*r*2);
	return 0;
}
double pi(void) {
	return atan(1.0) * 4.0;
}

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

typedef long long lli;
typedef pair<lli,lli> pll;
typedef vector<lli> vcL;
typedef vector<pll> vPL;


void solve() {
	lli n = 3;
//	cin >> n;
	
	lli _min = INT_MAX, _max = 0;
	
	vcL num( n, 0 );
	
	for (int i = 0; i < n; ++i) {
		cin >> num[i];
		_min = min( _min, num[i] );
		_max = max( _max, num[i] );
	}
	
	cout << _max-_min << '\n';
}

int main() {
	int t = 1;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve();
	}
	return 0;
} 


Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0
from bisect import bisect_left
for i in range(N):
    for j in range(i+1,N):
        t = bisect_left(L,L[i]+L[j])
        ans += max(0, t-(j+1))
print(ans)

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

int main(){
    int a, b, c, tmp;
    cin >> a >> b >> c;
    if(a>b){
        tmp = b;
        b = a;
        a = tmp;
    }
    if(b > c){
        tmp = c;
        c = b;
        b = tmp;
    }
    if(a > b){
        tmp = b;
        b = a;
        a = tmp;
    }
    cout << a << " ";
    cout << b << " ";
    cout << c << endl;
    
    return 0;
}


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int x, a, b,c;
    cin>>a>>b>>c>>x;
    int ans = 0;
    int sum;

    for (int i = 0; i <=a ;i++){
        for (int j = 0; j <=b ;j++){
            for (int k = 0; k <=c ;k++){
                sum = 500 * i + 100 * j + 50 * k;
                if(sum==x){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}


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

void solve() {
	int a, b;
	cin >> a >> b;
	int cnt = 1, ans = 0;
	while (cnt < b) {
		ans++;
		cnt += a - 1;
	}
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3604
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int count = 0;

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

        System.out.println(count);
    }
}



Measured memory_bytes: 26400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int main(){
	int x;cin>>x;
	puts(x<1200?"ABC":"ARC"); 
	return 0;
}

Measured memory_bytes: 3636
N = int(input())
A = list(map(int, input().split()))
C = set()
R = 0
for a in A:
    c = a//400 if a<3200 else 8
    C.add(c)
    if c==8: R+=1

print(len(C) - min(1, R, len(C)-1), len(C) + max(0, R-1))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
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; }


int main(void) {
    int N,D;
    cin>>N>>D;
    int ans=1;
    int x=1+2*D;
    while(x<N){
        ans++;
        x+=1+2*D;
    }
    cout<<ans<<endl;
}

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

int main()
{
    int a,q,w=0,b,c;
    cin >> a;
    for(int i=1;i<=a;i++)
    {
        cin >> b >> c;
        if(c>=b)
        {
            q=(c-b)+1;
        }
        w=w+q;
    }
    cout << w;
    return 0;
}


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

using namespace std;

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

		cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
   int n;
   cin>>n;
   vector<int> a(n);
   rep(i,0,a.size()){
       cin>>a[i];
   } 
   int cnt = 0;
   rep(i,0,a.size()){
       if (a[i]&1 && (i+1)&1 ){
           cnt++;
       }
   }
   cout<<cnt<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define ll long long
#define ALL(a) a.begin(), a.end()

int main(void)
{
  int n, m;
  cin >> n >> m;
  vec<ll> x(m);
  rep(i, m) cin >> x[i];
  sort(ALL(x));

  vec<ll> d(m - 1);
  rep(i, m - 1) d[i] = x[i + 1] - x[i];
  sort(ALL(d));
  ll count = 0;
  rep(i, m - n) count += d[i];
  cout << count << endl;
  return 0;
}



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

long long f(long long x) {
    long long n = x % 4;
    if (n == 0) return x;
    else if (n == 1) return 1;
    else if (n == 2) return x + 1;
    else if (n == 3) return 0;
}

int main() {
    long long a, b;
    cin >> a >> b;

    long long c = f(a - 1) ^ f(b);
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
//#include<vector>
//#include <iostream>
//#include <algorithm>
#include <limits>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;
#define nMAX numeric_limits<long long>::max()
int main(void){
	int N;
	ll W;
	int i,k;
	ll j;
	cin >> N>>W;
	int v[N+1];
	ll w[N+1];
	rep(i,N){
		cin >> w[i+1]>>v[i+1];
	}
	ll **dp = (ll**)malloc(sizeof(ll *)*(N+1));
	rep(i,N+1){
		dp[i]=(ll *)malloc(sizeof(ll)*(W+1));
		if (dp[i] == NULL) {
        	printf("Memory cannot be allocated.");
    	}
	}
	rep(i,N+1){
		dp[i][0] = 0;
	}
	rep(i,W+1){
		dp[0][j]=0;
	}
	for(i=1;i<N+1;i++){
		for(j=1;j<W+1;j++){
			if(j>=w[i]){
				dp[i][j] = max(dp[i-1][j-w[i]]+v[i],dp[i-1][j]);
			}else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	cout << dp[N][W] <<endl;
	rep(i,N+1)free(dp[i]);
	free(dp);
	return 0;
}

Measured memory_bytes: 78592
#include<stdio.h>
void quicksort(int a[],int s,int t){
  if(s<t){
    int i=s,j=t,p=a[(s+t)/2];
    while(1){
      while(a[i]<p)i++;
      while(p<a[j])j--;
      if(i>=j)break;
      a[i]^=a[j]^=a[i]^=a[j];
      i++;j--;
    }
    quicksort(a,s,i-1);quicksort(a,j+1,t);
  }
}
int main(){
  int n,i,j,d[1000001],a[200000];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  for(i=0;i<1000001;i++)d[i]=1;
  quicksort(a,0,n-1);
  for(i=0;i<n;i++)if(d[a[i]]){if(i>0&&a[i]==a[i-1])d[a[i]]=0;else for(j=2;j*a[i]<1000001;j++)d[a[i]*j]=0;}
  j=0;for(i=0;i<n;i++)j+=d[a[i]];
  printf("%d",j);
}


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

long long mod = 1000000007, dp[1009][1009]; string S, T;

int main() {
	cin >> S >> T;
	dp[0][0] = 1;
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j <= T.size(); j++) {
			if (j < T.size() && S[i] == T[j]) { dp[i + 1][j + 1] += dp[i][j]; dp[i + 1][j + 1] %= mod; }
			dp[i + 1][j] += dp[i][j]; dp[i + 1][j] %= mod;
		}
	}
	cout << dp[S.size()][T.size()] << endl;
	return 0;
}


Measured memory_bytes: 11092
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

int main() {
	int n, m;
	cin >> n >> m;
	int l_max = 0;
	int r_min = N + 1;
	rep(i, m) {
		int l, r;
		cin >> l >> r;
		l_max = max(l, l_max);
		r_min = min(r, r_min);
	}
	cout << max(r_min - l_max + 1, 0) << endl;
}


Measured memory_bytes: 256