akhauriyash/Code-Regression huggingface dataset:
import heapq


def calc(X,Y,A,B,C,p,q,r):
    heapq.heapify(p)
    heapq.heapify(q)
    heapq.heapify(r)
    for _ in range(A - X):
        heapq.heappop(p)
    for _ in range(B - Y):
        heapq.heappop(q)
    minp = heapq.heappop(p)
    minq = heapq.heappop(q)
    
    while r:
        maxr = -heapq.heappop(r)
        if minp < minq:
            if maxr > minp:
                heapq.heappush(p, maxr)
                minp = heapq.heappop(p)
            else:
                break
        else:
            if maxr > minq:
                heapq.heappush(q, maxr)
                minq = heapq.heappop(q)
            else:
                break
    return sum(p) + sum(q) + minp + minq



(X, Y, A, B, C) = tuple([int(s) for s in input().split()])
p = [int(s) for s in input().split()]
q = [int(s) for s in input().split()]
r = [-int(s) for s in input().split()]
print(calc(X,Y,A,B,C,p,q,r))

Measured memory_bytes: 23456
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator>inline void psortb(RandomAccessIterator first,RandomAccessIterator last){using P=pair<decltype(first->first),decltype(first->second)>;sort(first,last,[](const P&p1,const P&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

vector<ll>f(300001,-1);
ll calc_f(ll n)
{
    if(n==0){
        return 0;
    }else{
        if(auto foo=f[n%__builtin_popcountll(n)];foo!=-1){
            f[n]=foo+1;
        }else{
            f[n]=calc_f(n%__builtin_popcountll(n))+1;
        }
        return f[n];
    }
}
int main()
{
    for(ll i=300000;i>=0;--i){
        if(f[i]==-1){
            f[i]=calc_f(i);
        }
    }

    ll n;string s;cin>>n>>s;
    ll popcount=count(s.begin(),s.end(),'1');

    vector<ll>mod_2_i_pm1(300001,1),mod_2_i_pp1(300001,1);
    if(popcount>1)for(ll i=1;i<=300000;++i)mod_2_i_pm1[i]=2*mod_2_i_pm1[i-1]%(popcount-1);
                  for(ll i=1;i<=300000;++i)mod_2_i_pp1[i]=2*mod_2_i_pp1[i-1]%(popcount+1);

    ll fxm=0,fxp=0;
    for(ll i=0;i<n;++i){
        if(s[i]=='1'){
            if(popcount!=1){
                fxm+=mod_2_i_pm1[n-1-i];
                fxm%=popcount-1;
            }
            fxp+=mod_2_i_pp1[n-1-i];
            fxp%=popcount+1;
        }
    }

    for(ll i=0;i<n;++i){
        if(s[i]=='1'){
            if(popcount==1)
                cout<<0<<endl;
            else
                cout<<f[(popcount-1+fxm-mod_2_i_pm1[n-1-i])%(popcount-1)]+1<<endl;
        }else{
            cout<<f[(           fxp+mod_2_i_pp1[n-1-i])%(popcount+1)]+1<<endl;
        }
    }
}


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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

struct mint
{
  ll v;
  mint() : v(0) {}
  mint(ll v) : v((v % MOD + MOD) % MOD) {}
  mint pow(ll t) const;
  mint inv() const;
};
mint& operator+=(mint& a, mint b) { return a = a.v + b.v; }
mint& operator-=(mint& a, mint b) { return a = a.v - b.v; }
mint& operator*=(mint& a, mint b) { return a = a.v * b.v; }
mint operator+(mint a, mint b) { return a += b; }
mint operator-(mint a, mint b) { return a -= b; }
mint operator*(mint a, mint b) { return a *= b; }
mint operator-(mint a) { return 0 - a; }
mint& operator/=(mint& a, mint b) { return a *= b.inv(); }
mint operator/(mint a, mint b) { return a /= b; }
mint mint::pow(ll t) const
{
  if (!t) return 1;
  mint a = pow(t >> 1);
  a *= a;
  if (t & 1) a *= *this;
  return a;
}
mint mint::inv() const { return pow(MOD - 2); }
bool operator==(mint a, mint b) { return a.v == b.v; }
bool operator!=(mint a, mint b) { return a.v != b.v; }
istream& operator>>(istream& os, mint& a) { return (os >> a.v); }
ostream& operator<<(ostream& os, const mint& a) { return (os << a.v); }

mint dp[10005][101][2];

void solve()
{
  string K;
  int D, N;
  cin >> K >> D;
  N = K.length();
  dp[0][0][0] = 1;
  rep(i, N) rep(d, D) rep(isless, 2)
  {
    int c = K[i] - '0';
    rep(x, 10)
    {
			int nd = (d + x) % D, nisless = isless;
			if (!isless && c < x) continue;
			if (x < c) nisless = 1;
      dp[i + 1][nd][nisless] += dp[i][d][isless];
      // if (x < c)
      //   dp[i + 1][(d + x) % D][1] += dp[i][d][isless];
      // else if (x == c)
      //   dp[i + 1][(d + x) % D][isless] += dp[i][d][isless];
      // else {
      //   if (isless) dp[i + 1][(d + x) % D][isless] += dp[i][d][isless];
      // }
    }
  }
  dump(dp[N][0][0], dp[N][0][1]);
  cout << dp[N][0][0] + dp[N][0][1] - 1 << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

#define ris   return *this
#define tmplt template<class T
#define dbgo  debug& operator<<
tmplt > struct rge { T b, e; };
tmplt > rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
~debug(){cerr<<endl;}
tmplt > dbgo(T x){cerr<<boolalpha<<x;ris;}
tmplt, class C > dbgo(pair<T, C> x){ris<<"("<<x.first<<", "<<x.second<<")";}
tmplt > dbgo(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}ris<<"]";}
tmplt > dbgo(vector<T> x){ris<<range(x.begin(),x.end());}
#else
tmplt > dbgo(const T&){ris;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;

#define forn(i, n) for(int i = 0; i < int(n); i++)
#define ford(i, n) for(int i = n-1; i >= 0; i--) 

template<typename T> 
void min_self(T& a, T b) { 
   a = min(a, b); 
}
template<typename T>
void max_self(T& a, T b) { 
   a = max(a, b); 
}


int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   
   string s;
   cin >> s;
   while((int) s.length() > 3) {
      s.pop_back();
   }
   cout << s << '\n';
}















// Author: blondie


Measured memory_bytes: 3652
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main(){
    int N,sum,minIdx;
    cin>>N;
    minIdx=0;
    sum=0;
    vector<int> P(N);
    for(int i=0;i<N;i++)cin>>P.at(i);
    for(int i=0;i<N;i++){
        if(P.at(i)<=P.at(minIdx)){
            minIdx=i;
            sum++;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	double value ;
	string type;
	
	cin>>N;
	double yen = 0.0, bitcoin = 0.0;
	for(int i=0;i<N;i++){
		cin>>value>>type;
		if(type=="JPY") yen+=value;
		else bitcoin+=value;
	}
	printf("%lf\n",yen+bitcoin*380000.0);
	return 0;
}

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


struct record{
  int team;
  int solve;
  int time;
  vector< int > wa;
  
};

int getPenalty(record data, int pass){
  int cnt=0;
  for(int i=0;i<data.wa.size();i++){
    if(pass==data.wa[i])
      cnt++;
  }
  return cnt*20;

}

bool cmp(const record& a,const record& b){
  if(a.solve!=b.solve) return a.solve>b.solve;
  if(a.time!=b.time) return a.time<b.time;
  return a.team > b.team;

}

int main(){
  
  int m,t1,p,r;
  int t2,f;

  while(1){
    cin>>m>>t1>>p>>r;
    if(m==0 && t1==0 && p==0 && r==0) break;
    record record[t1];
    for(int i=0;i<t1;i++){
      record[i].team=i+1;
      record[i].solve=0;
      record[i].time=0;
    }
    
    for(int i=0;i<r;i++){
      cin>>m>>t2>>p>>f;
      if(f==0){
	record[t2-1].solve++;
	record[t2-1].time+=m+getPenalty(record[t2-1],p);
      }else{
	record[t2-1].wa.push_back(p);
      }
    }
    
    sort(record,record+t1,cmp);
    
    for(int i=0;i<t1;i++){
      printf("%d",record[i].team);
      if(i==t1-1) break;
      if(record[i].solve!=record[i+1].solve)
	printf(",");
      else{
	if(record[i].time!=record[i+1].time) printf(",");
	else printf("=");
      }
    }
    puts("");
  }
  return 0;
}

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

int n, k;
P p[100];

int main()
{
    cin >> n >> k;
    rep(i, n) cin >> p[i].first >> p[i].second;
    sort(p, p + n);

    ll res = 4 * 1e18;
    for(int left = 0; left < n - 1; left++)
    {
        for(int right = left + 1; right < n; right++)
        {
            while(p[right].first == p[right + 1].first)
            {
                right++;
            }
            vector<ll> y(0);
            for(int i = left; i <= right; i++)
            {
                y.emplace_back(p[i].second);
            }
            if(y.size() < k) continue;

            sort(y.begin(), y.end());
            int m = y.size();
            for(int l = 0; l < m - 1; l++)
            {
                for(int r = l + k - 1; r < m; r++)
                {
                    while(y[r] == y[r + 1])
                    {
                        r++;
                    }
                    ll ans = abs(p[right].first - p[left].first) * abs(y[r] - y[l]);
                    res = min(res, ans);
                }
            }
        }
    }
    cout << res << endl;
    
    return 0;
}

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

int main()
{
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    int nr = 0;
    for (int i = 0; i < m; i++)
    {
        cin >> b[i];
    }
    for (int i = 0; i < n; i++)
    {
        int sum = 0;
        for (int i = 0; i < m; i++)
        {
            int x;
            cin >> x;
            sum = sum + b[i] * x;
        }
        sum += c;
        if (sum > 0)
        {
            nr++;
        }
    }
    cout << nr;
    return 0;
}


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

int main ()
{
    int x, y, s;
    while (cin >> x >> y >> s, x || y || s) {
        int res = 0;
        for (int i = 1; i < s; i++) {
            for (int j = 1; j < s; j++) {
                int sum = j * (100 + x) / 100  + i * (100 + x) / 100;
                if (sum > s) break;
                else if (s == sum) res = max(res, i * (100 + y) / 100 + j * (100 + y) / 100);
            }
        }

        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
A_num,B_num,M_num = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
Waribiki = []
for _ in range(M_num):
    Waribiki.append(list(map(int,input().split())))
# 何も割引券を使わないときの最安値
min_price = min(A) + min(B)
# 割引券で安くなったときの値段を考える
for w in Waribiki:
    x = w[0]
    y = w[1]
    c = w[2]
    min_price = min(min_price, A[x-1]+B[y-1]-c)
print(min_price)








Measured memory_bytes: 38560
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, T;
  cin >> N >> T;
  vl A(N);
  REP(i, N) cin >> A[i];

  ll max_diff = -llINF;
  ll min_a = llINF;
  ll ans = 0;

  REP(i, N) {
    if (min_a > A[i])
      min_a = A[i];
    else {
      if (A[i] - min_a > max_diff) {
        max_diff = A[i] - min_a;
        ans = 1;
      } else if (A[i] - min_a == max_diff)
        ans += 1;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb push_back
#define pob pop_back
#define MP make_pair
#define MT make_tuple
#define rep(i,a,b) for(int i=a;i<b;i++)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define rept(it,v) for(auto it=v.begin();it!=v.end();it++)
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define sz(x) (int)x.size()
#define endl "\n"
#define ct continue
ll mod=1e9+7;
ll abs(ll a)
{
	if(a<0)
		return -1*a;
	return a;
}

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

void I_m_Beast()
{
	int n,k;
	cin>>n>>k;
	int H[n+1];
	rep(i,1,n+1)
		cin>>H[i];
	ll dp[n+1];
	rep(i,0,n)
		dp[i]=1e12;
	dp[1]=0;
	rep(i,1,n+1)
	{
		rep(j,1,k+1)
		{
			if(i+j<=n)
				dp[i+j]=min(dp[i+j],dp[i]+abs(H[i+j]-H[i]));
		}
	}
	cout<<dp[n]<<endl;
}

int main()
{
	fastio;
	int t=1;
//	cin>>t;
	while(t--)
	{
		I_m_Beast();
	}	
	return 0;	
}

Measured memory_bytes: 4800
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "D:\C++\test_lib_projects\testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>

bool debug=true;
/*
   Write In New Computer
    By XiaoGeNintendo
	     gwq2017
	Type:
*/
template<typename T1,typename T2>ostream& operator<<(ostream& os,pair<T1,T2> ptt){
	os<<ptt.first<<","<<ptt.second;
	return os;
}
template<typename T>ostream& operator<<(ostream& os,vector<T> vt){
	os<<"{";
	for(int i=0;i<vt.size();i++){
		os<<vt[i]<<" ";
	}
	os<<"}";
	return os;
}

int n,a[200005];
vector<int> v;

ll aa(ll a){
	return (a<0?-a:a);
}
ll sad(int b){
	ll ans=0;
	for(int i=0;i<n;i++){
		ans+=aa(a[i]-b-i);
	}
	
	return ans;
}
int main(int argc,char* argv[]){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		v.push_back(a[i]-i);
	}
	
	sort(v.begin(),v.end());

	if(v.size()%2==1){
		cout<<sad(v[v.size()/2]);
	}else{
		cout<<max(sad(v[v.size()/2]),sad(v[v.size()/2-1]));
	}
	return 0;
}


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

#define ls rt<<1
#define rs rt<<1|1
typedef pair<int,int> pii;
const int maxn = 1e5 + 10;
const int maxm = 1e6 + 10 ;
const int inf=0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
const int st=(1<<20)-1;
const int mod = 1e9+7;
const double eps = 1e-5;
const int vec[2][2]={1,0,0,1};

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

inline ll sv(ll x) {
    ll ans=1;
    for(int i=1;i<=x;i++) {
        ans*=i;
        ans%=mod;
    }
    return ans;
}

int a[105];
int main() {
#ifdef LOCAL
    freopen("input.txt","r",stdin);
#endif // LOCAL
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,x=-1,sum=0;
    n=read();
    for(int i=0;i<n;i++) a[i]=read(),sum+=a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++) {
        if(a[i]%10) {
            x=a[i];
            break;
        }
    }
    if(sum%10==0) {
        if(~x) sum-=x;
        else sum=0;
    }
    cout<<sum;
    return 0;
}
//校园网真tm卡


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define int long long 
    #define mp make_pair
    #define pb push_back
    #define pii pair<int,int>
    #define F first
    #define S second
    int const M=2e5+10,inf=1e9+10;
    int a[M],n;
    void print(int x,int y)
    {
    	y=y xor x;
    	if(y==1)cout<<"Second";
    	else cout<<"First";
    	exit(0);
    }
    void bt(int now)
    {
    	int cnt=0;
    	for(int i=1;i<=n;i++)
    	{
    		cnt+=a[i]%2;
    	}
    	if(cnt>=2)
    	{
    		if(cnt%2==n%2)
    		{
    			print(1,now);
    		}
    		else print(0,now);
    	}
    	bool flag=0;
    	if(cnt==1)
    	{
    		if(cnt%2!=n%2)
    		{
    			print(0,now);
    		}
    		else
    		{
    			flag=1;
    			for(int i=1;i<=n;i++)
    			{
    				if(a[i]%2){
    					if(a[i]==1)
    					{
    						print(1,now);
    					}
    					a[i]--;
    				}
    			}
    			int tmp=0;
    			for(int i=1;i<=n;i++)tmp=__gcd(tmp,a[i]);
    			for(int i=1;i<=n;i++)a[i]/=tmp;
    			bt(1-now);
    		}
    	}
    }
    int32_t main()
    {
    	cin>>n;
    	for(int i=1;i<=n;i++)cin>>a[i];
    	if(n==1)
    	{
    		if(a[1]%2==1)cout<<"Second";
    		else cout<<"First";
    		return 0;
    	}
    	bt(0);
    }

Measured memory_bytes: 1152
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 0xcccccccccccccccLL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}



//head



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a;
	cin >> a;
	cout << !a << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define all(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
const int mod = 1e9+7;

int main() {
    int k;
    cin >> k;
    rep(i, k) {
        cout << "ACL";
    }
    cout << endl;
}

Measured memory_bytes: 3636
def main():
	# n,m = map(int,input().split())
	# n,k = map(int,input().split())
	# n = int(input())
	# a = list(map(int,input().split()))
	# rsp = list(str(input()))
	# l = [list(map(int, input().split())) for _ in range(n)]
	# s = list(s)
	
	yoho = list(str(input()))
	jissai = list(str(input()))

	# print(yoho,jissai)
	ans = 0
	for i in range(len(yoho)):
		if yoho[i] == jissai[i]:
			ans += 1

	print(ans)


 
if __name__ == '__main__':
	main()

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    int x, a;
    cin >> x >> a;
    if(x < a)
    	cout << "0" << endl;
    else
    	cout << "10" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  string s;
  cin >> s;
  int n = s.size();
  
  char a = s[0];
  int ans = 0;
  
  for(int i = 1; i < n; i++){
    if(s[i] != a){
      ans++;
      a = s[i];
    }
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<bitset>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
#define ll long long
using namespace std;
int main() {
     int n, m;
     scanf("%d%d", &n, &m);
     int mm = m - 1000 * n;
     if (mm < 0) {
          printf("-1 -1 -1\n");
          return 0;
     }
     bool flag = false;
     for (int i = 0; 9000 * i <= mm; i++) {
          int res = mm - 9000 * i;
          if (res % 4000 == 0) {
               int ans = res / 4000;
               if (n - i - ans >= 0) {
                    printf("%d %d %d\n", i, ans, n - i - ans);
                    flag = true;
                    break;
               }
          }
     }
     if (!flag) printf("-1 -1 -1\n");
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B&lang=jp

#define MAX 100005

struct PS
{
    string name;
    int time;
};

int tail, head;
PS p[MAX];

static void enq(PS x) {
    p[tail] = x;
    tail = (tail + 1) % MAX;
}

static PS deq() {
    PS x = p[head];
    head = (head + 1) % MAX;
    return x;
}

int main() {
    int n, q;
    cin >> n >> q;
    REP(i, n) {
        string na;
        int t;
        cin >> na >> t;
        enq({na, t});
    }

    int elapse = 0;
    while(tail != head) {
        PS ps = deq();
        int c = min(q, ps.time);
        ps.time -= c;
        elapse += c;
        if (ps.time > 0) {
            enq({ps.name,ps.time});
        }
        else {
            printf("%s %d\n", ps.name.c_str(), elapse);
        }
    }

    return 0;
}



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

int main() {
    long long N;
    cin >> N;

    for (long long h = 1; h <= 3500; h++) {
        for (long long n = 0; n <= 3500; n++) {
            long long a = N * h * n;
            long long b = 4 * h * n - N * h - N * n;
            if (b > 0 && a % b == 0 && a / b <= 3500) {
                long long w = a / b;
                cout << h << " " << n << " " << w << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    final char[] S=sc.next().toCharArray();
    boolean flg=false;
    if(S[0]==S[1]){
      if(S[1]==S[2]){
        flg=true;
      }
    }else if(S[1]==S[2]){
      if(S[2]==S[3]){
        flg=true;
      }
    }
    if(flg){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22868
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		boolean[] A = new boolean[1000001];
		int a;
		int ans = 0;
		ArrayList<Integer> rep = new ArrayList<Integer>();
		for (int i = 1; i <= N; i++) {
			a = scan.nextInt();
			if (A[a]) {
				rep.add(a);
			}
			A[a] = true;
		}

		for (int i = 1; i < 1000001; i++) {
			if (A[i]) {
				for (int j = 2; i*j < 1000001; j++) {
					A[i*j] = false;
				}
			}
		}

		for (int i = 0; i < rep.size(); i++) {
			A[rep.get(i)] = false;
		}

		for (int i = 1; i < 1000001; i++) {
			if(A[i]) ans++;
		}

		System.out.println(ans);

	}

}

Measured memory_bytes: 66956
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        String[] days = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
        String current = in.next();

        int index = 0;
        for (int i = 0; i < days.length; i++) {
            if (days[i].equals(current)) {
                index = i;
                break;
            }
        }

        out.println(7 - index);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 21204
#include<iostream>
using namespace std;
int main ()
{
	int fif[100];
	int n,i;
	fif[0]=1,fif[1]=1;
	cin >> n;
	for(i=2;i<=n;i++)
	{
		fif[i]=fif[i-2]+fif[i-1];
	}
	cout << fif[n] << endl;
	return 0;
}

Measured memory_bytes: 3080
import scala.io.StdIn.readLine

object Main {
  def main(args:Array[String]) = {
    var n = readLine.trim.toInt
    while( n != 0 ) {
      var sum = 0
      val cnt = readLine.trim.toInt
      for(i<-1 to cnt) {
        val s = readLine.trim.split(" ").map(_.toInt)
        sum += s(1)-s(0)
      }
      if(sum >= n) println("OK")
      else println(n-sum)
      n = readLine.trim.toInt
    }
  }
}

Measured memory_bytes: 44496
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        String s3 = sc.next();
        System.out.println(s1.substring(0, 1).toUpperCase()
                + s2.substring(0, 1).toUpperCase()
                + s3.substring(0, 1).toUpperCase()
        );
    }

}


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

using namespace std;

using int64 = long long;


int main() {
  int64 A, B;
  cin >> A >> B;

  if(A == B) {
    cout << 1 << endl;
    return 0;
  }

  int p = -1, k = -1;
  for(int i = 60; i >= 0; i--) {
    if((B >> i) & 1 && !((A >> i) & 1)) {
      p = i;
      break;
    } else {
      A &= ~(1LL << i);
    }
  }
  for(int i = p - 1; i >= 0; i--) {
    if((B >> i) & 1) {
      k = i;
      break;
    }
  }

  int64 ret = (1LL << p) - A;

  pair< int64, int64 > latte = {(1LL << p), (1LL << p)};
  if(k >= 0) latte.second += (1LL << (k + 1));
  else ++latte.second;//throw 0;

//  cout << latte.first << " " << latte.second << endl;

  pair< int64, int64 > malta = {(1LL << p) + A, (1LL << (p + 1))};

//  cout << malta.first << " " << malta.second << endl;

  if(latte > malta) swap(latte, malta);
  if(latte.second <= malta.first) {
    ret += latte.second - latte.first;
    ret += malta.second - malta.first;
  } else {
    ret += max(latte.second, malta.second) - min(latte.first, malta.first);
  }

  cout << ret << endl;

}

Measured memory_bytes: 256
import heapq

n,m = map(int,input().split())
prod = list(map(int,input().split()))
prod = list(map(lambda x: x*(-1),prod))

heapq.heapify(prod)

for _ in range(m):
    a = heapq.heappop(prod)*(-1)

    a = a//2

    heapq.heappush(prod,(-1)*a)


ans = list(map(lambda x: (-1)*x,prod))

print(sum(ans))

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr <<__LINE__<< ": " << #x << " -> " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" -> ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n) {
        string s;
        cin >> s;
        mp[s]++;
    }
    int ans = 0;
    for (auto x : mp) {
        if (x.se > 0) ans++;
    }
    cout << ans << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


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

const int MAX_N = 1e5 + 1;
const int MAX_M = 1e5 + 1;

bool is_checked[MAX_N + MAX_M];
vector<int> graph[MAX_N + MAX_M];

void dfs(int node) {
    is_checked[node] = true;
    for (int i = 0; i < graph[node].size(); i++) {
        if (is_checked[graph[node][i]]) continue;
        dfs(graph[node][i]);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int K, L;
    for (int i = 0; i < N; i++) {
        cin >> K;
        for (int j = 0; j < K; j++) {
            cin >> L;
            L--;
            graph[i].push_back(N + L);
            graph[N + L].push_back(i);
        }
    }
    dfs(0);
    for (int i = 0; i < N; i++) {
        if (!is_checked[i]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _i64 H, W;
        while(cin >> H >> W && !(H == 0 && W == 0)){
            _rep(i, H) { _rep(j, W) { cout << ((i + j) % 2 == 0 ? "#" : ".") ; } cout << endl; }
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int main(){
    int n;cin>>n;
    string s,t;cin>>s>>t;
    for(int i=0;s[i]&&t[i];i++)cout<<s[i]<<t[i];
    return 0;
}

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

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

ll A,B,C,K;

int main(){
	cin>>A>>B>>C>>K;
	printf("%lld\n",K&1?B-A:A-B);
}

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

int main()
{
  int n;
  cin >> n;
  vector<char> v(n+10);
  rep(i, n)cin >> v[i];
  bool f = false;
  rep(i, n){
    if(v[i] == 'Y')f = true;
  }
  if(f)cout << "Four" << endl;
  else cout << "Three" << endl;
  system("pause");
}


Measured memory_bytes: 504
// C
// DeP
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long LL;
const int MAXN = 105;

int n;
int A[MAXN];

int main() {
    scanf("%d", &n);
    int Max = MAXN, Min = -MAXN;
    for (int i = 1; i <= n; ++i) {
        scanf("%d", A+i);
        Max = max(Max, A[i]), Min = min(Min, A[i]);
    }
    LL ans = 1e18;
    for (int x = Min; x <= Max; ++x) {
        LL now = 0;
        for (int i = 1; i <= n; ++i)
            now += 1LL * (A[i] - x) * (A[i] - x);
        ans = min(now, ans);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

template<class T>
void bubblesort(vector<T> &a,int& cnt)
{
  int n=a.size();
  bool flag=true;
  while(flag)
  {
    flag=false;
    for (int i = n-1; i >= 1; --i)
    {
      if(a[i]<a[i-1])
      {
        swap(a[i],a[i-1]);
        flag=true;
        cnt++;
      }
    }
  }
}

int main()
{
  int n,cnt=0;
  cin>>n;
  vector<int> a(n);
  for(auto&& e: a) 
  {
    cin>>e;
  }
  bubblesort(a,cnt);
  for (int i = 0; i < a.size(); ++i)
  {
    if(i!=n-1) cout<<a[i]<<" ";
    else cout<<a[i]<<endl;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3084
n = int(input())
ans = [0]*n
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            b =  x**2 + y**2 + z**2 + x*y + x*z + y*z - 1
            if b < n:
                ans[b] += 1
for a in ans:
    print(a)

Measured memory_bytes: 9248
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j,k;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[] l = new int[n];
		for(i=0;i<n;i++) {
			l[i] = parseInt(sc.next());
		}
		sc.close();
		Arrays.parallelSort(l);
//		out.println(Arrays.toString(l));
		long cnt = 0;
		int ks = 2;
		int ke = ks;
		for (i = 0; i < n-2; i++) {
			ks = i +2;
			ke = ks;
			for (j = i+1; j < n-1; j++) {
				if(ks<=j)ks=j+1;
				for (k = j+1; k < n; k++) {
					if(l[j]-l[i] < l[k]) break;
				}
				ks = k;
				if(ke<ks) ke=ks;
				for (k = ke; k < n; k++) {
					if(l[k] >= l[j]+l[i]) break;
				}
				ke = k;
//				out.printf("%d,%d_%d:%d%n",i,j,ks,ke);
				cnt+=ke-ks;
			}
		}
		out.println(cnt);
	}
}


Measured memory_bytes: 25688
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>

using namespace std;

#define memset_clear(_) memset(_,0,sizeof(_))
#define memset_clear_tre(_) memset(_,1,sizeof(_))
#define memset_clear_reg(_) memset(_,-1,sizeof(_))
#define memset_clear_max(_) memset(_,0x3f,sizeof(_))
#define memset_clear_min(_) memset(_,0x80,sizeof(_))
#define sqr(_) ((_)*(_))

#define int long long

const int maxn=105;
int n,m;
char a[maxn][maxn];
bool wrt[maxn];

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

signed main(){
	n=read();m=read();
	for (int i=1;i<=n;i++) scanf("%s",a[i]+1);
	for (int i=1;i<=m;i++){
		wrt[i]=false;
		for (int j=1;j<=n;j++) if (a[j][i]=='#') wrt[i]=true;
	}
	for (int i=1;i<=n;i++){
		bool flg=false;
		for (int j=1;j<=m;j++) if (a[i][j]=='#') flg=true;
		if (flg){
			for (int j=1;j<=m;j++) if (wrt[j]) putchar(a[i][j]);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 256
use std::io::stdin;

#[derive(Default)]
struct Scanner {
	buffer: Vec<String>
}

impl Scanner {
	fn next<T: std::str::FromStr> (&mut self) -> T {
		loop {
			if let Some(token) = self.buffer.pop() {
				return token.parse().ok().expect("Failed parse");
			}
			let mut input = String::new();
			stdin().read_line(&mut input).expect("Failed read");
			self.buffer = input.split_whitespace().rev().map(String::from).collect();
		}
	}
}

fn main() {
	let mut scan = Scanner::default();
	let s: String = scan.next();
	match &s[..] {
		"RRR" => println!("3"),
		"SSS" => println!("0"),
		"RRS" | "SRR" => println!("2"),
		_ => println!("1"),
	}
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int n, s;
int a[3000];
long dp[3001];
int main() {
  cin >> n >> s;
  for (int i = 0; i < n; ++i) cin >> a[i];
  
  dp[0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int k = s - 1; k >= 0; --k) {
      int nk = k + a[i];
      if (nk > s) continue;
      long del = dp[k];
      if (k == 0) del = del * (i + 1) % mod;
      if (nk == s) del = del * (n - i) % mod;
      dp[nk] += del;
      dp[nk] %= mod;
    }
  }
  cout << dp[s] << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <math.h>
#include <string.h>

using std::endl;
using std::string;

#define ll long long int
#define LEP(a, n) for(int a = 0; a < n; ++a)
#define INF 1145141919810
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std


int main()
{
	ll A, B, C;
	ll ans = 114514;

	IN >> A >> B >> C;

	ans = std::min(ans, std::abs(B - A) + std::abs(C - A));
	ans = std::min(ans, std::abs(B - A) + std::abs(C - B));
	ans = std::min(ans, std::abs(A - C) + std::abs(B - C));

	OUT << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

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

const int INF = 1001001001;
//const ll INF = 1e18;


int main() {
	int n;
	cin >> n;
	int count[10][10] = { 0 };
	for (int i = 1; i <= n; i++) {
		string s = to_string(i);
		int n = s.size();
		int first = s[0] - '0';
		int last = s[n - 1] - '0';
		count[first][last]++;
	}
	ll ans = 0;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			ans += count[i][j] * count[j][i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 105
#define trace(x) cout<<#x<<" = "<<x<<'\n'
#define trace2(x, y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<'\n'
#define trace3(x, y, z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<'\n'
#define sz(x) (int)(x).size()
using namespace std;
struct ii {
	int a, b;
	bool operator < (ii o) const { return tie(a, b) < tie(o.a, o.b); }
};
struct iii {
	int a, b, c;
	bool operator < (iii o) const { return tie(a, b, c) < tie(o.a, o.b, o.c); }
};
long long TC, N, M, K, Q, x, y, z;

long long W;
long long dp[MAXN][3*MAXN][MAXN], w[MAXN], v[MAXN];

long long f(int pos, int rem, int rem2) {
	if (pos == N) return 0;
	long long &ret = dp[pos][rem][rem2];
	if (ret != -1) return ret;
	ret = f(pos+1, rem, rem2);
	if (rem >= (w[pos]-w[0]) && rem2) ret = max(ret, f(pos+1, rem-(w[pos]-w[0]), rem2-1)+v[pos]);
	return ret;
}

int main() {
	#ifdef FAIRUZI10
	freopen("/home/fairuzi/Documents/CP/input.in", "r", stdin);
	#endif
	
	scanf("%lld%lld", &N, &W);
	for (int i = 0; i < N; i++) {
		scanf("%lld%lld", &w[i], &v[i]);
	}
	memset(dp, -1, sizeof(dp));
	long long ans = 0;
	for (long long i = 0; w[0]*i <= W; i++) ans = max(ans, f(0, min(W-w[0]*i, 3*i), i));
	printf("%lld\n", ans);
	
	return 0;
}



Measured memory_bytes: 27392
#include <stdio.h>

int main(){
int n;
scanf("%d",&n);
int l[n];
int max = 0;
int sum = 0;
for(int i = 0;i < n;i++){
	scanf("%d",&l[i]);
	if(l[i] > max){
		sum += max;
		max = l[i];
	}else{
	sum += l[i];
	}
}
if(sum > max)
printf("Yes");
else
printf("No");
return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using ll = long long;
using namespace std;


void solve() {
   ll n, m;
   cin >> n >> m;
   if(n == 1 || m == 1) {
      cout << 1 << endl;
      return;
   }
   ll ans = (n * m) / 2;

   if((n % 2 == 1) && (m % 2 == 1)) {
      ans++;
   }
   cout << ans << endl;
}

int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solve();
   } 
   return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#define MOD (1000000007l)

using namespace std;

int main(void) {
  int foo[4] = {0};
  for (int i = 0; i < 3; i++) {
    int tmp;
    cin >> tmp;
    foo[tmp-1] ++;
    cin >> tmp;
    foo[tmp-1] ++;
  }
  for (int i = 0; i < 4; i++) {
    if (foo[i] > 2) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    string s; cin >> s;
    char c = s[0];
    int cnt = 0;
    rep(i,1,s.length() - 1) if(s[i] != c && s[i+1] != c) cnt++;
    cout << ((cnt % 2) ? "First" : "Second") << endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

int main(){
  int n,k;
  cin >> n >> k;
  cout << (k==1 ? 0 : n-k) << endl;
}



Measured memory_bytes: 3568
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
   
    int r,g,b;
    cin>>r>>g>>b;
    
    if((r*100+g*10+b)%4==0){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
    
    
    return 0;
}






Measured memory_bytes: 256
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m=pow(10,9)+7;
	long int t=1;
	cin>>n;

	FOR(i,1,n+1){
		t*=i;
		t=t%m;
	}
		
	cout<<t<<"\n";
return 0;
}

Measured memory_bytes: 256