akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
int main()
{
  int n;cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];

  vector<char> head = {'M', 'A', 'R', 'C', 'H'};
  vector<ll> cnt(5,0);
  rep(i,n) {
    rep(j,5) {
      if(s[i][0] == head[j]) {
	cnt[j]++;
      }
    }
  }

  ll res = 0;
  for(int i = 0;i < 5;++i) {
    for(int j = i+1; j < 5; ++j) {
      for(int k = j+1; k < 5;++k) {
	res += cnt[i] * cnt[j] * cnt[k];
      }
    }
  }
  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <list>
#include <numeric>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

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

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

	ll n, k;
	cin >> n >> k;
	vector<ll> v(n);
	rep(i, n) cin >> v[i];

	// マイナスの場合もあるのか

	int head = 0;
	int rear = n - 1;

	// 左右それぞれ取る場所の線を二本入れる

	ll ans = -inf;

	vector<ll> lv;
	for (int left = -1; left < n; left++) {
		if (left >= 0) lv.push_back(v[left]);
		vector<ll> rv;
		for (int right = n; right > left; right--) {
			if (right < n) rv.push_back(v[right]);
			ll rest = k - (n - right + left + 1);
			if (rest < 0)continue;
			rest = min(rest, left + 1 + n - right);
			if ((int)lv.size() + (int)rv.size() == 0) {
				ans = max(ans, 0LL);
				continue;
			}
			// rest個戻せる
			sort(allof(lv));
			sort(allof(rv));
			int lcnt = 0;
			int rcnt = 0;
			rep(i, rest) {
				ll l, r;
				if (lcnt >= (int)lv.size())
					l = inf;
				else
					l = lv[lcnt];
				if (rcnt >= (int)rv.size())
					r = inf;
				else
					r = rv[rcnt];

				if (l < 0 || r < 0) {
					if (l < r) {
						lcnt++;
					}
					else {
						rcnt++;
					}
				}
			}
			ll tmp = 0;
			Rep(i, lcnt, (int)lv.size()) {
				tmp += lv[i];
			}
			Rep(i, rcnt, (int)rv.size()) {
				tmp += rv[i];
			}
			ans = max(ans, tmp);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main()
{  int maxl= INT_MIN;
int k;
 int A[3];
 for(int i=0;i<3;i++)
 { 
 cin>>A[i];	
 }
 cin>>k;
 for(int i=0;i<3;i++)
 { 
 maxl=max(A[i],maxl);
 	
 }
  
 cout<<maxl*((1 << k) - 1)+A[0]+A[1]+A[2];
	
 return 0;
}
 

Measured memory_bytes: 256
#include <iostream>

int main (){
    int left , right;
    std :: cin >> left >> right;

    if (left < right) { 
        std :: cout << "a" << " < " << "b" << std :: endl;
    }else if (left > right) { 
        std :: cout << "a" << " > " << "b" << std :: endl;
    }else if (left == right ){
        std :: cout << "a" << " == " << "b" << std :: endl;
    } 
    
}


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

#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007

ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
/*
ll factor(ll n){
    vll ans;
	if(n==2)ans.pb(2);
	else
    {for(ll i=2;i*i<=n;i++){if(n%i==0 && n%i!=i){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}ans.pb(n);}
    return ans.sz+1;
}
ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i; 
    return res; } 
  
ll nCr(ll n, ll r){ return fact(n) / (fact(r) * fact(n - r)); } 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 

ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
*/
void solve()
{
	ll n,k;
	cin>>n;
	ll a[n];
	ll sum=0;
	for(ll i=0;i<n;i++)
		cin>>a[i],sum+=a[i];
	ll l=0;
	ll r=sum;
	ll ans=1e16;
	for(ll i=0;i<n-1;i++)
	{
		// cout<<l<<r<<" ";
		l+=a[i];
		r-=a[i];
		ans=min(ans,abs(l-r));
	}
	cout<<ans;
}            

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 5180
#include <bits/stdc++.h>
using namespace std;
 
#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
#define treap_pair pair<treap*, treap*>
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 2e5 + 2;
const int M = 1e5 + 2;
const ll mod = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e16;

void data() {
	#ifdef PC
		freopen("main.in", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
}

ll dp[110][M], pr[110][M], n, k, a[110];

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

int main() {
	data();
	scanf("%lld %lld", &n, &k);
	for (int i = 1; i <= n; ++i)
		scanf("%lld", &a[i]);
	dp[0][0] = 1;
	for (int i = 0; i <= k; ++i)
		pr[0][i] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= k; ++j)
			if (j > a[i])
				dp[i][j] = add(pr[i - 1][j], -pr[i - 1][j - a[i] - 1]);	
			else
				dp[i][j] = pr[i - 1][j];
				
		for (int j = 0; j <= k; ++j)
			pr[i][j] = add(pr[i][j - 1 + (j == 0)], dp[i][j]);
	}
	printf("%lld", dp[n][k]);
}

/*
	Timus: 288481RF
	CodeForces: fractal
*/

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  ll n,m;cin>>n>>m;

  map<int, int>log;
  rep(i,2*m){
    int t;cin>>t;
    log[t]++;
  }

  bool f=true;
  for(auto p:log){
    if(p.second%2){
      f=false;
      break;
    }
  }
  cout<<(f?"YES":"NO");

  return 0;
}

