akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var P = string.Join("", Console.ReadLine().Split().Select(int.Parse).ToArray());
            var Q = string.Join("", Console.ReadLine().Split().Select(int.Parse).ToArray());

            var array = Enumerable.Range(1, N).ToArray();
            int a = 0, b = 0, count = 0;
            do
            {
                count++;
                if (P == string.Join("", array)) a = count;
                if (Q == string.Join("", array)) b = count;
            } while (NextPermutation(array)) ;

            Console.WriteLine(Math.Abs(a - b));
        }

        public static void Swap<T>(ref T one, ref T two)
        {
            var temp = one;
            one = two;
            two = temp;
        }

        public static bool NextPermutation<T>(T[] array, int index, int length, Comparison<T> comp)
        {
            if (length <= 1) return false;
            for (int i = length - 1; i > 0; i--)
            {
                int k = i - 1;
                if (comp(array[k], array[i]) < 0)
                {
                    int j = Array.FindLastIndex(array, delegate (T x) { return comp(array[k], x) < 0; });
                    Swap(ref array[k], ref array[j]);
                    Array.Reverse(array, i, length - i);
                    return true;
                }
            }
            Array.Reverse(array, index, length);
            return false;
        }
        public static bool NextPermutation<T>(T[] array) where T : IComparable
        {
            return NextPermutation(array, 0, array.Length, Comparer<T>.Default.Compare);
        }
    }
}


Measured memory_bytes: 17588
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define pri 1000000007
using namespace std;

int main() {
	ll n,k;
	cin>>n>>k;
	ll a[n][n];
	ll ans[n][n];
	ll ansnew[n][n];
	ll b[n][n];
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n;j++){
			cin>>a[i][j];
			ans[i][j]=0;
			if(i==j)ans[i][j]=1;
		}}
	while(k){
	     for(ll i=0;i<n;i++){
					for(ll j=0;j<n;j++){
					b[i][j]=0;
					
										}}
		if(k%2==1){
		//	cout<<k;
				for(ll i=0;i<n;i++){
					for(ll j=0;j<n;j++){
							ansnew[i][j]=0;
										}}
			
				
				for(ll i=0;i<n;i++){
					for(ll j=0;j<n;j++){
						for(ll ka=0;ka<n;ka++){
						//	if(a[ka][j]==1){cout<<ka<<j<<endl;}
								ansnew[i][j]=(ansnew[i][j]+(ans[i][ka]*a[ka][j])%pri)%pri;}
											}
									}
									
					for(ll i=0;i<n;i++){
							for(ll j=0;j<n;j++){
													ans[i][j]=ansnew[i][j];
										}}
		}
		
		for(ll i=0;i<n;i++){
				for(ll j=0;j<n;j++){
					 for(ll ka=0;ka<n;ka++){
					b[i][j]=(b[i][j]+a[i][ka]*a[ka][j])%pri;}
				}
			}
				for(ll i=0;i<n;i++){
				for(ll j=0;j<n;j++){
					a[i][j]=b[i][j];
				}}
		
		k=k/2;
	}
	ll se=0;
					for(ll i=0;i<n;i++){
				for(ll j=0;j<n;j++){
					se=(se+ans[i][j])%pri;
				}}
				cout<<se;
	// your code goes here
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second

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

map<string,int> syuki;
string in;
int pos;

map<string,int> mergemap(map<string,int>&l,map<string,int>&r){
  map<string,int> ret=l;
  FOR(miter,r)ret[miter->F]+=miter->S;
  return ret;
}

string getatom(){
  string ret;
  ret+=in[pos];
  ++pos;
  if(islower(in[pos])){
    ret+=in[pos];
    ++pos;
  }
  return ret;
}

int getnum(){
  int ret=0;
  while(isdigit(in[pos])){
    ret=ret*10+in[pos]-'0';
    ++pos;
  }
  return ret;
}

map<string,int> molecule(){
  map<string,int> ret;
  while(pos<in.size() && in[pos]!=')'){
    map<string,int> tmap;
    if(isupper(in[pos])){
      string atom=getatom();
      if(isdigit(in[pos])){
	int num=getnum();
	tmap[atom]=num;
      }else tmap[atom]=1;
    }else{
      ++pos;
      tmap=molecule();
      if(isdigit(in[pos])){
	int num=getnum();
	FOR(miter,tmap)tmap[miter->F]*=num;
      }
    }
    ret=mergemap(ret,tmap);
  }
  ++pos;
  return ret;
}

