akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

from collections import Counter
from scipy.special import comb

n, m = list(map(int, input().split()))
mod = 10**9+7


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


c = Counter(prime_factorize(m))

ans = 1
for key, value in c.items():
    ans *= comb(value+n-1, value, exact=True) % mod
print(ans % mod)


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

int main() {
	ll n;
    cin >> n;
    ll ans = 0;
    for (ll a = 1; a < n; ++a) {
        ll b = (n-1) / a;
        ans += b;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on
void main()
{
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long[] A = new long[](cast(size_t)(N));
    foreach (i; 0 .. cast(size_t)(N))
    {
        A[i] = input.front.to!long;
        input.popFront;
    }

    solve(N, A);
}

void solve(long N, long[] A)
{
    auto dp = new long[long][](N + 1);
    dp[0][1000] = 0;
    foreach (i; 0 .. N)
    {
        foreach (key, val; dp[i])
        {
            dp[i + 1][key] = dp[i + 1].get(key, 0).max(val);
            dp[i + 1][key % A[i]] = dp[i + 1].get(key % A[i], 0).max(val + key / A[i]);
            dp[i + 1][key + val * A[i]] = dp[i + 1].get(key + val * A[i], 0).max(0);
        }
    }
    writeln(dp[N].keys.reduce!max);
}


Measured memory_bytes: 34592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n,k;
  cin>>n>>k;
  vector<int>d(k),b(n);
  vector<vector<int>>a(k,vector<int>(n));
  rep(i,k){
    cin>>d[i];
    rep(j,d[i]){
      cin>>a[i][j];
      a[i][j]--;
      b[a[i][j]]++;
    }
  }
  int ans=0;
  rep(i,n){
    if(b[i]==0)
      ans++;
  }
  cout<<ans<<endl;
}

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

using namespace std;

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  REP(i, n){
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a.begin(), a.end());
  int m = a[n - 1];
  REP(i, n){
    cout << (b[i] == m ? a[n - 2] : m) << endl;
  }
  return 0;
}

Measured memory_bytes: 3200
a = input()
if a[0] == 'A':
	cnum = 0
	location = 0
	for i in range(2, len(a) - 1):
		if a[i] == 'C':
			cnum += 1
			location = i
	if cnum == 1:
		if a[1:location] + a[location + 1:] == (a[1:location] + a[location + 1:]).lower():
			print ('AC')
		else:
			print ('WA')
	else:
		print('WA')
else:
	print('WA')

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_c() {
	ll n, k;
	ll ans = 0;

	cin >> n >> k;

	map<ll, ll> m;
	V a(n);
	rep(i, n) {
		cin >> a[i];
		m[a[i]]++;
	}

	V val;
	for (auto p : m) {
		val.push_back(p.second);
	}

	sort(ALL(val));

	rep(i, m.size() - k) {
		ans += val[i];
	}

	cout << ans << "\n";
}

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

	solve_abc_c();

	return 0;
}

Measured memory_bytes: 16500
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    int N,T;
    cin >> N >> T;
    vector <int> c(N);
    vector <int> t(N);

    for (int i = 0; i < N; i++){
        cin >> c.at(i) >> t.at(i);
    }

    int c_min = 10000;
    for (int i = 0; i < N; i++){
        if (t.at(i) <= T){
            c_min = min(c_min,c.at(i));
        }
    }

    if(c_min == 10000) cout << "TLE" << endl;
    else cout << c_min << endl;
}

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

int main() {

  int i, A=1, N, K;
  
  cin >> N >> K;
  
  for (i = 0; i < N; i++) {
    if (A * 2 >= A + K) {
      A += K;
    } else {
      A *= 2;
    }
  }
  
  cout << A << endl;
  

}

Measured memory_bytes: 256
N = int(input())
XL = [list(map(int, input().split())) for _ in range(N)]

LR = [[0] * 2 for _ in range(N)]

for i in range(N):
  LR[i][0] = XL[i][0] - XL[i][1]
  LR[i][1] = XL[i][0] + XL[i][1]

LR.sort()
ans = N
k = LR[0][1]
for i in range(1, N):
  l, r = LR[i]
  if l < k:
    ans -= 1
    k = min(k, r)
  else:
    k = r

print(ans)

