akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, pair<int, int>> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, m, a[112345];
    int b[112345][31];
    memset(b, 0, sizeof(b));

    ll sum = 0;

    cin >> n >> m;
    REP(i, n)
    {
        cin >> a[i];
        sum += a[i];

        ll j = 0;
        while (true)
        {
            b[i][j] = a[i] / (1LL << j);

            if (a[i] / (1LL << j) == 0)
                break;

            j++;
        }
    }

    priority_queue<P> q;

    REP(i, n)
    {
        q.push({b[i][0] - b[i][1], {i, 1}});
    }

    while (m)
    {
        P p = q.top();
        q.pop();

        sum -= p.first;
        m--;
        q.push({b[p.second.first][p.second.second] - b[p.second.first][p.second.second + 1], {p.second.first, p.second.second + 1}});
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 15992
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
const long long MOD = 1000000007;

typedef long long ll;

int main(void) {
  int n;
  char s[100010];
  cin >> n >> s;
  int x = 0, y = 0;
  rep(i, n) {
    if ('A' <= s[i] && s[i] <= 'M') x++;
    if ('N' <= s[i] && s[i] <= 'Z') x--;
    if ('a' <= s[i] && s[i] <= 'm') y++;
    if ('n' <= s[i] && s[i] <= 'z') y--;
  }
  cout << abs(x) + abs(y) << endl;
  if (x > 0) rep(i, x) cout << 'A';
  else rep(i, -x) cout << 'N';
  if (y > 0) rep(i, y) cout << 'a';
  else rep(i, -y) cout << 'n';

  cout << endl;

  return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;
int d[10][10];

void warshall(){
    for(int k=0;k<10;k++){
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
}


int main(){
    
    int H,W;cin>>H>>W;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin>>d[i][j];
        }
    }
    
    warshall();
    
    ll ans=0;
    
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int a;cin>>a;
            if(a!=-1) ans+=d[a][1];
        }
    }
    
    cout<<ans<<endl;
    
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

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

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	ll x, a, b; cin >> x >> a >> b;
	if (b - a <= 0)cout << "delicious" << endl;
	else if (b - a <= x)cout << "safe" << endl;
	else cout << "dangerous" << endl;
	return 0;
}

Measured memory_bytes: 3568
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int n,k;
typedef pair<int,int> pii;
int color[100004];
vector <int> g[100004];
int main(){
	cin>>n;
	for (int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);  
	}
	memset (color,-1,sizeof(color));
	priority_queue <pii,vector <pii>,greater<pii> > q;
	cin>>k;
	for (int i=0;i<k;i++){
		int x,p;
		cin>>x>>p;
		color[x]=p;
		q.push(pii(p,x)); 
	}
	while (!q.empty()){
		pii u=q.top();
		q.pop();
		for (int i=0;i<g[u.second].size();i++)
			if (color[g[u.second][i]]==-1){
				color[g[u.second][i]]=u.first+1;
				q.push(pii(u.first+1,g[u.second][i]));
			}
	}
	for (int i=1;i<=n;i++){
		for (int j=0;j<g[i].size();j++)
			if (abs(color[i]-color[g[i][j]])==1);
			else{
				cout<<"No";
				return 0;
			}
		}
	cout<<"Yes"<<endl;
	for (int i=1;i<=n;i++) cout<<color[i]<<endl;
	return 0;
}

Measured memory_bytes: 7924
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<string>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  int N; std::cin >> N;
  std::vector<std::pair<int, int>> pls, mis;
  int sum = 0;
  for(int i = 0; i < N; ++i) {
    int mi = 0, cur = 0;
    std::string S; std::cin >> S;
    for(auto s: S) {
      if(s == ')') --cur; else ++cur;
      mi = std::min(mi, cur);
    }
    if(mi != 0 || cur != 0) {
      if(cur >= 0) pls.emplace_back(mi, cur);
      else         mis.emplace_back(mi-cur, -cur);
    }
    sum += cur;
  }
  if(sum != 0) fin("No");

  std::sort(pls.begin(), pls.end(), std::greater<std::pair<int,int>>());
  for(auto p: pls) {
    if(sum + p.first < 0) fin("No");
    sum += p.second;
  }
  sum = 0;
  std::sort(mis.begin(), mis.end(), std::greater<std::pair<int,int>>());
  for(auto p: mis) {
    if(sum + p.first < 0) fin("No");
    sum += p.second;
  }
  fin("Yes");
  return 0;
}


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

