akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

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

#define move(s) s += "#"

#define fr(i, a, b) for (ll i = a; i <= b; ++ i)
#define rf(i, a, b) for (ll i = a; i >= b; -- i)

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int main () {
    to_pray();

    string s;
    cin >> s;
    
    for (int i = 0; i < sz(s) - 1; ++ i)
    	if (s[i] == s[i + 1])
    		return cout << "Bad", 0;
    
    cout << "Good";
    
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;


int main() {
    int N;
    int res=0;
    cin >> N;
    for (int a = 1; a <= N; a++) {
        for (int b = 1; b <= N / a; b++) {
            if (N - a * b >= 1) res++;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3672
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

struct RollingHash {
    ll base[2];
    ll mod[2];
    vector<ll> h[2];
    vector<ll> pow[2];

    void init(const string &s) {
        int n = s.size();

        base[0] = 1009;
        base[1] = 1007;
        mod[0] = 1000000007;
        mod[1] = 1000000009;

        h[0].reserve(n+1);
        h[1].reserve(n+1);
        pow[0].reserve(n+1);
        pow[1].reserve(n+1);
        h[0][0] = h[1][0] = 0;
        pow[0][0] = pow[1][0] = 1;
        for(int k=0;k<2;k++) {
            for(int i=0;i<n;i++) {
                pow[k][i+1] = pow[k][i]*base[k]%mod[k];
                h[k][i+1] = (h[k][i]*base[k]+s[i])%mod[k];
            }
        }
    }

    RollingHash(const string &s) {
        init(s);
    }
    RollingHash() {}

    pair<ll,ll> hash(int l,int r) {
        ll hash1 = ((h[0][r]-h[0][l]*pow[0][r-l])%mod[0]+mod[0])%mod[0];
        ll hash2 = ((h[1][r]-h[1][l]*pow[1][r-l])%mod[1]+mod[1])%mod[1];
        return make_pair(hash1, hash2);
    }

};
int n,m;
string s;
set<pair<ll,ll> > S;

int main() {
    int r=1,l=0;
    cin>>n>>m;
    cin>>s;

    RollingHash rh(s);

    rep(i,m) {
        string q;
        cin>>q;
        if(q=="R++") r++;
        if(q=="R--") r--;
        if(q=="L++") l++;
        if(q=="L--") l--;

        S.insert(rh.hash(l,r));
    }
    cout<<S.size()<<endl;

    return 0;
}

Measured memory_bytes: 29528
#include <iostream>
#include <algorithm>
#define ll long long

using namespace std;

const int NMAX = 100005;
ll h[NMAX], nxt[NMAX], sum[NMAX];
ll poz, n;

void fct(int m) {
    int ok = 0;
    for(int i = 1; i <= 2 && i + m <= n; i++) {
        if((abs(h[m + i] - h[m]) + sum[m + i] <= abs(h[nxt[m]] - h[m]) + sum[nxt[m]]) || !ok) {
            ok = 1;
            nxt[m] = m + i;
            sum[m] = sum[m + i] + abs(h[m + i] - h[m]);
        }
    }
}

int main()
{
    int i;
    cin >> n;
    for(i = 1; i <= n; i++) {
        cin >> h[i];
    }
    sum[n] = 0; nxt[n] = 0;
    for(i = n - 1; i >= 1; i--) {
        fct(i);
    }
    cout << sum[1];
    return 0;
}


Measured memory_bytes: 5944
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int r;
    cin >> r;
    cout << r*r << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
using namespace std;
#define EPS  (1e-10)
#define equals(a,b) (fabs((a) - (b)) < EPS)

// 点类
class Point {
public :
	double x, y;
	Point() {};
	Point(double x, double y) :x(x), y(y) {}

	Point operator + (Point p) { return Point(x + p.x, y + p.y); }
	Point operator - (Point p) { return Point(x - p.x, y - p.y); }
	Point operator * (double a) { return Point(x * a, y * a); }
	Point operator / (double a) { return Point(x / a, y / a); }
	
	bool operator < (const Point &p) const {
		return x != p.x ? x < p.x : y < p.y;
	}

	bool operator == (const Point &p) const {
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}
};
// 线段类
class Segment {
public:
	Point p1, p2;
	Segment() {};
	Segment(Point p1, Point p2) :p1(p1), p2(p2) {};
};

#define BOTTOM 0
#define LEFT 1
#define RIGHT 2
#define TOP 3

class EndPoint {
public :
	Point p;
	int seg, st; // 线段的ID，端点的种类
	EndPoint() {}
	EndPoint(Point p, int seg, int st) :p(p), seg(seg), st(st) {}

	bool operator < (const EndPoint &ep) const {
		// 按y坐标升序排序
		if (p.y == ep.p.y) {
			return st < ep.st;
		}else {
			return p.y < ep.p.y;
		}
	}

};
EndPoint EP[2 * 1000010];

// 线段相交问题，曼哈顿几何
int manhattanIntersection(vector<Segment> S) {
	int n = S.size();
	//按照端点的y坐标升序排序
	sort(EP, EP + (2 * n));

	set<int> BT;			// 二叉搜索树
	BT.insert(10000000001); // 设置标记
	int cnt = 0;

	for (int i = 0; i < 2 * n; i++) {
		if (EP[i].st == TOP)
			BT.erase(EP[i].p.x); //删除上端点
		else if (EP[i].st == BOTTOM)
			BT.insert(EP[i].p.x);
		else if (EP[i].st == LEFT) {
			set<int>::iterator b = BT.lower_bound(S[EP[i].seg].p1.x);
			set<int>::iterator e = BT.upper_bound(S[EP[i].seg].p2.x);

			// 加上b到e距离
			cnt += distance(b, e);
		}

	}
	return cnt;
}
int main() {
	vector<Segment> S;
	Segment seg;
	int n , k = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf %lf %lf %lf", &seg.p1.x, &seg.p1.y, &seg.p2.x, &seg.p2.y);
		//调整端点p1、p2，保证左小右大
		if (seg.p1.y == seg.p2.y) {
			if (seg.p1.x > seg.p2.x)
				swap(seg.p1, seg.p2);
		}
		else if (seg.p1.y > seg.p2.y) {
			swap(seg.p1, seg.p2);
		}

		// 将水平线段添加到端点列表
		if (seg.p1.y == seg.p2.y) {
			EP[k++] = EndPoint(seg.p1, i, LEFT);
			EP[k++] = EndPoint(seg.p2, i, RIGHT);
		}
		else { // 将垂直线段添加到端点列表
			EP[k++] = EndPoint(seg.p1, i, BOTTOM);
			EP[k++] = EndPoint(seg.p2, i, TOP);
		}
		S.push_back(seg);
	}

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


Measured memory_bytes: 16396
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = Integer.parseInt(sc.next());
    int s = Integer.parseInt(sc.next());
    int count = 0;
    for (int i = 0; i <= k; i++){
      for(int j = 0; j <= k; j++){
          if((s-i-j) <= k && (s-i-j)>=0){
            count++;
        }
      }
    }
    System.out.println(count);
  }
}

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

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 101010
#define DEBUG_OUT true

#define ALL(x) (x).begin(), (x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int h,w;
  cin>>h>>w;

  vector<vector<int> >  a (h,vector<int>(w,0));
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
       cin>>a[i][j];
    }
  }

  vector<vector<int> >  b (h,vector<int>(w,0));
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
       cin>>b[i][j];
    }
  }
  int max_k = 160*80;
  vector<vector<vector<int> > > dp (81,vector<vector<int> >(81,vector<int>(max_k+1,0)));
  dp[0][1][0] = 1;
  dp[1][0][0] = 1;
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      for (int k = 0; k < max_k + 1; k++)
      {
        int d = abs(a[i][j] - b[i][j]);
        if(k + d <= max_k)dp[i+1][j+1][k+d] |= dp[i+1][j][k];
        if(abs(k-d) <= max_k)dp[i+1][j+1][abs(k-d)] |= dp[i+1][j][k];
        if(k + d <= max_k)dp[i+1][j+1][k+d] |= dp[i][j+1][k];
        if(abs(k-d) <= max_k)dp[i+1][j+1][abs(k-d)] |= dp[i][j+1][k];
      }
      
    }


  }
    
    int res = INF;
    for (int k = 0; k < max_k+1; k++)
    {
      if(dp[h][w][k])
      chmin(res,k);
    }
    cout<<res<<endl;
    
    
  return;
}


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

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

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

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

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