Measured memory_bytes: 41364
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<vector>
#include<complex>
using namespace std;
#define int long long
// 2円の交点

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
const D EPS = 1e-9;    // 許容誤差。問題によって変える
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)
VP crosspointCC(P a, D ar, P b, D br) {
	VP ps;
	P ab = b - a;
	D d = abs(ab);
	D crL = (norm(ab) + ar*ar - br*br) / (2 * d);
	if (EQ(d, 0) || ar < abs(crL)) return ps;

	P abN = ab * P(0, sqrt(ar*ar - crL*crL) / d);
	P cp = a + crL / d * ab;
	ps.push_back(cp + abN);
	if (!EQ(norm(abN), 0)) ps.push_back(cp - abN);
	return ps;
}
signed main() {
	while (true) {
		int N;
		cin >> N;
		if (N == 0)break;
		vector<int> x(N);
		vector<int> y(N);
		vector<int> l(N);
		double ng = 300;
		for (int i = 0; i < N; i++) {
			cin >> x[i] >> y[i] >> l[i];
			ng = min(ng, (double)l[i]);
		}

		double ok = 0;
		double m;
		bool f;

		while (ng - ok > 1e-9) {
			m = (ng + ok)*0.5;
			vector<pair<P, D> >vp;
			for (int i = 0; i < N; i++) {
				vp.push_back(make_pair(P(x[i], y[i]), sqrt(l[i] * l[i] - m * m)));
			}
			vector<P> kouho;
			for (int i = 0; i < N; i++) {
				kouho.push_back(P(x[i], y[i]));
				for (int j = 0; j < i; j++) {
					VP t = crosspointCC(vp[i].first, vp[i].second, vp[j].first, vp[j].second);
					for (auto p : t) {
						kouho.push_back(p);
					}
				}
			}
			f = false;
			
			for (auto p : kouho) {
				bool tf = true;
				for (int i = 0; i < N; i++) {
					if (abs(p - vp[i].first) > vp[i].second + EPS) {
						tf = false;
					}
				}
				if (tf)f = true;
			}
			if (f) {
				ok = m;
			}
			else {
				ng = m;
			}
		}

		cout << fixed << setprecision(15) << ok << endl;
	}

}


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

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  int t = 0;
  int index[3];
  vector<string> vs;
  rep(i, 0, 3) {
    string s;
    cin >> s;
    s += "z";
    vs.pb(s);
    index[i] = 0;
  }
  while (1) {
    if (vs[t][index[t]] == 'a') {
      index[t]++;
      t = 0;
    }
    else if (vs[t][index[t]] == 'b') {
      index[t]++;
      t = 1;
    }
    else if (vs[t][index[t]] == 'c') {
      index[t]++;
      t = 2;
    }
    else if (vs[t][index[t]] == 'z') {
      cout << (char)('A'+t) << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
struct Rin{}
impl Rin{
    fn input(&self)->String{
        let mut x=String::new();
        std::io::stdin().read_line(&mut x).ok();
        x
    }
    fn inputs(&self)->String{
        let s=self.input().trim().to_string();
        s
    }
    fn inputn(&self)->i32{
        let n:i32=self.input().trim().parse().unwrap();
        n
    }
    fn inputvs(&self)->Vec<String>{
        let vs=self.input().trim().split(' ').map(|x|x.to_string()).collect();
        vs
    }
    fn inputvn(&self)->Vec<i32>{
        let vn=self.input().trim().split(' ').map(|x|x.to_string().parse().unwrap()).collect();
        vn
    }
}

fn main(){
    let rin=Rin{};
    let n=rin.inputs();
    let mut flag=false;
    for c in n.chars(){
        if c=='7'{
            println!("Yes");
            flag=true;
            break;
        }
    }
    if flag==false{
        println!("No");
    }
}

Measured memory_bytes: 2064
length = int(input())
smallest = sorted([int(n) for n in input().split(" ")])
normal = sorted([int(n) for n in input().split(" ")], reverse = True)
biggest = sorted([int(n) for n in input().split(" ")], reverse = True)
norm_vs_s = [0 for n in range(length)]
index = length - 1
for i, n in enumerate(smallest):
    if normal[0] < n:
        index = i
        break
for i in range(length):
    while index >= 0 and normal[i] <= smallest[index]:
        index -= 1
    norm_vs_s[i] = index + 1
answer = 0
sum_normal = sum(norm_vs_s)
index = 0
for i in range(length):
    while index < length and normal[index] >= biggest[i]:
        sum_normal -= norm_vs_s[index]
        index += 1
    answer += sum_normal
print(answer)


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

int main(void) {
  int A, B, C, X;
  cin >> A >> B >> C >> X;

  int counter = 0;
  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        int sum = 500 * i + 100 * j + 50 * k;
        if (sum == X) {
          counter++;
        }
      }
    }
  }

  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 256
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

X = int(input())
while True:
    if len(prime_factorize(X)) == 1:
        break
    X += 1
print(X)

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

const int MAX = 1e5 + 5;
const int INF = 1e8;

#define dbg(a) cout << "-> " << __LINE__ << ": " << #a << " = " << a << endl