int main(){
    int n;
    while(cin>>n,n){
        int t,r=0,j=0,l=32;
        vector<int>v;
        for(int i=0;i<n;i++){
            cin>>t;
            v.push_back(t);
        }
        while(l){
            r++;
            if(r%2)
                l-=(l - 1) % 5;
            else{
                l-=v[j];
                j=(j+1)%n;
            }
            if(l<0)l=0;
            cout<<l<<endl;
        }
    }
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
int main()
{
int h,w,i;
  cin >> h >> w;
  string s[h];
  
  for(i=0;i<w+2;++i)
  {cout << '#';}
  cout << endl;
  
  for(i=0;i<h;++i)
  {cin >> s[i];
   cout << '#' << s[i] << '#' << endl;}

  for(i=0;i<w+2;++i)
  {cout << '#';}

return 0;}

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

int main(){
    int N,K; cin >> N >> K;
    vector <int> A(N);
    rep(i,N) cin >> A[i];
    
    //等差数列の方程式
    auto f=[&](int x){//xは項数
        return 1+(x-1)*(K-1);
    };
    
    int ans=0;
    int x=1;//初項
    while(1){
        if(f(x)>=N) break;//末項超えたら終了
        ans++;
        x++;
    }
    cout << ans;
}


Measured memory_bytes: 640
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=2e5+50;
const int mod=1e9+7;
using namespace std;
ll n,d,a,fw[nmax],x,y,z,cur,rs,i,j;
vector<pair<ll,ll> >vc;
void upd(int i,int v)
{
	for(;i<=n;i+=i&(-i))fw[i]+=v;
}
int qry(int i)
{
	int ans=0;
	for(;i>=1;i-=i&(-i))ans+=fw[i];
	return ans;
}
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>d>>a;
	for(i=1;i<=n;i++)cin>>x>>y,vc.pb(mkp(x,y));
	sort(vc.begin(),vc.end());
	for(i=0;i<n;i++)
	{
		x=vc[i].fr+d;
		j=upper_bound(vc.begin(),vc.end(),mkp(x+d,llinf))-vc.begin()-1;
		//cout<<i+1<<" "<<j+1<<endl;
		y=qry(i+1);
		cur=vc[i].sc-y;
		if(cur<=0)continue;
		z=(cur/a)+(cur%a!=0);
		rs+=z;
		upd(i+1,z*a);
		upd(j+2,-z*a);
	}
	cout<<rs<<endl;
	return 0;
}


Measured memory_bytes: 6384
n = int(input())
v = list(map(int, input().split()))

first = {}
second = {}

for i in range(n):
    if i % 2 == 0:
        if v[i] in first:
            first[v[i]] += 1
        else:
            first[v[i]] = 1
    else:
        if v[i] in second:
            second[v[i]] += 1
        else:
            second[v[i]] = 1

first = sorted(first.items(), key=lambda x: x[1])
second = sorted(second.items(), key=lambda x: x[1])

f = first.pop()
s = second.pop()

if f[0] == s[0]:
    if len(first) >= 1:
        if len(second) >= 1:
            f2 = first.pop()
            s2 = second.pop()

            if f2[1] + s[1] > f[1] + s2[1]:
                f = f2
            else:
                s = s2
        else:
            s = second.pop()
    elif len(second) >= 1:
        f = first.pop()
    else:
        s = (0, 0)

print(n-f[1]-s[1])

Measured memory_bytes: 23692
#include <iostream>
#include <vector>
#include <numeric>
#include <iterator>
#include <climits>
using namespace std;

int main(void){
	int N;
	while (cin >> N, N) {
		vector<int> a(N);
		for (int i = 0; i < N; i++)
			cin >> a[i];
		vector<int> sums;
		sums.push_back(0);
		partial_sum(a.begin(), a.end(), back_inserter(sums));

		int m = INT_MIN;
		for (int i = 0; i < N; i++) {
			for (int j = i; j < N; j++) {
				m = max(m, sums[j + 1] - sums[i]);
			}
		}

		cout << m << endl;
	}
}

Measured memory_bytes: 1264
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    s=chomp(readline())
    b=0
    w=count(x->x=='.',s)
    arr=Vector{Int}([w])
    for i in s
        if i=='#'
            b+=1
        else
            w-=1
        end
        push!(arr,b+w)
    end
    println(minimum(arr))
end
main()

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

judge = True
for A in An:
    if A % 2 == 0:
        if A % 3 == 0 or A % 5 == 0:
            judge = True
        else:
            judge = False
            break

if judge:
    print('APPROVED')
else:
    print('DENIED')


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

using namespace std;

typedef long long ll;

signed main(){
    ll n, x;
    cin >> n >> x;

    vector<ll> all(1, 1);
    for(ll i = 0; i < 50; ++i)
        all.push_back(all.back() * 2 + 3);

    vector<ll> pat(1, 1);
    for(ll i = 0; i < 50; ++i)
        pat.push_back(pat.back() * 2 + 1);

    // [0,index)
    function<ll(ll,ll)> calc = [&](ll level, ll index){
        if(level == 0)
            return index;

        if(!index)
            return 0LL;
        --index;
        ll ans = 0;
        if(index < all[level - 1]){
            return calc(level - 1, index);
        }else{
            ans += pat[level - 1];
            index -= all[level - 1];
        }
        if(index < 2)
            return ans + index;
        --index;
        ++ans;
        return ans + calc(level - 1, min(all[level - 1], index));
    };

    cout << calc(n, x) << endl;
}


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