int main() {
	int n;cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++){
		if(i<10) {ans++;continue;}
		int d;
		if(i<100) d=2;
		else if(i<1000) d=3;
		else if(i<10000) d=4;
		else if(i<100000) d=5;
		else d=6;
		int r=i%10;
		if(r==0) continue;
		int l=i/pow(10,d-1);
		int e[]={0,0,2,22,222,2222,22222};
		int f[]={0,0,0,4,24,224,2224};
	//	if(r==l) ans+=d*2-1;
		if(l==r){
			if(d==2) ans+=3;
			else{
				int c=(i-l*pow(10,d-1))/10;
				ans+=f[d]+2*c+1;
//				cout<<i<<' '<<l<<' '<<c<<' '<<r<<endl;
			}
		}
		else if(l>r) ans+=e[d];
		else ans+=e[d-1];
//		cout<<i<<' '<<ans<<' '<<l<<' '<<r<<endl;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
A=int(input())
B=int(input())
C=int(input())
X=int(input())
cnt=0

for i in range(A + 1):
  for j in range(B + 1):
    for k in range(C + 1):
      if (500*i + 100*j + 50*k) == X:
        cnt += 1

print(cnt)

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

ifstream in ("test.in" );
ofstream out("test.out");

const int DIM = 1e2 + 5;

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

bool oki[DIM][DIM]; int mat[DIM][DIM];
pair<int, int> lst[DIM * DIM];

int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(); cout.tie();
    
    int h, w, n;
    cin >> h >> w >> n;
    
    for (int i = 0; i <= h + 1; ++i)
        oki[i][0] = oki[i][w + 1] = 1;
    for (int j = 0; j <= w + 1; ++j)
        oki[0][j] = oki[h + 1][j] = 1;
    
    oki[1][1] = 1; lst[1] = make_pair(1, 1);
    for (int i = 1, j = 1, p = 2, d = 0; p <= h * w; ++p) {
        while (oki[i + dx[d]][j + dy[d]])
            d = (d + 1) & 3;
        
        i += dx[d]; j += dy[d];
        oki[i][j] = 1; lst[p] = make_pair(i, j);
    }
    
    for (int i = 1, j = 1; i <= n; ++i) {
        int x;
        cin >> x;
        
        for (; x != 0; --x, ++j)
            mat[lst[j].first][lst[j].second] = i;
    }
    
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j)
            cout << mat[i][j] << " ";
        cout << "\n";
    }

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main(void){
    int n,k;cin>>n>>k;
    vector<int>V[n];
    int fr,to;
    rep(i,n-1){
        cin>>fr>>to;fr--;to--;
        V[fr].push_back(to);
        V[to].push_back(fr);
    }
    vector<bool>judge(n,false);
    queue<int>Q;
    Q.push(0);judge[0]=true;
    int ans=k;
    while(!Q.empty()){
        int now=Q.front();Q.pop();
        if(now==0){
            rep(i,V[now].size()){
                ans*=(k-i-1);ans%=mod;
                judge[V[now][i]]=true;
                Q.push(V[now][i]);
            }
        }
        else{
            int x=k-2;
            rep(i,V[now].size()){
                if(judge[V[now][i]])continue;
                ans*=x;ans%=mod;
                x--;
                judge[V[now][i]]=true;
                Q.push(V[now][i]);
            }
        }
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 7284
s = str(input())
t = str(input())

match = 0
for l in range(len(s)-len(t)+1):
    ma = 0
    for m in range(len(t)):
        if s[l+m] == t[m]:
            ma += 1
        match = max(match, ma)
            
print(len(t)-match)



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

int main() {
    int n; cin >> n;
    vector<int> a(n); rep(i,n) { cin >> a[i]; a[i]--; }
    vector<int> aa(n); rep(i,n) aa[a[i]] = i;

    ll ans = 0ll;
    set<int> data;
    data.insert(-1);
    data.insert(n);
    rep(i,n) {
        auto iter = data.upper_bound(aa[i]);
        ans += (ll)(i+1) * (ll)(*iter - aa[i]) * (ll)(aa[i] - *prev(iter));
        data.insert(aa[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14300
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int num,n,i,j,k,l,ge,shi,bai,key,flag;
	string s;
	cin>>n;
	cin>>s;
	int a[1000]={0};
	for(i=0;i<=999;i++)
	{
		key=0;
		ge=i%10;
		shi=(i/10)%10;
		bai=i/100;
		for(j=0;j<=s.size()-1;j++)
		if((s[j]-'0')==bai)
		{
			for(k=j+1;k<=s.size()-1;k++)
			if((s[k]-'0')==shi)
			{
				for(l=k+1;l<=s.size()-1;l++)
				if ((s[l]-'0')==ge)
				{
					a[i]=1;
				}
				break;
			}
			break;
		}
	}
	for(i=0;i<=999;i++)
	if(a[i]>0)num++;
	cout<<num;
}

Measured memory_bytes: 256
dic = {}
while line = gets
  k, v = line.chomp.split
  if dic.key?(k)
    dic[k] << v.to_i
  else
    dic.store(k, [v.to_i])
  end
end

dic.sort.each do |d|
  puts d[0]
  puts d[1].sort.join(' ')
end

Measured memory_bytes: 2360
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int N;
	cin >> N;
	vector<int> d(N);
	rep(i,N) cin >> d[i];
	int ans=0;
	rep(i,N){
		for(int j=i+1; j<N; j++) ans+=d[i]*d[j];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
macro_rules! input { (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        a: usize,
        b: usize,
        x: usize,
    }
    let mut ans = 0;
    if a % x == 0 {
        ans = b / x - a / x + 1;
    } else {
        ans = b / x - a / x;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    ll N, sum=0; int M; scanf("%lld %d", &N, &M);
    rep(i,M){
        ll A; scanf("%lld", &A);
        sum += A;
    }
    printf("%lld\n", max(-1LL, N-sum));
}

Measured memory_bytes: 3812
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

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

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    int R; cin >> R;
    cout << 3 * R * R << endl;
    return 0;
}

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

int main() {
  int x;
  cin >> x;

  int a = x / 500;
  int b = (x % 500) / 5;

  cout << (a * 1000 + 5 * b) << endl;

  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int a[100050],n,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		if(a[i]==a[i-1])
			ans++;
	if(ans%2==1) ans++;
	cout<<n-ans<<endl;
	return 0;
}


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

int main(){
  ll x;
  cin >> x;

  ll a = x/11;
  ll b = x%11;

  if(b>=7){
    cout << a*2 + 2 << endl;
  }
  else if(b>=1){
    cout << a*2 + 1 << endl;
  }
  else{
    cout << a*2 << endl;
  }

  

  return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<string.h>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int main(void) {
	int n; cin >> n;
	int a;
	int cnt[100000];
	fill(cnt, cnt + 100000, 0);
	for (int i = 0; i < n; i++) {
		cin >> a;
		cnt[a - 1]++;
	}
	vector<int>num;
	for (int i = 0; i < 100000; i++) {
		if (cnt[i] > 0) {
			num.push_back(cnt[i]);
		}
	}
	if (num.size() % 2 == 1) {
		cout << num.size() << endl;
	}
	else {
		cout << num.size()-1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    ll n,ans = 1;
    cin >> n;
    rep(i, n)ans = ans * (i + 1) % mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import qualified Data.List as L

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = fst . fromJust . BS.readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  n <- getInt
  a <- getIntList
  putStrLn $ solve a

solve :: [Int] -> String
solve a = do
  let s = filter (\n -> n `mod` 2 == 0) a
      b = filter (\n -> n `mod` 3 /= 0) (filter (\n -> n `mod` 5 /= 0) s)
      n = length b
      in if n == 0 then "APPROVED" else "DENIED"

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            var Mod = 1000000007;

            var count = new int[26];
            for (var i = 0; i < N; i++)
                count[S[i] - 'a']++;

            var ans = 1L;
            for (var i = 0; i < count.Length; i++)
            {
                ans *= count[i] + 1;
                ans %= Mod;
            }

            ans += Mod - 1;
            ans %= Mod;

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll l, r, d;
    cin >> l >> r >> d;
    cout << (r / d - (l - 1) / d) << endl;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(){
	char action[123];
	scanf("%s", action);
	
	int length = strlen(action);
	int count=0;
	for(int i=0; i<length; i++){
		if(i%2==0){
			if(action[i]!='L'){
				count++;
			}
			else i=length;
		}
		else{
			if(action[i]!='R'){
				count++;
			}
			else i=length;
		}
	}
	
	if(count==length) printf("Yes");
	else printf("No");
	
	return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;
import java.util.function.*;

public class Main {
    public static void main(String[] args) {
        new Main().solve();
    }

    int N, K;
    boolean[] D;
    public Main() {
        Scanner in = new Scanner(System.in);
        N = in.nextInt();
        K = in.nextInt();
        D = new boolean[10];
        for (int i = 0; i < K; i++) {
            D[in.nextInt()] = true;
        }
    }

    void solve() {
        Function<Integer, Boolean> ok = (n) -> {
            while (n > 0) {
                if (D[n % 10]) return false;
                n /= 10;
            }
            return true;
        };
        for (int n = N; ; n++) {
            if (ok.apply(n)) {
                System.out.println(n);
                break;
            }
        }
    }
}

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

int main()
{
  int n,w;
  cin>>n;
  cin>>w;
  if(n==0){
  cout<<"0"<<endl;
  return 0;
  }
  vector<unsigned long long> v(w+1);
  vector<unsigned long long> wt(n);
  vector<unsigned long long> val(n);
  for(int i=0;i<n;i++)
  cin>>wt[i]>>val[i];

  //dp[1]=abs(v[1]-v[0]);
  for(int i=1;i<=n;i++)
  {
      for(int j=w;j>=0;j--)
      {
        if(wt[i-1]<=j)
        v[j]=max({v[j],v[j-wt[i-1]]+val[i-1]});
      }
  }
  cout<<v[w]<<endl;
  return 0;
}


Measured memory_bytes: 1024
let is_triangle a b c =
    a**2.0 +. b**2.0 = c**2.0

let to_result a b c =
    if is_triangle a b c then "YES" else "NO"

let () =
    let n = Scanf.scanf "%d\n" (fun x -> x) in
    for i = 1 to n do
        let lengthes = Scanf.scanf "%f %f %f\n" (fun a b c -> [|a; b; c|]) in
        Array.sort compare lengthes ;

        let a, b, c = lengthes.(0), lengthes.(1), lengthes.(2) in
        let result  = to_result a b c in
        Printf.printf "%s\n" result ;
    done

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

using namespace std;

// 入力
int N;
vector<int> A, B, C;

int main(void) {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int a_in;
        cin >> a_in;
        A.push_back(a_in);
    }
    for (int i = 0; i < N; ++i) {
        int b_in;
        cin >> b_in;
        B.push_back(b_in);
    }
    for (int i = 0; i < N; ++i) {
        int c_in;
        cin >> c_in;
        C.push_back(c_in);
    }

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    long long sum = 0;
    for (int i = 0; i < N; ++i) {
        long long a_num = (long long) (lower_bound(A.begin(), A.end(), B[i]) - A.begin());
        long long c_num = (long long) N - (long long) (upper_bound(C.begin(), C.end(), B[i]) - C.begin());
        sum += a_num * c_num;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int dp[100100][3];

struct tp {
	int a;
	int b;
	int c;
	tp(int x, int y, int z) {
		a = x;
		b = y;
		c = z;
	}
	int get(int p) {
		if (p == 0) return a;
		else if (p == 1) return b;
		else return c;
	}
};

int solve(int n, vector<tp> v) {
	rep(j,3) dp[0][j] = 0;
	for (int i = 1; i < n+1; i++) {
		rep(j,3) {
			dp[i][j] = max(dp[i-1][(j+1) % 3] + v[i-1].get(j), dp[i-1][(j+2) % 3] + v[i-1].get(j));
		}
	}
	int res = 0;
	rep(j,3) res = max(res, dp[n][j]);
	return res;
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	rep(i,n) cin >> a[i] >> b[i] >> c[i];
	vector<tp> v;
	rep(i,n) {
		v.push_back(tp(a[i], b[i], c[i]));
	}
	cout << solve(n, v) << endl;
}

Measured memory_bytes: 7984
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func main() {
  NK := NextIntVec()
  N, K := NK[0], NK[1]
  P := make([][]int, N)
  for i := range P {
    P[i] = make([]int, 3)
  }
  for i := 0; i < N; i++ {
    a, b := 0, 0
    if 0 < N % 2 {
      a = 2 * i % N
      b = (2 * i + 1) % N
    } else {
      a = 2 * i
      if N <= a { a -= N - 1 }
      b = 2 * i
      if 0 < i { b-- }
      if N <= b { b -= N - 1 }
    }
    P[a][0] = K + i
    P[b][1] = K + N + i
    P[i][2] = K + 2 * N + i
  }
  if (N + 1) / 2 < K {
    Write(-1)
  } else {
    for _, p := range P {
      WriteIntVec(p)
    }
  }
  Output()
}

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


int main(){
  int N;
  cin >> N;
  vector<int> v;
  rep(i,N-1){
    int a;
    cin >> a;
    v.push_back(a);
  }

  ll ret = 0;
  rep(i,N){
    int mn = 100000;
    if(i<v.size()) mn = min(mn, v[i]);
    if(i-1>=0) mn = min(mn, v[i-1]);

    ret += mn;
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 256
using System;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		long[] a=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
		int n=-1;
		string[] ans=new string[s[0]];
		ans[0]="Possible";
		for(int i=1;i<s[0];i++){
			if(a[i-1]+a[i]>=s[1]){n=i;break;}
		}
		if(n==-1){Console.WriteLine("Impossible");}
		else{
			for(int i=1,j=1;i<s[0];i++){
				if(n==i){j=s[0]-2;}
				else if(n>i){
					ans[j]=i.ToString();
					j++;
				}
				else{
					ans[j]=i.ToString();
					j--;
				}
			}
			ans[s[0]-1]=n.ToString();
			Console.WriteLine(String.Join("\n",ans));
		}
	}
}

Measured memory_bytes: 31068
#!/usr/bin/env python3
#ABC106 B

n = int(input())

def count(n):
    c = 0
    for i in range(1,n+1):
        if n % i == 0:
            c += 1
    return c
ans = 0
for i in range(1,n+1):
    if i % 2 == 0:continue
    x = count(i)
    if x == 8:
        ans += 1
print(ans)


Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int main(){
	ll N;
	cin>>N;
	rep1(x_,3500) rep1(y_,3500){
		ll x = x_, y = y_;
		ll a = 4*x*y-N*y-N*x;
		ll b = N*x*y;
		if(a!=0 && b%a==0 && b/a > 0){
			ll c = b/a;
			cout<<x<<" "<<y<<" "<<c<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 764
n=int(input())
a=[int(input()) for _ in range(n)]
if n%2==1:
  a=sorted(a)
  res=abs(2*(sum(a[:n//2])-sum(a[n//2:]))+a[n//2]+a[n//2+1])

  a=a[::-1]
  res=max(res,abs(2*(sum(a[:n//2])-sum(a[n//2:]))+a[n//2]+a[n//2+1]))
else:
  a=sorted(a)
  res=abs(2*(sum(a[:n//2])-sum(a[n//2:]))+a[n//2]-a[n//2-1])
print(res)

Measured memory_bytes: 8284
/*
    In the name of
        "ALLAH"
    And say "AL-HAM-DU-LILLAH"
*/

#include<bits/stdc++.h>
#define ll long long
#define llu unsigned long long

int take() {
    int n;
    scanf("%d",&n);
    return n;

}
double ttake() {
    double n;
    scanf("%lf",&n);
    return n;
}
ll takes() {
    ll n;
    scanf("%lld",&n);
    return n;

}

#define Int take()
#define Dnt ttake()
#define LL takes()
#define done {return 0;}
#define fr(n) for(int i=1;i<=n;i++)
#define FR(a,b,x) for(int i=(a);i<=(b);i+=(x))
#define rfr(n) for(int i=n;i>=1;i--)
int cas;
#define print printf("Case %d:",++cas)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pii pair<int,int>
#define vii vector<pii>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mk  make_pair
#define fill(x,v) memset(x,v,sizeof x)

using namespace std;

bool approximatelyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool essentiallyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool definitelyGreaterThan(float a, float b, float epsilon) {
    return (a - b) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool definitelyLessThan(float a, float b, float epsilon) {
    return (b - a) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
#define STR {struct info}
#define dbg(x) {cout<<"ekhane"<<x<<endl;}
#define  SS second
#define  FF first
#define PQ priority_queue
#define great greatest
#define less lesser
#define mii map<int,int>
#define mil map<int,ll>
#define mll map<ll,ll>
#define msb map<string,bool>
#define M 100005
//////////////////////////////////////////
bool nw[51][51][51];

int main(){

    int a=Int,b=Int,c=Int,x=Int,ans=0;
    int m=500,n=100,p=50;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
                ll v=x-(500*1ll*i)-(100*1ll*j);
                if(v<0 || v%p) continue;
                int d=v/p;
                if(d>c) continue;
                if(!nw[i][j][d] && (i|| j|| d)) ans++,nw[i][j][d]=1;;
        }
    }
    printf("%d\n",ans);
    done;
}




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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

int n, c;

int D[35][35];
int inp[505][505];

ll dp[3][35];

int main(){
    fastScan(n); fastScan(c);
    for(int i = 1; i <= c; i++){
        for(int j = 1; j <= c; j++){
            fastScan(D[i][j]);
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            fastScan(inp[i][j]);
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            int rem = (i + j) % 3;
            for(int k = 1; k <= c; k++){
                dp[rem][k] += D[inp[i][j]][k];
            }
        }
    }
    ll ans = 1e18;
    for(int i = 1; i <= c; i++)
        for(int j = 1; j <= c; j++)
            for(int k = 1; k <= c; k++)
                if(i != j && i != k && j != k) ans = min(ans, dp[0][i] + dp[1][j] + dp[2][k]);
    printf("%lld\n", ans);
}


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

int main () {
  int N, A;
  cin >> N >> A;
  N = N % 500;
  if (( 0 <= N && N <= A )) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include "atcoder/scc.hpp"
#include <atcoder/all>
#include <vector>
using namespace std;
using namespace atcoder;

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

  int K;
  cin >> K;
  while (K--)
    cout << "ACL";
  cout << '\n';
}


Measured memory_bytes: 3644
# include <bits/stdc++.h>
# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define forn(i, n) for (int i = 0; i < int(n); i++)
# define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define in freopen("input.txt", "r", stdin)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
  
using namespace std;
  
const ll INF = 1e18;
const int mod = 1e9 + 7;
const ll N = 1e5 + 7;
typedef vector < vector < ll > > matrix;
   
int main()
{   
    speed;
    int n, k;
    cin >> n >> k;
    vector < int > a(n), dp(n);
    forn( i, n ) cin >> a[i];
    fore( i, 1, n ) {
        dp[i] = mod;
        forn( j, k ) {
            if ( j >= i ) break;
            dp[i] = min( dp[i], dp[i - (j + 1)] + abs( a[i] - a[i - (j + 1)] ) );
        }
    }
    cout << dp[n - 1];
    time;
}

Measured memory_bytes: 1024
from fractions import gcd
a, b = map(int, input().split())
work = gcd(a, b)
count = 1
for i in range(2, int(work**0.5)+1):
    flag = False
    while work%i == 0:
        work //= i
        if not flag:
            count += 1
        flag = True
if work > 2:
    count += 1
print(count)

Measured memory_bytes: 5048
#include <stdio.h>
 
int main(void){
    int n, k;
    int sum,ans;
    scanf("%d %d",&n,&k);
    int pro[n];
    
    for(int i=0;i<n;i++) {scanf("%d", &pro[i]);}
    sum=0;
    for(int i=0;i<k;i++){sum+=pro[i];}
    ans=sum;
    for(int i=k;i<n;i++){
        sum+=(pro[i]-pro[i-k]);
        if(ans<sum){
            ans=sum;
        }
    }
    
    printf("%f",(double)(ans+k)/2);
    
    return 0;
}


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

int main(){

  // string s;
  // cin >> s;

  // int ipos = str.find_first_of("A"||"T"||"G"||"C");

  string str;
  cin >> str;

  int tmp_cont = 0;
  int max_cont = 0;

  for(int i = 0 ; i < str.size() ; i++){
    if( str[i] == 'A' || str[i] == 'G' || str[i] == 'T' || str[i] == 'C' ){
      tmp_cont++;
      // cout << i << "\t" << tmp_cont << "\t" <<str[i] << endl;
      if(max_cont < tmp_cont) max_cont = tmp_cont;
    }else{
      // cout << "else" << endl;
      tmp_cont = 0;
    }
  }

  cout << max_cont << endl;

  // for(int i = 0 ; i < str.size() ; i++){
  //   printf("test %d : %c\n", i, str[i]);
  //   if(str[i] == 'A') cout << "OK" << endl;
  // }
  
}

Measured memory_bytes: 256
#include<stdio.h>


int main(void){
	int m;
	long long int n;
	long long int a;
	long long int ret;
	int i;

	ret = 0;

	scanf("%lld",&n);
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%lld",&a);
		ret += a;

	}

	if(n<ret){
		printf("-1\n");
	}
	else{
		printf("%lld\n",n - ret);

	}

	return 0;

}



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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VI h(n);
    REP(i, n) cin >> h[i];
    VI dp(n);
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    FOR(i, 2, n - 1) 
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), 
                    dp[i - 2] + abs(h[i - 2] - h[i]));
    cout << dp[n - 1] << ln;
    return 0;
}


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

int gcd (int a, int b) {

    if (a % b == 0) return b;
    else return gcd(b, a % b);
}

int main () {

    int N, X;
    scanf("%d %d", &N, &X);

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

    int dist[N];

    for (int i = 0; i < N; i++) {
        dist[i] = abs(x[i] - X);
    }

    int D = dist[0];

    for (int i = 1; i < N; i++) {
        D = gcd(D, dist[i]);
    }

    printf("%d\n", D);

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(int argc, char* argv[]) {
  long long N, K, Q;
  cin >> N >> K >> Q;

  vector<long long> ans(N);
  set<long long> survivors;
  for (long long i = 0; i < Q; ++i) {
    long long a;
    cin >> a;
    a -= 1;
    ++ans[a];
    if (ans[a] > -(K - Q) && survivors.find(a) == survivors.end())
      survivors.insert(a);
  }

  for (long long i = 0; i < N; ++i) {
    if (Q < K)
      cout << "Yes" << endl;
    else if (survivors.find(i) == survivors.end()) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }

  return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    int len_s = s.size(), len_t = t.size();
    vector<vector<pair<int, int>>> dp(len_s + 1, vector<pair<int, int>>(len_t + 1));
    for(int i = 0; i <= len_s; ++i){
        dp[i][0].first = 0;
    }
    for(int i = 0; i <= len_t; ++i){
        dp[0][i].first = 0;
    }
    for(int i = 1; i <= len_s; ++i){
        for(int j = 1; j <= len_t; ++j){
            if(s[i-1] == t[j-1]){
                dp[i][j].first = 1 + dp[i-1][j-1].first;
                dp[i][j].second = 0;
            }else{
                // dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
                if(dp[i-1][j] > dp[i][j-1]){
                    dp[i][j].first = dp[i-1][j].first;
                    dp[i][j].second = 1;
                }else{
                    dp[i][j].first = dp[i][j-1].first;
                    dp[i][j].second = 2;
                }
            }
        }
    }
    int i = len_s, j = len_t;
    string subseq = "";
    while(i > 0 and j > 0){
        if(dp[i][j].second == 0){
            subseq += s[i - 1];
            --i;
            --j;
        }else if(dp[i][j].second == 1){
            --i;
        }else{
            --j;
        }
    }
    reverse(subseq.begin(), subseq.end());
    cout << subseq << endl;
	return 0;
}

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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort((c).begin(), (c).end(), greater<int>());
#define fi first
#define se second
  
typedef pair<int,int> P;
typedef vector<int> vi;

int N;
vi a;

signed main() {
    priority_queue<int, vector<int>, greater<int>> q1;
    priority_queue<int> q2;

    cin >> N;
    int sum1 = 0, sum2 = 0;
    rep(i, 0, 3*N) {
        int A; cin >> A;
        a.pb(A);
        if(i <= N-1) {
            q1.push(A);
            sum1 += A;
        }
        if(i >= 2*N) {
            q2.push(A);
            sum2 += A;
        }
    }

    
     vi s1, s2;
     s1.pb(sum1);
     s2.pb(sum2);

     rep(k, 0, N) {
         q1.push(a[N+k]);
         sum1 += a[N+k];
         sum1 -= q1.top();
         q1.pop();
         s1.pb(sum1);

         q2.push(a[2*N-1-k]);
         sum2 += a[2*N-1-k];
         sum2 -= q2.top();
         q2.pop();
         s2.pb(sum2);

    }

     int max;
     rep(i, 0, N+1) {
         int ret = s1[i] - s2[N-i];
         if(i == 0) max = ret;
         if(ret > max) max = ret;
     }

     cout << max << endl;
     return 0;
}





    

    


Measured memory_bytes: 8932
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    
    if(a+b>=c){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

    return 0;
}

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

int main()
{
    string A, B;
    cin >> A >> B;
    for (int i = 0; i < A.size(); i++)
    {
        if (A == B)
        {
            cout << "Yes" << endl;
            return 0;
        }
        A = A.substr(1, A.size() - 1) + A.substr(0, 1);
    }
    cout << "No" << endl;
}


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

using namespace std;

int main() {
	string S;
	cin >> S;
	for( size_t i = 0; i < 4; i++ ) {
		cout << S[i];
	}
	cout << " ";
	for( size_t i = 4; i < S.length(); i++ ) {
		cout << S[i];
	}
	cout << endl;
}

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

int main(){
    double r;
    cin>>r;
    cout<<fixed<<setprecision(7)<<3.14159265358979*(double)r*(double)r<<" "<<fixed<<setprecision(7)<<3.14159265358979*2*(double)r<<endl;
}


Measured memory_bytes: 3220
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    plus = [A[i] for i in range(N) if A[i] >= 0]
    minus = [A[i] for i in range(N) if A[i] < 0]

    ans = 1

    P = len(plus)
    M = len(minus)
    plus.sort(reverse=True)
    minus.sort()
    mod = 10**9 + 7

    if N == K:
        for x in A:
            ans *= x
            ans %= mod
    elif P == 0:
        if K % 2 == 1:
            minus.sort(reverse=True)
        for i in range(K):
            ans *= minus[i]
            ans %= mod
    else:  # 必ず正の値が作れる？ 1つ以上余るので、偶奇は選べるはず
        id = 0
        if K % 2 == 1:
            ans = plus[0]
            id = 1
            P -= 1
            K -= 1
        pp = [plus[i] * plus[i+1] for i in range(id, P-1+id, 2)]
        mm = [minus[i] * minus[i+1] for i in range(0, M-1, 2)]

        id = 0
        id2 = 0

        for i in range(K // 2):
            if id < P // 2 and (id2 >= M // 2 or pp[id] >= mm[id2]):
                ans *= pp[id]
                id += 1
            else:
                ans *= mm[id2]
                id2 += 1
            ans %= mod

    print(ans % mod)


main()


Measured memory_bytes: 31764