Measured memory_bytes: 4352
n=int(input())
a=list(map(int, input().split()))
cnt_2=0
cnt_1=0
cnt_0=0

for num in a:
    if num%4==0:
        cnt_2+=1
    elif num%2==0:
        cnt_1+=1
    else:
        cnt_0+=1

if cnt_1==0:
    if cnt_2+1>=cnt_0:
        print("Yes")
    else:
        print("No")

else:
    if cnt_2>=cnt_0:
        print("Yes")
    else:
        print("No")

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

const int Maxn=2e5+10;
int T[Maxn],A[Maxn];
int as[4]={1,0,3,2};
int n,sr,sc,H,W;

void ud(char c,int x,bool id){
	int val;
	if(c=='L') val=0;
	else if(c=='R') val=1;
	else if(c=='U') val=2;
	else val=3;
	if(!id) T[x]=val;
	else A[x]=val; 
}

bool ne(int x,int f){
	if(f<2) return x<0||x>W-1;
	else return x<0||x>H-1;
}

int main(){
	scanf("%d%d",&H,&W);
	scanf("%d",&n);
	scanf("%d%d",&sr,&sc);
	sr--;sc--;
	for(int i=0;i<2;i++)
		for(int j=0;j<n;j++){
			char c;
			cin>>c;
			ud(c,j,i);
		}
	bool f=false;
	for(int i=0;i<4;i++){
		int pos;
		if(i==0||i==1) pos=sc;
		else pos=sr;
		for(int j=0;j<n;j++){
			if(T[j]==i){
				if(i<2){
					if(i==0) pos--;
					else pos++;
				}
				else{
					if(i==2) pos--;
					else pos++;
				}
			}
			if(ne(pos,i)) f=true;
			if(A[j]==as[i]){
				if(i<2){
					if(i==0&&pos<W-1) pos++;
					if(i==1&&pos>0) pos--;
				}
				else{
					if(i==2&&pos<H-1) pos++;
					if(i==3&&pos>0) pos--;
				}
			}
		}
		if(ne(pos,i)) f=true;
	//	cout<<pos<<endl;
	}
	if(!f) cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){
  string s,t,A;
  cin>>s>>t;
  A=s;
  int a=s.size(),b=t.size();
  for(int i=0;i<a;i++){
    for(int j=0;j<a;j++){
      s[j]=A[j+1+i];
      if(j+1+i>=a) s[j]=A[j+1+i-a];
    }
    
    if(s==t){
      cout<<"Yes"<<endl;
      break;
    }
    if(i==a-1) cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//990589
//4076361
const int mod=2019;
int a[990589+10];
int main()
{
	int l,r;
	cin>>l>>r;
	int n1=l/mod;
	int n2=r/mod;
//	if(r%mod==0) n2--;
	int qq=0;
//	a[qq++]=n*mod;
	if(n1==n2)
	{
//		printf("%d %d\n",(l%mod),((l+1)%mod));
//		int woc[2019];
		
//		int a1=l+(l+1);
//		int a2=r*(r-1);
//		int www=a1/2019;
//		if(a1%2019!=0) www++;
//		int www2=a2/2019;
////		if(a2%2019!=0) 
//		for(int i=www;i<=www2;i++)
//		{
//			
//			if((www*2019)%)
//		}
//		cout<<((l%mod)*((l+1)%mod))%mod<<endl;
		long long int minn=0x3f3f3f3f;
//		cout<<l<<r<<endl;
		for(long long int i=l;i<r;i++)
		{
			for(long long int j=i+1;j<=r;j++)
			{
//				cout<<(i*j)%mod<<endl;
//				getchar();
				minn=min(minn,(i*j)%mod);
//			if(minn==0) cout<<i<<j<<endl;
			}
		}
		cout<<minn<<endl;
	}
	else{
		cout<<0<<endl;
	}

	
}

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

#define ll long long
#define sc(n) long long int n; scanf("%d",&n);
#define mod 10000007
#define N 100001
#define MX 1000000001
#define log(n) (int)log2(n)
#define pb(x) push_back(x);
#define T int t, q=0; scanf("%d", &t); while(q++<t)
#define scArr(n) int n; scanf("%d", &n); int a[n]; for(int i=0; i<n; i++) scanf("%d", &a[i]);


int main()
{
    int n, k;
    string s;
    cin>>n>>k>>s;
    s+='2';
    map<pair<int, int> , int> m;
    vector<pair<int, int> > v;
    int in=0, mid=0, det=0;
    int i=0;
    if(s[0]=='0')
    {
        det=1;
        i++;
    }

    for(;i<s.size();i++)
    {
        if(s[i]=='0' && det==0)
        {
            det=1;
        }
        else if(s[i]=='0' && det==1 && s[i-1]!='0')
        {
            m.insert({{in, i-1}, i-in});
            det=0;
            for(i=i-1;i>=0;i--)
            {
                if(s[i]=='0')
                {
                    in=++i;
                    break;
                }
            }
        }
        else if(s[i]=='2')
        {
            m.insert({{in, s.size()-2}, s.size()-1-in});
        }
    }

    for(auto it=m.begin();it!=m.end();it++)
    {
        v.push_back({it->first.first, it->first.second});
    }
    int sum=0, mx;
    for(int i=0;i<k && i<v.size();i++)
    {
//        cout<<v[i].first<<" "<<v[i].second<<endl;
        mx=sum=v[i].second+1;
    }
//    cout<<mx<<endl;
    for(int i=k;i<v.size();i++)
    {
        sum=v[i].second-v[i-k+1].first+1;
        if(sum>mx) mx=sum;
    }
    cout<<mx;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;


int main(){
   string s; cin>>s;
   bool ans=true;
   int n=s.size();
   reverse(ALL(s));
 
   int i=0;
   while(i<n){
               if(n-5>i&&s.substr(i,6)=="resare")i+=6;
            else if(n-4>i&&s.substr(i,5)=="esare")i+=5;
          
            else if(n-6>i&&s.substr(i,7)=="remaerd")i+=7;
            else if(n-4>i&&s.substr(i,5)=="maerd")i+=5;
            else{
               ans=false;
               break;
            }
   }
 
  if(ans)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
} 

Measured memory_bytes: 512
N = int(input())
a = list(map(int, input().split()))

A = []
B = []

while N > 0:
    A.append(max(a))
    a.remove(max(a))
    N -= 1
    if N != 0:
        B.append(max(a))
        a.remove(max(a))
        N -= 1

print(sum(A) - sum(B))

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

struct convex_hull_trick {
    struct line {
        i64 a, b;
        i64 at(i64 x) { return a * x + b; }
    };

    deque<line> q_;

    bool validate(line a, line b, line c) {
        return (b.b - c.b) * (b.a - a.a) <= (a.b - b.b) * (c.a - b.a);
    }

    void add(i64 a, i64 b) {
        line l { a, b };
        for (i64 n; n = q_.size(), n > 1 && validate(q_[n - 2], q_[n - 1], l);) {
            q_.pop_back();
        }
        q_.push_back(move(l));
    }

    i64 query(i64 x) {
        if (q_.empty()) return INF;
        while (q_.size() > 1 && q_[0].at(x) >= q_[1].at(x)) {
            q_.pop_front();
        }
        return q_[0].at(x);
    }
};

void solve() {
    i64 n, c;
    cin >> n >> c;

    i64 h;
    cin >> h;
    convex_hull_trick cht;
    cht.add(-2 * h, h * h);

    i64 dp = 0;
    for (i64 i = 1; i < n; i++) {
        cin >> h;
        dp = cht.query(h) + h * h + c;
        cht.add(-2 * h, dp + h * h);
    }
    cout << dp << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 5432
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef struct pair<int,int> P;
typedef long long ll;

ll n,k,l;

int dp1[16002][3]={};
int dp2[16002][3]={};
ll c[200001]={};
int main() {
	string a,b,c;

	cin>>a>>b>>c;
	int la=a.length();
	int lb=b.length();
	if(a[la-1]==b[0]&&b[lb-1]==c[0]){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
//	int ls=s.length();
//
//	int m=0;
//	int a1=0;
//	int a2=0;
//	int a3=0;
//	int a0=0;
//	bool flg=true;
//	for(a1=1;(s[a1]==s[a1-1])&&(a1<ls);a1++);
//	m=a1-a0;
//	for(a2=a1+1;(s[a2]==s[a2-1])&&(a2<ls);a2++);
//	m=max(a2-a1,a1-a0);
//	if(a2==ls)flg=false;
//	for(a3=a2+1;a3<ls;a3++){
//		for(;(s[a3]==s[a3-1])&&(a3<ls);a3++);
//		m=max(m,((a2-a1)+min(a1-a0,a3-a2)));
//		a0=a1;
//		a1=a2;
//		a2=a3;
//	}
//	if(flg)m=max(m,((a2-a1)+min(a1-a0,a3-a2)));
//	cout<<m<<endl;
	return 0;
}


Measured memory_bytes: 256
using Yorukatsu049.Questions;
using Yorukatsu049.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu049.Questions
{
    /// <summary>
    /// ABC059 D
    /// </summary>
    public class QuestionF : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var xy = inputStream.ReadLongArray();
            var x = xy[0];
            var y = xy[1];

            if (Math.Abs(x - y) <= 1)
            {
                yield return "Brown";
            }
            else
            {
                yield return "Alice";
            }
        }
    }
}


namespace Yorukatsu049
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionF();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu049.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu049.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Main {
    string S, T;
    void input() { cin >> S >> T; }
    void output() {
        string res;
        if (SZ(S) < SZ(T)) {
            cout << "UNRESTORABLE" << endl;
            return;
        }
        for (int i = 0; i < SZ(S) - SZ(T) + 1; ++i) {
            bool ok = true;
            string copy = S;
            for (int j = 0; j < SZ(T); ++j) {
                if (S[i + j] == '?' || S[i + j] == T[j]) {
                    copy[i + j] = T[j];
                } else {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                REP(i, SZ(S)) {
                    if (copy[i] == '?') { copy[i] = 'a'; }
                }
                if (res.empty() || res > copy) { res = copy; }
            }
        }
        if (res.empty()) { res = "UNRESTORABLE"; }
        cout << res << endl;
    }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

int main(){
    int n; cin >> n;
    int t[n+1], total=0;
    reps(i, 1, n+1){
        cin >> t[i];
        total+=t[i];
    }

    int m; cin >> m;
    int p[m+1], x[m+1];
    reps(i, 1, m+1){
        cin >> p[i] >> x[i];
    }

    reps(i, 1, m+1){
        int ans = total - t[p[i]]+x[i];
        out(ans);
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
static const int MAX_N = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, m;
int dist[MAX_N][MAX_N];
int color[MAX_N], p[MAX_N], d[MAX_N];

int prim(){
	int u, mincost;
	for(int i = 0; i < n; i++){
		d[i] = INFTY; p[i] = -1; color[i] = WHITE;
	}

	d[0] = 0;

	while(1){
		mincost = INFTY;
		u = -1;
		for(int i = 0; i < n; i++){
			if(mincost > d[i] && color[i] != BLACK){
				u = i; mincost = d[i];
			}
		}
		if(u == -1) break;
		color[u] = BLACK;
		for(int v = 0; v < n; v++){
			if(color[v] != BLACK && dist[u][v] != INFTY){
				if(d[v] > dist[u][v]){
					d[v] = dist[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
	}
	int sum = 0;
	for(int i = 0; i < n; i++){
		if(p[i] != -1) sum += dist[i][p[i]];
	}
	return sum;
}

int main(){
	while(1){
		int a, b, d;
		scanf("%d", &n);
		if(n == 0) break;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				dist[i][j] = INFTY;
			}
		}
		scanf("%d", &m);
		for(int i = 1; i <= m; i++){
			scanf("%d,%d,%d", &a, &b, &d);
			dist[a][b] = dist[b][a] = d / 100 - 1;
		}

		cout << prim() << endl;
	}
	return 0;
}

Measured memory_bytes: 3240
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 1;
    LL sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

double exp(double a, LL b){
    double res = 1;
    double sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

class Date{
public:
    int year;
    int month;
    int day;
    Date(const string &str){
        year = 0;
        month = 0;
        day = 0;
        int place = 0;
        while(str[place]!='/'){
            year*=10;
            year+=str[place]-'0';
            ++place;
        }
        ++place;
        while(str[place]!='/'){
            month*=10;
            month+=str[place]-'0';
            ++place;
        }
        ++place;
        while(place<str.size()){
            day*=10;
            day+=str[place]-'0';
            ++place;
        }
    }
};

void operator++(Date &a){
    ++a.day;
    if(a.month==2){
        if((a.year%4==0)!=(a.year%100==0)!=(a.year%400==0)){
            if(a.day==30){
                a.day=1;
                ++a.month;
            }
        }else{
            if(a.day==29){
                a.day=1;
                ++a.month;
            }
        }
    }else if(a.month == 4 || a.month == 6 || a.month == 9 || a.month == 11){
        if(a.day==31){
            a.day=1;
            ++a.month;
        }
    }else{
        if(a.day==32){
            if(a.month==12){
                a.month=0;
                ++a.year;
            }
            ++a.month;
            a.day=1;
        }
    }
}
signed  main(){
    string str;
    cin >> str;
    Date date(str);
    if(date.year > 2019 or date.year == 2019 and date.month > 4 or date.year==2019 and date.month == 4 and date.day >30){
        cout << "TBD" << endl;
    }else{
        cout << "Heisei" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;

using pii = pair<int, int>;

const int N = 2048;

int proxima_right[N], proxima_left[N], sum[N];

vector<pii> choices;
int n, ant;

static int get_sum(int a, int b) {
	if (a > b)
		return (sum[n - 1] - sum[a - 1]) + sum[b];
	else
		return sum[b] - (a > 0 ? sum[a - 1] : 0); }

int main() {
#ifdef HOME
	freopen("agc19d.in", "r", stdin);
	freopen("agc19d.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	vector<pii>::iterator it;
	string a, b;
	int tmp, add, mx, m;

	cin >> a >> b;
	n = a.size();

	if (b == string(n, '0')) {
		cout << -int(a != b) << endl;
		return 0; }

	for (int i = 0; i < n; ++i)
		sum[i] = (b[i] - '0') + (i > 0 ? sum[i - 1] : 0);

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j) if (b[(i + j) % n] == '1') {
			proxima_right[i] = j;
			break; }

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j) if (b[(i - j + n) % n] == '1') {
			proxima_left[i] = j;
			break; }

	ant = n * 2;
	choices.reserve(n);
	for (int shift = -n + 1; shift < n; ++shift) {
		add = 0;
		choices.resize(n);
		for (int i = 0; i < n; ++i) {
			if (a[i] == b[(i + shift + n) % n]) {
				choices[i] = pii(-1, -1); }
			else if ((shift < 0 ? get_sum((i + n + shift) % n, i) : get_sum(i, (i + n + shift) % n))) {
				add+= 1;
				choices[i] = pii(-1, -1); }
			else {
				choices[i] = {proxima_left[i], proxima_right[i]}; } }

		it = partition(begin(choices), end(choices), [&](const pii &x) { return x != pii(-1, -1); });
		choices.erase(it, end(choices));

		tmp = 2 * n;
		m = choices.size();
		if (shift > 0) {
			mx = abs(shift);
			sort(begin(choices), end(choices), [&](const pii &a, const pii &b) {
				return a.x == b.x ? a.y < b.y : a.x > b.x; });
			for (auto i: choices) {
				tmp = min(tmp, 2 * (mx + i.x) + m - abs(shift));
				mx = max(mx, i.y); } }
		else {
			mx = abs(shift);
			sort(begin(choices), end(choices), [&](const pii &a, const pii &b) {
				return a.y == b.y ? a.x < b.x : a.y > b.y; });
			for (auto i: choices) {
				tmp = min(tmp, 2 * (mx + i.y) + m - abs(shift));
				mx = max(mx, i.x); } }

		if (m == 0)
			tmp = abs(shift);

		ant = min(ant, tmp + add); }

	cout << ant << endl;

	return 0; }


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

using namespace std;


int main() {
    int h,w;
    cin>>h>>w;
    char map[h][w];
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin>>map[i][j];
        }
    }
    for (int k = 0; k < h; ++k) {
        for (int i = 0; i < w; ++i) {
            if(map[k][i]=='#'){
                if(k==0){
                    if(i==0){
                        if(map[k][i+1]=='.'&&map[k+1][i]=='.'){
                            cout<<"No"<<endl;
                            return 0;
                        }
                    }
                    else if(i==w-1){
                        if(map[k][i-1]=='.'&&map[k+1][i]=='.'){
                            cout<<"No"<<endl;
                            return 0;
                        }
                    }
                    else{
                        if(map[k][i-1]=='.'&&map[k][i+1]=='.'&&map[k+1][i]=='.'){
                            cout<<"No"<<endl;
                            return 0;
                        }
                    }
                }
                else if(k==h-1){
                    if(i==0){
                        if(map[k][i+1]=='.'&&map[k-1][i]=='.'){
                            cout<<"No"<<endl;
                            return 0;
                        }
                    }
                    else if(i==w-1){
                        if(map[k][i-1]=='.'&&map[k-1][i]=='.'){
                            cout<<"No"<<endl;
                            return 0;
                        }
                    }
                    else{
                        if(map[k][i-1]=='.'&&map[k][i+1]=='.'&&map[k-1][i]=='.'){
                            cout<<"No"<<endl;
                            return 0;
                        }
                    }
                }
                else{
                    if(i==0){
                        if(map[k][i+1]=='.'&&map[k-1][i]=='.'&&map[k+1][i]=='.'){
                            cout<<"No"<<endl;
                            return 0;
                        }
                    }
                    else if(i==w-1){
                        if(map[k][i-1]=='.'&&map[k-1][i]=='.'&&map[k+1][i]=='.'){
                            cout<<"No"<<endl;
                            return 0;
                        }
                    }
                    else{
                        if(map[k][i+1]=='.'&&map[k-1][i]=='.'&&map[k+1][i]=='.'&&map[k][i-1]=='.'){
                            cout<<"No"<<endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
const int INFI = 2147483647;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


const int N_MAX = 200000;
/*
vector<ll> inv(N_MAX); // inv[i]...i+1のmod MODにおける逆元
 
void Ninit(){
  for (int i=0; i<N_MAX; i++){
    // i+1のmodMODにおける逆元を計算する
    inv.at(i) = powerM((ll)(i+1), MOD-2);
  }
}
*/

// 二項係数nCk mod pの計算-------------------------------------
const int MAX = 510000;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  COMinit();
  //Ninit();
  ll n,k; cin >>n >>k;
  if (k >= n-1){
    /*
    移動回数kがn以上であれば全ての人を動かせるので全ての可能性が考えられる。
    そのときの場合の数はn+n-1Cn = 2n-1Cnとなる
    */
    ll res = COM((int)(2*n-1), (int)n);
    cout <<res <<endl;
  }else{
    ll res = 0;
    // kがn未満の時これがわからない。
    // 0人の部屋をkより多くはできないということ
    for (int i=0; i<=k; i++){
      // 空いた部屋の数、乃ち動かす人の数...i
      ll buf = COM((int)n, i); // 空き部屋の選び方
      ll room = n - i; // 使える部屋の数
      // i+n-i-1Ci = n-1Ci ... 人の突っ込み方
      buf = buf * COM((int)(n-1), i) % MOD;
      res = (res + buf) % MOD;
    }
    cout <<res <<endl;
  }
}

Measured memory_bytes: 12160
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
using namespace std;
int maxsum(int x,vector<long int> a){
	
	vector<long int> s(x+1,0);
	long int max;
	for(int i=1;i<=x;i++){
		if(s[i-1]<0&&s[i-1]<a[i])
			s[i]=a[i];
		else
			s[i]=s[i-1]+a[i];
	}
	max = *max_element(&s[1],&s[x+1]);
	return max;
	
}

int main(){
	
	int n;
	while(cin>>n,n!=0){
		
		vector<long int> a(n+1,0);
		
		for(int i=1;i<=n;i++)
			cin>>a[i];
		
		cout<<maxsum(n,a)<<endl;
	}
	
 	
}

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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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);
}

//* Mod int
const int mod = 1000000007;
struct mint {
  ll x;
  mint() : x(0) {}
  mint(ll x) : x((x % mod + mod) % mod) {}
  // mint(ll x):x(x){}
  mint &fix() {
    x = (x % mod + mod) % mod;
    return *this;
  }
  mint operator-() const { return mint(0) - *this; }
  mint &operator+=(const mint &a) {
    if((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint &a) {
    if((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint &a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
};
istream &operator>>(istream &i, mint &a) {
  i >> a.x;
  return i;
}
ostream &operator<<(ostream &o, const mint &a) {
  o << a.x;
  return o;
}
typedef vector<mint> vm;
typedef vector<vm> vvm;
//*/
long long modPow(long long x, long long n) {
  if(n == 0)
    return 1;
  if(n % 2 == 0) {
    long long sqrtX = modPow(x, n / 2);
    return sqrtX * sqrtX % mod;
  } else {
    return x * modPow(x, n - 1) % mod;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, k;
  cin >> n >> k;
  VLL a(n);
  rep(i, n) cin >> a[i];
  vector<mint> right(n, 0);
  vector<mint> sum(n, 0);
  rep(i, n) {
    FOR(j, i + 1, n) {
      if(a[i] > a[j]) {
        right[i] += 1;
      }
    }
  }

  rep(i, n) {
    rep(j, n) {
      if(a[i] > a[j]) {
        sum[i] += 1;
      }
    }
  }
  mint ans = 0;
  mint kk = k;
  rep(i, n) {
    ans += right[i] * k;
    ans += (kk - 1) * ((mint)(2) * sum[i] + mint(kk - 2ll) * sum[i]) *
           modPow(2ll, mod - 2);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
if len(set(S)) == 1:
    print(0)
    exit()

sum_blacks = [0] * N
if S[0] == "#":
    sum_blacks[0] += 1
for i in range(1, N):
    if S[i] == "#":
        sum_blacks[i] = sum_blacks[i - 1] + 1
    else:
        sum_blacks[i] = sum_blacks[i - 1]
ans = float('inf')
ans = min(ans, sum_blacks[-1])
ans = min(ans, N - sum_blacks[-1])
for i in range(N):
    l_blacks = sum_blacks[i]
    l_whites = i + 1 - l_blacks
    r_blacks = sum_blacks[-1] - l_blacks
    r_whites = N - l_blacks - l_whites - r_blacks
    ans = min(ans, l_blacks + r_whites)
print(ans)

Measured memory_bytes: 10116
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	int x, y, z; cin >> x >> y >> z;
	cout << z << ' ' << x << ' ' << y << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
        public static void main(String args[]){
                Scanner stdin = new Scanner(System.in);
                long X, Y;
                X = stdin.nextLong();
                Y = stdin.nextLong();

                int res = 0;
                while (X <= Y) {
                        res++;
                        X *= 2;
                }
                System.out.println(res);
        }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<ll, ll> pll;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
/* global variables */
/* function */
/* main */
int main(){
    ll N, D, A;
    cin >> N >> D >> A;
    vector<pll> v(N + 1);
    ll x, h;
    for (int i = 0; i < N; i++) {
        cin >> x >> h; v[i] = pll(x, h);
    }
    v[N] = pll(LINF, 0);
    sort(v.begin(), v.end());

    vector<ll> sum(N + 1);
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        x = v[i].first, h = v[i].second;
        h += sum[i];
        if (h <= 0) { sum[i+1] += sum[i]; continue; }
        int cnt = ceil((double) h / A);
        ans += cnt;
        sum[i] += -A * cnt;
        int upper = lower_bound(v.begin(), v.end(),
                    make_pair(x + 2*D + 1, numeric_limits<ll>::min())) - v.begin();
        sum[upper] += A * cnt;
        sum[i+1] += sum[i];
    }
    cout << ans << '\n';
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  int M=max({A,B,C});
  int a=3*M-A-B-C;
  int b=3*(M+1)-A-B-C;
  if(a%2==0){cout << a/2 << endl;}
  else{cout << b/2 << endl;}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int n[5],i;
    for(i=1;i<=4;i++)
    scanf("%1d",&n[i]);
    if(n[1]==n[2]&&n[2]==n[3])
    {
	printf("Yes\n");
    return 0;
	}
    if(n[2]==n[3]&&n[3]==n[4])
    {
		printf("Yes\n");
	    return 0;
	}
    printf("No\n");
   	return 0;
}

Measured memory_bytes: 256
point=input().split(" ")
sx=int(point[0])
sy=int(point[1])
tx=int(point[2])
ty=int(point[3])



a="R"*(tx-sx)+"U"*(ty-sy)+"L"*(tx-sx)+"D"*(ty-sy)
a+="D"
a+="R"*(tx-sx+1)+"U"*(ty-sy+1)
a+="L"
a+="U"
a+="L"*(tx-sx+1)+"D"*(ty-sy+1)
a+="R"

print(a)


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


int main() {
  int K,A,B;
  cin >> K >> A >> B;
  if (B / K != A / K || A % K == 0 || B % K == 0)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// union-find tree

const int max_n = 100005;

int par[max_n];
int rnk[max_n];

void init(int n){
	rep(i,n){
		par[i+1] = i+1;
		rnk[i+1] = 0;
	}
}

// find root of tree with x
int find(int x){
	if(par[x] == x) return x;
	else return par[x] = find(par[x]);
}

void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y) return;

	if(rnk[x] < rnk[y]) par[x] = y;
	else{
		par[y] = x;
		if(rnk[x] == rnk[y]) rnk[x]++;
	}
}

bool same(int x, int y){
	return find(x) == find(y);
}

// end union-find tree

bool matched[max_n];

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

	int n,m;
	cin >> n >> m;

	int p[n+1];
	rep(i,n) cin >> p[i+1];

	init(n);
	rep(i,n) matched[i+1] = false;

	rep(i,m){
		int x, y;
		cin >> x >> y;
		unite(x,y);
	}

	int ans = 0;
	rep(i,n){
		if(p[i+1] == i+1){
			ans++;
			matched[i+1] = true;
		}
		else{
			if(same(i+1,p[i+1]) && !matched[p[i+1]]){
				ans++;
				matched[p[i+1]] = true;
			} 
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1536
N = int(input())
list = list(map(int, input().split()))

huriwake = [0, 0, 0, 0, 0, 0, 0, 0]
rea = 0
count = 0

for i in list:
    if i < 400:
        huriwake[0] = 1
    elif i < 800:
        huriwake[1] = 1
    elif i < 1200:
        huriwake[2] = 1
    elif i < 1600:
        huriwake[3] = 1
    elif i < 2000:
        huriwake[4] = 1
    elif i < 2400:
        huriwake[5] = 1
    elif i < 2800:
        huriwake[6] = 1
    elif i < 3200:
        huriwake[7] = 1
    else:
        rea += 1

for h in huriwake:
    if h == 1:
        count += 1

if count == 0 and rea > 0:
    count += 1
    rea -= 1

min = count

if rea > 0:
    count += rea

max = count

print("{0} {1}".format(min, max))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
// IO
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
#define pd(a) printf("%d ", a)
#define pld(a) printf("%d\n", a)
#define pda(a, n) fo(i, n) pd(a[i])
#define pl printf("\n")
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b) 
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
// math
const ll mod = 1e9+7;
template<typename T> T gcf(T a, T b) {return (b == 0) ? a : gcf(b, a%b);} 
template<typename T> T lcm(T a, T b) {return (a*b)/gcf(a, b);}
template<typename T> T sumTo(T x) {return x * (x+1) / 2;}
template<typename T> T sumSquaresTo(T x) {return x * (x+1) * (2*x+1) / 6;}
template<typename T> T ceilDiv(T n, T d) {return (n+d-1)/d;}

void solve() {
    int n, q, k; cin >> n >> k >> q;
    int s[n+1] = {0};
    int p;
    fo(i, q) {
        cin >> p;
        s[p]++;
    }
    fo1(i, n) {
        if (s[i] > q-k) {
            Yes();
        }
        else {
            No();
        }
    }

}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long ;
using ld=long double;

int ncount(int n){
    int count=0;
    while(n>0){
        n/=10;
        count++;
    }
    return count;
}
int main(){
    int n;
    cin>>n;
    int count=0;
    for(int i=1;i<=n;i++){
        int x=ncount(i);
        if(x%2!=0){
            count++;
        }
    }
    
    cout<<count;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <iomanip>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int N;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
    cin >> N;
    if (N%2) {
        cout << ((N+1)/2)/(double)N << endl;
    } else {
        cout << 0.5 << endl;
    }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,k=map(int,input().split())
    k+=1
    AB=[tuple(map(int,input().split())) for _ in range(n)]

    dp=[0]*35 # dp[d]: less than が確定するのが d 桁目のときの最大値
    # dp[d] の状態のものが a を買えるのは、d 以上の桁については ad<=kd かつ、
    # d 桁目については ad<kd となるもののみ
    for a,b in AB:
        for d in range(34,-1,-1):
            kd=(k>>d)&1
            ad=(a>>d)&1
            if(ad>kd): break
            if(ad<kd):
                dp[d]=dp[d]+b

    print(max(dp))
resolve()

Measured memory_bytes: 55772
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using M = map<string,ll>;


int main(){
    ll N;
    cin >> N;
    ll K;
    cin >> K;
    cout<<min(N%K,K-N%K)<<endl;

return 0;
}  



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

using namespace std;

//2 factor sort
struct num {
	int x;
	int l;

	bool operator<(const num &in) const {
		return x+l<in.x+in.l;
	};
};

int main(){

	int n, np,ans=1;
	vector<num> v;

	cin>> n;
	v.resize(n);
	for(int i=0;i<n;i++) cin>> v[i].x >> v[i].l;

	sort(v.begin(), v.end());

	np = v[0].x + v[0].l;

	for (int i = 1;i < v.size();i++) {
		if (np <= v[i].x - v[i].l) {
			np = v[i].x + v[i].l;
			ans++;
		}
	}

	cout << ans << endl;


}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct node
{
    int u,v;
    ll w;
    bool operator<(const node &o)const{return w<o.w;}
}e[200005*18];
int n,cot=0,a[200005],fail[200005];
ll d;
void add(int l,int r)
{
    if(l>=r) return;
    int m=l+r>>1;
    ll mi=1e18,pos;
    for(int i=l;i<=m;i++)
    {
        ll f=a[i]-d*i;
        if(f<mi) mi=f,pos=i;
    }
    for(int i=m+1;i<=r;i++)
        e[cot].u=pos,e[cot].v=i,e[cot++].w=a[i]+a[pos]+d*(i-pos);
    mi=1e18;
    for(int i=m+1;i<=r;i++)
    {
        ll f=a[i]+d*i;
        if(f<mi) mi=f,pos=i;
    }
    for(int i=l;i<=m;i++)
        e[cot].u=i,e[cot].v=pos,e[cot++].w=a[i]+a[pos]+d*(pos-i);
    add(l,m);add(m+1,r);
}
int get_fa(int x)
{
    return fail[x]==x?x:fail[x]=get_fa(fail[x]);
}
ll kruskal()
{
    sort(e,e+cot);
    for(int i=1;i<=200000;i++) fail[i]=i;
    ll ans=0;
    for(int i=0;i<cot;i++)
    {
        int fu=get_fa(e[i].u),fv=get_fa(e[i].v);
        if(fu==fv) continue;
        fail[fu]=fv;
        ans+=e[i].w;
    }
    return ans;
}
int main()
{
    scanf("%d%lld",&n,&d);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    add(1,n);
    printf("%lld\n",kruskal());
}


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


int n,m;
double f[3005][3005];
double a[3005],ans;

void inp()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
}

void proc()
{
    f[0][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        f[i][0] = f[i-1][0]*(1-a[i]);
        for (int j = 1; j <= i; j++)
        {
            f[i][j] = (f[i-1][j-1] * a[i]) + (f[i-1][j] * (1-a[i]));
        }
    }

    for (int i = n; i*2 > n; i--)
    {
        ans += f[n][i];
    }
    printf("%.9f",ans);
}


int main()
{
    inp();
    proc();
    return 0;
}


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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++)
        cin >> d[i];

    ll sum = 0;
    for(int i = 0; i < n - 1; i++)
    {
        for(int j = i + 1; j < n; j++)
            sum += d[i] * d[j];
    }

    cout << sum;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
	int n,i;
	scanf("%d",&n);
	printf("%d:",n);
	for(i=2;i<=sqrt(n);i++){
		if(n%i==0){
			n/=i;
			printf(" %d",i);
			i=1;
		}
	}
	printf(" %d\n",n);
	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i, n) cin >> p[i];
	int ans = 0;
	rep(i, n - 1) {
		if (p[i] == i + 1) {
			swap(p[i], p[i + 1]);
			ans++;
		}
	}
	if (p.back() == n) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
L, R = map(int,input().split())
l = str(L)
r = str(R)
last_l = ""
last_r = ""
for i in range(L):
    last_r += r 
for i in range(R):
    last_l += l     
if L > R:
    print(last_r)
else:
    print(last_l)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
#define pb push_back
int main(void){
    ll a[10]={1,1,0,2,0,0,1,0,1,0};
    string n;
    cin>>n;
    ll x=a[atoi(n.substr(n.length()-1,1).c_str())];
    if(x==0){
        cout<<"hon";
    }else if(x==1){
        cout<<"pon";
    }else{
        cout<<"bon";
    }
}

Measured memory_bytes: 3596