int main(){
	
	int n ;
	
	while( cin >> n ){
		if( cin.eof() ) break ;
		
		int ans = 0 ;
		for( int a = 0 ; a < 10 ; a++ ){
			if( a > n ) break ;
			for( int b = 0 ; b < 10 ; b++ ){
				if( a+b > n ) break ;
				for( int c = 0 ; c < 10 ; c++ ){
					if( a+b+c > n ) break ;
					for( int d = 0 ; d < 10 ; d++ ){
						if( a+b+c+d > n ) break ;
						if( a+b+c+d == n ) ans++ ;
					}
				}
			}
		}
		
		cout << ans << endl;
	}
	
	
	
return 0 ;
}

Measured memory_bytes: 1160
import Numeric

stddiv ns =
  sqrt $ ((sum [(s - m)^2 | s <- ns]) / n)
  where m = sum ns / n
        n = fromIntegral $ length ns

showF f = showFFloat Nothing f ""
readNums = fmap (map read . words) getLine

main = do
  n <- readLn
  if n == 0 then return ()
  else do
   ss <- readNums
   putStrLn $ showF $ stddiv ss
   main

Measured memory_bytes: 4808
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for (int i=0 ; i<s.size() ; ++i)
    {
        if (s[i]!=',')
        {
            cout<<s[i];
        }
        else
        {
            cout<<" ";
        }
    }
    cout<<endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <fstream>
#include <vector>
#include <memory>
#include <map>
#include <random>
#include <set>
#include <numeric>
#include <iomanip>
#include <bitset>

using namespace std;

void run(istream &cin, ostream &cout){
    int a, b;
    cin >> a  >> b;
    if(a + b == 15) cout << '+';
    else if(a * b == 15) cout << '*';
    else cout << 'x';
}

int main() {
#ifdef  LOCAL
    ifstream cin("input.txt");
    ofstream cout("output.txt");
#else
    cin.tie(0);
    ios::sync_with_stdio(0);
#endif
    run(cin, cout);
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef list<int> LI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EMP empty()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000

const double EPS = 1e-10;
const double PI  = acos(-1.0);
////////////////////////////////////////////////
#define MAX 100000

class Disjos
{
public:
	vector<int> rank,p;
	Disjos(){}
	Disjos(int size)
	{
		rank.resize(size,0);
		p.resize(size,0);
		for(int i=0;i<size;i++)makeSet(i);
	}
	
	void makeSet(int x)
	{
		p[x]=x;
		rank[x]=0;
	}
	
	bool same(int x,int y)
	{
		return findSet(x)==findSet(y);
	}
	
	void unite(int x,int y)
	{
		link(findSet(x),findSet(y));
	}
	
	void link(int x,int y)
	{
		if(rank[x]>rank[y])
		{
			p[y]=x;
		}
		else
		{
			p[x]=y;
			if(rank[x]==rank[y])
			{
				rank[y]++;
			}
		}
	}
	
	int findSet(int x)
	{
		if(x!=p[x])
		{
			p[x]=findSet(p[x]);
		}
		return p[x];
	}
};

class Edge
{
public:
	int source,target,cost;
	Edge(int source=0,int target=0,int cost=0):
	source(source),target(target),cost(cost){}
	bool operator<(const Edge &e)const
	{
		return cost<e.cost;
	}
};

int kruskal(int N,vector<Edge> edges)
{
	int totcost=0;
	sort(ALL(edges));
	Disjos dset=Disjos(N+1);
	
	REP(i,N)dset.makeSet(i);
	
	int source,target;
	REP(i,SZ(edges))
	{
		Edge e=edges[i];
		if(!dset.same(e.source,e.target))
		{
			totcost+=e.cost;
			dset.unite(e.source,e.target);
		}
	}
	return totcost;
}

int main()
{
	int N,M,cost,source,target;
	cin>>N>>M;
	
	vector<Edge> edges;
	REP(i,M)
	{
		cin>>source>>target>>cost;
		edges.PB(Edge(source,target,cost));
	}
	
	cout<<kruskal(N,edges)<<endl;
	
	return 0;
}

Measured memory_bytes: 5464
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#include <utility>
#include <map>
#include <functional>
#include <initializer_list>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;

int main(){
    string S;
    cin >> S;
    if(S=="SUN") cout << 7;
    else if(S=="MON") cout << 6;
    else if(S=="TUE") cout << 5;
    else if(S=="WED") cout << 4;
    else if(S=="THU") cout << 3;
    else if(S=="FRI") cout << 2;
    else if(S=="SAT") cout << 1;

}

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

using namespace std;
typedef pair<int, int> P;
vector<P> Mark;
int maxPoint = 0;

void DFS(int D, int pos, int point)
{
	if (maxPoint < point)
	{
		maxPoint = point;
	}
	
	for (int i = pos; i < Mark.size(); ++i)
	{
		if (D - Mark[i].first >= 0)
		{
			DFS(D - Mark[i].first, i + 1, point + Mark[i].second);
		}
	}
}

void solve()
{
	int D, x;
	cin >> D >> x;
	for (int i = 0; i < x; ++i)
	{
		string answer;
		int point;
		cin >> answer >> point;
		if (answer == "D")
		{
			P p(1, point);
			Mark.push_back(p);
		}
	}
	int y;
	cin >> y;
	for (int i = 0; i < y; ++i)
	{
		string answer;
		int point;
		cin >> answer >> point;
		if (answer == "DD")
		{
			P p(2, point);
			Mark.push_back(p);
		}
	}
	DFS(D, 0, 0);
	cout << maxPoint << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1216
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    d, t, s = rli()
    if t*s >= d:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9172
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    bool ok = true;
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if(x % 2 == 0 && x % 5 != 0 && x % 3 != 0) {
            ok = false;
        }
    }
    if(ok) cout << "APPROVED\n";
    else cout << "DENIED\n";
}



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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long a = sc.NextLong();
        long b = sc.NextLong();
        long c = sc.NextLong();
        long k = sc.NextLong();

        long answer = 0;

        if (k > a)
        {
            k -= a;
            answer += a;
        }
        else
        {
            answer += k;
            k = 0;
        }

        if (k > b)
        {
            k -= b;
        }
        else
        {
            k = 0;
        }

        if (k > 0)
        {
            answer -= k;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 27452
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
	int n = 0;
	int m = 0;

	scanf("%d", &n);
	scanf("%d", &m);

	int a[51][51] = { -1 };
	int b[51][51] = { -1 };
	char tmp;


	//a読み込み部
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			scanf("%c", &tmp);
			if (tmp == '\n') { scanf("%c", &tmp); }
			if (tmp == '.') { a[i][j] = 0; }
			else if(tmp == '#'){ a[i][j] = 1; }

		}
	}

	//b読み込み部
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < m; j++) {
			scanf("%c", &tmp);
			if (tmp == '\n') { scanf("%c", &tmp); }

			if (tmp == '.') { b[i][j] = 0; }
			else if (tmp == '#') { b[i][j] = 1; }

		}
	}

	if (n - m < 0) {printf("No");	return 0;}

	int x = 0;
	int y = 0;

	for (int i = 0; i < n - m +1; i++) {
		for (int j = 0; j < n - m +1; j++) {

			for (x = 0; x < m; x++) {
				for (y = 0; y < m; y++) {
					if (a[i+x][j+y] != b[x][y]) { goto next; }
				}
				if (x == (m - 1) && y == (m) ) { printf("Yes"); 
				return 0; }
			}
			next:;

		}
	}

	printf("No");

	return 0;
}