int main() {
    int n, m;
	string s;
	cin >> n >> m >> s;
	vector<int> dp(n + 1, INF), next(n, -1);
	dp[n] = 0;
	set<pair<int, int>> st;
	st.emplace(0, n);
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] != '1') {
			dp[i] = min(dp[i], st.begin()->first + 1);
			next[i] = st.begin()->second;
		}
		if (i + m <= n) {
			st.erase({dp[i + m], i + m});
		}
		st.emplace(dp[i], i);
	}
	if (dp[0] == INF) {
		puts("-1");
	}
	else {
		int pos = 0;
		while (pos != n) {
			printf("%d ", next[pos] - pos);
			pos = next[pos];
		}
		puts("");
	}
    return 0;
}


Measured memory_bytes: 5632
use whiteread::parse_line;

fn main() {
    let (a, b, c): (u32, u32, u32) = parse_line().unwrap();
    let mut tmp = 0;
    let mut ans = "NO";

    for _ in 0..b {
        if tmp % b == c {
            ans = "YES";
            break;
        }
        tmp %= b;
        tmp += a;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
#define pb push_back
#define PI 3.14159265
int M = 998244353;
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int a[n];
  unordered_map<int, int> m;
  bool e = false;
  for (int i = 0; i < n; ++i)
  {
    cin >> a[i];
    m[a[i]]++;
  }
  int ans = n;
  for (int i = 0; i < n; ++i)
  {
    bool flag = false;
    if (m[a[i]] > 1)
    {
      ans--;
      continue;
    }
    for (int j = 1; j * j <= a[i]; ++j)
    {
      if (a[i] % j == 0)
      {
        int f = j;
        int s = a[i] / j;
        if (m[f] > 0 && f != a[i])
        {
          flag = true;
          break;
        }
        if (m[s] > 0 && s != a[i])
        {
          flag = true;
          break;
        }
      }
    }
    if (flag)
      ans--;
  }
  cout << ans;


}

Measured memory_bytes: 33260
#include <iostream>
using namespace std;
int main(void)
{
	int L,r,n,l,e;
	cin>>n>>l;
	L=l;
	r=l+n-1;
	if(r<=0) e=r;
	else if(L>=0) e=L;
	else e=0;
	cout<<(L+r)*n/2-e<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
int a,b,c,d;
scanf("%d %d %d %d",&a,&b,&c,&d);
a=a*b;
c=c*d;
if(a<=c){printf("%d\n",c);}
else{printf("%d\n",a);}
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
using namespace std;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;

int n;
int a[N];
ll cnt;
map<int,int> res;

int main() {
    ios::sync_with_stdio(false);
    cin>>n;
     for(int i=1;i<=n;++i){
         cin>>a[i];
         res[a[i]+i]++;
     }
     for(int i=1;i<=n;++i){
         cnt+=res[i-a[i]];
     }
     printf("%lld\n",cnt);

    return 0;
}

Measured memory_bytes: 21512
K = int(input())
A = [int(i) for i in input().split()]

N_min = 2
N_max = 2
for a in A[K::-1]:
	if N_min + (a - N_min) % a > N_max:
		print(-1)
		exit(0)
	else:
		# N_min -> smallest # that is # >= prev N_min and # % a == 0
		N_min += (a - N_min) % a
		# N_max -> smallest # that is # >= prev N_max and # % a == a-1
		N_max += (a - N_max - 1) % a
print(N_min, N_max)


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

int main() {
  int n;
  cin >> n;
  int ans=0-n;
  rep(i,n) {
    int x;
    cin >> x;
    ans+=x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define ALL(v) (v).begin(), (v).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
//cout << std::fixed << std::setprecision(15) << y << endl;

int main(){
    ll N;
    cin >> N;
    VL a(N);
    rep(i,0,N) cin >> a[i];
    
    ll ans = 0;
    ll ma = 0;
    rep(i,0,N){
        ma = max(ma, a[i]);
        if(a[i] < ma) ans += ma - a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4804
#include<iostream>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
	typedef long long ll;
	using namespace std;

	
	int main() {

		ll a, b, k;
		cin >> a;
		
		for (int i = a; i < 10000000; i++) {
			int hantei=0;
			for (int j = 2; j < i; ++j) {
				if (i % j == 0) {
					hantei = 1;
				}
			}
			if (i >= a&&hantei==0) {
				cout << i;
				break;
			}
		}
		
	}
	
	

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

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v,n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vlint(v,n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v,n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v,n1,n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v,n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()

static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long int MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);

static const int dy4[]={0, 0, 1, -1};
static const int dx4[]={1, -1, 0, 0};
static const int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
static const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};



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

  	int N, M;
    cin>>N>>M;

  	int a[100][100]={},b[100][100]={};

    REP(i, N)REP(j, N) if(i!=j)b[i][j]=1<<28;
  	REP(i, M)
  	{
  		int u,v,c;
  		std::cin>>u>>v>>c;u--,v--;
  		a[u][v]=a[v][u]=b[u][v]=b[v][u]=c;
  	}
  	REP(k, N)REP(i, N)REP(j, N) b[i][j]=std::min(b[i][j],b[i][k]+b[k][j]);
  	int c=0;
  	REP(i, N)REPS(j, i+1, N)if(a[i][j]>b[i][j])c++;
  	std::cout<<c<<endl;

}


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

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<long long> q;
    for (int i = 0; i < n; ++i) {
        long long a;
        cin >> a;
        q.push(a);
    }

    for (int i = 0; i < m; ++i) {
        long long a = q.top();
        q.pop();
        q.push(a/2);
    }
    long long ans = 0;
    while (!q.empty()) {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
    return 0;
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

const int dif = 100;
struct zahyo
{
    int x;
    int y;
    int turn;
};


int board[200][200];
queue<zahyo> points;


void point_process(int x, int y, int turn){
    if(board[x][y]==0){
        board[x][y]=1;
        points.push({x+1,y,turn+1});
        points.push({x+1,y+1,turn+1});
        points.push({x,y+1,turn+1});
        points.push({x,y-1,turn+1});
        points.push({x-1,y,turn+1});
        points.push({x-1,y-1,turn+1});
    }
}

int main(){
    while(1){
        int turn,n,x,y;
        cin >> turn >> n;
        if(turn==0)break;
        
        //初期化
        REP(i,0,200) REP(j,0,200) board[i][j]=0;
        queue<zahyo>().swap(points);

        //障害物を2に設定
        REP(i,0,n){
            cin >> x >> y;
            //P2(x,y);
            board[x+dif][y+dif]=2;
        }
        

        cin >> x >> y;
        //P("start");
        //P2(x,y);
        points.push({x+dif,y+dif,0});

        while(!points.empty()){
            if(points.front().turn>turn)break;
            point_process(points.front().x, points.front().y, points.front().turn);
            points.pop();
        }
        /**
        REP(i,0,61){
            REP(j,0,61){
                cout << board[i][j];
            }
            cout << endl;
        }
        cout << endl;
        **/
        
        int ans=0;
        REP(i,0,200) REP(j,0,200) if(board[i][j]==1)ans++;
        cout << ans << endl;
        
    }
}


Measured memory_bytes: 3256
#include <algorithm>
#include <iostream>
#include <iterator>
#include <string>
#include <vector>
double compute(std::vector<double> inpvec)
{
    if (inpvec.size() == 1) { return inpvec[0]; }
    else
    {
        for (int i = 0; i < inpvec.size() - 1; i++) { inpvec[i + 1] = (inpvec[i] + inpvec[i + 1]) / 2.0; }
        return inpvec[inpvec.size() - 1];
    }
}

int main()
{
    int N;
    std::cin >> N;
    std::vector<double> vec;
    double v, ans = 0.0;
    for (int i = 0; i < N; i++)
    {
        std::cin >> v;
        vec.push_back(v);
    }
    std::sort(vec.begin(), vec.end());
    ans = compute(vec);

    std::cout << ans << std::endl;

    return 0;
}

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

struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

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

  ll n;
  cin >> n;
  string s;
  cin >> s;

  map<char, ll> mp;
  for (int i = 0; i < n; i++) {
    mp[s[i]]++;
  }

  mint ans = mint(1);
  for (auto m : mp) {
    ll cnt = m.second;

    ans *= mint(cnt + 1);
  }

  cout << ans.x - 1 << ln;

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
int main(){
    int n;
    cin>>n;
    ll a=0,b=0,ab=0;
    ll ans=0;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        for(int j=1;j<s.size();j++){
            if(s.at(j-1)=='A'&&s.at(j)=='B')ans++;
        }
        if(s.at(s.size()-1)=='A'&&s.at(0)=='B')ab++;
        else if(s.at(0)=='B')b++;
        else if(s.at(s.size()-1)=='A')a++;
    }
if(ab==0)ans+=min(a,b);
else if(a+b>0)ans+=ab+min(a,b);
else ans+=ab-1;
    cout<<ans<<endl;
}

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

int main(){
  int N, C;
  cin >> N >> C;
  if (N == 1){
    cout << 0 << endl;
    return 0;
  }
  vector<vector<int> > D(C, vector<int>(C));
  for (int i=0; i<C; i++){
    for (int j=0; j<C; j++) cin >> D[i][j];
  }
  vector<int> res0;
  vector<int> res1;
  vector<int> res2;
  for (int i=1; i<N+1; i++){
    for (int j=1; j<N+1; j++){
      int c;
      cin >> c;
      if ((i+j)%3 == 0) res0.push_back(c);
      else if ((i+j)%3 == 1) res1.push_back(c);
      else res2.push_back(c);
    }
  }
  vector<int> score0(C);
  vector<int> score1(C);
  vector<int> score2(C);
  for (int i=0; i<C; i++){
    int score = 0;
    for (int x: res0) score += D[x-1][i];
    score0[i] = score;
  }
  for (int i=0; i<C; i++){
    int score = 0;
    for (int x: res1) score += D[x-1][i];
    score1[i] = score;
  }
  for (int i=0; i<C; i++){
    int score = 0;
    for (int x: res2) score += D[x-1][i];
    score2[i] = score;
  }
  int ans = 1000000000;
  for (int i=0; i<C; i++){
    for (int j=0; j<C; j++){
      for (int k=0; k<C; k++){
        if ((i==j) || (j==k) || (k==i)) continue;
        else ans = min(ans, score0[i] + score1[j] + score2[k]);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1524
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(void) {
  vector<vector<int>> a(3, vector<int>(3));
  fr(i, 3) fr(j, 3) cin >> a[i][j];

  vector<int> v(101, 0);
  int b, n;
  cin >> n;
  fr(i, n) cin>>b, v[b]++;
  
  bool can = false;
  
  fr(i, 3) if(v[a[i][0]]+v[a[i][1]]+v[a[i][2]]==3) can = true; 
  fr(i, 3) if(v[a[0][i]]+v[a[1][i]]+v[a[2][i]]==3) can = true;
  if(v[a[0][0]]+v[a[1][1]]+v[a[2][2]]==3) can = true; 
  if(v[a[0][2]]+v[a[1][1]]+v[a[2][0]]==3) can = true; 
  
  
  cout << (can ? "Yes" : "No") << endl;
  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int

using namespace __gnu_pbds;

typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;


#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
#define mod 1000000007
/* Precode Start Here *\


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);

 ll a=0,b=0;
 string s;
 cin>>s;
 for(int i=0;i<s.size();i++)
 {
     if(s[i]=='A')
        a++;
     else
        b++;
 }
 if(a>0&&b>0)
 {
     cout<<"Yes"<<endl;
 }
 else
    cout<<"No"<<endl;

return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int main(){
    int N;
    string s;
    cin >> s;
    N = s.size();
    if(s[N-1] == 's') {
	cout << s + "es" << endl;
    }
    else cout << s+"s" << endl;
    
    
    return 0;
}



Measured memory_bytes: 3632
N_ko, M_hon = map(int, input().split())
Height = list(map(int, input().split()))

Low = []
ans = 0

for i in range(M_hon):
    a, b = map(int, input().split())
    
    h_a = Height[a - 1]
    h_b = Height[b - 1]

    
    if (h_a != h_b):
        
        if (h_a > h_b):
            Low.append(b)
        else:
            Low.append(a)
    else:
        Low.append(a)
        Low.append(b)

ans = N_ko - len(set(Low))


print(ans)

Measured memory_bytes: 19976
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ar array
const int mxn=1e5+3,INF=1e18;
int n,m;
vector<int> g[mxn];
int vis[mxn][3];
int s,t;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for (int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
       // g[v].push_back(u);
    }
    cin>>s>>t;
   // for (int i=1;i<=n;i++) vis[i][0]=vis[i][1]=vis[i][2]=-1;
    queue<ar<int,2>> q;
    q.push({s,0});
    vis[s][0]=0;
    while(!q.empty())
    {
        int u=q.front()[0],time=q.front()[1];
        q.pop();
        for (int v : g[u])
        if (!vis[v][(time+1)%3])
        {
            vis[v][(time+1)%3]=vis[u][time]+1;
            q.push({v,(time+1)%3});
        }
    }
    if (vis[t][0]) cout<<vis[t][0]/3;
    else cout<<-1;
}


Measured memory_bytes: 11440
int main(){
 int n; int d, min, max; long long sum; scanf("%d%d", &n, &d); sum = min = max = d; while (--n > 0) { scanf("%d", &d); if (d < min) min = d; if (d > max) max = d; sum += d; } printf("%d %d %lld\n", min, max, sum); return 0; } 


Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    String s = sc.next();
    int cnt = 0;
    int os = 0;

    for (int i = 0; i < n; i++) {
      if (s.charAt(i) == 'a') {
        if (cnt < a + b) {
          System.out.println("Yes");
          cnt++;
        } else {
          System.out.println("No");
        }
      } else if (s.charAt(i) == 'b') {
        os++;
        if (cnt < a + b && os <= b) {
          System.out.println("Yes");
          cnt++;
        } else {
          System.out.println("No");
        }
      } else {
        System.out.println("No");
      }
    }

  }
}

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

int main(){
    ll mod = 1e9+7;
    string s;
    cin >> s;
    reverse(s.begin(), s.end());

    vector<vector<ll>> cnt(s.size(), vector<ll>(13, 0));

    if(s[0] == '?'){
        rep(i, 0, 10) cnt[0][i] = 1;
    }else{
        cnt[0][(ll)(s[0]-'0')] = 1;
    }
    
    vector<vector<ll>> l(s.size(), vector<ll>(10, 0));
    rep(i, 0, 10) l[0][i] = i;
    rep(i, 1, s.size()){
        rep(j, 0, 10){
            l[i][j] = (10*l[i-1][j])%13;
        }
    }

    rep(i, 1, s.size()){
        if(s[i] == '?'){
            for(auto j : l[i]){
                rep(k, 0, 13){
                    cnt[i][(j+k)%13] += cnt[i-1][k];
                    cnt[i][(j+k)%13] %= mod; 
                }    
            }
        }else{
            rep(j, 0, 13){
                cnt[i][(j+l[i][(ll)(s[i]-'0')])%13] += cnt[i-1][j];
                cnt[i][(j+l[i][(ll)(s[i]-'0')])%13] %= mod; 
            }
        }
    }
    
    cout << cnt[s.size()-1][5] << endl;
    return 0;
}

Measured memory_bytes: 25344
def f_e_dp():
    n = int(input())
    s = input()
    dp = [[0]*(n+1) for _ in range(n+1)]
    for i in reversed(range(n)):
        for j in reversed(range(n)):
            if s[i]==s[j] and i<j:
                dp[i][j] = dp[i+1][j+1]+1
    a = 0
    for i in range(n):
        for j in range(n):
            if i<j:
                a = max(a, min(j-i, dp[i][j]))
    print(a)

if __name__ == "__main__":
    f_e_dp()

Measured memory_bytes: 230280
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n, _ := nextInt(), nextInt()
	s := make([]string, n)
	res := ""

	for i := 0; i < n; i++ {
		s[i] = next()
	}

	sort.Strings(s)

	for i := 0; i < n; i++ {
		res += s[i]
	}

	fmt.Println(res)
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pint;
typedef map<int,int> mint;
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int inf=1e9+100;
ll infi =1e18+100;

int N;
ll a[200100];

int main() {
	cin>>N;
	if(N%2==0){
		rep(i,N){
			if(i%2==0){
				cin>>a[N/2+1-i/2];
			}
			else{
				cin>>a[N/2+(i+1)/2];
			}
		}
		rep(i,N-1) cout<<a[i]<<" ";
		cout<<a[N]<<endl;
	}
	else{
		rep(i,N){
			if(i%2==0){
				cin>>a[(N+1)/2+(i/2)];
			}
			else{
				cin>>a[(N+1)/2-(i-1)/2];
			}
		}
		rep(i,N-1) cout<<a[i]<<" ";
		cout<<a[N]<<endl;
	}

	return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int a[55],b[55],c[55],d[55];
int t[11];
int n,m,q;
int ans;
void dfs(int len,int now)
{
	t[len]=now;
	if(len==n)
	{
		int res=0;
		rep(i,q)
			if(t[b[i]]-t[a[i]]==c[i])res+=d[i];
		ans=max(ans,res);
		return;
	}
	forn(i,now,m)dfs(len+1,i);
}
int main()
{
	ios::sync_with_stdio(0);
	cin>>n>>m>>q;
	rep(i,q)cin>>a[i]>>b[i]>>c[i]>>d[i];
	forn(i,1,n)dfs(1,i);
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
ll N;
l_l a[105];

l_l f(string s) {
    ll delta = 0;
    ll minimum = 0;
    for(auto c : s) {
        if(c == '(') delta++;
        else delta--;
        chmin(minimum, delta);
    }
    return {delta, minimum};
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    vector<l_l> one, two;
    for(int i = 0; i < N; i++) {
        string s;
        cin >> s;
        l_l now = f(s);
        if(now.first >= 0) {
            one.push_back({-now.second, now.first});
        } else {
            two.push_back({now.second - now.first, now.first});
        }
    }
    sort(one.begin(), one.end());
    sort(two.begin(), two.end());
    ll now = 0;
    bool ok = true;
    for(auto tmp : one) {
        //cerr << -tmp.first << " " << tmp.second << endl;
        if(now < tmp.first) ok = false;
        now += tmp.second;
    }
    for(auto tmp : two) {
        //cerr << tmp.first << " " << tmp.second << endl;
        if(now < -tmp.first - tmp.second) ok = false;
        now += tmp.second;
    }
    if(now != 0) ok = false;
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3240
import re

S = input()
ct = 0

na = 0
bf = False
ct = 0
for s in S:
  if s =='A':
    if bf==True:
      na = 1
    else:
      na += 1
    bf = False
      
  if s == 'B':
    if na > 0 and bf==False:
      bf = True
    else:
      na = 0
      bf = False
  if s == 'C':
    if bf:
      ct += na
    else:
      na = 0
    bf = False
print(ct)

Measured memory_bytes: 3628
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main() {
    int N;
    cin >> N;
    vector<int> ais;
    vector<int> bis;
    for (int i = 0; i < N; i++) {
        int ai;
        cin >> ai;
        ais.push_back(ai);
    }
    for (int i = 0; i < N; i++) {
        int bi;
        cin >> bi;
        bis.push_back(bi);
    }
    ll bound_sum = 0;
    for (int i = 0; i < N; i++) {
        ll xi = bis[i]-ais[i];
        ll bound = max(-xi, (ll)ceil((double)xi/(double)2.0)-xi);
        bound_sum += bound;
    }
    if (bound_sum > 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    int K;
    cin >> K;
    ll ans = 0;
    for (int i = 1; i <= K; i++)
        for (int j = 1; j <= K; j++)
            for (int k = 1; k <= K; k++) ans += gcd(i, gcd(j, k));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

int main() {
   Int n;
   std::cin >> n;
   std::vector<Int> xs(n);
   rep(i,n) std::cin >> xs[i];
   std::sort(xs.begin(), xs.end());
   xs.erase(std::unique(xs.begin(), xs.end()), xs.end());
   printf("%lu\n", xs.size());
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * ABC111B
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        for (int i = 1; i <= 9; i++) {
            if ((N / (i * 111) == 1 && N % (i * 111) == 0) || (N / (i * 111) == 0)) {
                System.out.println(i * 111);
                break;
            }
        }

        sc.close();
    }
}

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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int main(){
	int n, d;
	string s, t;
	cin >> n >> s >> d;
	t = s;
	rep(i, n) if(s[i] == '0' && d) t[i] = '1', d--;
	for(int i = n - 1; i >= 0; i--) if(s[i] == '1' && t[i] == '1' && d) t[i] = '0', d--;
	cout << t << endl;
	
	return 0;
}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (auto &x : a) {
		cin >> x;
	}

	int x = 0;
	for (int i = 0; i < N; ++i) {
		if (a[i] == x + 1) {
			++x;
		}
	}
	if (x == 0) {
		cout << -1 << endl;
	}
	else {
		cout << N - x << endl;
	}
}


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

import sys
sys.setrecursionlimit(300000)

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(A: int, B: int, C: int, D: int):
    while True:
        C -= B
        if C <= 0:
            ret = YES
            break
        A -= D
        if A <= 0:
            ret = NO
            break
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(A, B, C, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61912
#include <stdio.h>

int main(void)
{
	int n, a, b;
	
	scanf("%d %d %d", &n, &a, &b);
	
	if(n * a <= b){
		printf("%d", n * a);	
	}
	else{
		printf("%d", b);
	}
	
	return 0;
}


Measured memory_bytes: 128
a = list(map(int,input().split()))
a.sort()
count= 0

if a[2] != a[1] and a[1] != a[0] and a[2] != a[0]:
  sum = a[2]-a[1]
  for i in range(a[2]-a[1]):
    a[1] += 1
    a[0] += 1  
  for i in range(10**12):
    a[0] += 2
    count += 1
    if a[0] >= a[1]:
      break
      
  if a[0] == a[1]:
    print(sum + count)
  elif a[0] > a[1]:
    print(sum + count + 1)

elif a[2] == a[1] and a[1] != a[0]:
  for i in range(10**4):
    a[0] += 2
    count += 1
    if a[0] >= a[1]:
      break
  
  if a[0] == a[1]:
    print(count)
  elif a[0] > a[1]:
    print(count + 1)
    
elif a[0] == a[1] and a[1] != a[2]:
  print(a[2]-a[1])
  
elif a[1] == a[2] and a[2] == a[0]:
  print(0)
  

Measured memory_bytes: 3064
N,M = map(int,input().split())
num = []
for i in range(N):
    a,b = map(int,input().split())
    li = [a,b]
    num.append(li)
num.sort()
yen = 0
for i in range(N):
    if num[i][1] < M:
        yen += (num[i][0] * num[i][1])
        M -= num[i][1]
    else:
        yen += num[i][0] * M
        break
print(yen)

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

using ll = long long;
using Pi = pair < int, int >;

constexpr int mod = 1000000007;
constexpr int INF = (1 << 30) - 1;
constexpr int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
constexpr int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

template < typename T > T gcd(T a, T b) { return ( b ? gcd(b, a % b) : a ); }
template < typename T > T lcm(T a, T b) { return ( a / gcd(a, b) * b ); }

int main()
{
	int N;
	int cnt[256];

	string S;
	cin >> N >> S;
	
	fill_n(cnt, 256, 1);

	for ( int i = 0; i < N; i++ ) cnt[S[i]]++;

	ll ans = 1;

	for ( int i = 0; i < 256; i++ ) {
		(ans *= cnt[i]) %= mod;
	}

	cout << (ans + mod - 1) % mod << endl;

	return ( 0 );
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin>>N;
	int anser=N;
	vector<int> vea(N);
	vector<int> veb(N);
	for(int i=0; i<N; i++){
		cin>>vea.at(i)>>veb.at(i);
	}
	for(int i=0; i<N; i++){
		anser+=(veb.at(i)-vea.at(i));
	}
	cout<<anser<<endl;
}


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

void solveA(){
  int x;
  cin >> x;

  if(x==7 || (x==5 || x==3)) cout << "YES" << endl;
  else cout << "NO" << endl;
}
void solveB(){
  string s;
  cin >> s;
  int ans = 1000;
  for(int i=0;i<s.size()-2;i++){
    int n = (s[i]-'0')*100 + (s[i+1]-'0')*10 + s[i+2]-'0';
    ans = min(ans,abs(n-753));
  }
  cout << ans << endl;
  
}
void solveC(){
  
}
void solveD(){
  
}

int main(){
  solveB();
}

Measured memory_bytes: 256
N,M = list(map(int,input().split()))
ab = [list(map(int,input().split())) for _ in range(M)]
ab.sort(key = lambda x: (x[1],x[0]))
ans = 0
m = 0
for a,b in ab:
    if a<m:
        continue
    ans += 1
    m = b
print(ans)

Measured memory_bytes: 35476
#pragma GCC optimize ("Ofast")
#pragma GCC target(*sse4.2*)
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define PB push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define vvii vector<vii>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define read(x) long long x;cin>>x;
#define FOR(a,b,c,d) for(int a=b;a<=c;a+=d)
#define MP make_pair
#define F first
#define S second
#define debug(x) cout<<("#x)<<": "<<(x)<<"\n"
#define SZ(x) x.size()
#define mod 1000000007
#define lg2(x) 63-(__builtin_ctzll(x))
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
typedef unsigned long long ull;
typedef long double d64;


int main(){
fast
read(k);
string s;
cin>>s;
if(k<s.size()){
    for(int i=0;i<k;i++){
    cout<<s[i];}cout<<"...";
}
else cout<<s;



return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

typedef long long ll;
const int MAX_N = 3010;
const int MAX_T = 3010;

void chmax(int &a, int b){ if( a < b){ swap(a,b);} return ;}

int dp[MAX_N][MAX_T];
pair<int,int> AB[MAX_N];

int main(){
  int n,T; scanf("%d %d", &n, &T);
  
  for(int i = 0 ; i < n; i++){
    scanf("%d %d", &AB[i].first, &AB[i].second);
  }
  
  sort(AB,AB+n); //調理時間が短い順にソートする
  
  for(int i = 0; i < n; i++){ fill(dp[i],dp[i]+MAX_T,-1);}
  // -1は未更新
  
  dp[0][0] = 0;
  
  for(int i = 0; i < n; i++){
    for(int t = 0; t < MAX_T; t++){
      
      if(dp[i][t] == -1){ continue;} //未更新から飛ばす必要はない
      
      chmax(dp[i+1][t],dp[i][t]);
      
      if( t+AB[i].first <= T){
        chmax( dp[i+1][t+AB[i].first], dp[i][t]+AB[i].second);
      }
    }
  }
  
  for(int i = 0; i < n; i++){
    for(int j = 0; j < T; j++){
     chmax(dp[i][j+1],dp[i][j]);
    }
  }
  
  int ans = 0;
  
  for(int i = 0; i < n; i++){ chmax(ans, dp[i][T-1]+AB[i].second);}
  
  printf("%d\n", ans); 
  
  return 0;
}
  
      

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
const int mod=1e9+7;
int a[maxn];
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        a[s[i]-'a']++;
    }
    ll ans=1;
    for(int i=0;i<26;i++)
        ans=(ans*(a[i]+1))%mod;
    ans=(ans-1)%mod;
    cout<<ans<<"\n";
}


Measured memory_bytes: 512
#include <stdio.h>
int main(){
	int k,s=1000,a,i,j;
	scanf("%d",&k);
	for(i=0;i<k;i++)
	{
		scanf ("%d",&a);
		for(j=0;j<1000;j++){
		if(a%2==0){
			a=a/2;
		}
		else{
		if(s>j){
			s=j;
			break;
		}	
		}	
		}
	}
	printf ("%d",s);
	return 0;
	}

Measured memory_bytes: 128