akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
using namespace std;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || '9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x*f;
}

inline void writes(int x)
{
	if(x>=10)writes(x/10);
	putchar('0'+x%10);
}

inline void write(int x,char ch='\n')
{
	if(x<0)putchar('-'),writes(-x);
	else writes(x);putchar(ch);
}

const int N=1e5+9;
const int K=2009;
const int KK=(K<<1)+9;

int n,k,kk;
int x[N],y[N];
int w[KK][KK],b[KK][KK];

inline int query(int (*a)[KK],int x1,int y1,int x2,int y2)
{
	x2=min(x2,kk),y2=min(y2,kk);
	int ret=0;
	if(x2>=0 && y2>=0)ret=a[x2][y2];
	if(x1>0 && y2>=0)ret-=a[x1-1][y2];
	if(y1>0 && x2>=0)ret-=a[x2][y1-1];
	if(x1>0 && y1>0)ret+=a[x1-1][y1-1];
	return ret;
}

int main()
{
	if(fopen("vj.in","r"))
	{
		freopen("vj.in","r",stdin);
		freopen("vj.out","w",stdout);
	}

	n=read();k=read();
	char c[190];
	kk=k*2;
	for(int i=1;i<=n;i++)
	{
		x[i]=read();y[i]=read();scanf("%s",c+1);
		if(c[1]=='B')
			b[x[i]%kk][y[i]%kk]++;
		else
			w[x[i]%kk][y[i]%kk]++;
	}

	for(int i=0,j=1;j<=kk;j++)
	{
		b[i][j]+=b[i][j-1];
		w[i][j]+=w[i][j-1];
	}
	for(int i=1,j=0;i<=kk;i++)
	{
		b[i][j]+=b[i-1][j];
		w[i][j]+=w[i-1][j];
	}
	for(int i=1;i<=kk;i++)
		for(int j=1;j<=kk;j++)
		{
			b[i][j]+=b[i-1][j]+b[i][j-1]-b[i-1][j-1];
			w[i][j]+=w[i-1][j]+w[i][j-1]-w[i-1][j-1];
		}

	/*
	for(int i=0;i<=6;i++,puts(""))
		for(int j=0;j<=6;j++)
			printf("%d ",b[i][j]);
	puts("");
	for(int i=0;i<=6;i++,puts(""))
		for(int j=0;j<=6;j++)
			printf("%d ",w[i][j]);
	*/

	int ans=0;
	for(int tim=0;tim<=1;tim++)
	{
	for(int i=0;i<=k;i++)
		for(int j=0;j<=k;j++)
		{
			int satw=query(w,i,j,i+k-1,j+k-1)+query(w,i+k,j+k,i+k+k-1,j+k+k-1);
			satw+=query(w,i+k,0,i+k+k-1,j-1)+query(w,0,j+k,i-1,j+k+k-1);
			if(i>0 && j>0)satw+=w[i-1][j-1];

			int satb=query(b,i+k,j,i+k+k-1,j+k-1)+query(b,i,j+k,i+k-1,j+k+k-1);
			satb+=query(b,i,0,i+k-1,j-1)+query(b,0,j,i-1,j+k-1);

			ans=max(ans,satw+satb);
		}

	swap(w,b);
	}

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


Measured memory_bytes: 127616
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int arr[n+1]={0};
    for(int i=1;i<101;i++)
    {
        for(int j=1;j<101;j++)
        {
            for(int k=1;k<101;k++)
            {
                int val=i*i+j*j+k*k+i*j+j*k+k*i;
                if(val>n)
                    continue;
                arr[val]++;

            }
        }
    }
    for(int i=1;i<=n;i++)cout<<arr[i]<<endl;
}


Measured memory_bytes: 3680
/**
*    author:  souzai32
*    created: 15.08.2020 02:26:08
**/

#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
typedef long long ll;
using namespace std;

