akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007ll
#define mod1 998244353ll
#define endl "\n"
#define inf (ll)1e18+1
using namespace std::chrono;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    ll ar[n];
    for(ll x=0;x<n;x++){
        cin>>ar[x];
    }
    ll dp[n];
    dp[n-1]=0;
    dp[n-2]=abs(ar[n-1]-ar[n-2]);
    for(ll x=n-3;x>=0;x--){
        dp[x]=inf;
        for(ll y=1;y<=k;y++){
            if(x+y<=n-1){
                dp[x]=min(dp[x],abs(ar[x]-ar[x+y])+dp[x+y]);
            }else{
                break;
            }
        }
    }
    cout<<dp[0]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	int a,b,c,d,p,s,ss;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&p);
	s=a*p;
	if(c<p){
		ss=b+d*(p-c);
	}
	else{
		ss=b;
	}
	if(s<ss){
		printf("%d\n",s);
	}
	else{
		printf("%d\n",ss);
	}
	return 0;
}

Measured memory_bytes: 1024
s = gets.chomp

if s[0] != "A"
	puts "WA"
	exit
end

if s[2..-2].count("C") != 1
	puts "WA"
	exit
end

a = s.split("")
a.size.times do |i|
	next if i == 0
	if a[i] != "C"
		unless "a" <= a[i] && a[i] <= "z"
			puts "WA"
			exit
		end
	end
end

puts "AC"



Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }

int main()
{
    int n, k, r, s, p;
    cin >> n >> k;
    vector<int> rsp(3);
    cin >> rsp[0] >> rsp[1] >> rsp[2];
    string t;
    cin >> t;
    vector<int> pnt(n);
    rep(i,n) {
        if (t[i] == 'r') pnt[i] = 2;
        else if (t[i] == 's') pnt[i] = 0;
        else if (t[i] == 'p') pnt[i] = 1;
    }
    int ans = 0;
    rep(i,k) {
        int res = rsp[pnt[i]], prev = pnt[i];
        for (int id = i + k; id < n; id += k) {
            if (pnt[id] != prev) {
                res += rsp[pnt[id]];
                prev = pnt[id];
            } else if (id + k < n) {
                if (prev != pnt[id+k]) {
                    prev = 3 - prev - pnt[id+k];
                } else{
                    prev = (prev + 1) % 3;
                }
            }
        }
        ans += res;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 896
// Problem : A - Don't be late
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

///Astalavista Code........~boy_with_no_gf
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout<<endl
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (x) << endl
#define PTT(x) cout << (#x) << " is " << (x) << endl
#define lets_go ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
const int N = 2e6 + 10;
const int IM = 1e15 + 37;
const double PI = 3.1415926535897932384;
inline void PP(int n) { cout << n << " ";}
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " " ; cout << endl;}
void PVV(vii v) {for (int i = 0 ; i < v.size() ; i++) cout << v[i].first << " " << v[i].second << endl;}
void PA(int v[], int n, int x = 0) { for (int i = x ; i < n + x; i++)cout << v[i] << ' ' ; cout << endl;}
void IN(int a[], int n, int x = 0) {for (int i = x; i < n + x; i++)cin >> a[i];}

// <=================================================================================================================================
// <=================================================================================================================================

void fun(){
	int a,b,c;cin>>a>>b>>c;
	double ans=(double)a/c;
	if(ans<=b)
		cout<<"Yes";
	else
		cout<<"No";
}

signed  main() {
    lets_go

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

    fun();

    }



    return 0;

}


Measured memory_bytes: 3648
#include <iostream>
#include <cmath>


bool isSquare(int num){

	int sqrt = (int)(std::sqrt((double)num) + 0.5);
	return num == (sqrt * sqrt);
}


int main(void){

	int a, b;
	std::cin >> a >> b;

	// 動かす桁を求める
	int tmp = b;
	int digit = 10;
	while( (tmp / 10) != 0){
		tmp /= 10;
		digit *= 10;
	}

	a = (a * digit) + b;

	std::cout << (isSquare(a) ? "Yes" : "No") << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

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

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    vector<vector<ll>> dp(45, vector<ll>(2, -1));
    dp[44][0] = 0;
    for (int i = 43; i >= 0; --i) {
        ll cnt = 0;
        rep(j, n) {
            //cout << (1LL<<i) << endl;
            if (a[j] & (1LL<<i)) {
                //cout << a[j] << endl;
                ++cnt;
            }
        }
        //cout << i << " " << cnt << endl;
        if (dp[i+1][0] >= 0) {
            if (k & (1LL<<i)) {
                dp[i][0] = max(dp[i][0], dp[i+1][0] + (n - cnt) * (1LL<<i));
                dp[i][1] = max(dp[i][1], dp[i+1][0] + cnt * (1LL<<i));
            }
            else {
                dp[i][0] = max(dp[i][0], dp[i+1][0] + cnt * (1LL<<i));
            }
        }
        if (dp[i+1][1] >= 0) {
            dp[i][1] = max(dp[i][1], dp[i+1][1] + max(cnt, n-cnt) * (1LL<<i));
        }
    }
    //for (int i = 44; i >= 0; --i) {
    //    cout << dp[i][0] << " " << dp[i][1] << endl;
    //}
    cout << max(dp[0][0], dp[0][1]) << endl;
    return 0;
}


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