Measured memory_bytes: 128
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

import GHC.Exts

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, l ] <- readInts
	print $ sum $ tail $ sortWith abs $ take n [ l .. ]

Measured memory_bytes: 380
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	ll a,b,c,x,y;

	cin>>a>>b>>c>>x>>y;

	ll total=0;
	ll total2=10000000000;
	for(ll i=0; i<max(x,y)+1; i++){
		if(i<x){
			total+=(x-i)*a;
		}
		if(i<y){
			total+=(y-i)*b;
		}
		total2=min(total2,total);
		total=c*(i+1)*2;
	}
	cout<<total2<<endl;

	return 0;
}


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

namespace PaizaTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var text = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
            var line = text.Split(',').Select(x => int.Parse(x)).ToList();
            var index = int.Parse(Console.ReadLine());

            Console.WriteLine(line[index - 1]);
        }
    }
}


Measured memory_bytes: 11348
#include <iostream>

using namespace std;

long long MOD = 1e9+7;

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

	long long dp[N+1][5][5][5];
    for(int n = 0; n < N+1; n++){
        for(int i = 0; i < 5; i++){
            for(int j = 0; j < 5; j++){
                for(int k = 0; k < 5; k++){
                    dp[n][i][j][k] = 0;
                }
            }
        }
    }
    dp[0][0][0][0] = 1;

	for(int n = 0; n < N; n++){
        for(int i = 0; i < 5; i++){
            for(int j = 0; j < 5; j++){
                for(int k = 0; k < 5; k++){
                    for(int l = 1; l < 5; l++){
                        if(i == 1 && j == 2 && l == 3) continue;
                        if(i == 1 && k == 2 && l == 3) continue;
                        if(j == 1 && k == 2 && l == 3) continue;
                        if(j == 2 && k == 1 && l == 3) continue;
                        if(j == 1 && k == 3 && l == 2) continue;

                        dp[n+1][j][k][l] += dp[n][i][j][k];
                        dp[n+1][j][k][l] %= MOD;
                    }
                }
            }
        }
    }

	long long ans = 0;
    for(int j = 1; j < 5; j++){
        for(int k = 1; k < 5; k++){
            for(int l = 1; l < 5; l++){
                ans += dp[N][j][k][l];
                ans %= MOD;
            }
        }
    }

    cout << ans << endl;


    return 0;
}

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

 int main()
{
    int N, K;
     cin >> N >> K;
     for(int i = 0;i < N;i++){
         if((N/pow(K,i)<1)){
             cout << i  << endl;
             break;
         }
         else if((N/pow(K,i)==1)){
             cout << i + 1 << endl;
             break;
         }
     }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
C = [[0]*10 for i in range(10)]

def get_ab(n):
    str_n = str(n)
    return map(int, [str_n[0], str_n[-1]])

for i in range(1, N + 1):
    a, b = get_ab(i)
    C[a][b] += 1

# print(C)
ans = 0
for i in range(10):
    for j in range(10):
        ans += C[i][j] * C[j][i]
print(ans)


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

signed main(){
    int a;
    string s;
    cin >> a;
    cin >> s;
    if(a >= 3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC123_D_Cake_123
{
	class Program
	{
		static void Main(string[] args)
		{
			long[] input = Console.ReadLine().Split(' ').Select(n => long.Parse(n)).ToArray();
			long x = input[0];
			long y = input[1];
			long z = input[2];
			long k = input[3];
			long[] ax = Console.ReadLine().Split(' ').Select(n => long.Parse(n)).ToArray();
			long[] by = Console.ReadLine().Split(' ').Select(n => long.Parse(n)).ToArray();
			long[] cz = Console.ReadLine().Split(' ').Select(n => long.Parse(n)).ToArray();
			long[] values_ab = new long[x * y];
			long count = 0;
			
			for(long i = 0; i < x; i++)
			{
				for(long j = 0; j < y; j++)
				{
					values_ab[count] = ax[i] + by[j];
					count++;
				}
			}

			Array.Sort(values_ab);
			Array.Reverse(values_ab);

			long[] values = new long[k];
			for(long i = 0; i < Math.Min(k, values_ab.Length); i++)
			{
				values[i] = values_ab[i];
			}

			count = 0;
			long[] values_abc = new long[values.Length * z];
			for(long i = 0; i < k; i++)
			{
				for(int j = 0; j < z; j++)
				{
					values_abc[count] = values[i] + cz[j];
					count++;
				}
			}

			Array.Sort(values_abc);
			Array.Reverse(values_abc);

			for(int i = 0; i < k; i++)
			{
				Console.WriteLine(values_abc[i]);
			}
		}
	}
}


Measured memory_bytes: 45024
N=int(input())
a=list(map(int,input().split()))
b,c,d=0,0,0
for i in range(N):
    if a[i]%2:
        b+=1
    elif not a[i]%4:
        c+=1
    else:
        d+=1
if b<=c+1 and d==0:
    print("Yes")
elif b<=c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 15020
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    string ans = s;
    ll numl = 0;
    for(char c : s){
        if(c == '('){
            numl++;
        }else{
            if(numl == 0){
                ans.insert(0, 1, '(');
            }else{
                numl--;
            }
        }
    }
    for(int i = 0; i < numl; ++i){
        ans.push_back(')');
    }
    cout << ans << endl;
    return 0;
}


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

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main() {
  int K, a, b, sum;
  cin >> K;
  sum = 0;
  for (int l = 1; l <= K; l++) {
    for (int m = 1; m <= K; m++) {
      for (int n = 1; n <= K; n++) {
        a = gcd(l, m);
        a = gcd(a, n);
        //cout << a << endl;
        sum += a;
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3636
use io::*;
use std::cmp::{max, min};
use std::i64;

fn main() {
    let con = read_string();
    let mut sc = Scanner::new(&con);

    let n: usize = sc.next();
    let m: usize = sc.next();

    let ds: Vec<(i64, i64, i64)> = (0..n).map(|_| (sc.next(), sc.next(), sc.next())).collect();

    let mut ans = 0;

    for p in 0..8 {
        let mut tbl = vec![vec![i64::MIN; n + 1]; m + 1];
        ans = max(ans, rec(m, 0, p, &ds, &mut tbl));
    }

    println!("{}", ans);
}

fn rec(rest: usize, pos: usize, p: i32, ds: &Vec<(i64, i64, i64)>, tbl: &mut Vec<Vec<i64>>) -> i64 {
    if rest == 0 {
        return 0;
    }

    if pos == ds.len() {
        return i64::MIN + 1;
    }

    if tbl[rest][pos] != i64::MIN {
        return tbl[rest][pos];
    }

    let ret = rec(rest, pos + 1, p, ds, tbl);
    let ret = {
        let t = rec(rest - 1, pos + 1, p, ds, tbl);
        if t == i64::MIN + 1 {
            ret
        } else {
            let b0 = if p & 1 != 0 { 1 } else { -1 };
            let b1 = if p & 2 != 0 { 1 } else { -1 };
            let b2 = if p & 4 != 0 { 1 } else { -1 };
            max(ret, t + ds[pos].0 * b0 + ds[pos].1 * b1 + ds[pos].2 * b2)
        }
    };
    tbl[rest][pos] = ret;
    ret
}

//-----

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 12540
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = s; i < b; i+=d)
#define lpsb(i, s, b) for(size_t i = s; i < b; i++)
#define lpn(i, n) for(size_t i = 0; i < n; i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)

using namespace std;
using ull = unsigned long long;

const ull MOD = 1000000007;

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

int main(void)
{
    ull A, B, C, D;
    cin >> A >> B >> C >> D;
    auto CD = C * D / gcd(C, D);
    A--;
    auto a = A - A/C - A/D + A/CD;
    auto b = B - B/C - B/D + B/CD;
    cout << (b - a) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int rot[24][7] = {
    { 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
    { 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
    { 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
    { 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
    { 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
    { 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };
int assign[7];

int main()
{
    int i, j;
    int a[7], b[7], dice[7];
    
    for (i = 1; i <= 6; i++) scanf("%d", assign+i);
    for (i = 1; i <= 6; i++) scanf("%d", a+i);
    for (j = 0; j < 24; j++) {
        for (i = 1; i <= 6; i++) dice[i] = rot[j][i];
        for (i = 1; i <= 6; i++) b[i] = assign[dice[i]];
        for (i = 1; ; i++) {
            if (i > 6) { puts("Yes"); return 0; }
            if (a[i] != b[i]) break;
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
	map<char, char>m;
	m['D'] = 'A';
	m['E'] = 'B';
	m['F'] = 'C';
	m['G'] = 'D';
	m['H'] = 'E';
	m['I'] = 'F';
	m['J'] = 'G';
	m['K'] = 'H';
	m['L'] = 'I';
	m['M'] = 'J';
	m['N'] = 'K';
	m['O'] = 'L';
	m['P'] = 'M';
	m['Q'] = 'N';
	m['R'] = 'O';
	m['S'] = 'P';
	m['T'] = 'Q';
	m['U'] = 'R';
	m['V'] = 'S';
	m['W'] = 'T';
	m['X'] = 'U';
	m['Y'] = 'V';
	m['Z'] = 'W';
	m['A'] = 'X';
	m['B'] = 'Y';
	m['C'] = 'Z';
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		s[i] = m[s[i]];
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
#define Elhabashy ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}
const int N=18,mod=1e9+7;
typedef long long ll;
ll n,arr[N][N],dp[1<<N],cm[1<<N];
ll solve(int msk = (1<<n)-1)
{
    if (!msk)
        return 0;
    ll &ret = dp[msk];
    if (~ret)
        return ret;
    ret = -1e9;
    for(int cur=msk;cur;cur=((cur-1)&msk)){
        int tmp=cur^msk;
        ret=max(ret,cm[cur]+solve(tmp));
    }
    return ret;
}
void gen1()
{
    for(int i=0; i<(1<<n); i++)
    {
        ll sum=0;
        vector<int>tmp;
        for(int j=0; j<n; j++)
        {
            if((1<<j)&i)
            {
                tmp.push_back(j);
            }
        }
        for(int x=0; x<tmp.size(); x++)
        {
            for(int y=x+1; y<tmp.size(); y++)
            {
                int idx1=tmp[x],idx2=tmp[y];
                sum+=arr[idx1][idx2];
            }

        }
        cm[i]=sum;

    }
}
int main()
{
    Elhabashy
    input();
    cin>>n;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
            cin>>arr[i][j];
    }
    gen1();
    memset(dp,-1,sizeof dp);
    cout<<solve()<<endl;
}


Measured memory_bytes: 6176
// inputに入力データ全体が入る
function Main(input) {
  
   input = input.split("\n");
   var NK = input[0].split(" ");
  var N= parseInt(NK[0], 10);
 var K= parseInt(NK[1], 10);
 
   var S = input[1];

   var K = K - 1;
   var p = S[K ].toLowerCase() ;
 var SS = S.substr(0,K) + p + S.substr(K+1);
   console.log(SS);                  
  }
 
  
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
string u="abcdefghijklmnopqrstuvwxyz";

int main(){
    string s;
    cin >> s;
    int cg=0,cp=0;
    int ans=0;
    for(int i=0;i<s.length();i++){
        if(cg==cp){
            if(s[i]=='p') ans--;
            cg++;
        }
        else if(cp<cg){
            if(s[i]=='g'){
                ans++;
                cp++;
            }
            else{
                cp++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int n,ans,a[200005],f[200005];
bool vis[200005];

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		f[i]=1;
	}
	for(int i=1;i<=n;i++){
		vis[a[i]]=true;
		if(vis[a[i]-1]){
			f[a[i]]=f[a[i]-1]+1;
		}
		if(f[a[i]]>ans)ans=f[a[i]];
	}
	cout<<n-ans<<'\n';
	return 0;
}

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

int main() {
	int n, a[100005], ans = 0, ima = 1;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	
	while (ima != 2) {
	    ima = a[ima];
	    ans++;
	    if (ans > n) break;
	}
	if (ans < n) cout << ans;
	else cout << -1;
	return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>

#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{

    int A, B;
    cin >> A >> B;

    if (A + B < 10) {
    	printf("%d\n", A + B);
    }
    else {
    	printf("error\n");
    }

	return 0;
}

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

int main()
{
    int n, k, l = 0;
    cin >> n >> k;
    int x[n];
    for (int i = 0; i < n; i++)
    {
        cin >> x[i];
        if (x[i] > k - x[i])
        {
            l += 2 * (k - x[i]);
        }
        else
        {
            l += 2 * x[i];
        }
    }
    cout << l << endl;
}

Measured memory_bytes: 256
//
// Created by 10940 on 2020/7/11.
//

#include <bits/stdc++.h>

using namespace std;
//#define LOCAL
int a[10005];

void fun(int num) {
    int ans = 0;
    for (int i = 1; i * i <= num; i++) {
        for (int j = 1; j * j <= num; j++) {
            for (int k = 1; k * k <= num; k++) {
                int re = i * i + j * j + k * k + i * j + j * k + i * k;
                if (re <= num) {
                    a[re]++;
                }
            }
        }
    }
}


int main() {
/*#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif*/
    int N;
    cin >> N;
    fun(N);
    for (int i = 1; i <= N; i++) {
        cout << a[i] << endl;
    }
    /*printf("Time used = %.3fs\n", (double) clock() / CLOCKS_PER_SEC);
    printf("Time used = %dms", clock());*/
    return 0;
}


Measured memory_bytes: 3680
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cmath>

#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, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(a, n) sort(a, a+n)
#define VSORT(v) sort(v.begin(), v.end())

using namespace std;

int main()
{
    int n;

    cin >> n;

    int r = 0, g = 0, b = 0;
    char s[n];

    REP(i, n) {
        cin >> s[i];
        if(s[i] == 'R') { r += 1; }
        else if(s[i] == 'G') { g += 1; }
        else { b += 1; }
    }

    long count = (long)r * g * b;
    int k;

    REP(i, n) {
        FOR(j, i+1, n+1) {
            k = 2 * j - i;
            if(k >= n) { break; }
            if((s[i] != s[j]) && (s[j] != s[k]) && (s[k] != s[i])) { count -= (long)1; }
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3628
N = int(input())
A = [[int(i) for i in input().split()] for j in range(2)]

idx = 0
ct = [[], []]
for i in A:
    ct[idx].append(i[0])
    for j in range(1, N):
        ct[idx].append(ct[idx][j-1] + i[j])
    idx += 1

ct[1].insert(0, 0)

ans = 0
for i in range(N):
    ans = max(ans, ct[0][i]+ct[1][-1]-ct[1][i])

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main(){
  int a,b;
  cin >> a >> b;
  if(a<10&&b<10)
    cout << a*b << endl;
  else
    cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111

	void solve(){

		ini(n);
		vi morty(n);
		FOR(i,0,n)in(morty[i]);
		ini(n1);
		map<int,int> map1;
		int tmp = 0;
		FOR(i,0,1<<n){
			int tmp1 = 0;
			FOR(i1,0,n){
				if((1<<i1) & i)tmp1+=morty[i1];
			}
			map1[tmp1] = 1;
		}
		FOR(i,0,n1){
			ini(x);
			if(map1[x] == 1)out("yes");
			else out("no");
		}

		
		
		








	}	























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}



Measured memory_bytes: 3276
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
#define int long long		
int a[214514];
int b[214514];
signed main(){
	int n,a,b,c,d,e;
	cin>>n>>a>>b>>c>>d>>e;
	c((n-1)/min({a,b,c,d,e})+5)
}	

Measured memory_bytes: 256
import math
 
N = int(input())
d_list = []
 
for i in range(1, int(math.sqrt(N)) + 1):
  if N % i == 0:
    if i != 1:
      if (N // (i - 1)) == (N % (i - 1)):
        d_list.append(i)
    if i != math.sqrt(N):
      if (N // (N / i - 1)) == (N % (N / i - 1)):
        d_list.append(N / i)
 
output = sum(d_list) - len(d_list)
print(int(output))

Measured memory_bytes: 3064
//abc148D
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void) {
  int n, i, cou=1;
  long long sum=0;
  scanf(" %d", &n);
  int a[n];

  for(i=0; i < n; i++){
    scanf(" %d", &a[i]);
    if(a[i] == cou) cou++;
    else sum++;
  }
  if(sum == n) printf("-1");
  else printf("%d", sum);
}

Measured memory_bytes: 896
import collections


def main():
    _ = int(input())
    A = list(map(int, input().split()))
    q = int(input())

    CNT = [0] * (10 ** 5)

    C = collections.Counter(A)
    for k, v in C.items():
        CNT[k - 1] = v

    s = 0
    for i in range(10 ** 5):
        s += (i + 1) * CNT[i]

    # S = []
    for i in range(q):
        b, c = map(int, input().split())
        value = CNT[b - 1]
        CNT[b - 1] = 0
        CNT[c - 1] += value

        s = s - b * value + c * value
        print(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21280
#include<bits/stdc++.h>
using namespace std;
#define INF (1e9)
int N,M;
int s[15];
int d[100];
int sum[(1<<15)];
int dp[(1<<15)];

void init(){
  for(int i=0;i<(1<<N);i++){
    sum[i]=0;
    dp[i]=0;
  }
}

int solve(){
  for(int i=0;i<M;i++){
    for(int bit=0;bit<(1<<N);bit++){
      for(int j=0;j<N;j++){
        dp[bit|(1<<j)]=min(dp[bit|(1<<j)],dp[bit]);
      }
    }
    for(int bit=0;bit<(1<<N);bit++){
      dp[bit]+=abs(sum[bit]-d[i]);
    }
  }
  int ans=INF;
  for(int bit=0;bit<(1<<N);bit++){
    ans=min(ans,dp[bit]);
  }
  return ans;
}

int main(){
  while(1){
    cin>>N>>M;
    if(N==0&&M==0)break;
    init();
    for(int i=0;i<N;i++)cin>>s[i];
    for(int i=0;i<M;i++)cin>>d[i];
    sort(d,d+M);
    for(int bit=0;bit<(1<<N);bit++)
      for(int i=0;i<N;i++)
        if(bit>>i&1)sum[bit]+=s[i];
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3352
import numpy as np

N,T = [int(_) for _ in input().split()]
t = [int(_) for _ in input().split()]
sum = 0
last_time=0
for time in t:
    if time - last_time >= T:
        sum += T
    else:
        sum += time-last_time
    last_time = time
sum += T
print (sum)

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

#define int long long

signed main(){
    int n;
    int a[100010];
    cin >> n;

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

    int ans[100010] = {};
    for(int i = 0;i < n;i++){
        if(i % 2 == 0){
            ans[0] += a[i];
        }else{
            ans[0] -= a[i];
        }
    }

    for(int i = 1;i < n;i++){
        ans[i] = (a[i-1]-ans[i-1]/2)*2;
    }

    for(int i = 0;i < n;i++){
        cout << ans[i];
        if(i < n-1){
            cout << " ";
        }else{
            cout << endl;
        }
    }


    return 0;
}



Measured memory_bytes: 2816
s=input()
st=[]
ans=0
for i in s:
  # print("入力:",i,"stack:",st)
  if i=="0":
    if not st or st[-1]=="0":
      st.append(i)
    elif st[-1]=="1":
      st.pop()
      ans+=2
  elif i =="1":
    if not st or st[-1]=="1":
      st.append(i)
    elif st[-1]=="0":
      st.pop()
      ans+=2
      # print(" 合体",st)

print(ans)

Measured memory_bytes: 3956
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(){
  vector<int> X[10];
  int N,D,cnt=0;
  cin >> N >> D;
  for(int j=0;j<N;j++){
    for(int k=0,x;k<D;k++){
      cin >> x;
      X[j].push_back(x);
    }
    
    for(int i=0;i<j;i++){
      int sum=0;
      for(int k=0;k<D;k++){
       sum+=(X[j][k]-X[i][k])*(X[j][k]-X[i][k]);
      }
      if(ceil(sqrt(sum))==sqrt(sum))cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

int main(){
    int a,b,C;
    scanf("%d %d %d",&a,&b,&C);
    double r=C*M_PI/180;  //????????¢????????????
    double S,L,h;
    S=a*b*sin(r)/2;
    L=sqrt(a*a+b*b-2*a*b*cos(r))+b+a;
    h=b*sin(r);
    printf("%.8f %.8f %.8f\n",S,L,h);
    return 0;
}

Measured memory_bytes: 1068
fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    
    val stations = Array(N - 1, {Triple(0, 0, 0)})
    (0 until N - 1).map{val (C, S, F) = readInputLine().split(" ").map{it.toInt()}; stations[it] = Triple(C, S, F)}

    for (i in 0 until N) {
        var t = 0
        for (j in i until N - 1) {
            if (t < stations[j].second) {
                t = stations[j].second
            } else if (t % stations[j].third != 0) {
                t += stations[j].third - t % stations[j].third
            }
            
            t += stations[j].first
        }
        println(t)
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 38424
#include<stdio.h>
int main(void)
{
    int x,y,z,i,I;
    scanf("%d",&I);
    for(i=0;i<I;i++){
        scanf("%d %d %d",&x,&y,&z);
        if(x*x==y*y+z*z || y*y==x*x+z*z || z*z==x*x+y*y){
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 576
#include <iostream>
using namespace std;
int main()
{
  string s;
  cin >> s;
  int count = 700;
  if ( s.at(0) == 'o' ){
  count += 100;
  }
  if ( s.at(1) == 'o' ){
  count += 100;
  }
  if ( s.at(2) == 'o' ){
  count += 100;
  }
  cout << count << endl;
}

Measured memory_bytes: 256