int main() {

    string s;
    cin >> s;
    int left=0, right=s.size()-1;
    int count=0;
    while(left<=right){
        if(s.at(left)==s.at(right)){
            left++;
            right--;
        }else if(s.at(right)=='x'){
            right--;
            count++;
        }else if(s.at(left)=='x'){
            left++;
            count++;
        }else{
            count=-1;
            break;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,alice=0,bob=0;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
   if(n%2==0){ for(int i=n-1;i>=0;i--)
    {
        if(i%2==1) alice+=a[i];
        else bob+=a[i];
    }
   }
   else { for(int i=n-1;i>=0;i--)
    {
        if(i%2==0) alice+=a[i];
        else bob+=a[i];
    }

   }
    cout<<alice-bob<<"\n";


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
int A[100010];
int main()
{
	int K;
	cin >> K;
	for (int i = 0; i < K; i++) cin >> A[i];
	ll ans = 2;
	for (int i = K - 1; i >= 0; i--)ans = (ans + A[i] - 1) / A[i] * A[i];
	ll num = ans;
	for (int i = 0; i < K; i++)num -=  num % A[i];
	if (num != 2)
    {
		cout << -1 << endl;
		return 0;
	}
	cout << ans << " ";
	ans = 2;
	for (int i = K - 1; i >= 0; i--)ans = (ans / A[i] + 1) * A[i] - 1;
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll a[200005],s[200005],b[200005];
int main(){
	string s;
	cin>>s;
	ll flag=0;
	for(int i=0;i<s.size();i++){
		if((i)%2==0&&s[i]=='R'||s[i]=='U'||s[i]=='D')continue;
		if((i)%2==1&&s[i]=='L'||s[i]=='U'||s[i]=='D')continue;
		else{
			flag=1;
			break;
		}
	}if(flag==1)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N, C, K;
  cin >> N >> C >> K;
  vector<int> T(N);
  REP(i,N) cin >> T[i];
  sort(ALL(T));

  int res = 0;
  int t = 0;
  int ctmp = 0;
  REP(i,N) {
    if(ctmp == C || t < T[i]) {
      ++res;
      t = T[i] + K;
      ctmp = 1;
    }else{
      ++ctmp;
    }
  }
  cout << res << endl;
  return 0;
}



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

using ll = long long;

int main() {
    int N, L, minabs = 200, minabstaste = 200, ans = 0;
    cin >> N >> L;
    rep(i, N) {
        int taste = L + i;
        ans += taste;
        //cout << i << " " << taste << endl;
        if (abs(taste) < minabs) {
            minabs = abs(taste);
            minabstaste = taste;
        }
    }
    ans -= minabstaste;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <limits>

using namespace std;

#define COMMANDMAX 2000000
#define MAXVALUE 2000000000

int ARRAY[COMMANDMAX+1];
string command[3] = { "insert", "extract", "end" };

class CompleteBinaryTree
{
public:
    int parent(const int i) const { return (i / 2); };
    int left(const int i) const { return (i * 2); };
    int right(const int i) const { return (i * 2 + 1); };
};

class MaxmumHeap : public CompleteBinaryTree
{
public:
    MaxmumHeap();
    ~MaxmumHeap();

    int HEAPSIZE;
    void maxHeapify(const int);
    void buildMaxHeap();
};

class PriorityQueue : public MaxmumHeap
{
public:
    PriorityQueue();
    ~PriorityQueue();

    void insert(const int);
    int extractMax();
    void heapIncreaseKey(int, const int);
};

void swap(int*, int*);

int main() {
    string s;
    int key;
    PriorityQueue _q;

    while(true) {
        cin >> s;
        if(s == command[0]) {
            cin >> key;
            _q.insert(key);
        }

        else if(s == command[1]) {
            key = _q.extractMax();
            cout << key << endl;
        }

        else if(s == command[2]) {
            break;
        }
    }

    return 0;
}

void swap(int *p1, int *p2) {
    int tmp;
    tmp = *p2;
    *p2 = *p1;
    *p1 = tmp;
}

MaxmumHeap::MaxmumHeap() : HEAPSIZE(0) {
    
}

MaxmumHeap::~MaxmumHeap() {}

PriorityQueue::PriorityQueue() {

}

PriorityQueue::~PriorityQueue() {

}

void MaxmumHeap::maxHeapify(const int i) {
    int l = left(i), r = right(i), largest;
    if(l <= HEAPSIZE && ARRAY[l] > ARRAY[i])
        largest = l;

    else
        largest = i;
    
    if(r <= HEAPSIZE && ARRAY[r] > ARRAY[largest])
        largest = r;
    
    if(largest != i) {
        swap(&ARRAY[i], &ARRAY[largest]);
        maxHeapify(largest);
    }
}

void MaxmumHeap::buildMaxHeap() {
    for(int i = HEAPSIZE/2; i >= 1; --i) {
        maxHeapify(i);
    }
}

void PriorityQueue::insert(const int key) {
    HEAPSIZE++;
    ARRAY[HEAPSIZE] = INT16_MIN;
    heapIncreaseKey(HEAPSIZE, key);
}

void PriorityQueue::heapIncreaseKey(int i, const int key) {
    if(key < ARRAY[i]) {
        fprintf(stderr, "Error!\n");
        return ;
    }
    
    ARRAY[i] = key;
    while(i>1 && ARRAY[parent(i)] < ARRAY[i]) {
        swap(&ARRAY[i], &ARRAY[parent(i)]);
        i = parent(i);
    }
}

int PriorityQueue::extractMax() {
    if(HEAPSIZE < 1) {
        fprintf(stderr, "ERROR HEAPUNDERFLOW\n");
        exit(2);
    }

    int max = ARRAY[1];
    ARRAY[1] = ARRAY[HEAPSIZE];
    HEAPSIZE--;
    maxHeapify(1);

    return (max);
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 int H, W;
 int seen[10000][10000];
  char S[10000][10000];
vector<pair<ll, ll>> prime_factorize(ll n) { //素因数分解と各素数の個数
    vector<pair<ll, ll>> res;

    for (ll i = 2; i * i <= n; i++)
    {
        if (n % i != 0)
        {
            continue;
        }
        int num = 0;
        
        while (n % i == 0)
        {
            ++num;
            n /= i;
        }
        res.push_back(make_pair(i, num));
       
    }
     if (n != 1) 
        {
            res.push_back(make_pair(n, 1));
        }
        return res;
        
} 
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll lcm(ll x, ll y) {
    return x / GCD(x, y) * y;//先に割り算をして掛けられる数を小さくして掛け算を行う
}
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void dfs(int st, int fi) {
  //  cout << st << " " << fi <<  endl;
    if (st < 0 || fi < 0 || st >= H || fi >= W)
    {
        return ;
    }
    if (S[st][fi] == '#')
    {
        return ;
    }

    if (seen[st][fi] == 1)
    {
        return ;
    }
    
    
    if (S[st][fi] == '.')
    {
        seen[st][fi] = 1;
    }
    

    dfs(st + 1, fi);
    dfs(st, fi + 1);
    dfs(st, fi - 1);
    dfs(st - 1, fi);
    
}
int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> a(N), b(N);
    vector<pair<ll, ll>> pa;
    for(ll i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
        pa.push_back(make_pair(a[i], b[i]));
    }

    map<ll, ll> p;

   /* for(auto i : pa) {
        cout << i.first << " " << i.second << endl;
    }*/
    for(ll i = 0; i < N; i++) {
        p[a[i]] += b[i];
    }

    
    ll sum = 0;
    ll ans = 0;
   // sort(p.begin(), p.end());
    for(auto i : p) {
        sum += i.second;
       // cout << sum << endl;
        if(sum >= K) { ans = i.first; cout << ans << endl; return 0; }
        
    }

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


Measured memory_bytes: 10348
N = int(input())
import math 
m = math.floor(math.log(N,6)) #max 8
n = math.floor(math.log(N,9)) #max 7
s = [1]
for i in range(1,m+1):
    s.append(6**i)
for j in range(1,n+1):
    s.append(9**j)
s.sort()
l = len(s)
dp = [ i for i in range(N+1)]
for i in range(1,N+1):
    for j in range(1,6):
        m = 9**j
        
        K = min(i//m,8)
        for k in range(K+1):
            dp[i] = min(dp[i],dp[i-m*k]+k)
    for j in range(1,7):
        m = 6**j
        
        K = min(i//m,5)
        for k in range(K+1):
            dp[i] = min(dp[i],dp[i-m*k]+k)
print(dp[N])

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

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define DOUBLE fixed << setprecision(10)
#define fi first
#define se second
const double pi = acos(-1.0);
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };
template <typename T>
bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
};
template <typename T>
bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
};
void Pvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void Pvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Ps(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void Pvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

void Yay(bool x) {
	if (x) cout << "Yay!\n";
	else cout << ":(\n";
}


ll  n, m, r, l, k, h, ans = 0, ret = M;
bool flag = false, flag2 = false, flag3 = false;
string s,t;

void INIT() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << DOUBLE;
}

ll gcd(ll m,ll n){
    while(m!=n){
        if(m>n)m-=n;
        else n-=m;
    }
    return m;
}
ll lcm(ll m,ll n){
    return m*n/gcd(m,n);
}

int main() {
    INIT();
    int n;cin>>n;
    vll v(n);
    ans=1;
    rep(i,n){
        cin>>v[i];
        ans=lcm(ans,v[i]);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3216
var
s:string;
i:longint;
begin
readln(s);
while i<length(s) do
begin
if copy(s,i+1,11)='dreameraser' then i:=i+11
else if copy(s,i+1,10)='dreamerase' then i:=i+10
else if copy(s,i+1,6)='eraser' then i:=i+6
else if copy(s,i+1,5)='erase' then i:=i+5
else if copy(s,i+1,7)='dreamer' then i:=i+7
else if copy(s,i+1,5)='dream' then i:=i+5
else begin writeln('NO'); halt; end;
end;
writeln('YES');
end.



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
 
void solve(){
    int x, y;
    cin >> x >> y;
    for(int i = 0; i <= x; ++i) {
        int l = i;
        int f = x - i;
        if(2 * l + 4 * f == y) {
            cout << "Yes";
            return;
        }
    }
    cout << "No";
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

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

int main(){
    int W;
    cin >> W;
    int H;
    cin >> H;
    int x;
    cin >> x;
    int y;
    cin >> y;
    int r;
    cin >> r;
    if (r <= x && x <= W-r && r <= y && y<=H-r) {
    cout << "Yes" << endl;
}   else {
    cout << "No" << endl;
}   return 0 ;
}



Measured memory_bytes: 3116
# include <stdio.h>
	# include <string.h>
	int main () {
		int a = 0;
		int c =0;
		scanf ("%d",&a);
		c = 1000 -(a%1000) ;
		if (c==1000) {
			c= 0;
		}
		printf ("%d",c);
		return 0;
	}

Measured memory_bytes: 1736
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	int N;
	string S;
	cin >> N >> S;
	string mae, ato;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		
		if (S[i] == '(')cnt++;
		else cnt--;

		if (cnt < 0) {
			cnt = 0;
			mae += '(';
		}
	}
	for (int i = 0; i < max(0, cnt); i++)ato += ')';
	cout << mae + S + ato << endl;
	return 0;
}

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

namespace AOJ
{
    class Program
    {

        const int BLOCK_W = 2;
        const int BLOCK_H = 4;

        private int w, h;
        private int[,] borad;
        private int start_x;
        private int start_y;
        private int goal_x;
        private int goal_y;

        private bool isToGoal(int c,int x,int y){

            if (x > w || y > h) return false;
            if (borad[x, y] != c) return false;
            if (x == goal_x && goal_y == y) return true;

            borad[x, y] += 10; //通過フラグ

            bool r = false;
            r = isToGoal(c, x + 1, y);
            if (!r) r = isToGoal(c, x - 1, y);
            if (!r) r = isToGoal(c, x, y + 1);
            if (!r) r = isToGoal(c, x, y - 1);
            return r;
        }

        private string solve(int p_w,int p_h)
        {
            w = p_w;
            h = p_h;
            string[] tmp_start = Console.ReadLine().Split(new char[] { ' ' });
            string[] tmp_goal = Console.ReadLine().Split(new char[] { ' ' });
            start_x = int.Parse(tmp_start[0]);
            start_y = int.Parse(tmp_start[1]);
            goal_x = int.Parse(tmp_goal[0]);
            goal_y = int.Parse(tmp_goal[1]);

            borad = new int[w+1,h+1];
            
            int n = int.Parse(Console.ReadLine());

            //ブロック読み込み
            for (int i = 0; i < n; i++)
            {
                string[] block_i = Console.ReadLine().Split(new char[] { ' ' });
                int color = int.Parse(block_i[0]);
                int d = int.Parse(block_i[1]);
                int x = int.Parse(block_i[2]);
                int y = int.Parse(block_i[3]);

                int x_e,y_e;
                if (d == 0)
                {
                    x_e = x + BLOCK_H - 1;
                    y_e = y + BLOCK_W - 1;
                }
                else
                {
                    x_e = x + BLOCK_W - 1;
                    y_e = y + BLOCK_H - 1;
                }
                for(int x_i = x;x_i<= x_e;x_i++){
                    for (int y_i = y; y_i <= y_e;y_i++ )
                    {
                        borad[x_i, y_i] = color;
                    }   
                }
            }

            //for (int i = 0; i < w; i++)
            //{
            //    for (int j = 0; j < h; j++)
            //    {
            //        Console.Write(borad[i, j].ToString() + ",");
            //    }
            //    Console.WriteLine();
            //}

            for (int c = 1; c <= 5; c++)
            {
                if (isToGoal(c, start_x, start_y)) return "OK";
            }
            return "NG";

        }
        
        static void Main(string[] args)
        {
            Program obj = new Program();
            while (true) {
                string[] s = Console.ReadLine().Split(new char[] { ' ' });
                if (s[0] == "0" && s[1] == "0") break;
                Console.WriteLine(obj.solve(int.Parse(s[0]), int.Parse(s[1])));
            }
        }
    }
}

Measured memory_bytes: 5516
#include <iostream>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
  if(b==0) return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){
  return a*b/gcd(a,b);
}
int main()
{
  ll a,b;
  cin >> a >> b;
  cout << lcm(a,b) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main() {
    int N;
    cin >> N;
    map<int, int> num;
    for (int i = 0; i < N; i++) {
        int ai;
        cin >> ai;
        num[ai]++;
    }
    vector<int> divisible = vector<int>(1000100, false);
    int ans = 0;
    for (auto keyval: num) {
        if (keyval.second == 1 && !divisible[keyval.first]) {
            ans++;
        }
        for (int i = 1; keyval.first * i < 1000050; i++) {
            divisible[keyval.first * i] = true;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 16304
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t a,b,m,ans=100000000000;
  cin >> a >> b >> m;
  int64_t A[a],B[b];
  for(int64_t i=0;i<a;i++)cin >> A[i];
  for(int64_t j=0;j<b;j++)cin >> B[j];
  for(int64_t i=0;i<m;i++){
    int64_t x,y,c;
    cin >> x >> y >> c;
    ans=min(ans,A[x-1]+B[y-1]-c);
  }
  sort(A,A+a);
  sort(B,B+b);
  if(ans<A[0]+B[0])cout << ans << endl;
  else cout << A[0]+B[0] << endl;
}

Measured memory_bytes: 5172
#include <iostream>
#include <vector>
using namespace std;
#define ll long long
int main(){
    int n;
    cin >> n;
    int nums[n];
    int nums2[n];
    int ans=0;
    vector<int> cnts(100000,0);
    for(int i=0;i<n;i++){
        cin>>nums[i];
        nums2[i]=nums[i]-(i+1);
    }
    for(int j=0;j<2;j++){
        for(int i=0;i<n;i++){
            if(nums2[i]==nums2[i+1] && nums2[i]==0){
                ans++;
                nums2[i]=nums[i]-(i+2);
                nums2[i+1]=nums[i+1]-(i+1);
            }else{
                if(nums2[i]==0){
                    nums2[i]=nums[i]-(i+2);
                    nums2[i+1]=nums[i+1]-(i+1);
                    ans++;
                }
            }
        }
    }

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

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define	foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define	mp make_pair
#define	pb push_back
#define sz(a) int((a).size())
#define all(a)  a.begin(), a.end()
#define	debug(ccc)	cout << #ccc << " = " << ccc << endl;
#define present(c,x) ((c).find(x) != (c).end())
const double eps = 1e-8;
#define EQ(a,b) (fabs((a)-(b))<eps)
inline int max(int a,int b){return a<b?b:a;}
inline int min(int a,int b){return a>b?b:a;}
inline ll max(ll a,ll b){return a<b?b:a;}
inline ll min(ll a,ll b){return a>b?b:a;}
const int mod = 1e9+7;
const int N = 1e6+10;
const ll inf = 1e18;

ll power(ll a,ll n){
	if(n==0){
		return 1;
	}
	ll b = power(a,n/2);
	b = b*b%mod;
	if(n%2) b= b*a%mod;
	return b;
}

int add(int a,int b){ return (a+b)%mod;}
int mul(int a,int b){ return (ll)a*b%mod;}


int mat[55][26];
char r[100];

int main(){
 // 	freopen("nice.in","r",stdin);
 // freopen("nice.out","w",stdout);
	int n; scanf("%d",&n);
	REP(i,n){
		scanf("%s",r);
		int p = strlen(r);
		REP(j,p) mat[i][r[j]-'a']++;
	}
	REP(i,26){
		int mn = mod;
		REP(j,n){
			mn = min(mn,mat[j][i]);
		}
		REP(j,mn) printf("%c",i+'a');
	}
	printf("\n");
	return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;


public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(; scanner.hasNext();)
		{
			int hit = 0;
			int blow = 0;
			
			int[] a = new int[4];
			for(int i=0; i<4; i++)
			{
				a[i] = scanner.nextInt();
			}
			int[] b = new int[4];
			for(int i=0; i<4; i++)
			{
				b[i] = scanner.nextInt();
			}
			
			
			for(int i=0; i<4; i++)
			{
				for(int j=0; j<4; j++)
				{
					if(i!=j && a[i]==b[j])
					{
						blow ++;
					}
				}
				if(a[i] == b[i])
				{
					hit ++;
				}
			}
			
			System.out.println(hit + " " + blow);
		}
	}
}

Measured memory_bytes: 26520
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>arr(n+2);
  map<int,int>compress;
  map<int,int>cnt;
  int uniq=0;
  for(int i=1;i<=n;i++)
  {
    cin>>arr[i];
    int J=i-arr[i];
    if(compress.find(J)==compress.end()){
    	compress[J]=uniq++;
    }
    cnt[compress[J]]++;
  }
  long long ans=0;
  for(int i=1;i<=n;i++){
    int X=arr[i]+i;
    if(compress.find(X)!=compress.end())
        ans+=cnt[compress[X]];
  }
   cout<<ans<<"\n";
}
  

Measured memory_bytes: 21284
#include<string>
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long int llint;
#define  pub push_back
const llint big=(200000000)*(2000000000)+114514;
int main(void){
	int n,t,bef,ans=0,q;
	scanf("%d %d",&n,&t);
	bef=-t;
	for(;n>0;n--){
		scanf("%d",&q);
		ans+=min(q-bef,t);
		bef=q;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
n=int(input())
k = [list(map(int, input().split())) for i in range(n)]
import math
ans=0
p=(n*(n-1))//2
z=math.factorial(n)
q=z*(n-1)
for i in range(n-1):
    for j in range(i+1,n):
        z=math.sqrt((k[i][0]-k[j][0])**2+((k[i][1]-k[j][1])**2))
        ans+=(q/p)*z

z=math.factorial(n)
print(ans/z)

Measured memory_bytes: 3064
n = io.read("*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
table.sort(a)
if n % 2 == 0 then
  hn = n // 2
  ret = 0
  for i = 1, hn - 1 do
    ret = ret + a[n + 1 - i] - a[i]
  end
  ret = ret * 2 + a[hn + 1] - a[hn]
  print(ret)
else
  hn = n // 2
  ret1 = 0
  for i = 1, hn - 1 do
    ret1 = ret1 + a[n + 1 - i]
  end
  for i = 1, hn do
    ret1 = ret1 - a[i]
  end
  ret1 = 2 * ret1 + a[hn + 1] + a[hn + 2]
  ret2 = 0
  for i = 1, hn do
    ret2 = ret2 + a[n + 1 - i]
  end
  for i = 1, hn - 1 do
    ret2 = ret2 - a[i]
  end
  ret2 = 2 * ret2 - a[hn] - a[hn + 1]
  print(math.max(ret1, ret2))
end


Measured memory_bytes: 4320
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<ll,ll,ll>
#define pr(x) cout << x << endl;
using namespace std;
 
int main(){
  int n,m; cin >> n >> m;
  vector<T> cakes;
  rep(i,n){
    ll x,y,z; cin >> x >> y >> z;
    cakes.emplace_back(x,y,z);  
  }

  ll ans=0;

  rep(i,2)rep(j,2)rep(k,2){
    vector<ll> sum(n);
    rep(p,n){
      ll nx,ny,nz;
      tie(nx,ny,nz) = cakes[p];
      if(i==1) nx*=-1;
      if(j==1) ny*=-1;
      if(k==1) nz*=-1;
      sum[p]=nx+ny+nz;
    }
    sort(all(sum));
    ll tmp=0;
    rep(i,m) tmp+=sum[n-i-1];
    ans=max(ans,tmp);
  }
  cout << ans << endl;
return 0;
}

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

int main() {
  int K, S;
  cin >> K >> S;

  int ans = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      int z = S - x - y;
      if (0 <= z && z <= K) ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

n, k = nm()
values = nl()
a = 0
b = 0

for i, v in enumerate(values):
    tmp_a = 0
    cnt_b = 0
    for j, v_c in enumerate(values):
        if v > v_c:
            tmp_a += 1
            if i > j:
                cnt_b += 1
    tmp_b = tmp_a * k - cnt_b
    a -= tmp_a
    b += tmp_b
    
print((a * k * (k + 1) // 2 + (b - a) * k) % (10 ** 9 + 7))
    


Measured memory_bytes: 3188
#include <stdio.h>
int main(){
    int a,b,c,s;
    scanf( "%d %d %d" , &a , &b , &c );

    if( a > b ){
        s = a;
        a = b;
        b = s;
    }
    if( a > c ){
        s = a;
        a = c;
        c = s;
    }
    if( b > c ){
        s = b;
        b = c;
        c = s;
    }
    printf( "%d %d %d\n" , a, b, c );
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

vector<pair<int,int>> kinbo4(int ch,int cw)
{
    vector<pair<int,int>> list(4);
    list[0] = pair<int, int>(ch, cw + 1);
    list[1] = pair<int, int>(ch, cw - 1);
    list[2] = pair<int, int>(ch + 1, cw);
    list[3] = pair<int, int>(ch - 1, cw);
    return list;
}

int main(void)
{
    int h, w;
    cin >> h >> w;
    vector<vector<char>> s(h + 2, vector<char>(w + 2, '#'));

    FOR(i,1,h+1){
        FOR(j,1,w+1){
            cin >> s[i][j];
        }
    }

    // FOR(i,0,h+2){
    //     FOR(j,0,w+2){
    //         cout << s[i][j];
    //     }
    //     cout << endl;
    // }

    //vector<vector<int>> maxdis(h + 2, vector<int>(w + 2, 0));

    int amax = 0;

    FOR(i,1,h+1){
        FOR(j,1,w+1){
            if(s[i][j] == '#'){
                continue;
            }
            queue<pair<int, int>> ta;
            ta.push(pair<int, int>(i, j));
            vector<vector<int>> dis(h + 2, vector<int>(w + 2, 0));
            vector<vector<int>> color(h + 2, vector<int>(w + 2, 0));
            color[i][j]++;
            while (!ta.empty())
            {
                pair<int, int> v = ta.front();
                int ch = v.first;
                int cw = v.second;
                ta.pop();
                vector<pair<int, int>> kin4 = kinbo4(ch, cw);
                REP(k,kin4.size()){
                    int nh = kin4[k].first;
                    int nw = kin4[k].second;
                    if(s[nh][nw] == '.' && color[nh][nw] == 0){
                        color[nh][nw] = 1;
                        dis[nh][nw] = dis[ch][cw] + 1;
                        ta.push(kin4[k]);
                    }
                }
            }

            //int amax = 0;
            FOR(k,1,h+1){
                FOR(m,1,w+1){
                    if(dis[k][m] > amax){
                        amax = dis[k][m];
                    }
                }
            }

            //maxdis[i][j] = amax;
        }
    }

    cout << amax << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N; cin >> N;
    vector<int> a(N+2, 0);
    for(int i=1; i<=N; ++i) cin >> a[i];

    ll sum = 0;
    for(int i=0; i<=N; ++i) sum += abs(a[i+1]-a[i]);

    for(int i=1; i<=N; ++i){
        cout << sum - abs(a[i-1]-a[i]) - abs(a[i+1]-a[i]) + abs(a[i+1]-a[i-1]) << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
n = int(input())
a = list(map(int,input().split()))
p =[0 for i in range(9)]
for i in a:
    if 1 <= i <= 399:
        p[0] = 1
    elif 400 <= i <= 799:
        p[1] = 1
    elif 800 <= i <= 1199:
        p[2] = 1
    elif 1200 <= i <= 1599:
        p[3] = 1
    elif 1600 <= i <= 1999:
        p[4] = 1
    elif 2000 <= i <= 2399:
        p[5] = 1
    elif 2400 <= i <= 2799:
        p[6] = 1
    elif 2800 <= i <= 3199:
        p[7] = 1
    elif 3200 <= i:
        p[8] += 1

cou = 0
for i in range(8):
    if p[i] == 1:
        cou += 1

if cou != 0:
    print(str(cou) + " " + str(cou + p[8]))
elif cou == 0:
    print(str(1) + " " + str(p[8]))

Measured memory_bytes: 3064
#include <cstdio>

int main(){
	int a, b, n, t1, t2, way[17][17];
	while(scanf("%d %d", &a, &b), a || b){
		scanf("%d", &n);
		for(int i = 1;i <= b;i++)
			for(int j = 1;j <= a;j++)way[i][j] = 0;
		for(int i = 0 ;i < n;i++)scanf("%d %d", &t1, &t2), way[t2][t1] = -1;
		for(int i = 1;i <= a;i++){if(way[1][i] == -1)break;way[1][i] = 1;}
		for(int i = 1;i <= b;i++){if(way[i][1] == -1)break;way[i][1] = 1;}
		for(int i = 2;i <= b;i++){
			for(int j = 2;j <= a;j++){
				if(way[i][j] != -1){
					int w = 0, h = 0;
					if(way[i][j-1] != -1)w = way[i][j-1];
					if(way[i-1][j] != -1)h = way[i-1][j];
					way[i][j] = w + h;
				}
			}
		}
		printf("%d\n", way[b][a]);
	}
	return 0;
}

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

class Program{
  static void Main(){
    int N = int.Parse(Console.ReadLine());
    long[] A = Console.ReadLine().Split(' ')
      .Select(x => long.Parse(x))
      .ToArray();
    
    int c_negative = 0; // 負の数の個数
    long min_abs = long.MaxValue; // 最も絶対値が小さい数（の絶対値）
    long sum = 0; //総和
    for (int i = 0; i < N; i++){
      min_abs = Math.Min(min_abs, Math.Abs(A[i]));
      sum += Math.Abs(A[i]);
      if (A[i] < 0)
        c_negative++;
    }
    
    if (c_negative % 2 == 1)
      sum -= min_abs * 2;
    Console.WriteLine(sum);
    
  }
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> A(N);
    vector<ll> B(N);
    vector<ll> C(N);

    REP(i, N){
        cin >> A[i];
    }
    REP(i, N){
        cin >> B[i];
    }
    REP(i, N){
        cin >> C[i];
    }

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

    ll ans = 0;
    REP(i, N){

        vector<ll>::iterator position1;  // auto position; で良い．
        ll id1;

        position1 = upper_bound(C.begin(), C.end(), B[i]);  // 3 を二分探索
        id1 = distance(C.begin(), position1);

        // B より後ろにある数
        ll t1 = N - id1;

        vector<ll>::iterator position2;  // auto position; で良い．
        ll id2;

        position2 = lower_bound(A.begin(), A.end(), B[i]);  // 3 を二分探索
        id2 = distance(A.begin(), position2);
        
        ll t2 = id2;

        ans += t1*t2;

    }

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

Measured memory_bytes: 5628
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
const int N = 50;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll k;
    cin >> k;
    cout << N << endl;
    for(int i = 0; i < N; i++) {
        if(i < N - 1 - (k - 1) % N) {
            cout << (k - 1) / N + i << " ";
        } else if(i == N - 1) {
            cout << (k - 1) / N + N << " ";
        } else {
            cout << (k - 1) / N + N - 1 << " ";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,sac[300009];
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a;
    for(b=2; b<=300000; b++){
        if(sac[b]==0){
            for(c=b*b; c<=300000; c+=b){
                sac[c]=1;
            }
        }
    }
    for(b=a; ; b++){
        if(sac[b]==0){
            cout<<b;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

ll f(ll b, ll n){
    if(n < b) return n;
    return f(b, n / b) + n % b;
}

signed main(){
    ll n,s;
    cin >> n >> s;
    if(n < s){
        cout << -1 << endl;
        return 0;
    }
    if(n == s){
        cout << n + 1 << endl;
        return 0;
    }
    for(ll b = 2; b * b <= n; b++){
        if(f(b, n) == s){
            cout << b << endl;
            return 0;
        }
    }
    for(ll p = sqrt(n); p > 0; p--){
        if((n - s) % p != 0) continue;
        ll b = (n - s) / p + 1;
        if(f(b, n) == s){
            cout << b << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    n = len(d)
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

def solve():
    N = II()
    edge_list = {}
    # i, j は 0 origin で入れる
    for i in range(N):
        edge_list[i] = []
        ei = SI()
        for j, e in enumerate(ei):
            if e == '1':
                edge_list[i].append(j)

    # 二部グラフチェック
    # -1, 1 をアサインしていく
    bip = [0 for i in range(N)]

    # キュー
    from collections import deque
    qu = deque()
    qu.append((-1, 0)) # 親のbip, nodeid。0はおやを-1と仮定する

    # 既読
    seen = set()
    is_bip = True


    while qu:
        parent_bip, n = qu.popleft()

        # 親と同じ側にアサインされているなら、bipではないので終了
        if parent_bip * bip[n] == 1:
            is_bip = False
            print(-1)
            return

        # 親と反対側にアサイン
        bip[n] = parent_bip * -1

        if n not in seen:
            for neib in edge_list[n]:
                qu.append((bip[n], neib))
        dprint('parent_bip:',parent_bip, 'n:', n, 'edge:', edge_list[n], 'q:', qu, seen)
        seen.add(n)

    dprint(bip)

    # bipなら直径
    mx = N + 1
    d = [[mx for i in range(N)] for i in range(N)]
    for i in range(N):
        for e in edge_list[i]:
            d[i][e] = 1
        d[i][i] = 0
    d = warshall_floyd(d)

    ans = 0
    for i in range(N):
        for j in range(N):
            ans = max(ans, d[i][j])

    dprint(d)

    print(ans+1)

solve()

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int,int> pii;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define error(x) cerr << #x << " = " << x << endl
#define sz(x) (int)(x).size()
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int INF = 1e9 + 7;
ll N;

int G(ll x) {
    int res = 0;
    while (x) ++res, x /= 10;
    return res;
}

int F(ll x, ll y) {
    return max(G(x), G(y));
}

int main(void) {
    ios_base::sync_with_stdio(0), cin.tie(nullptr);
    cin >> N;
    int res = INF;
    for (ll i = 1; i * i <= N; ++i) if (N%i == 0) {
        res = min(res, F(i, N/i));
    }
    cout << res << '\n';
    return 0;
}


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

int main(void) {
    int a, b;
    int sum;
    
    while(cin >> a >> b) {     //この条件文は重要！！
        sum = a + b;
        
        for(int i = 0; i < 7; ++i) {
            sum /= 10;
            if(sum == 0) {
                cout << i + 1 << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 3072
N = int(input().strip())
A = [input().strip() for i in range(N)]

print('AC x {}'.format(A.count('AC')))
print('WA x {}'.format(A.count('WA')))
print('TLE x {}'.format(A.count('TLE')))
print('RE x {}'.format(A.count('RE')))

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

using namespace std;

int main() {
	int a, b, c;
	set < int > s;
	scanf("%d %d %d", &a, &b, &c);
	s.insert(a);
	s.insert(b);
	s.insert(c);
	int cnt = s.size();
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 256
N = int(input())

s = set()

def solve(n):
    global s

    if n == N:
        return

    if len(s) == 0:
        s.add('a')
        solve(n+1)
    else:
        new_s = set()
        for v in s:
            xc = chr(ord(max(v))+1)
            for vc in v:
                new_s.add(v + vc)
                new_s.add(v + xc)
        s = new_s
        solve(n+1)

solve(0)
ans = sorted(s)
print(*ans, sep='\n')

Measured memory_bytes: 67932
#include<bits/stdc++.h>
#include<atcoder/math>
using namespace std;
using namespace atcoder;
int main(){
    int t;
    cin >> t;
    for(int i = 0; i < t; i++){
        int n, m, a, b;
        cin >> n >> m >> a >> b;
        cout << floor_sum(n, m, a, b) << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

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

int main(){
    int n;
    cin >> n;
    if ( n == 1 ) {
        cout << 1 << endl;
        return 0;
    }
    vector<ll> lim_num(n+1, 0);
    for ( int i = 1; i <= n; ++i ) {
        lim_num[i] = lim_num[i-1] + (ll)i;
    }
//    cout << lim_num[n] << endl;
    int num;
    vector<int> ans;
    for ( int i = n; i >= 1; --i ) {
//        cout << i << endl;
        if ( lim_num[i-1] < n - i ) {
            num = i + 1;
            break;
        }
    }
//    cout << num << endl;
    ans.push_back(num);
    int diff_num = lim_num[num-1] - ( n - num );
//    cout << num << " " << diff_num << " " << lim_num[num-1] << endl;
    for ( int i = 1; i <= num-1; ++i ) {
        if ( i == diff_num ) continue;
        ans.push_back(i);
    }
    for ( auto tmp_ans : ans ) {
        cout << tmp_ans << endl;;
    }
    return 0;
}


Measured memory_bytes: 78464
N, Y = map(int, input().split())
Y = Y / 1000

for i in range(N+1):
    for j in range(N-i+1):
        if 10*i + 5*j + N-i-j == Y:
            print("{} {} {}".format(i, j, N-i-j))
            exit()

print("-1 -1 -1")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL =LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

int im[31][200005];
int main() {
    int n,c;cin>>n>>c;
    rep(i,n){
        int s,t,d;cin>>s>>t>>d;
        s*=2;
        t*=2;
        im[d][s-1]++;
        im[d][t]--;
    }
    
    for(auto i = 1; i<200005; i++){
        rep(j,31){
            im[j][i] += im[j][i-1];
        }
    }
    
    int maxcom = 0;
    
    for(auto i = 1; i<200005; i++){
        int temp = 0;
        rep(j,31){
            temp += (im[j][i]>0);
        }
        maxcom = max(maxcom,temp);
    }
    
    cout<<maxcom<<endl;
    
    return 0;
}










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

int main(){
  int N,X;
  cin >> N >> X;
  
  vector<int> v(10010);
  vector<int> d(10010);
  
  d.at(0)=0;
  
  int count=0;
  
  for(int i=1;i<N+2;i++){
    cin >> v.at(i);
    d.at(i)=d.at(i-1)+v.at(i-1);
    if(d.at(i)<X+1){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 384
import math

from itertools import accumulate

def cumsum(a):
    return list(accumulate(a))

n,k = map(int, input().split())
if n == 1:
    print(1)
    exit()
mod = 10 ** 9 + 7
now = n
big = []
for i in range(2,int(math.sqrt(n)+2)):
    d = n // i
    big.append(now - d)
    now = d
big.reverse()
l = [1] * d + big
l2 = [1] * d + big
for i in range(k-1):
    a = cumsum(l)
    a.reverse()
    count = 0
    for i,j in zip(a,l2):
        l[count] = (i * j) % mod
        count += 1
l = cumsum(l)
ans = l[-1] % mod
print(ans)
    

Measured memory_bytes: 82672
#include <bits/stdc++.h>
using namespace std;
int N, K;
int ct[200000 + 10];
int main () {
  ios::sync_with_stdio(false);
  cin >> N >> K;
  for(int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    ct[a]++;
  }

  sort(ct, ct + N + 1);
  reverse(ct, ct + N + 1);
  int good = 0;
  for(int i = 0; i < K; ++i) good += ct[i];
  cout << N - good << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

ll dp[105][100010];

int main() {
    int n, w,a,b;
    cin >> n >> w;
    REP(i, n) {
        cin >> a >> b;
        REP(j, w) {
            if (i != 1) {
                int g = j - a;
                if (g >= 0)dp[i][j] = (dp[i - 1][j] < dp[i-1][j - a] + b) ? dp[i-1][j - a] + b : dp[i - 1][j];
                else dp[i][j] = dp[i - 1][j];
            }
            else dp[i][j] = (j >= a) ? b : 0;
        }
    }
    cout << dp[n][w] << endl;
    return 0;
}


Measured memory_bytes: 79360