using namespace std;

long long ans = 1e15;
int main(){
	long long n;
	cin >> n;
	for(long long  i = 1; i * i <= n; i++){
		if(n % i == 0){
			long long  temp = i + (n / i);
			long long sum = temp - 2;
			ans = min(ans,sum);
		}
	}
	cout << ans << endl;
}

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

int main(){
	int A,B,C,D;
	cin >> A >> B >> C >> D;
	bool flag=true;
	while(1){
		if(flag)C-=B;
		else A-=D;
		if(C<=0){
			cout << "Yes" << endl;
			return 0;
		}
		if(A<=0){
			cout << "No" << endl;
			return 0;
		}
		flag=(!flag);
	}
	return 0;
}

Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

ll rec(string s) {
	ll n = s.size();
	if (s[1] != '[') {
		string t = s.substr(1, n - 2);
		return (stol(t) / 2 + 1);
	}
	ll ans = 0, cnt = 0; // 和
	vector<ll> a;
	string tmp = "";
	int state  = 0;
	for (int i = 1; i < n - 1; i++) {
		if (s[i] == '[' && state == 0) {
			tmp = "[";
			cnt++;
			state++;
		} else if (s[i] == ']' && state == 1) {
			tmp = tmp + s[i];
			a.push_back(rec(tmp));
			state--;
		} else {
			tmp = tmp + s[i];
			if (s[i] == '[') state++;
			if (s[i] == ']') state--;
		}
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < cnt / 2 + 1; i++) {
		ans += a[i];
		//dump(a[i]);
	}

	return ans;
}

int main() {
	IOS;
	ll n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		dump(rec(s));
	}
	return 0;
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
int main()
{
    using ll = long long;
    int n;
    cin >> n;
    vector<ll> x(n);
    vector<ll> y(n);
    vector<ll> h(n);
    for(int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i] >> h[i];
    }
    for(int i = 0; i <= 100; i++)
    {
        for(int j = 0; j <= 100; j++)
        {
            ll hp = -1;
            ll mhp = 1000000000000;
            bool flag = true;
            for(int k = 0; k < n; k++)
            {
                ll dx = abs(i - x[k]);
                ll dy = abs(j - y[k]);
                if(h[k] == 0)
                {
                  mhp = min(mhp, dx + dy);
                  continue;
                }
                if(hp == -1)
                {
                    hp = h[k] + dx + dy;
                }

                if(hp != dx + dy + h[k])
                {
                    flag = false;
                    break;
                }
            }
            if(flag && mhp >= hp)
            {
                cout << i << " " << j << " " << hp << endl;
                return 0;
            }
        }
    }
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	char a[8][9];
	int i, j;
	int x[4];
	int y[4];
	int num;

	while(1){
		num = 0;
		for(i=0; i<8; i++){
			if(scanf("%s", a[i]) == EOF) return 0;
		}
		for(i=0; i<8; i++){
			for(j=0; j<8; j++){
				if(a[i][j] == '1'){
					x[num] = j;
					y[num] = i;
					num++;
				}
			}
		}
		if(x[0] == x[1] && x[1] == x[2] && x[2] == x[3]) puts("B");
		else if(y[0] == y[1] && y[1] == y[2] && y[2] == y[3]) puts("C");
		else if(x[0] == x[2] && x[1] == x[3] && y[0] == y[1] && y[2] == y[3]) puts("A");
		else if(x[0] == x[2] && x[1] == x[3] && y[1] == y[2] && y[0] < y[3] && x[0] > x[3]) puts("D");
		else if(x[1] == x[2] && y[0] == y[1] && y[2] == y[3] && x[0] < x[2] && y[0] < y[3]) puts("E");
		else if(x[0] == x[1] && x[2] == x[3] && y[1] == y[2] && y[0] < y[3] && x[0] < x[3]) puts("F");
		else if(x[0] == x[3] && x[1] > x[2] && y[0] == y[1] && y[2] == y[3] && y[1] < y[2]) puts("G");
	}

	return 0;

}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdio>
#include<map>
using namespace std;

int N,W,V[100];

