akhauriyash/Code-Regression huggingface dataset:
boundaries = [399, 799, 1199, 1599, 1999, 2399, 2799, 3199, 4800]
input()
rates = sorted([int(x) for x in input().split()])
counts = []
for boundary in boundaries:
    tmp = 0
    while rates and rates[0] <= boundary:
        tmp += 1
        rates.pop(0)
    counts.append(tmp)
least = sum([x > 0 for x in counts[:-1]])
print("{} {}".format(1 if least == 0 else least, counts[-1]+least))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

//vector<vector<ll>> dpx(1000,vector<ll>()), dpy(10000,vector<ll>());
set<ll> dpx, dpy;
deque<ll> vx,vy;
/*
ll dfs(ll now, ll id ll n){
    if(id == n) return 0;
    dpx[now + vx[id]]++;
    dfs(now + vx[id], id+1, n);
    dpx[now + vx[id]]++;
    dfs(now - vx[id], id+1, n);
    return 0;
}*/

int main(){
    string s;
    ll x,y,N;
    cin >> s;
    N = s.size();
    cin >> x >> y;
    bool st = true;
    ll d = 0;
    rep(i,N){
        if(s[i]=='F'){
            d++;
        }else{
            if(st){
                vx.push_back(d);
            }else{
                vy.push_back(d);
            }
            d = 0;
            st = !st;
        }
    }
    if(d != 0){
        if(st){
            vx.push_back(d);
        }else{
            vy.push_back(d);
        }
    }
    if(!vx.empty()){
        x -= vx[0];
        vx.pop_front();
    }
    dpx.insert(0);
    for(auto& xi:vx){
        auto buf = dpx;
        dpx.clear();
        for(auto& e:buf){
            dpx.insert(e+xi);
            dpx.insert(e-xi);
        }
    }
    //cout <<"aaa"<<endl;
    dpy.insert(0);
    for(auto& yi:vy){
        auto buf = dpy;
        dpy.clear();
        for(auto& e:buf){
            dpy.insert(e+yi);
            dpy.insert(e-yi);
        }
    }
    if(dpx.count(x) && dpy.count(y)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


}

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

int main()
{
  vector<int> A;
  while (1)
  {
    int n;
    cin >> n;
    if (n == 0)
    {
      break;
    }
    A.push_back(n);
  }
  for (int i = 0; i < A.size(); i++)
  {
    cout << "Case " << i + 1 << ": " << A.at(i) << endl;
  }
}


Measured memory_bytes: 3232
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int N, M;
  pii a[100010];

  cin >> N >> M;
  for (int i = 0; i < N; ++i) {
    int x, y;
    cin >> x >> y;
    a[i] = pii(x, y);
  }

  sort(a, a+N);

  i64 cnt = 0;
  i64 ans = 0;

  for (int i = 0; i < N; ++i) {
    int take = min<i64>(M - cnt, a[i].second);

    ans += i64(a[i].first) * take;
    cnt += take;
    if (cnt >= M) break;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 1024
from bisect import bisect_right

N = int(input())
*A, = map(int, input().split())
A.sort()

ac = [0]*(N+1)
for i in range(1, N+1):
    ac[i] = ac[i-1]+A[i-1]
ans = 0
for i in A:
    bef = bisect_right(A, i*2)
    aft = bisect_right(A, ac[bef]*2)
    while bef!=aft:
        v = ac[aft]
        bef = aft
        aft = bisect_right(A, ac[aft]*2)
    ans += int(aft==N)
print(ans)

Measured memory_bytes: 63984
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int A,B,T; cin>>A>>B>>T;
    LL ans;
    ans = (T/A) * B;
    cout << ans << endl;

}

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

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

int main(){
    int k,a,b;
    cin >> k >> a >> b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

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

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)



signed main(){

	int N, M;
	int X[123456] = { 0 };
	cin >> N >> M;
	for (int i = 0; i < M; i++) cin >> X[i];
	if (N >= M){ cout << 0 << endl; return 0;}
	sort(X, X + M);
	int diff[123456] = { INF };

	for (int i = 0; i < M - 1; i++){
		diff[i] = X[i + 1] - X[i];
	}
	sort(diff, diff + M - 1);
	int ans = 0;
	for (int i = 0; i < M - N; i++){
		ans += diff[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2176
word = input().strip().split(" ")
ans = []
t = 0
for i in range(len(word)):
    if word[i] == "+":
        s = ans.pop()
        t = ans.pop()
        ans.append(t+s)
    elif word[i] == "-":
        s = ans.pop()
        t = ans.pop()
        ans.append(t-s)
    elif word[i] == "*":
        s = ans.pop()
        t = ans.pop()
        ans.append(t*s)
    else:
        ans.append(int(word[i]))
print(ans[0])


Measured memory_bytes: 5604
using System;
using System.Collections.Generic;

class Program {
    static void Main(string[] args) {

        int n = int.Parse(Console.ReadLine());
        int[] x = new int[n];
        int[] y = new int[n];

        for(int a = 0; a < n; a++) {
            string xy = Console.ReadLine();
            x[a] = int.Parse(xy.Split(' ')[0]);
            y[a] = int.Parse(xy.Split(' ')[1]);
        }
        long nb = 1;
        for(int a = 1; a <= n - 1; a++) {
            nb *= a;
        }


        decimal result = 0;

        for(int a = 0; a < n; a++) {
            for(int b = a; b < n; b++) {
                decimal dis = (decimal)Math.Sqrt(Math.Pow((x[a] - x[b]),2) + Math.Pow((y[a] - y[b]) , 2));
                result += nb * dis*2;
            }
        }

        Console.WriteLine(result/nb/n);
    }
}

Measured memory_bytes: 13140
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
using namespace std;

int main() {
  int K ;
  string S, ans;
  cin >> K >> S;
  if(K >= S.size()){
    cout << S << endl;
  }
  else{
    for(int i=0; i < K ; i++){
      ans += S.at(i);
    }
    ans += "...";
    cout << ans << endl;
  }
 

        
  
}


Measured memory_bytes: 3636
import Data.List

main = do
  line <- getLine
  let input = (map read $ words line :: [Int])
      insert x ln 
        | ln == []        = [x]
        | (head ln) > x   = x : ln
        | otherwise       = (head ln) : (insert x $ tail ln)
      sort src dst
        | src == []  = dst
        | otherwise  = sort (tail src) $ (insert $ head src) dst :: [Int]
    in putStrLn $ intercalate " " $ map show $ sort input []



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

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  
  if (A+B==C+D){
    cout<<"Balanced"<<endl;
  }
  else if (A+B>=C+D){
    cout<<"Left"<<endl;
  }
  else{
    cout<<"Right"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main()
{
    int n;
    string name;
    string sign;
    int fmatch, ffin;
    int ans=0;
    cin >> n >> name;
    for(int i=0;i<n;++i)
    {
        cin >> sign;
        for(int j=0;name.size()*(1+j)-j<=sign.size();++j)
        {
            ffin=0;
            for(int k=0;name.size()*(1+j)-j+k<=sign.size();++k)
            {
                fmatch=0;
                for(int l=0;l<name.size();++l)
                {
                    if(name[l]!=sign[k+l+j*l])
                    {
                        fmatch=1;
                        break;
                    }
                }
                if(!fmatch)
                {
                    ffin=1;
                    break;
                }
            }
            if(ffin)
            {
                ++ans;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1208
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

void good(){
  cout << "Heisei" << endl;
}
void bad(){
  cout << "TBD" << endl;
}

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

    string s ;
    cin >> s;
    int year = stoi(s.substr(0,4));
    int month = stoi(s.substr(5,2));
    int day = stoi(s.substr(8,2));
    if(year < 2019){
      good(); return 0;
    }
    if(year > 2019) {
      bad(); return 0;
    }
    if(month < 4) {
      good(); return 0;
    }
    if(month > 4){
      bad(); return 0;
    }
    if(day > 30) {
      bad(); return 0;
    }
    good();
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <iostream>

int main()
{
	for (int x, y; std::cin >> x >> y, x || y;)
	{
		if (x < y)
		{
			std::cout << x << " " << y << std::endl;
		}
		else
		{
			std::cout << y << " " << x << std::endl;
		}
	}
	return 0;
}


Measured memory_bytes: 2996
#include <iostream>
#include <string>

using namespace std;

int main() {
  double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
  while (cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2) {
    bool a = (xb1 < xa1) && (xb2 < xa1);
    bool b = (xa2 < xb1) && (xa2 < xb2);
    bool c = (yb1 < ya1) && (yb2 < ya1);
    bool d = (ya2 < yb1) && (ya2 < yb2);
    string ans = (a || b || c || d) ? "NO" : "YES";
    cout << ans << endl;
  }
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int T;
  cin>>T;
  int a[N];
  int b[N];
  int mi = 100000;
  bool t = 0;
  for(int i = 0;i<N;i++){
    cin>>a[i]>>b[i];
    if(b[i]<=T){
      mi = min(a[i],mi);
      t = 1;
    }
  }
  if(t == 1){
    cout << mi << endl;
  }
  else{
    cout << "TLE" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
x=[]
for i in range(m):
    b,c=map(int,input().split())
    x.append([b,c])
y=sorted(x,key=lambda x:(x[1],x[0]),reverse=True)

p=0
q=0
for i in range(n):
    if a[i]<y[p][1]:
        a[i]=y[p][1]
        q+=1
    else:
        break
    if q==y[p][0]:
        p+=1
        q=0
        if p==m:
            break

print(sum(a))
        

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

using namespace std;
using LL = long long;

const int MAXN = 3005;
const LL INF = (LL)1e18;

int R, C;
LL dp[MAXN][MAXN][4], g[MAXN][MAXN];

LL solve(int r, int c, int qt) {
    if (r > R || c > C) return -INF;
    if (r == R && c == C) return (qt < 3 ? g[r][c] : 0LL);

    LL &p = dp[r][c][qt];
    if (p != -1) return p;

    p = 0;
    
    p = max(p, solve(r + 1, c, 0));
    p = max(p, solve(r, c + 1, qt));

    if (qt < 3) {
        p = max(p, g[r][c] + solve(r + 1, c, 0));
        p = max(p, g[r][c] + solve(r, c + 1, qt + 1));
    }

    return p;

}

void solver() {
    int k;
    cin >> R >> C >> k;

    for(int i = 0; i < k; ++i) {
        int x, y, v;
        cin >> x >> y >> v;
        g[x][y] = v;
    }

    memset(dp, -1, sizeof dp);

    cout << solve(1, 1, 0) << '\n';

}

int main() {

    ios_base :: sync_with_stdio(0); cin.tie(NULL);

    int t = 1;
    //cin >> t;
    
    while(t--)
        solver();

    return 0;
}

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

struct Team {

	char name;
	int  winCnt;
	int  loseCnt;

};

int main()
{

	int n, r;
	int inInfo[10];
	Team t[10];

	while( cin >> n, n ) {

		for( int i = 0; i < 10; i++ ) { t[i].winCnt = t[i].loseCnt = 0; inInfo[i] = i + 1; }

		for( int i = 0; i < n; i++ ) {
			cin >> t[i].name;
			for( int j = 0; j < n - 1; j++ ) {

				cin >> r;
				if( r == 0 ) t[i].winCnt++;
				else if( r == 1 ) t[i].loseCnt++;

			}
		}

		for( int i = 0; i < n - 1; i++ ) {
			for( int j = i + 1; j < n; j++ ) {

				int  itemp;
				Team stemp;

				if( t[i].winCnt == t[j].winCnt ) {
					if( t[i].loseCnt == t[j].loseCnt ) {
						if( inInfo[i] > inInfo[j] ) {

							stemp = t[i];  itemp     = inInfo[i];
							t[i]  = t[j];  inInfo[i] = inInfo[j];
							t[j]  = stemp; inInfo[j] = itemp;

						}
					}
					if( t[i].loseCnt > t[j].loseCnt ) {

						stemp = t[i];  itemp     = inInfo[i];
						t[i]  = t[j];  inInfo[i] = inInfo[j];
						t[j]  = stemp; inInfo[j] = itemp;

					}
				}
				else if( t[i].winCnt < t[j].winCnt ) {

						stemp = t[i];  itemp     = inInfo[i];
						t[i]  = t[j];  inInfo[i] = inInfo[j];
						t[j]  = stemp; inInfo[j] = itemp;

				}

			}
		}

		for( int i = 0; i < n; i++ ) cout << t[i].name << endl;

	}

	return 0;

}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	string S;
	int N, Q;
	cin >> N >> Q >> S;

	vector<int> v(S.size());
	for (int i = 1; i < S.size(); i++) {
		if (S[i] == 'C') {
			if (S[i - 1] == 'A') v[i] = v[i - 1] + 1;
			else v[i] = v[i - 1];
		}
		else {
			v[i] = v[i - 1];
		}
	}

	for (int i = 0; i < Q; i++) {
		int l, r;
		cin >> l >> r;
		l--;
		r--;
		int ans = v[r] - v[l];
		cout << ans << endl;
	}
}

Measured memory_bytes: 3832
#include<iostream>
#include<vector>
#include<sstream>
#include<bitset>
using namespace std;
 
const int NMAX=13;
const int ainf= (int) 1e9;
 
int main(){
    int N,M;
    cin >> N >> M;
    vector <int> a(M),b(M);
    int atmp, btmp, ctmp;
    vector < vector <int> > c(M);
 
    stringstream ss;
    string s;
 
    for(int i=0; i<M; i++){
        //cout << "i " << i << endl;
        cin >> a[i] >> b[i];
        for(int j=0; j<b[i]; j++){
            cin >> ctmp;
            c[i].push_back(ctmp);
        }
    }
 
    for(int i=0; i<M; i++){
        //cout << "i a[i] b[i]" << i << " " << a[i] << " " << b[i] << endl;
    }
 
    vector <int> dp((1<<N)+1,ainf), dp_prev((1<<N)+1,ainf);
    dp[0]=0;
 
    for(int i=0; i<M; i++){
        for( int j=0; j< (1<<N); j++ ){
            dp_prev[j]=dp[j];
        }
 
        int tmp=0;
        for(int j=0; j<b[i]; j++){
            //cout << "i j c[i][j] = " << i << " " << j << " " << c[i].at(j) << endl;
            tmp = ( tmp | (1 << (c[i].at(j)-1)) );
        }
 
        //ss << bitset<NMAX>(tmp);
        //s = ss.str();
        //ss.str("");
        //cout << "tmp " << s << endl;
 
        for( int j=0; j< (1<<N); j++ ){
            if( dp[ j|tmp ] > dp_prev[j]+a[i] ){
                dp[ j|tmp ] = dp_prev[j] + a[i];
                //ss << bitset<NMAX>( j|tmp );
                //s = ss.str();
                //ss.str("");
                //cout << "j|tmp dp " << s << " " << dp[j|tmp] << endl;
            }
        }
    }
 
    if( dp[(1<<N)-1] >= ainf ){
        cout << -1 << endl;
    }else{
        cout << dp[(1<<N)-1] << endl;
    }
 
    return 0;
}

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

int main(){
    int p,q,r;
    cin >> p >> q >> r;
    cout << p+q+r-max({p,q,r}) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.InputMismatchException;

class Main {
   public static void main(String args[]) {
      int x=0 ,y=0;
      Scanner scanner = new Scanner(System.in);
      x = scanner.nextInt();
      y = scanner.nextInt();
      scanner.close();
      if (x>12) {
         System.out.println(y);
      } else if (x < 6) {
         System.out.println(0);
      } else {
         System.out.println(y/2);
      }

   }
}


Measured memory_bytes: 21716
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define mp make_pair
#define INF 100000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define BLACK 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

class Edge {
public:
    ll t;
    ll w;
    Edge() {}
    Edge(ll t, ll w): t(t), w(w) {}
};

ll N, M;
vector<ll> G[MAX];

int main(void) {
    cin >> N >> M;
    ll i;
    ll a, b;
    ll cnt[100000]={};
    for(i=0; i<M; i++) {
        cin >> a >> b;
        a--; b--;
        if(a!=0) cnt[a]++;
        if(b!=0) cnt[b]++;
    }
    
    for(i=0; i<N; i++) {
        if(cnt[i]%2==1) {
            pNO;
            return 0;
        }
    }
    
    pYE;
}

Measured memory_bytes: 3328
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    const long Mod = (long)1e9 + 7;
    
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
        var (n, k) = (nk[0], nk[1]);

        var count = new Modular(0, Mod);
        for (; k <= n + 1; ++k)
        {
            count += k * (n - k + 1) + 1;
        }
    
        Console.WriteLine(count.Value);
    }
    
    readonly struct Modular
    {
        public readonly long Mod;
        public readonly long Value;

        public Modular(long x, long m) : this() => (this.Value, this.Mod) = ((x + m) % m, m);

        public static Modular operator +(Modular a, long x) => new Modular(a.Value + x, a.Mod);
        public static Modular operator -(Modular a, long x) => new Modular(a.Value - x + a.Mod, a.Mod);
        public static Modular operator *(Modular a, long x) => new Modular(a.Value * x, a.Mod);
        public static Modular operator /(Modular a, long x) => new Modular(a.Value / x, a.Mod);
    }
}


Measured memory_bytes: 28248
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def cd(a, b):
  if a == 1 or b == 1:
    return 1

  while a != 0 and b != 0:
    if a < b:
      b %= a
    else:
      a %= b

  return a if a != 0 else b


def main():
  input()
  prevs = list(map(int, input().split()))
  posts = prevs[::-1]

  for i in range(1, len(prevs)):
    prevs[i] = cd(prevs[i - 1], prevs[i])
    posts[i] = cd(posts[i - 1], posts[i])

  posts = posts[::-1]

  gcd = max(prevs[-2], posts[1])

  for i in range(1, len(prevs) - 1):
    gcd = max(cd(prevs[i - 1], posts[i + 1]), gcd)

  print(gcd, flush=True)


if __name__ == '__main__':
  main()



Measured memory_bytes: 14076
#include<bits/stdc++.h>
using namespace std;
long long n,ans,s; 
int main()
{
    scanf("%lld",&n); 
    for(int i=sqrt(n);i>0;i--) if(n%i==0){ans=n/i;break;}
    while(ans>0){s++;ans/=10;}
    printf("%lld\n",s); 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define SZ(x) x.size()
#define pii pair<int,int>
#define ll long long
using namespace std;
int main() {
    int n, r;
    scanf("%d%d", &n, &r);
    if(n >= 10)
        printf("%d", r);
    else
        printf("%d", 100 * (10 - n) + r);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

int N,K;
int A[200001];
int flag[200001] = {0};
set<int> st;

int main(){
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        flag[A[i]]++;
        st.insert(A[i]);
    }

    sort(flag,flag+200001);

    int num = st.size() - K;

    int cnt=0;
    for(int i = 0; i <  200001; i++){
        if(num <= 0) break;
        if(flag[i] > 0){
            cnt += flag[i];
            num--;
        } 
    }

    cout << cnt << endl;

    return 0;


}


Measured memory_bytes: 11136
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  int n, m;
  readf("%s %s\n", &n, &m);
  auto x = readln.chomp.split.to!(long[]);
  sort(x); 
  if (m == 1) {
    0.writeln;
    return;
  }
  auto d = new long[](m-1);
  foreach (i; 0..m-1) {
    d[i] = x[i+1] - x[i];
  }
  sort(d);
  (d.sum - d[$-min(m,n-1)..$].sum).writeln;
}


Measured memory_bytes: 4232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,t;cin >> n >> t;
	vector<pii> a(n);
	rep(i,n) cin >> a.at(i).first >> a.at(i).second;
	sort(a.begin(),a.end());
	vector<vector<ll>> dp(n + 1,vector<ll>(t + 3020));
	rep(i,n){
		rep(j,t){
			dp[i + 1][j + a.at(i).first] = max(dp[i + 1][j + a.at(i).first], dp[i][j] + a.at(i).second);
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
		}
	}
	ll ans = 0;
	rep(i,n + 1){
		rep(j,t + 3010){
			ans = max(ans, dp[i][j]);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 141568
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;

typedef long long ll;
ll n, m, la, s, a[N];
int main()
{
	ll i;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf ("%lld", &a[i]);
	}
	sort(a, a + n);
	s = a[0];
	for (i = 1; i < n; i++) {
		if (s * 2 < a[i]) la = i;
		s += a[i];
	}
	cout << n - la;
    return 0;
}


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

int count_perm(vector<int>A){
    //与えられた数列が辞書順で何番目か

    vector<int>B(A.size());
    rep(i,A.size()){
        B.at(i)=A.at(i);
    }
    sort(B.begin(),B.end());
    int count=1;
    int flag=0;
    do{
       for(int i=0;i<A.size();i++){
           if(B.at(i)!=A.at(i)){
               flag=1;
           }
       }
       if(flag==1){
           count++;
           flag=0;
       }else{
           break;
       }
    }while(next_permutation(B.begin(),B.end()));

    return count;

}
int main(){
   int N;
   cin>>N;
   vector<int>P(N);
   vector<int>Q(N);
   rep(i,N){
       cin>>P.at(i);
   };
   rep(i,N){
       cin>>Q.at(i);
   }
   int count_p=count_perm(P);
   int count_q=count_perm(Q);

    cout<<abs(count_p-count_q)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
ll mod = 1e9+7;


ll s[200010];
int main(){
    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    s[0] = 0;
    rep(i,200010){
        s[i+1] = s[i] + i;
    }

    reps(i,k,n+2){
        //cout << s[n+1]-s[n+1-i]<<" " << s[i]-1 << endl;
        //cout << (s[n+1]-s[n+1-i]) - (s[i]-1) << endl; 
        ans += ((s[n+1]-s[n+1-i]) - (s[i]-1));
        ans %= mod;
        //cout << i << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5196
s = input()
n = len(s)
s1 = s[:(n-1)//2]
s2 = s[(n+3)//2 - 1:]
_s1 = s1[::-1]
_s2 = s2[::-1]

# print(s1)
# print(s2)
# print(_s1)
# print(_s2)

if s == s[::-1] and s1 == _s1 and s2 == _s2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
N,M = map(int,input().split())
ac = (N+1)*[0]
wa = (N+1)*[0]
pt = 0
for i in range(M):
  p,s = input().split()
  p = int(p)
  if ac[p] == 0 and s == "AC":
    ac[p] = 1
    pt += wa[p]
  wa[p] += 1
print(sum(ac),pt)  


Measured memory_bytes: 10376
#include <iostream>
using namespace std;
int main(void){
    int H,W;
    
    while(1){
        cin>>H>>W;
        if(H==0 && W==0)break;
        for(int tate=0; tate<H; tate++){
            for(int yoko=0; yoko<W; yoko++){
                cout<<"#";
            }
            cout <<endl;
        }
        cout<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MAX_N = 1e5 + 10;
int N;
LL A[MAX_N],B[MAX_N],C[MAX_N];

bool isOK1(int mid, int key)
{
    if(C[mid] > key) return true;
    else return false;
}


bool isOK2(int mid, int key)
{
    if(B[mid] > key) return true;
    else return false;
}


int binary_search1(int key) {
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = N; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (abs(ng - ok) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK1(mid, key)) ok = mid;
        else ng = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return ok;
}

int binary_search2(int key) {
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = N; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (abs(ng - ok) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK2(mid, key)) ok = mid;
        else ng = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return ok;
}



int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    cin >> N;
    REP(i,N) cin >> A[i];
    REP(i,N) cin >> B[i];
    REP(i,N) cin >> C[i];

    sort(A, A + N);
    sort(B, B + N);
    sort(C, C + N);


    LL ans = 0;

    vector<LL> Bmemo(N);
    vector<LL> Bsum(N);

    for(int i = N - 1; i >= 0; i--)
    {
        dump(i)
        Bmemo[i] = N-1 - binary_search1(B[i]) + 1;
        dump(Bmemo[i])
        dump(B[i])
        dump(binary_search1(B[i]))
        Bsum[i] = (i == N - 1 ? 0 : Bsum[i+1]) + Bmemo[i];
        dump(Bsum[i])
    }
    REP(i,N)
    {
        ans += Bsum[binary_search2(A[i])];
    }
    cout << ans << endl;

}


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

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define int ll
#define endl "\n"
#define all( x ) x.begin(), x.end()
#define fast ios::sync_with_stdio(0);cin.tie(0);

typedef unsigned long long ull;

const int inf = 1e9 + 5;
const long double PI = 3.141592653589793;

void solve(){
  int n, k;
  cin >> n >> k;
  vector<int> h(n+1);
  for(int i = 1;i<n+1;i++){
    cin >> h[i];
  }
  vector<int> dp(n+1, inf);
  dp[0] = dp[1] = 0;
  for(int i = 1; i<n+1;i++){
    for(int d = 1; d <= k;d++){
      if(i - d > 0){
        dp[i] = min(dp[i], dp[i-d] + abs(h[i] - h[i - d]));
      }
      else{
        break;
      }
    }
  }
  cout << dp[n] <<endl;
  return;
}  
signed main(){
  fast;
  int t;
  t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}



Measured memory_bytes: 4756
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    let t: String = read();
    let ss: String = read();
    let mut t = t.chars().collect::<Vec<char>>();
    let ss = ss.chars().collect::<Vec<char>>();
    let n = t.len();
    let m = ss.len();
    for i in 0..n {
        if n < (i + m) {
            break;
        }
        let j = n - i - m;
        let mut ok = true;
        for k in 0..m {
            if t[j + k] != '?' && t[j + k] != ss[k] {
                ok = false;
                break;
            }
        }
        if ok {
            for k in 0..m {
                t[j + k] = ss[k];
            }
            for k in 0..n {
                if t[k] == '?' {
                    t[k] = 'a';
                }
            }
            let ans: String = t.into_iter().collect();
            println!("{}", ans);
            return;
        }
    }
    println!("UNRESTORABLE");
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = ReadInt();

            Console.WriteLine(3 * r * r);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
int A, B, C, D, ans, t;
void solve()
{
}
int gcd(int a, int b)
{
    while (1) {
        if (a < b)
            swap(a, b);
        if (!b)
            break;
        a %= b;
    }
    return a;
}


int lcm(int number1, int number2)
{
    return number1 * number2 / gcd(number1, number2);
}
signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> A >> B >> C >> D;
    int x;
    x = lcm(C, D);
    ans = B;
    ans -= (B / C) + (B / D) - (B / x);
    t = A - 1;
    t -= (A - 1) / C + (A - 1) / D - (A - 1) / x;
    ans -= t;
    cout << ans << endl;
    solve();
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Read, StdinLock};
#[allow(unused_imports)]
use std::io::prelude::*;
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::{HashSet, HashMap, BinaryHeap, VecDeque};
#[allow(unused_imports)]
use std::vec::Vec;

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;
#[allow(dead_code)]
const EPS: f64 = 1.0e-10;
#[allow(dead_code)]
const MOD: i32 = 1000_000_007;
#[allow(dead_code)]
const MODLL: i64 = 1000_000_007;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let out = stdout();
    let mut out = BufWriter::new(out.lock());

    let n: usize = sc.read();
    let mut cnt: Vec<i64> = vec![0; 5];
    fn conv(c: char) -> usize {
        match c {
            'M' => 0,
            'A' => 1,
            'R' => 2,
            'C' => 3,
            'H' => 4,
            _   => 10
        }
    };
    for _ in 0..n {
        let s: String = sc.read();
        let s: Vec<char> = s.chars().collect();
        let p = conv(s[0]);
        if p != 10 {
            cnt[p] += 1;
        }
    }

    let mut ans = 0;
    for s in 0u32..(1 << 5) {
        if s.count_ones() != 3 {
            continue;
        }
        let mut t = 1;
        for i in 0..5 {
            if s & (1 << i) > 0 {
                t *= cnt[i];
            }
        }
        ans += t;
    }
    writeln!(out, "{}", ans).unwrap();
}

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

using namespace std;

int main(){

  int N, C, K;
  cin >> N >> C >> K;
  
  int T[N];
  for (int i = 0; i< N; i++) {
    cin >> T[i];
  }
  sort(T, T + N);
  int bus_count = 0;
  int ninzu;
  
  int i = 0;
  while(i < N) {
    bus_count++;
    int bus_time = T[i] + K;
    int j = i;
    ninzu = 0;
    while (j < N && T[j] <= bus_time && ninzu < C) {
      j++;
      ninzu++;
    }
    i = j;
  }

  cout << bus_count << endl;
}

Measured memory_bytes: 640
K = int(input())
 
sevens = 7 % K
count = 1
 
while(sevens % K !=0):
  # 計算桁を減らすために(mod K)で7, 77, 777,,,を計算する
  sevens = sevens * (10 % K) + (7 % K)
  sevens = sevens % K
  
  count += 1
  if count > K:
    count = -1
    break
    
print(count)

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

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

signed main()
{
    vector<int> a(3); rep(i, 3) cin >> a[i];

    int num5 = 2;
    int num7 = 1;
    rep(i, 3) 
        if (a[i] == 5) --num5; else if (a[i] == 7) --num7;

    if (!num5 && !num7) puts("YES"); else puts("NO");

    return 0;
}


Measured memory_bytes: 256
n=input()
from sys import stdin,stdout
l=list(map(int,stdin.readline().split()))
l1=[0,abs(l[1]-l[0])]
for i in range(2,n):
    l1.append(min(abs(l[i-1]-l[i])+l1[-1],abs(l[i-2]-l[i])+l1[-2]))
stdout.write(str(l1[-1])+'\n')
    


Measured memory_bytes: 44848
import sys
input=sys.stdin.readline

class UnionFind():
    def __init__(self,n):
        self.n=n
        self.parents=[-1]*n

    def find(self,x): #根を見つける、繋ぎ直す
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    
    def unite(self,x,y): #x,yの含むグループを併合する
        x=self.find(x)
        y=self.find(y)

        if x==y:
            return
        
        if self.parents[x]>self.parents[y]:
            x,y=y,x

        self.parents[x]+=self.parents[y]
        self.parents[y]=x
    
    def same(self,x,y):#xとyが同じグループにいるか判定
        return self.find(x)==self.find(y)
    
    def members(self,x):#xと同じグループのメンバーを列挙
        root=self.find(x)
        return [i for i in range(self.n) if self.find(i)==root]
    
    def size(self,x):#xが属するグループのメンバーの数
        return -self.parents[self.find(x)]
    
    def roots(self):#ufの根を列挙
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):#グループの数を数える
        return len(self.roots())

    def all_group_members(self):#根:メンバの辞書を返す
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):#print()での表示用
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    n,m = map(int,input().split())
    p = [int(i)-1 for i in input().split()]
    dic = {i:idx for idx,i in enumerate(p)}   

    uf = UnionFind(n)
    for _ in range(m):
        x,y = map(int,input().split())
        x -= 1
        y -= 1
        uf.unite(x,y)
    
    cnt = 0
    for i in range(n):
        if uf.same(dic[i],i):
            cnt += 1
    
    print(cnt)  
  
if __name__=='__main__':
    main()


Measured memory_bytes: 20640
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Array.ConvertAll( Console.ReadLine().Split(' '),int.Parse);

            int ans = 0;

            for(int i = 0; i < input.Length; i++)
            {
                if(input[i] == 0)
                {
                    ans = i + 1;
                    break;
                }
            }

            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 27344
#include <stdio.h>
 
int main(){
  int A,B,C;
  scanf("%d %d %d",&A,&B,&C);
  if(A==B && B==C){
    printf("No\n");
  }else if(A==B || B==C || C==A){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}



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

int main(){
    int64_t N, A, B;
    cin >> N >> A >> B;
    vector<int64_t> X(N);
    for (int64_t i= 0;  i < N; i++){
        cin >> X.at(i);
    }
    int64_t exh = 0;
    for (int64_t i = 0;  i < N - 1; i++){
        int64_t d = X.at(i + 1) - X.at(i);
        exh += min(A * d, B);
    }
    cout << exh << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
 
int main()
{
   int k;
   cin>>k;
   string s;
   cin>>s;
   if(s.length()<=k){
      cout<<s<<endl;
   }
   else {
      s.erase(k,s.length()-k);
      s+="...";
      cout<<s<<endl;
   }
   return 0;
}

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

#define ull unsigned long long

#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}

int main(void) {
    long A, B;
    long count = 0;
    cin >> A >> B;
    for(long i = A;i <= B;i++) {
        long a, b, c, d, temp;
        temp = i;
        a = temp % 10;
        temp /= 10;
        b = temp % 10;
        temp /= 100;
        c = temp % 10;
        temp /= 10;
        d = temp % 10;
        if(a == d && b == c) count += 1;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n;
    int a;
    int min=11111111,max=-1111111;
    long long sum=0;
    scanf("%d",&n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d",&a);
        sum+=a;
        
        if(min>a){
            min=a;
        }
        
         if(max<a){
            max=a;
        }
    }
    printf("%d %d %lld\n",min,max,sum);
       
        
       
        
    return 0;
}


Measured memory_bytes: 2760
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	char a, b, c; cin >> a >> b >> c;
	int count = 0;
	if (a == 'o') count++;
	if (b == 'o') count++;
	if (c == 'o') count++;
	cout << (700 + count * 100) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
struct edge{int to;ll cap;int rev;};
int main(){
    ll n;
    cin>>n;
    ll ans = 0;
    rep(i,n-1) ans+= (i+1);
    cout<<ans<<endl;
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
    int n,cnt=0;string s;cin>>n>>s;
    for(int i=0;i<n-2;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
            cnt++;
        }
    }
    cout<<cnt<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N;
  cin >> N;
  cout << 180 * (N-2) << endl;
  return 0;
}


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

long long N;
string S;
int P;

long long solve() {
    if (P == 2 || P == 5) {
        long long res = 0;
        for (int i = 0; i < N; ++i) if ((S[N-i-1]-'0') % P == 0) res += N-i;
        return res;
    }
    vector<long long> val(P, 0);
    long long tenfactor = 1;
    long long cur = 0;
    val[cur]++;
    for (int i = 0; i < N; ++i) {
        cur = (cur + (S[N-i-1]-'0') * tenfactor) % P;
        tenfactor = (tenfactor * 10) % P;
        val[cur]++;
    }
    long long res = 0;
    for (int p = 0; p < P; ++p) res += val[p] * (val[p] - 1) / 2;
    return res;
}

int main() {
    cin >> S;
  
  	N=S.size();
    P=2019;
    cout << solve() << endl;
}

Measured memory_bytes: 3760
def ispalindrome(s):
    h = len(s)
    if (h % 2) == 0:
        h = int(h/2)
        for a, b in zip(s[:h], reversed(s[h:])):
            if a != b: return 0
    else:
        h = int(h/2)
        for a, b in zip(s[:h], reversed(s[h+1:])):
            if a != b: return 0
    return 1

str_in = input()
N = len(str_in)
result = ispalindrome(str_in)

if result == 0:
    print('No')
else:
    if N == 3:
        print('Yes')
    else:
        str_half = str_in[:int((N-1)/2)]
        result &= ispalindrome(str_half)

        if result == 0:
            print('No')
        else:
            str_half = str_in[int(((N+3)/2)-1):]
            result &= ispalindrome(str_half)

            if result == 0:
                print('No')
            else:
                print('Yes')


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

vector<ll> factorize(ll x) {
    vector<ll> res;
    for (ll i = 1; i * i <= x; ++i) {
        if (x % i == 0) {
            res.push_back(i);
            if (i * i != x) {
                res.push_back(x / i);
            }
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    vector<ll> divisors = factorize(M);
    ll ans = 0;
    for (auto& d : divisors) {
        if (M / d >= N) {
            chmax(ans, d);
        }
    }
    cout << ans << endl;
    return 0;
}

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

if K%2 != 0:
    # modK = 0となる1以上N以下のものの直積
    ans = (N//K)**3

else:
    # 上記に加えて、modK = K/2となるものの直積
    ans = (N//K)**3 + ((N-K//2)//K+1)**3
print(ans)


Measured memory_bytes: 2940