main(){
  while(cin>>in){
    if(in=="END_OF_FIRST_PART")break;
    int t;
    cin>>t;
    syuki[in]=t;
  }

  while(cin>>in){
    if(in=="0")break;
    pos=0;
    map<string,int> ans=molecule();
    bool unk=false;
    int ansnum=0;
    FOR(miter,ans){
      //cout<<miter->F<<" "<<miter->S<<endl;
      if(syuki.count(miter->F)){
	ansnum+=syuki[miter->F]*miter->S;
      }else {
	unk=true;
	break;
      }
    }
    if(unk)cout<<"UNKNOWN"<<endl;
    else cout<<ansnum<<endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <cmath>
#include <limits.h>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;
using P = pair<int,int>;
using ll = long long;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int MAX=(1<<18)+10;
const int CHANGE=1024;
int n;
vector<int> v(MAX),w(MAX);
vector<vector<ll>> d(CHANGE,vector<ll>(100010,0));
void dfs(int idx){
    if(idx*2>n||idx*2>=CHANGE)return;
    for(int i=0;i<100010;i++){
        chmax(d[idx*2][i],d[idx][i]);
        if(i+w[idx*2]<100010)chmax(d[idx*2][i+w[idx*2]],d[idx][i]+v[idx*2]);
    }
    for(int i=1;i<100010;i++){
        chmax(d[idx*2][i],d[idx*2][i-1]);
    }
    dfs(idx*2);
    if(idx*2+1>n||idx*2+1>=CHANGE)return;
    for(int i=0;i<100010;i++){
        chmax(d[idx*2+1][i],d[idx][i]);
        if(i+w[idx*2+1]<100010)chmax(d[idx*2+1][i+w[idx*2+1]],d[idx][i]+v[idx*2+1]);
    }
    for(int i=1;i<100010;i++){
        chmax(d[idx*2+1][i],d[idx*2+1][i-1]);
    }
    dfs(idx*2+1);
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>v[i]>>w[i];
    d[1][w[1]]=v[1];
    for(int i=1;i<100010;i++)chmax(d[1][i],d[1][i-1]);
    dfs(1);
    int q;
    cin>>q;
    while(q--){
        int u,l;
        ll ret=0;
        cin>>u>>l;
        if(u<CHANGE){
            ret=d[u][l];
        }else{
            vector<int> root;
            int now=u;
            while(now>=CHANGE){
                root.emplace_back(now);
                now/=2;
            }
            for(int bit=0;bit<(1<<root.size());bit++){
                ll vcnt=0,wcnt=0;
                for(int i=0;i<root.size();i++){
                    if(bit&(1<<i)){
                        vcnt+=v[root[i]];
                        wcnt+=w[root[i]];
                    }
                }
                if(wcnt<=l)chmax(ret,vcnt+d[now][l-wcnt]);
            }
        }
        cout<<ret<<endl;
    }
}

Measured memory_bytes: 808804
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;

int main() {
	int k, a, b;
	cin >> k >> a >> b;
	bool ans = false;
	for (int i = a;i <= b;i++) {
		if (i%k == 0) {
			ans = true;
			break;
		}
	}
	if (ans)
		cout << "OK" << endl;
	else
		cout << "NG" << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define prin(a) cout<<a<<"\n"
#define kaigyo cout<<"\n"
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define SORT(V) sort(ALL(V))
#define REV(V) reverse(ALL(V))
#define RSORT(V) SORT(V);REV(V)

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<string> vst;
typedef vector<char> vc;
typedef vector<long double> vd;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
typedef vector<vector<int>> vint2;
ll mod=1e9+7;

const double pi=acos(-1.0);
const ll inf=1LL<<60;
ll gcd(ll p,ll q){if(q==0)return p;return gcd(q,p%q);}  
ll lcm(ll p,ll q){return (p*q)/gcd(p,q);}
ll kaizyo(ll k){ll sum=1;rep1(i,k){sum*=i;sum%=mod;}return sum;}
ll ncr(ll n,ll r){return kaizyo(n)/(kaizyo(r)*kaizyo(n-r));}


int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
cout.precision(20);
int n,d;cin>>n>>d;
int cnt=0;
vd x(n),y(n);
rep(i,n)cin>>x[i]>>y[i];
rep(i,n){
    if(hypot(x[i],y[i])<=d)cnt++;
}
prin(cnt);
return 0;
}



Measured memory_bytes: 9464
#include <iostream>
#include <vector>
#include <string>
#include <stack>
using namespace std;
int main() {
    string str;
    getline(cin, str);
    int begin = 0;
    string moji;
    vector<string> v;
    vector<string> ans;
    for(int i = 0; i <= str.size(); i++){
        if(str[i] == ' '){
            v.push_back(str.substr(begin, i - begin));
            begin = i + 1;
        }
    }
    v.push_back(str.substr(begin, str.size() - begin));
    for(int i = 0; i < v.size(); i++){
        if((v[i][v[i].size() - 1] == ',' ||v[i][v[i].size() - 1] == '.') && v[i].size() >= 4 && v[i].size() <= 7 ){
          v[i][v[i].size() - 1] = ' ';
            ans.push_back(v[i]);
        }else if(v[i].size() >= 3 && v[i].size() <= 6){
            v[i] = v[i] + ' ';
            ans.push_back(v[i]);
    }
    }
    for(int i = 0; i < ans.size(); i++){
        if(i == ans.size() - 1){
            for(int j = 0; j < ans[i].size() - 1; j++){
                cout << ans[i][j];
            }
            break;
        }cout << ans[i];
    }
    cout << endl;
        return 0;
}

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


long long extGcd(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGcd(b, a%b, y, x);
    y -= a / b * x;
    return d;
}


int main() {
    long long a, b, x, y;
    cin >> a >> b;
    extGcd(a, b, x, y);
    cout << x << ' ' << y << endl;
}



Measured memory_bytes: 3096
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
const i64 MOD = 1000000007;

i64 n, k;
vec<i64> a;
bool dp[5001][5001];

bool need(i32 i) {
    dp[0][0] = true; upto(1, n, j) dp[0][j] = false;
    upto(1, n, j) {
        upto(0, k, l) {
            dp[j][l] = dp[j-1][l];
            if (l >= a[j] && j != i) {
                dp[j][l] |= dp[j-1][l-a[j]];
            }
        }
    }
    bool ok = false;
    range(max(0ll, k-a[i]), k, j) {
        if (dp[n][j]) {
            ok = true;
            break;
        }
    }
    return ok;
}

i32 main()
{
    cin >> n >> k;
    a.resize(n+1);
    upto(1, n, i) {
        cin >> a[i];
    }
    sortall(a);

    i32 low = 0;
    i32 high = n+1;
    while (high-low > 1) {
        i32 mid = (low+high)/2;
        if (need(mid)) {
            high = mid;
        } else {
            low = mid;
        }
    }
    cout << low << endl;

    return 0;
}

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

using namespace std;

int main()
{
    int n;
    long long a[100];
    a[0] = 2;
    a[1] = 1;
    for (int i = 2;i <= 87;++i)
        a[i] = a[i-1]+a[i-2];
    while (cin >> n) {
        cout << a[n] << endl;
    }
}


Measured memory_bytes: 256
var mem = [];
function fib(n) {
	if (mem[n]) return mem[n];
	if (n <= 1) return 1;
	var ret = fib(n - 1) + fib(n - 2);
	mem[n] = ret;
	return ret;
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var n = +input.trim();

console.log(fib(n));

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

using namespace std;

#define MAXN 100010
typedef long long LL;

LL n, p[100];


int main( int argc , char * argv[] ){
//	freopen( "input.txt" , "r" , stdin );
//	freopen( "output.txt" , "w" , stdout );
    int i, L, l, r, m; p[0] = 1;
    char c;
	for(i = 1; i <= 12; ++i){
        p[i] = p[i - 1] * 10;
	}
	printf("? %lld\n", p[12]);
	fflush(stdout);
    scanf(" %c", &c);
    if(c == 'Y'){
        for(i = 1; i <= 12; ++i){
            printf("? %lld\n", p[i] - 1);
            fflush(stdout);
            scanf(" %c", &c);
            if(c == 'Y') break;
        }
        printf("! %lld\n", p[i - 1]);
    }
    else{
        for(i = 1; i <= 12; ++i){
            printf("? %lld\n", p[i]);
            fflush(stdout);
            scanf(" %c", &c);
            if(c == 'N') break;
        }
        L = i;
        for(i = 1; i < L; ++i){
            n *= 10;
            for(l = 0, r = 9; l < r;){
                m = (l + r + 1) >> 1;
                printf("? %lld\n", n + m);
                fflush(stdout);
                scanf(" %c", &c);
                if(c == 'Y') l = m;
                else r = m - 1;
            }
            n += l;
        }
        n *= 10;
        for(i = L == 1 ? 1 : 0; i <= 9; ++i){
            printf("? %lld\n", (n + i) * 10 + 9);
            fflush(stdout);
            scanf(" %c", &c);
            if(c == 'Y') break;
        }
        n += i;
        printf("! %lld\n", n);
	}
	return 0;
}


Measured memory_bytes: 648
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<long long,int> P;
class Edge
{
	public:
	int to,ind;
	ll cost;
	Edge(int t,int c,int i)
	{
		to=t;cost=c;ind=i;
	}
};
vector<Edge> g[800];
bool used[800];
ll wfcost[800][800];
//nowから辿れるパスの全コスト
ll dfs(int now)
{
	//cerr<<now<<endl;
	ll ret=0;
	used[now]=true;
	for(int i=0;i<g[now].size();i++)
	{
		Edge e=g[now][i];
		if(!used[e.to])
			ret+=e.cost+dfs(e.to);
	}
	return ret;
}

void wfdfs(int s,int now,ll length)
{
	wfcost[s][now]=length;
	used[now]=true;
	for(int i=0;i<g[now].size();i++)
	{
		Edge e=g[now][i];
		if(!used[e.to])
			wfdfs(s,e.to,length+e.cost);
	}
	return;
}
//dfsで全点間最短路を求める
void wf(int n)
{
	for(int i=0;i<n;i++)
	{
		fill(used,used+800,false);
		wfdfs(i,i,0);
	}
}

int main()
{
	while(1)
	{
		int n;
		ll ans=1e16-1;
		cin>>n;
		if(n==0)
			break;
		fill(used,used+800,false);
		fill(wfcost[0],wfcost[800],1e14-1);
		for(int i=0;i<800;i++)
			g[i].clear();
		int p[800];
		for(int i=1;i<n;i++)
		{
			cin>>p[i];
			p[i]--;
		}
		int index=0;
		ll sum=0;
		for(int i=1;i<n;i++)
		{
			int d;
			cin>>d;
			g[i].push_back(Edge(p[i],d,index));
			g[p[i]].push_back(Edge(i,d,index));
			index++;
		}
		//葉は無条件で取り除けるので除く
		for(int i=0;i<n;i++)
		{
			if(g[i].size()==1)
			{
				used[i]=true;
				sum+=g[i][0].cost;
			}
		}
		//スタートとゴール地点の候補を全列挙する
		vector<int> sg;
		for(int i=0;i<n;i++)
		{
			if(used[i])
				continue;
			int p=0;
			for(int j=0;j<g[i].size();j++)
			{
				if(!used[g[i][j].to])
					p++;
			}
			if(p==1)
				sg.push_back(i);
		}
		if(sg.size()<2)
		{
			cout<<sum<<endl;
			continue;
		}
		//cerr<<sg.size()<<" "<<sg[0]<<endl;
		//残った辺のコスト総和を求める
		sum+=(dfs(sg[0])*3);
		//cerr<<sum<<endl;
		wf(n);
		for(int i=0;i<sg.size();i++)
		{
			for(int j=i+1;j<sg.size();j++)
			{
				//sg[i]->sg[j]の最短パスを求める
				ll path=wfcost[sg[i]][sg[j]];
				ans=min(ans,sum-path);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 55, mod = 1e9 + 7;

int n, m;
bool g[N][N], bk[N][N];

bool check()
{
    for(int i = 1; i <= n; i++)
        if(!g[1][i])
            return true;
    return false;
}

void floyd()
{
    for(int k = 1; k <= n; k++)
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= n; j++)
                g[i][j] |= g[i][k] && g[k][j];
}

int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++)
            if(i == j) bk[i][j] = true;
            else bk[i][j] = false;

    for(int i = 0; i < m; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        bk[a][b] = bk[b][a] = true;
    }

    int res = 0;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j < i; j++)
            if(bk[i][j])
            {
                memcpy(g, bk, sizeof bk);
                g[i][j] = g[j][i] = false;
                floyd();
                if(check()) res++;
            }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second

typedef long long ll;
typedef std::pair < int, int > pr;
const int N = 305;

#define int ll
using std::cin;
using std::cout;

int n, dis[N][N], ans, P[N][N];
signed main() {
	std::ios::sync_with_stdio(false), std::cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j) cin >> dis[i][j];
	for (int k = 1; k <= n; ++k)
	    for (int i = 1; i <= n; ++i)
	        for (int j = 1; j <= n; ++j) {
	            if (i == j || j == k || i == k) continue;
	            if (dis[i][j] > dis[i][k] + dis[k][j]) return cout << -1 << '\n', 0;
	            if (dis[i][j] == dis[i][k] + dis[k][j]) P[i][j] = 1;
            }
    for (int i = 1; i <= n; ++i)
        for (int j = i + 1; j <= n; ++j) 
            if (! P[i][j]) ans += dis[i][j];
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 5028
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
using namespace std;

string YorN(bool P) { if (P)return "YES"; else return "NO"; }

int main() {

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

    if (A == B)cout << C << endl;
    else if (A == C)cout << B << endl;
    else cout << A << endl;
    
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

const int64 mod = 1e9+7;
map<int64, int64> memo[212345];

int main(void){
	string s;
	cin >> s;
	int64 cnt[2] = {};
	REP(i, s.size()) {
		cnt[s[i]-'0']++;
	}
	cout << min(cnt[0], cnt[1])*2 << endl;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

ll n,c,k;
ll t[110000];
ll ans;

int main(){
  cin>>n>>c>>k;
  rep(i,n){
    cin>>t[i];
  }

  sort(t,t+n);
  t[n] = 1e11;

  for(int i=0;i<n;i++){
    ll s = t[i];
    ll co = 1;
    while(co<c&&t[i+1]<=s+k){
      co++;
      i++;
    }
    ans++;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		//System.out.println(N);
		long m=0;
		long a=0;
		long r=0;
		long c=0;
		long h=0;
		for(int i =0;i<N;i++){
			String str=sc.next();
			//System.out.println(hoge);
			if(str.startsWith("M")){
				//System.out.println("M");
				m++;
			}else if(str.startsWith("A")){
				a++;
				//System.out.println("A");
			}else if(str.startsWith("R")){
				r++;
				//System.out.println("R");
			}else if(str.startsWith("C")){
				c++;
				//System.out.println("C");
			}else if(str.startsWith("H")){
				h++;
				//System.out.println("H");
			}
		}
		long ans=0;
		ans = m*(a*(r+c+h)+r*(c+h)+c*h)+a*(r*(c+h)+c*h)+r*c*h;
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 43460
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using Graph = vector<vector<int>>;


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;
}
ll modinv(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while(b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if(u < 0) u += m;
    //cout << u << endl;
    return u;
}

ll paty_counter(ll level, ll x){
    ll size = pow(2, level+2) - 3;
    ll pmi = pow(2, level) - 1;
    if(x == 0){
        return 0;
    }else if(level == 0){    
        return 1;
    }else{
        if(x <= (size - 1)/2){
            return paty_counter(level-1, x-1);
        }else{
            return pmi + 1 + paty_counter(level-1, x - pow(2, level+1) + 3 - 2);
        }
    }

}
 
using namespace std;
using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
static ll x;
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v); // 再帰的に探索
        x ++;
    }
}

int main() {
    int x;
    cin >> x;
    cout << abs(x-1) << endl;
}



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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

#define P pair<lli,lli>

signed main(){

	lli d,n;
	cin>>d>>n;
	if(n==100)n++;

	lli s;
	if(d==0)s=1;
	else if(d==1)s=100;
	else s=10000;

	lli cnt=1;
	for(lli i=s;;i+=s){
		if(cnt==n){
			cout<<i<<endl;
			return 0;
		}
		cnt++;
	}

	return 0;
}

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

int main() {

	int a, b, c;
	int counter = 0;
	int i;

	cin >> a >> b >> c;

	for (i = a; i < b + 1; i++) {
		if((c%i) == 0) counter += 1;
	}

	cout << counter << endl;

	return 0;
}


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

int main() {
	int N;
	int a[200001];
	int b[200001];
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < N; ++i) {
		b[i] = a[i];
	}

	sort(a, a + N);
	for (int i = 0; i < N; i++) {
		if (b[i] <= a[N / 2 - 1]) {
			cout << a[N / 2] << endl;
		}
		else {
			cout << a[N / 2 - 1] << endl;
		}
	}
}

Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int r;
	cin>>r;
	cout<<(3*r*r);
	
	return 0;
}

Measured memory_bytes: 256
if !ENV['RUBY_THREAD_VM_STACK_SIZE']
  exec({'RUBY_THREAD_VM_STACK_SIZE'=>'1000000000'}, '/usr/bin/ruby', $0)
end

# require 'pry'
N = gets.to_i
@g = {}
(N-1).times do
  s, t, u = gets.split.map(&:to_i)
  (@g[s-1] ||= []) << [t-1, u]
  (@g[t-1] ||= []) << [s-1, u]
end
# p @g
Q, K = gets.split.map(&:to_i)
que = []
Q.times do
  que << gets.split.map(&:to_i)
end
# p que

def dfs(now, prev, dist = 0)
  @g[now].each do |to, cost|
    next if to == prev
    dfs(to, now, dist + cost)
  end
  @dp[now] = dist
end
# binding.pry
@dp = Array.new(N)
dfs(K-1, -1)
# p @dp
que.each do |x, y|
  puts @dp[x-1] + @dp[y-1]
end

Measured memory_bytes: 253892
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,f,n) for(int i=f;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;

int n, m, q, res;
vector<tuple<int, int, int, int> > abcd;

void dfs(vector<int>& vec){
    if(vec.size() == n){
        int sum = 0;
        for(auto [a, b, c, d] : abcd){
            if(vec[b-1] - vec[a-1] == c){
                sum += d;
            }
        }
        chmax(res, sum);
        return;
    }
    int low = (vec.size() ? vec.back() : 1ll);
    for(int i = low; i <= m; ++i){
        vec.emplace_back(i);
        dfs(vec);
        vec.pop_back();
    }
}

signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    cin >> n >> m >> q;

    abcd.resize(q);

    for(auto&& [a, b, c, d] : abcd){
        cin >> a >> b >> c >> d;
    }

    vector<int> vec;
    dfs(vec);

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3660
#include <stdio.h>
int n, p[6]; double d;
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf("%lf", &d);
		if(d < 165.0) {
			p[0]++;
		}
		else if(d < 170.0) {
			p[1]++;
		}
		else if(d < 175.0) {
			p[2]++;
		}
		else if(d < 180.0) {
			p[3]++;
		}
		else if(d < 185.0) {
			p[4]++;
		}
		else {
			p[5]++;
		}
	}
	for(int i = 0; i < 6; i++) {
		printf("%d:", i + 1);
		for(int j = 0; j < p[i]; j++) {
			printf("*");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2688
s = gets.chomp.split("/").map(&:to_i)
if s[0] < 2019
    puts "Heisei"
elsif s[0] == 2019 && s[1] < 4 
    puts "Heisei"
elsif s[0] == 2019 && s[1] == 4 && s[2] <= 30
    puts "Heisei"
else
    puts "TBD"
end


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

int main(){
  string S;
  cin >> S;
  if( S.at(2) == S.at(3) && S.at(4) == S.at(5) ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// Gaurav Aggarwal
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    ll n,a,b;
    cin>>n>>a>>b;

    ll f = abs(a-b);

    if(f & 1) {
        ll one = max(a,b) - 1;
        ll two = n - min(a,b);
        ll ans = min(one,two);

        ll diff = n - max(a,b);
        ll move = diff;
        ll ta = min(a + diff, b + diff);
        ll tb = max(b + diff, a + diff);
        move += 1;
        ta += 1;

        if( ta != tb) {
            move += abs(ta - tb)/2;
            ans = min(move, ans);
        }

        diff = min(a,b) - 1;
        move = diff;
        ta = min(a - diff, b - diff);
        tb = max(a - diff, b - diff);
        move += 1;
        tb -= 1;

        if( ta != tb) {
            move += abs(ta - tb)/2;
            ans = min(move,ans);
        }

        
        cout<<ans;
    }
    else {
        ll ans = f/2;
        cout<<ans;
    }

    return 0;
}

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

using namespace std;

#define IO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define ull unsigned long long int

const int INF = 1e9 + 7;
const int N = 1e5+5;

int main() {

	IO;

	int n;
	cin >> n;
	
	cout << (n < 1000 ? "ABC" : "ABD");	
}


Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>

using namespace std;

class Vector
{
public:
  int x;
  int y;

  Vector(){}
  Vector( int x, int y ) : x(x), y(y) {}

  Vector operator + ( const Vector v ) { return Vector( x + v.x, y + v.y ); }
  Vector operator - ( const Vector v ) { return Vector( x - v.x, y - v.y ); }
  Vector operator * ( const int k ) { return Vector( x * k, y * k ); }
  bool operator < ( const Vector &v ) const { return x * x + y * y < v.x * v.x + v.y * v.y; }

  double length() { return sqrt( norm() ); }
  int norm() { return x * x + y * y; }

  static int dot( Vector v1, Vector v2 ) { return v1.x * v2.x + v1.y * v2.y; }
  static int cross( Vector v1, Vector v2 ) { return v1.x * v2.y - v1.y * v2.x; }
};

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

  int x0, y0, x1, y1, x2, y2, x3, y3;
  
  for ( auto i = 0; i < q; ++i )
    {
      cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

      Vector p0( x0, y0 );
      Vector p1( x1, y1 );
      Vector p2( x2, y2 );
      Vector p3( x3, y3 );

      Vector p10 = p1 - p0;
      Vector p32 = p3 - p2;

      if ( Vector::dot( p10, p32 ) == 0 )
        cout << "1" << endl;
      else if ( Vector::cross( p10, p32 ) == 0 )
        cout << "2" << endl;
      else
        cout << "0" << endl;
    }
          
  return 0;
}

Measured memory_bytes: 1156
#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d %d %d",&a,&b,&c);
    d=b/a;
    if(d<c)
        printf("%d\n",d);
    else if("d>c||d==c")
        printf("%d\n",c);
    else
        printf("0\n");
    return 0;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 5005;
int N;
string S;

unordered_map<int, int> MAP;
unordered_set<int> SET[5];

class RollingHash {
public:
  RollingHash(string& _S) {
    makeHashTable(_S);
  }

  void makeHashTable(string& _S) {
    S = _S; N = S.size();
    for(int h = 0; h < HASH_TABLE_SIZE; h++) {
      hashTable[h].clear(); hashTable[h].resize(N+1);
      sumRollA[h].clear(); sumRollA[h].resize(N+1);
      sumRollA[h][0] = 1;
      for(int n = 0; n < N; n++) {
        sumRollA[h][n+1] = (sumRollA[h][n] * rollA[h]) % rollB[h];
        hashTable[h][n+1] = (hashTable[h][n]*rollA[h] + S[n]) % rollB[h];
      }
    }
  }

  LL getHash(int l, int r, int h = 0) {
    return (int)((hashTable[h][r] + rollB[h]) - (int)((sumRollA[h][r-l]*hashTable[h][l])%rollB[h])) % rollB[h];
  }

  bool isSameSubstr(int l1, int r1, int l2, int r2) {
    for(int n = 0; n < HASH_TABLE_SIZE; n++) {
      if(getHash(l1, r1, n) != getHash(l2, r2, n)) {
        return false;
      }
    }
    return true;
  }

private:
  string S;
  int N;
  static const int HASH_TABLE_SIZE = 5;
  vector<LL> hashTable[HASH_TABLE_SIZE];
  LL rollA[HASH_TABLE_SIZE] = {53,107,109,113,127};
  LL rollB[HASH_TABLE_SIZE] = {1000000007, 1000000009, 1000000021, 1000000033, 998244353};
  vector<LL> sumRollA[HASH_TABLE_SIZE];
};

signed main()
{
  cin >> N;
  cin >> S;
  RollingHash rh(S);

  int ans = 0;
  int lLen = 0, rLen = S.size();
  while(rLen-lLen > 1) {

    int len = (rLen + lLen)/2;

    bool check = false;
    for(int r = S.size(); 1 <= r; r--) {
      int l = r-len;
      if(0 <= l) {
        int cnt = 0;
        REP(n,5) {
          if(SET[n].find(rh.getHash(l,r,n)) != SET[n].end()) {
            cnt++;
          }
        }
        if(cnt == 5) {
          check = true;
        }
      }
      int rr = r-1+len;
      if(rr <= S.size()) {
        REP(n,5) {
          SET[n].insert(rh.getHash(r-1,rr,n));
        }
      }
    }

    REP(n,5) {
      SET[n].clear();
    }

    if(check) {
      lLen = len;
    } else {
      rLen = len;
    }
  }
  
  cout << lLen << endl; 

  return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;



string S;
ll ans;


int main() {

	cin >> S;
	int n = S.length();
	int cnt1=0, cnt2=0;
	FOR(i, 0, n) {//はじめしろ
		if (i % 2 == 0) {
			if (S[i] == '0')cnt1++;
		}
		if (i % 2 == 1 && S[i] == '1')cnt1++;
	}
	FOR(i, 0, n) {//はじめくろ
		if (i % 2 == 1) {
			if (S[i] == '0')cnt2++;
		}
		if (i % 2 == 0 && S[i] == '1')cnt2++;
	}
	cout << min(cnt1, cnt2) << endl;

	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B;
	cout<<max(0,A-2*B)<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,k,temp;
    scanf("%d" "%d",&n,&k);
    
	/*	printf("n;%d",n);
		printf("\n");
		printf("k;%d",k);
		printf("\n");*/
    
    
    int i[n-1];
    int max[k-1];
    int count=0;
    int total=0;


    for(int j=0;j<k;j++){
    	max[j] = 0;
    }


    for(int j=0;j<n;j++){
   	    scanf("%d",&temp);
    	i[j] = temp;
    }

/*    for(int j=0;j<n;j++){
		printf("i[%d];%d",j,i[j]);
		printf("\n");
    }*/
    
    
    while(count != k){
    	for(int m=0;m<k;m++){
	   		for(int l=0;l<n;l++){

				if(max[m] < i[l]){
					max[m] = i[l];
				}
    		}
    		
	   		for(int q=0;q<n;q++){
				if(max[m] == i[q]){
					i[q] = 0;
					break;
				}		    			
   			}
    		
    	
    	}
    	count = count+1;
    }

 /*   for(int j=0;j<k;j++){
		printf("max[%d];%d",j,max[j]);
		printf("\n");
    }

		printf("cou;%d",count);
		printf("\n");*/

    for(int p=0;p<k;p++){
		total = total + max[p];
   }
		printf("%d",total);
		printf("\n");

}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
    string ans = "";
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            char c;
            cin >> c;

            if (i == j) {
                ans += c;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
h, w = map(int, input().split())

ans = 10 ** 10
if (h % 3 == 0) or (w % 3 == 0):
    ans = 0
# 半分 or 半分+1 で切って全探索
else:
    if h % 3 == 1:
        Sa = int(h//3) * w
        Sb = int(h//3) * w
        Sc = (int(h//3)+1) * w
        dif = max(Sa, Sb, Sc) - min(Sa, Sb, Sc)
        ans = min(ans, dif)
    elif h % 3 == 2:
        Sa = int(h//3) * w
        Sb = (int(h//3)+1) * w
        Sc = (int(h//3)+1) * w
        dif = max(Sa, Sb, Sc) - min(Sa, Sb, Sc)
        ans = min(ans, dif)
    
    if w % 3 == 1:
        Sa = int(w//3) * h
        Sb = int(w//3) * h
        Sc = (int(w//3)+1) * h
        dif = max(Sa, Sb, Sc) - min(Sa, Sb, Sc)
        ans = min(ans, dif)
    elif w % 3 == 2:
        Sa = int(w//3) * h
        Sb = (int(w//3)+1) * h
        Sc = (int(w//3)+1) * h
        dif = max(Sa, Sb, Sc) - min(Sa, Sb, Sc)
        ans = min(ans, dif)

    if h % 2 == 0:
        for i in range(1,w):
            Sa = int(h/2) * i
            Sc = h * (w-i)
            dif = abs(Sa-Sc)
            ans = min(ans, dif)
    elif h % 2 == 1:
        for i in range(1,w):
            Sa = int(h // 2)  * i
            Sb = (int(h // 2) + 1) * i
            Sc = h * (w-i)
            dif = max(Sa, Sb, Sc) - min(Sa, Sb, Sc)
            ans = min(ans, dif)
        
    if w % 2 == 0:
        for j in range(1,h):
            Sa = int(w/2) * j
            Sc = w * (h-j)
            dif = abs(Sa-Sc)
            ans = min(ans, dif)
    elif w % 2 == 1:
        for j in range(1,h):
            Sa = int(w // 2)  * j
            Sb = (int(w // 2) + 1) * j
            Sc = w * (h-j)
            dif = max(Sa, Sb, Sc) - min(Sa, Sb, Sc)
            ans = min(ans, dif)
print(ans)


Measured memory_bytes: 3320
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    
        var sc = new Scanner(System.in);
    
        String s = sc.next();
        
        int ans = 0;
        int count = 0;
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == 'R'){
                count++;
                ans = Math.max(count, ans);
            }else{
                count = 0;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35496
# ABC106B - 105
def divisors(x: int) -> set:
    """
    Compute divisors of a number.
    
    Args: x (int): an integer to be evaluated.
    Returns: divs (set): set of divisors
    """
    divs = set()
    for i in range(1, int(x ** 0.5) + 1):
        if x % i == 0:
            divs.add(i), divs.add(x // i)
    return divs


def main():
    N = int(input())
    ans = sum(len(divisors(i)) == 8 for i in range(1, N + 1, 2))
    print(ans)


if __name__ == "__main__":
    main()

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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> ans(N, 0);
    rep(i, M)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        ans.at(a)++;
        ans.at(b)++;
    }
    rep(i, N) cout << ans.at(i) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    vector<ll> cnt(5,0);
    for(auto &I:a){cin>>I; cnt[I+2]++;}
    vector<ll> use(5,0);
    use.back()=cnt.back();
    use[0]+=cnt[0]/2*2;
    if((cnt[0]&1) && cnt[1]){use[0]++; use[1]++;}
    cout<<use[0]+use[1]+use[4]<<endl;
    vector<ll> ans;
    for(int i=0;i<n;i++){
        if(use[a[i]+2]){use[a[i]+2]--; ans.push_back(i);}
    }
    for(int i=0;i<ans.size();i++){
        cout<<ans[i]+1<<endl;
    }
    
    
    return 0;
}



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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int N; cin >> N;
  vector<int> a(N);
  map<int, long long> mp;
  for(int i = 0; i < N; ++i) {
    cin >> a[i];
    mp[a[i]]++;
  }
  int ans = 0;
  for(auto p: mp) {
    int x = p.first;
    int n = p.second;
    if(n < x) ans += n;
    else ans += n - x;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6656
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	ll inner = 0, outer = 0;
	rep(i,n){
		cin >> a[i];
		if(i < k) inner += a[i];
		else{
			if(a[i] > 0) outer += a[i];
		}
	}
	ll ans = 0;
	chmax(ans, inner + outer);
	for(int i = k; i < n; ++i){
		inner -= a[i-k];
		inner += a[i];
		if(a[i-k] > 0) outer += a[i-k];
		if(a[i] > 0) outer -= a[i];
		chmax(ans, max(inner, 0LL) + outer); 
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3988
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

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

    long long ans,input;
    cin>>ans;

    for(int i=1;i<N;++i){
        cin>>input;
        input/=__gcd(ans,input);
        ans=ans*input;
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n, count = 0;
    int min;
    int p[200010];
    cin >> n;
    for(int i = 0; i < n; i++){
        scanf("%d",&p[i]);
    }

    min = p[0];

    for(int i = 0; i < n; i++){
        int flag = 1;
        if(min > p[i]){
            min = p[i];
        }
        if(min < p[i]){
                flag = 0;
            }
        if(flag){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1024