void solve(){
    int ma=0,t=0;
    for(int i=0;i<N;i++)ma=max(ma,V[i]/W);
    vector<int>cnt(ma+1,0);

    for(int i=0;i<N;i++){
        cnt[V[i]/W]++;
        t=max(cnt[V[i]/W],t);
    }
    double ans=0.01;

    for(int i=0;i<=ma;i++){
        double d=1.0*cnt[i]/t;
        d*=1.0*(ma-i)/(ma);
        ans+=d;
    }

    printf("%lf\n",ans);
}
int main(){
    while(scanf("%d%d",&N,&W),N||W){
        for(int i=0;i<N;i++)scanf("%d",&V[i]);
        solve();
    }
    return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second

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;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

template <class T>
T gcd(T a,T b) {
	if (b==0) return a;
	else return gcd(b,a%b);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,X;
	cin>>n>>X;
	vector<int> x(n);
	rep(i,n){
		cin>>x[i];
	}
	x.push_back(X);
	sort(begin(x),end(x));
	int ans=x[1]-x[0];
	rep(i,x.size()-1){
		ans=gcd(ans,x[i+1]-x[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<unordered_map>
/*
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*    ▀▀       ▀▀▀▀▀▀    ▀     ▀▀▀▀▀▀      ▀    ▀
*   ▀  ▀      ▀         ▀     ▀            ▀  ▀
*  ▀    ▀     ▀ ▀ ▀     ▀     ▀ ▀ ▀         ▀
* ▀ ▀▀▀▀ ▀    ▀         ▀     ▀             ▀
*▀        ▀   ▀         ▀     ▀             ▀
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*/
using namespace std;
void afify()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
#define ll long long
#define ld long double
#define mk make_pair
#define loop(i,intial,n)  for(int i=int(intial);i<n;i++)
#define loopn(j,n) for(int j=int(n);j>=0;j--)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(v) v.begin(),v.end()
///////////////////////////////////////
#define SCD(a) scanf("%d",&a)
#define SCD2(a,b) scanf("%d %d",&a,&b)
#define SCLL(a) scanf("%lld",&a)
#define SCLL2(a,b) scanf("%lld %lld",&a,&b)
#define PRD(a) printf("%d\n",a)
#define PRLL(a) printf("%lld\n",a)
///////////////////////////////////////
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vi> vvi;
typedef vector <vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<vpii> vvpii;
typedef stringstream ss;
const ll oo = (ll) 10e9+7;
const double EPS = 1e-4;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
//ifstream ifs("input.txt");
//ofstream ofs("output.txt");

int main()
{
    afify(); 
	int a,b;
	cin>>a>>b;
	if(a+b>=10){
		cout<<"error"<<endl;
	}
	else cout<<a+b<<endl;
	return 0; 
 
} 

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>
#include <bitset>

using namespace std;

//http://www9.plala.or.jp/sgwr-t/c/sec14.html
//https://qiita.com/drken/items/7c6ff2aa4d8fce1c9361
//http://drken1215.hatenablog.com/entry/2018/08/05/224100

vector<long long> p;
vector<long long> c;

int main() {
	//input
	int d, g = 0;
	cin >> d >> g;
	for (int i = 0; i < d; ++i) {
		int tmp1, tmp2 = 0;
		cin >> tmp1 >> tmp2;
		p.push_back(tmp1);
		c.push_back(tmp2);
	}

	//各点数項目について完全回答にする場合としない場合を列挙する(d~2通りあり得る)
	long long ans = 9999999999999999; //答え

	for (int maskbit = 0; maskbit < (1 << d); ++maskbit) {//全完かどうかのmaskbit
		long long score = 0; //点数
		long long num = 0; //カウンタ
		for (int j = 0; j < d; ++j) {//☆右から数える(0,1)なら先に1が立ってる方を見ていることに
			if (maskbit & (1 << j)) {// bit の i 番目のフラグが立っているかどうか
				score = score + c.at(j) + 100 * (j + 1) * p.at(j);
				num = num + p.at(j);
			}
		}
		if (score >= g) {
			ans = min(num, ans);//点数が目標点を超えていたら最小回答数の更新チェック
		}
		else {
			for (int i = d - 1; i >= 0; --i) {//得点の種類数で降順にループ(i)⇒☆高い点数から足していくため
				if (maskbit & (1 << i)) {// bit に i 番目のフラグが立っているなら以下の処理をスキップ
					continue;
				}
				for (int j = 0; j < p.at(i); ++j) {//その得点種の数でループ(j)
					if (score >= g) {
						break;//合計点が目標を越えたらループを抜ける
					}
					score = score + 100 * (i + 1);
					num = num + 1;
				}			
			}
			ans = min(num, ans);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7,MAX = 1e5;

int main()
{
	ll n;
	string s,t;
	cin >> s;
	n = s.size();
	s.push_back('A');
	for(ll i = 0;i<n;i++)
	{
		if(s[i]=='B'&&s[i+1]=='C')
		{
			t.push_back('D');
			i++;
		}
		else
		{
			if(i<n)t.push_back(s[i]);
		}		
	}
	ll m = t.size();

	ll cnta = 0,cntd = 0;
	ll ans = 0;
	for(ll i = 0;i<m;i++)
	{
		if(t[i]=='C'||t[i]=='B')
		{
			cnta = 0;cntd = 0;
		}
		else if(t[i]=='A')
		{
			cnta++;
		}
		else if(t[i]=='D')
		{
			ans += cnta;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加

ll mod = 1e9+7;
  
// 検索タグ
int main() {
	// 入力
	ll H, W;cin>>H>>W;
	
    
	// 解法
	ll ans;
	if (H==1) ans = 1;
	else if (W==1) ans = 1;
	else if (H%2==0) ans = (H/2)*W;
	else if (W%2==0) ans = (W/2)*H;
	else ans = (H/2)*W + W/2+(ll)1;
	cout<<ans<<endl;
	// printf("%lld\n", ans);
}


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

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

  string t0;
  cout << "? ";
  for (int i = 0; i < n; i++) cout << i + 1 << ' ';
  cout << endl;
  cin >> t0;

  int l = 0, r = n;
  while (l + 1 < r) {
    int m = l + (r - l) / 2;
    cout << "? ";
    for (int i = 0; i < n; i++) cout << m + i + 1 << ' ';
    cout << endl;
    string t;
    cin >> t;
    if (t == t0) {
      l = m;
    } else {
      r = m;
    }
  }

  string c(2 * n, '.');
  for (int i = 0; i < 2 * n; i++) {
    cout << "? " << i + 1 << ' ';
    if (l <= i && i < l + n) {
      for (int j = 0; j < n - 1; j++) cout << ((l + n + 1) + j) % (2 * n) + 1 << ' ';
    } else {
      for (int j = 0; j < n - 1; j++) cout << (l + 1) + j + 1 << ' ';
    }
    cout << endl;
    string t;
    cin >> t;
    c[i] = "BR"[t[0] == 'R'];
  }
  cout << "! " << c << endl;
}


Measured memory_bytes: 724
#include<iostream>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int A[2*N], tmp=0;
  for(int i=0; i<2*N; i++){
    cin >> A[i];
  }
  for(int j=1; j<2*N; j++){
    for(int k=0; k<j+1; k++){
      if(A[j] > A[k]){
        int tmp = A[k];
        A[k] = A[j];
        A[j] = tmp;
      }
    }
  }
  int count = 0;
  int a=1;
  while(a<2*N){
    count += A[a];
    a = a+2;
  }
  cout << count;
  return 0;
}

    
  
  

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        int s[][] = new int[h + 2][w + 2];
        Queue<Pair> que = new ArrayDeque<>();
        for (int i = 1; i <= h; i++) {
            char c[] = sc.next().toCharArray();
            for (int j = 1; j <= w; j++) {
                if (c[j - 1] == '.') {
                    s[i][j] = -1;
                } else {
                    que.add(new Pair(i, j));
                }

            }
        }
        sc.close();

        Pair p;
        int ans = 0;
        while (!que.isEmpty()) {
            p = que.poll();
            ans = s[p.x][p.y];
            if (s[p.x + 1][p.y] == -1) {
                s[p.x + 1][p.y] = ans + 1;
                que.add(new Pair(p.x + 1, p.y));
            }
            if (s[p.x - 1][p.y] == -1) {
                s[p.x - 1][p.y] = ans + 1;
                que.add(new Pair(p.x - 1, p.y));
            }
            if (s[p.x][p.y + 1] == -1) {
                s[p.x][p.y + 1] = ans + 1;
                que.add(new Pair(p.x, p.y + 1));
            }
            if (s[p.x][p.y - 1] == -1) {
                s[p.x][p.y - 1] = ans + 1;
                que.add(new Pair(p.x, p.y - 1));
            }
        }
        System.out.println(ans);
    }
}

class Pair {
    int x;
    int y;

    public Pair(int x, int y) {
        this.x = x;
        this.y = y;
    }
}

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

int main() {
	long long int ans[4];
	long long int a, b, c, d;
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	
	

	
	if (a * c > a * d && a * c > b * c && a * c > b * d) {
		printf("%lld\n", a * c);
	}
	else if(a * d > a * c && a * d > b * c && a * d > b * d) {
		printf("%lld\n", a * d);
	}
	else if (b * c > a * d && b * c > a * c && b * c > b * d) {
		printf("%lld\n",  b*c);
	}
	else {
		printf("%lld\n", b * d);
	}


	return 0;
}

Measured memory_bytes: 1736
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

P v[100100];
ll a[100100],b[100100];
int p[100100],q[100100],ufr[100100],ufp[100100];

void ufinit(int n){
	int i;
	for(i=0; i<n; ++i){
		ufr[i] = 1;
		ufp[i] = i;
	}
}

int ufind(int x){
	if(ufp[x]==x){
		return x;
	}
	return ufp[x] = ufind(ufp[x]);
}

bool unionf(int x, int y){
	x = ufind(x);
	y = ufind(y);
	if(x==y){
		return false;
	}
	if(ufr[x]<ufr[y]){
		swap(x,y);
	}
	ufr[x] += ufr[y];
	ufp[y] = x;
	return true;
}

int main(void){
	int n,i,t=0;
	cin >> n;
	ufinit(n);
	for(i=0; i<n; ++i){
		cin >> a[i];
		v[i].second = a[i];
	}
	for(i=0; i<n; ++i){
		cin >> b[i];
		v[i].first = b[i];
	}
	sort(v,v+n);
	sort(b,b+n);
	for(i=0; i<n; ++i){
		a[i] = v[i].second;
	}
	for(i=0; i<n; ++i){
		v[i].first = a[i];
		v[i].second = i;
	}
	sort(v,v+n);
	for(i=0; i<n; ++i){
		p[i] = v[i].second;
	}
	for(i=0; i<n; ++i){
		unionf(i,p[i]);
		if(a[p[i]]>b[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	for(i=0; i<n; ++i){
		if(ufind(i)==i){
			++t;
		}
	}
	if(t>1){
		cout << "Yes" << endl;
		return 0;
	}
	for(i=1; i<n; ++i){
		if(a[p[i]]>b[i-1]){
			continue;
		}
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 4480
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u){
  int i, c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if( T[u].p == NIL ) cout << "root, ";
  else if( T[u].l == NIL) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";

    for(i = 0, c = T[u].l; c != NIL; i++, c = T[c].r){
      if(i) cout << ", ";
      cout << c;
    }
  cout << "]" << endl;
}

int rec(int u, int p){
  D[u] = p;
  if( T[u].r != NIL ) rec(T[u].r, p);
  if( T[u].l != NIL ) rec(T[u].l,p + 1);
}

int main(){
  int i, j, d, v, c , l, r;
  cin >> n;
  for(i = 0; i < n; i++)  T[i].p = T[i].l = T[i].r = NIL;

  for( i = 0; i < n; i++){
    cin >> v >> d;
    for(j = 0; j < d; j++){
      cin >> c;
      if( j == 0) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  for(i = 0; i < n; i++){
    if(T[i].p == NIL) r = i;
  }
  
  rec(r, 0);

  for(i = 0; i < n; i++) print(i);

  return 0;
}
    



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

using ll = long long;
using ull = unsigned long long;
constexpr ll mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;

using namespace std;
vector<int> ran(int d){
    vector<int> ret(d);
    std::random_device rnd{};
    std::mt19937 mt(rnd());
    std::uniform_int_distribution<> rand26(0, 25);    
    for(int i=0;i<d;++i){
        ret[i] = rand26(mt);
    }
    return ret;
}
vector<int> yuu(int d,vector<int> &c){
    vector<int> ret(d);
    vector<pair<int,int>> p;
    for(int i=0;i<26;++i){
        p.push_back({c[i],i});
    }
    sort(p.rbegin(),p.rend());
    for(int i=0;i<d;++i){
        ret[d-i-1] = p[i].second;
    }
    return ret;
}
int score(int d,vector<int> r,vector<int> c,vector<vector<int>> s){
    int sum = 0;
    vector<int> last(26);
    for(int i=0;i<d;++i){
        sum += s[i][r[i]];
        last[r[i]] = i+1;
    }
    for(int i=0;i<26;++i){
        sum -= c[i]*(d-last[i]);
    }
    return sum;
}
int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int d;
    cin>>d;
    vector<int> c(26);
    vector<vector<int>> s(d,vector<int>(26));
    for(auto & a : c) cin>>a;
    for(int i=0;i<d;++i){
        for(int j=0;j<26;++j){
            cin>>s[i][j];
        }
    }
    auto randomver = ran(d);
    auto yuuver = yuu(d,c);
    vector<int> ret;
    if(score(d,randomver,c,s) > score(d,yuuver,c,s)){
        ret = randomver;
    }else ret = yuuver;
    for(int i=0;i<d;++i){
        cout << ret[i]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3788
N, Ma, Mb = map(int,input().split())
L = []
for _ in range(N):
    L.append( list(map(int,input().split())) )
dp = [[[10**10 for _ in range(601)] for _ in range(601)] for _ in range(N+10)]
dp[0][0][0] = 0

for l in range(N):
    for i in range(200):
        for j in range(200):
            dp[l+1][i][j] = min(dp[l+1][i][j],dp[l][i][j])
            dp[l+1][i+L[l][0]][j+L[l][1]] = min(dp[l+1][i+L[l][0]][j+L[l][1]],dp[l][i][j] + L[l][2])


ans = 10**10
for i in range(1,10000):
    try: ans = min(ans, dp[N][Ma*i][Mb*i])
    except: pass
if ans == 10**10: print(-1)
else: print(ans)





Measured memory_bytes: 236920
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<Integer> list = new ArrayList<Integer>();
		while(scan.hasNext()){
			int a = scan.nextInt();
			int b = scan.nextInt();
			int c = a + b;
			String sNum = String.valueOf(c);
			int len = sNum.length();
			list.add(len);
		}
		for(int n : list){
			System.out.printf("%d\n", n);
		}
	}
}

Measured memory_bytes: 26212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[1000];
int main()
{
  ll n,k,sum=0;
  cin>>n>>k;
  for(ll i=0;i<n;i++)
   cin>>a[i];
  sort(a,a+n);
  for(ll i=0;i<k;i++)
    sum+=a[i];
    cout<<sum;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int val=((n+999)/1000)*1000;
    val=val-n;
    printf("%d\n",val);
    return 0;
}

Measured memory_bytes: 3812
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Convert.ToUInt64(Console.ReadLine());
            UInt64 sum = 0;

            for (UInt64 i = 0; i <= input; i++)
            {
                if (i % 15 != 0 && i % 5 != 0 && i % 3 != 0)
                {
                    sum += i;
                }
            }

            Console.WriteLine(sum);
            Console.Read();
        }
    }
}


Measured memory_bytes: 27560
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

ll act[100005][3],dp[100005][3];

ll f(ll x,ll y){
	if(x==-1){
		return 0;
	}
	if(dp[x][y]>=0)return dp[x][y];
	dp[x][y]=max(f(x-1,(y+1)%3),f(x-1,(y+2)%3))+act[x][y];
	return dp[x][y];
}

int main(){FIN;
	ll n; cin>>n;
	fore(i,0,n){
		fore(j,0,3){
			cin>>act[i][j];
		}
	}
	memset(dp,-1,sizeof dp);
	cout<<max(max(f(n-1,0),f(n-1,1)),f(n-1,2));
	
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
const int N = 15;

int a[N][N];
int c[N];

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    for(int i = 0; i < n; i ++){
        cin >> c[i];
        for(int j = 1; j <= m; j ++)
            cin >> a[i][j];
    }
    int ans = 1e9;
    for(int i = 0; i < 1 << n; i ++){
        int b[N];
        memset(b, 0, sizeof b);
        int tmp = 0;
        for(int j = 0; j < n; j ++){
            if((i >> j) & 1){
                tmp += c[j];
                for(int k = 1; k <= m; k ++)
                    b[k] += a[j][k];                
            }
        }

        // printf("i = %d tmp = %d\n", i, tmp);
        // for(int j = 1; j <= m; j ++)
        //     printf("%d ", b[j]);
        // printf("--------------------------------\n");

        int mark = 1;
        for(int j = 1; j <= m; j ++)
            if(b[j] < x){
                mark = 0;
                break;
            }
        if(mark) ans = min(ans, tmp);
    }
    if(ans == 1e9) puts("-1");
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
from collections import deque
from bisect import bisect_left
inf = float('inf')


N = int(input())
A = [int(input()) for _ in range(N)]

color = deque()
color.appendleft(A[0])

for a in A[1:]:
    pos = bisect_left(color, a)
    if pos == 0:
        color.appendleft(a)
    else:
        color[pos-1] = a

ans = len(color)
print(ans)

Measured memory_bytes: 8828
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long int LL;
typedef vector<LL> VL;
#define SMAX 100001
#define MOD 1000000007

int main() {
  LL N, X;
  cin >> N >> X;
  VL S;
  REP(i, N) {
    int s;
    cin >> s;
    S.push_back(s);
  }
  sort(S.begin(), S.end(), greater<LL>());
  
  LL C[SMAX] = {};
  C[X] = 1;
  REP(i, N) {
    int tS = S[i];
    LL nC[SMAX] = {};
    REP(j, SMAX) {
      nC[j%tS] += C[j];
      nC[j] += C[j] * (N - i - 1);
    }
    REP(j, SMAX) {
      C[j] = nC[j] % MOD;
    }
  }
  LL sum = 0;
  REP(i, SMAX) {
    sum += C[i] * i;
    sum %= MOD;
  }
  cout << sum << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int> R(n);
  for(int i=0; i<n; i++){
      cin >> R.at(i);
  }
  int maxv=-2000000000;
  int minv=R.at(0);

  for(int i=1; i<n; i++){
    maxv=max(maxv,R.at(i)-minv);
    minv=min(minv,R.at(i));
  }

  cout << maxv << endl;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
ll a,b,ans=0;
int main()
{
	cin>>a>>b;
	rep2(i,b,a+2)
	{
		ans+=i*(a+1-i)+1;
	}
	ans%=1000000007;
	re(ans);
	return 0;}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

string s[2];

int main() {
	cin >> s[0] >> s[1];
	REP(i, s[0].size()) {
		cout << s[0][i];
		if (i != s[1].size())cout << s[1][i];
	}
	cout << endl;
}

Measured memory_bytes: 256
//
//  main.cpp
//  Candy_Distribution_Again
//
//  Created by Uttam Datta on 02/06/19.
//  Copyright © 2019 Uttam Datta. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector <int> A;
int N,sweets;

int ans(){
    sort(A.begin(), A.end());
    int temp = 0, res = 0;
    while(temp < N && sweets >= 0){
        sweets -= A[temp];
        if(sweets >= 0){
            res++;
            temp++;
        }
    }
    if(sweets > 0){
        return res-1;
    }
    else{
        return res;
    }
}

int main(){
    cin >> N >> sweets;
    A.clear();
    A.resize(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    cout << ans() << endl;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            var sc = new Scanner();

            int N = sc.NextInt();
            int M = sc.NextInt();
            var L = new int[M];
            var R = new int[M];
            for (int i = 0; i < M; i++)
            {
                L[i] = sc.NextInt();
                R[i] = sc.NextInt();
            }

            Console.WriteLine(Math.Max(0, R.Min() - L.Max() + 1));
        }
    }
}




class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private readonly StreamReader _stream;
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}


Measured memory_bytes: 15948
#ABC122C
def main():
    import sys, re
    N, Q = map(int, sys.stdin.readline().split())
    S = sys.stdin.readline().rstrip()
    L = [tuple(map(int, sys.stdin.readline().split())) for _ in range(Q)]
    #print(S)
    #累積和
    W = [0 for _ in range(N+1)]
    for m in re.finditer('AC', S):
        W[m.span()[1]] = 1
    for i in range(N):
        W[i+1] += W[i]
    #print(W)
    for i in range(Q):
        print(W[L[i][1]]-W[L[i][0]])

if __name__ == '__main__':
    main()

Measured memory_bytes: 21548
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    if(N/10 == 9 || N%10 == 9) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

#define MAX_LEN 1200

int main()
{
	std::string input;
	std::getline(std::cin, input);
	
	for (int i = 0; i < input.length(); i++)
	{
		char c = input[i];

		if (islower(c) > 0)
		{
			std::cout << (char)toupper(c);
		}
		else if (isupper(c) > 0)
		{
			std::cout << (char)tolower(c);
		}
		else
		{
			std::cout << c;
		}
	}	
	std::cout<<std::endl;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long int in, cnt = 0,k;
	bool flag = true;
	cin >> in;
	for (long long int i = 0; i < in; i++)
	{
		cin >> k;
		if (i + 1 != k)cnt++;
	}
	(cnt <= 2)?cout << "YES"<<endl:cout << "NO"<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<atcoder/all>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;

using mint = modint998244353;
/*
template<class T>
struct optional {
    bool valid;
    T x;
    operator bool() {return valid;}
    optional(const T& x): valid(true), x(x) {}
    optional(): valid(false) {}
    T& value() {return x;}
};
*/
template <class S,
          S (*op)(S, S),
          class F,
          F (*composition)(F, F),
          S (*mapping)(F, S)>
class lazy_lazy_segtree {
    template<class T, T (*f)(T, T)>
    static optional<T> funcmap(optional<T> x, optional<T> y) {
        if (!x) return y;
        if (!y) return x;
        return f(x.value(), y.value());
    }
    template<class T>
    static optional<T> idfunc() { return {};};
    static optional<S> optional_mapping(optional<F> f, optional<S> s) {
        if (f && s) {
            return mapping(f.value(), s.value());
        } else {
            return s;
        }
    }
public:
    lazy_segtree<optional<S>,funcmap<S, op>,idfunc<S>,optional<F>,optional_mapping,funcmap<F, composition>,idfunc<F>> seg;
    lazy_lazy_segtree() : lazy_lazy_segtree(0) {}
    lazy_lazy_segtree(int n) : seg(std::vector<optional<S>>(n)) {}
    lazy_lazy_segtree(const std::vector<S>& v) : seg(std::vector<optional<S>>(v.begin(),v.end())) {}
    void set(int p, S x) {seg.set(p, x);}
    S get(int p) {
        auto x = seg.get(p);
        return x ? x.value() : S();
    }
    S prod(int l, int r) {
        auto x = seg.prod(l, r);
        return x ? x.value() : S();
    }
    S all_prod() {
        auto x = seg.all_prod();
        return x ? x.value() : S();
    }
    void apply(int p, F f) {seg.apply(p, f);}
    void apply(int l, int r, F f) {seg.apply(l, r, f);}
    template<bool (*g)(S)> bool map_g(optional<S> x) {return x ? g(x.value()) : true;}
    template <bool (*g)(S)> int max_right(int l) {return seg.max_right<map_g<g>>(l);}
    template <class G> int max_right(int l, G g) {return seg.max_right(l, [&g](optional<S> x){return x ? g(x) : true;});}
    template <bool (*g)(S)> int min_left(int r) {return seg.min_left<map_g<g>>(r);}
    template <class G> int min_left(int r, G g) {return seg.min_left(r, [&g](optional<S> x){return x ? g(x) : true;});}
};



struct S {
    mint x, w;
};
S op(S l, S r) {return {l.x * r.w + r.x, l.w * r.w};}
using F = int;
F composition(F l, F r) { return l;}
mint inv9 = mint(1) / 9;
S mapping(F l, S r) { return {(r.w - 1) * inv9 * l, r.w};}

int main() {
    int n, q;
    cin >> n >> q;
    lazy_lazy_segtree<S, op, F, composition, mapping> seg(vector<S>(n, {1, 10}));
    while(q--) {
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        seg.apply(l, r, d);
        cout << seg.all_prod().x.val() << endl;
    }
}

Measured memory_bytes: 15364
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int sum(int n,int m){
    return n+m;
}
int dif(int n,int m){
    return n-m;
}

int a[4];
int n;
int main() {
    cin >> n;
    REP(i,4){
        a[3-i] = n - n/10*10;
        n/=10;
    }
    int x[3][8] = {{0,0,0,0,1,1,1,1},{0,1,0,1,0,1,0,1},{0,0,1,1,0,0,1,1}};
    int cal;
    REP(i,8){
        cal = a[0];
        REP(j,3){
            if(x[j][i]==0){
                cal += a[j+1];
            }else{
                cal -= a[j+1];
            }
        }
        if(cal==7){
            string s;
            REP(k,4){
                s += to_string(a[k]);
                if(k<3){
                    if(x[k][i]==0){
                        s += '+';
                    }else{
                        s += '-';
                    }
                }
            }
            s += "=7";
            put(s);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long, long long>
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define MAXN 10000057
#define mod 998244353
#define fr(i, s, e, st) for(ll (i) = (s); (i) < (e); (i) += (st))
#define fre(i, s, e, st) for(ll (i) = (s); (i) <= (e); (i) += (st))
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);

using namespace std;

int main()
{
    fastio;
    ll T = 1;
    //cin >> T;
    //sieve();
    while (T--)
    {
        ll a,b;
        cin>>a>>b;
        cout<<a*(a-1)/2 + b*(b-1)/2<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
#define MODSIZE 1000000007
priority_queue<int, vector<int>, greater<int> > PQ; // 昇順PQ
// priority_queue<int> PQ;

  ll a[1000006];

int main(){
  ll n;
  ll ans = 0;

  scanf("%lld", &n);

  if(n == 1){
    printf("0\n");
    return 0;
  }

  ll i,j;
  ll t;
  ll z = n;
  ll sp = 0;
  for(i = 2;i*i <= z;i++){
    t = i;
    if(z % i == 0){
    while(z % i == 0){
      z /= i;
      a[sp]++;
    }
    sp++;
  }
  }

  if(z != 1) {
    a[sp]++;
    sp++;
  }
  
  for(i = 0;i < sp;i++){
    j = 1;
    while(a[i] >= j){
      ans++;
      a[i] -= j;
      j++;
    }
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 3832
#include<stdio.h>
#include<stdlib.h>
#define N 500000
#define SENTINEL 1000000000
 
void mergesort( int,int);
void merge(int,int,int);
 
int A[N],count=0;
main(){
  int left,right,mid,i,n;
  scanf("%d",&n);
  left = 0;
  right = n;
  mid = (left + right)/2;
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }
  mergesort(left,mid);  
  mergesort(mid,right);
  merge(left,mid,right);
  for(i=0;i<n;i++)
    {
      printf("%d",A[i]);
      if(i == n-1)break;
      printf(" ");
    }
  printf("\n%d\n",count);
  return 0;
}
 
void mergesort(int l,int r ){
  int m;
  if(l+1<r)
    {
      m = (l + r)/2;
      mergesort(l,m);
      mergesort(m,r);
      merge(l,m,r);
    }
}
 
 
void merge(int l,int m,int r){
  int n1,n2,k,j,i;
  int *L,*R;
  n1 = m - l;
  n2 = r - m;
  L = malloc(sizeof(int)*(n1+1));
  R = malloc(sizeof(int)*(n2+1));
  for(i=0;i<n1;i++)
    {
      L[i] = A[l+i];
    }
  L[n1] = SENTINEL;
  for(i=0;i<n2;i++)
    {
      R[i] = A[m+i];
    }
  R[n2] = SENTINEL;
  j = 0;
  k = 0;
  for(i=l;i<r;i++)
    {
      if(L[j] <=R[k])
	{
	  A[i] = L[j];
	  j++;
	  count++;
	}
      else
	{
	  A[i] = R[k];
	  k++;
	  count++;
	}
    } 
}

Measured memory_bytes: 63344
//package abc165.D

import java.io.*
import java.math.*
import java.util.*
import kotlin.math.*

var reader: BufferedReader = System.`in`.bufferedReader()
var writer: PrintWriter = PrintWriter(System.`out`)

fun next() = reader.readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextStrings() = next().split(" ")
fun nextInts() = nextStrings().map { it.toInt() }
fun nextLongs() = nextStrings().map { it.toLong() }
fun nextDoubles() = nextStrings().map { it.toDouble() }

fun put(v: Any?) = writer.print(v)
fun puts() = writer.println()
fun puts(v: Any?) = writer.println(v)

var debug = false
fun dp(v: Any?) {
    if (debug) println(v)
}
fun dp() {
    if (debug) println()
}

tailrec fun gcd(a: Long, b: Long): Long {
    if(b == 0L) return a
    return gcd(b, a % b)
}

fun test(case: Int, input: String, expected: String) {
    reader = input.trimIndent().reader().buffered()

    val stringWriter = StringWriter()
    writer = PrintWriter(stringWriter)

    solve()
    writer.flush()

    val actual = stringWriter.toString()

    println("[test $case]")
    if ("${expected}" == actual) {
        println("OK")
    } else {
        println("NG")
        println()
        println("expected: \"${expected}\"")
        println("actual:   \"${actual}\"")
    }
    println()
}

@Suppress("UNUSED_PARAMETER")
fun xtest(case: Int, input: String, expected: String) {}

fun main(args: Array<String>) {
    if ((args.size == 1) && (args[0] == "test")) {
        testAll()
    } else {
        solve()
        writer.flush()
    }
}

///////////////////////////////////////////////////////////

fun testAll() {
    debug = true

    test(1,
    """
    5 7 4
    """,
    "2"
    )
    test(2,
    """
    11 10 9
    """,
    "9")
}

fun solve() {

    val (A, B, N) = nextLongs()

    val d = gcd(A, B)
    val n = min(B-1, N) / d

    val x = d*n
    val result = (A*x)/B - A*(x/B)
    put(result)
}


Measured memory_bytes: 36420
#include "bits/stdc++.h"
using namespace std;
int main() {
	int ans;
  	string s;
  	cin >> s;
	if (s[0] == '1') ans++;	
  	if (s[1] == '1') ans++;
  	if (s[2] == '1') ans++;
  	cout << ans << endl;
}



Measured memory_bytes: 256