akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <numeric>
#include <queue>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <iomanip>
#include <set>
#include <queue>
#include <bitset>
#include <iomanip>
#include <map>
#include <string.h>
#include <stack>
#include <algorithm>

//#include <unordered_map>
//#include <unordered_set>

using namespace std;

int cnt[100010];
bool flag[100010];

int main()
{
	int i , j , n , m;
	while (scanf("%d%d" , &n , &m) != EOF)
	{
		memset(flag , 0 , sizeof(flag));
		flag[1] = true;
		for (i = 1;i <= n;i ++)
			cnt[i] = 1;
		for (i = 0;i < m;i ++)
		{
			int x , y;
			scanf("%d%d" , &x , &y);
			// 如果可以移动
			if (cnt[x] > 0)
			{
				cnt[x] --;
				cnt[y] ++;
				// 如果存在red ball
				if (flag[x])
					flag[y] = true;
			}
			// 如果空了
			if (cnt[x] == 0)
				flag[x] = false;
		}
		int ans = 0;
		for (i = 1;i <= n;i ++)
		{
			if (flag[i])
				ans ++;
		}
		printf("%d\n" , ans);
	}
	return 0;
}




Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
    int k,n;
    cin>>k>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int d[n];
    for(int i=0;i<n-1;i++)d[i]=a[i+1]-a[i];
    d[n-1]=a[0]+k-a[n-1];
    sort(d,d+n,greater<int>());
    cout<<k-d[0]<<'\n';
    return 0;
}

Measured memory_bytes: 1920
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef tuple<ll,ll,ll> tl3;
// https://atcoder.jp/contests/abc176/tasks/abc176_b
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string ans[2] = {"No","Yes"};
    bool isAnswer = false;
    string s;
    cin >> s;
    ll temp = 0;
    for(auto k : s){
        temp += (k-'0');
    }
    if(temp % 9 == 0) isAnswer = true;
    cout << ans[isAnswer];


    return 0;
}



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

using namespace std;

using ll = long long;

void Solve() {
    array<string, 3> s;
    cin >> s[0] >> s[1] >> s[2];

    int turn = 0;
    array<int, 3> idx = {0, 0, 0};
    while (true) {
        if (idx[turn] == s[turn].size()) {
            cout << (char)('A' + turn) << endl;
            return ;
        }
        int nxt = (int)(s[turn][idx[turn]] - 'a');
        ++idx[turn];
        turn = nxt;
    }
}

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

    Solve();

    return 0;
}


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

int main()
{
    int flag = 0;

    string s;
    cin >> s;

    int len = s.length();
    int i, count = 0;
    for(i = 0; i < len; i ++)
    {
    	if(s[i] == 'W' && flag != 1)
    	{
    		flag = 1;
    		count ++;
    	}
    	else if(s[i] == 'B' && flag != 2)
    	{
    		flag = 2;
    		count ++;
    	}
    }

    cout << count - 1 << endl;
}

Measured memory_bytes: 512
//
//  main.cpp
//  ABC169D

#include <iostream>
#include <vector>
using namespace std;
using ll=long long;
using P=pair<ll,int>;

int main(int argc, const char * argv[]) {
    ll N;
    cin >> N;
    int x;
    vector<P> fs;
    // Nを因数分解する
    for (long long i=2; i*i<N; i++) {
        x=0;
        while (N%i==0) {
            N/=i;
            x++;
        }
        if (x!=0) {
            fs.emplace_back(i,x);
        }
    }
    if (N!=1) {
        fs.emplace_back(N,1);
    }
    // 因数分解終了
    
    // それぞれの素数で何回操作できるか
    // y:素数
    // k:操作回数
    int ans=0;
    for (int i=0; i<fs.size(); i++) {
        //cout<<fs.at(i).first<<" "<<fs.at(i).second<<endl;
        int y=fs.at(i).second;
        int k=1;
        while(y-k>=0){
            y-=k;
            k++;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3200
// https://atcoder.jp/contests/abc089/tasks/abc089_d
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w, d, t, q;
    cin >> h >> w >> d;
    vector<pii> v(h * w + 1);
    vector<vector<int>> disp(h, vector<int>(w));
    REP(i, h) REP(j, w) {
        cin >> t;
        v[t] = {i, j};
        disp[i][j] = t;
    }
    vector<ll> memo(h * w + 1, 0);
    REP(i, d) {
        int start = i;
        int goal = h * w;
        ll sum = 0;
        while (start < goal) {
            if (start + d > h * w)
                break;
            pii posNow = v[start];
            pii posNext = v[start + d];
            int diff = abs(posNow.first - posNext.first) +
                       abs(posNow.second - posNext.second);
            sum += diff;
            start += d;
            if (start > h * w)
                break;
            memo[start] = sum;
        }
    }
    cin >> q;
    vector<pii> s(q);
    REP(i, q) cin >> s[i].first >> s[i].second;
    REP(i, q) cout << memo[s[i].second] - memo[s[i].first] << "\n";

    return 0;
}


Measured memory_bytes: 3712
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: print('Yes' if b else 'No')
YESNO=lambda b: print('YES' if b else 'NO')

def main():
    N=int(input())
    S=list(input())
    c=[0,0,0]
    for i,s in enumerate(S):
        if s=='R':
            c[0]+=1
        elif s=='G':
            c[1]+=1
        else:
            c[2]+=1
    count=0
    for i in range(N):
        for j in range(1,N//2+1):
            if i+j*2>=N:
                continue
            if S[i]!=S[i+j] and S[i]!=S[i+j*2] and S[i+j]!=S[i+j*2]:
                count+=1
    print(c[0]*c[1]*c[2]-count)
                

if __name__ == '__main__':
    main()


Measured memory_bytes: 73768
import sys
input = sys.stdin.readline
mod = 998244353

def sub(a, b):
    return (a % mod + mod - b % mod) % mod

class SegTree:
    def __init__(self, init_val, n, ide_ele, seg_func):
        self.segfunc = seg_func
        self.num = 2**(n-1).bit_length()
        self.ide_ele = ide_ele
        self.seg=[self.ide_ele]*2*self.num
        for i in range(n):
            self.seg[i+self.num-1]=init_val[i]    
        for i in range(self.num-2,-1,-1) :
            self.seg[i]=self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 
        
    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        while k+1:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1],self.seg[k*2+2])
        
    def query(self, p, q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res=self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res,self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res,self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res,self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
        return res

def main():
    n, = list(map(int, input().split()))
    t = 1
    dd = [t]
    for _ in range(n):
        t=2*t%mod
        dd.append(t)

    xs, ys = [], []
    for _ in range(n):
        x, y = list(map(int, input().split()))
        xs.append(x)
        ys.append(y)

    ini = sorted(list(range(n)), key=lambda x:xs[x])
    for i, yi in enumerate(sorted(list(range(n)), key=lambda x:ys[x])):
        ys[yi] = i 
    nys = [ys[i] for i in ini]

    ss1 = SegTree([0] * n, n, 0, lambda x,y:x+y)
    r = 0
    for i, y in enumerate(nys):
        ss1.update(y, 1)
        d = ss1.query(0, y)
        c = i - d
        b = (n-1) - y - c
        a = (n-1) - b - c - d
        r = (r + sub(dd[b+c] + dd[c+d] + dd[d+a] + dd[a+b],
                dd[a] + dd[b] + dd[c] + dd[d])) % mod

    print(sub((dd[n] * n) % mod, (r+n)%mod))
main()


Measured memory_bytes: 119556
#include <stdio.h>
#include <vector>

int main(void){

#ifdef __McDic__ // Local testing I/O
    freopen("VScode/IO/input.txt", "r", stdin);
    freopen("VScode/IO/output.txt", "w", stdout);
#endif

    int M, D; scanf("%d %d", &M, &D);
    int answer = 0;
    for(int m=1; m<=M; m++){
        for(int d=1; d<=D; d++){
            int d1 = d%10, d10 = d/10;
            if(d1 >= 2 && d10 >= 2 && d1*d10 == m) answer++;
        }
    } printf("%d\n", answer);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  rep(i, H) cin >> S[i];
  vector<vector<int> > dp(H, vector<int>(W, inf));
  dp[0][0] = S[0][0]=='#';
  int dx[] = {-1, 0}, dy[] = {0, -1};
  rep(i, H) rep(j, W) {
    rep(k, 2) {
      int ipre = i+dx[k], jpre = j+dy[k];
      if(ipre >= 0 && jpre >= 0) {
	if(S[i][j] == '#' && S[ipre][jpre] == '.') {
	  dp[i][j] = min(dp[ipre][jpre]+1, dp[i][j]);
	} else {
	  dp[i][j] = min(dp[ipre][jpre], dp[i][j]);
	}
      }
    }
  }
  cout << dp[H-1][W-1] << endl;
  return 0;
}


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

int main() {
  int a,b,c;
  cin >> b >> a;
  if(b%2==1){
  c=b*25/2+1;
  }
  else{
  c=b*25/2;
  }  
  if((a+1)*10<=b*25/2 || a*10>=(b+1)*25/2){   
  cout << -1 << endl;
  }
  else{
  cout << max(max(a*10,c),1) << endl;  
  }  
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <bits/stdc++.h> 
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll l[300020],r[300020];

int main(){
  int n;
  cin >> n;
  ll a[3*n];
  rep(i,3*n)cin >> a[i];
  priority_queue<ll> que;
  rep(i,n){
    l[n-1]+=a[i];
    que.push(-a[i]);
  }
  rep(i,n+1){
    que.push(-a[n+i]);
    ll x=-que.top();
    que.pop();
    l[n+i]=l[n+i-1]+a[n+i]-x;
  }
  while(!que.empty())que.pop();
  rep(i,n){
    r[2*n]+=a[2*n+i];
    que.push(a[2*n+i]);
  }
  rep(i,n+1){
    que.push(a[2*n-1-i]);
    ll x=que.top();
    que.pop();
    r[2*n-1-i]=r[2*n-i]+a[2*n-1-i]-x;
  }
  ll ans=-longinf;
  rep(i,n+1){
    ans=max(ans,l[n+i-1]-r[n+i]);
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 6388
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>
using namespace std;
#define REP(i, n) for(int i=0; i<(n); i++)
typedef long long int lli;

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

    map<pair<string, string>, lli> en[2];
    for(int d=0; d<2; d++){
        for(int i=0; i<(1<<n); i++){
            string stra = "";
            string strb = "";
            for(int j=0; j<n; j++){
                if((i & 1<<j) != 0) stra += s[d*n +j];
                else strb += s[d*n +j];
            }
            if(d==1){
                reverse(stra.begin(), stra.end());
                reverse(strb.begin(), strb.end());
            }
            en[d][make_pair(stra, strb)]++;
        }
    }

    lli ans = 0;
    for(auto elem: en[0]){
        if(en[1].count(elem.first) != 0){
            ans += elem.second * en[1][elem.first];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 89088
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;

int main() {

	vector<long long int> a;
	vector<long long int> saiyo;
	size_t n_count;
	long long n;

	cin >> n;

	for (long long i = 0; i < n; i++) {
		long long tmp;
		cin >> tmp;
		a.push_back(tmp);
	}

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

	long long oldValue;
	long long newValue;
	
	while (a.size() > 1) {
		oldValue = a.back();
		a.pop_back();
		newValue = a.back();
		if (oldValue == newValue) {
			//採用
			saiyo.push_back(oldValue);
			
			//二つ採用したらおしまい
			if (saiyo.size() == 2) {
				printf("%lld", saiyo[0] * saiyo[1]);
				return 0;
			}
			else {
				a.pop_back();
			}
		}
	}

	//おしまいにならず⇒作れない
	printf("0");
	return 0;

}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define M 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long int
#define mem(x) memset(x,0,sizeof(x))
#define setbits(x)  __builtin_popcount(x)
#define ull unsigned long long int
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep1(i,b,a) for(int i=b;i>a;i--)
#define all(c) (c).begin(),(c).end()
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define cps CLOCKS_PER_SEC
#define complex cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / cps << '\n';
#define db double
#define endl "\n"
#define  fbo(x) find_by_order(x)
#define  ook(x) order_of_key(x)

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os1;
typedef tree<int, null_type, greater<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os2;
inline void fast()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
 
const ll mod=(ll)(1e9)+7;
ll pmod(ll x,ll n){
  ll r=1;
  while(n)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
  }
  return r;
}

//think recursively also

void solve()
{  

 int n,m;
 cin>>n>>m;
 int h[n+1];

 vector<int>adj[n+1];
 for(int i=1;i<=n;i++)
  cin>>h[i];
for(int i=1;i<=m;i++)
{ int a,b;
  cin>>a>>b;
  
  adj[a].pb(b);
    adj[b].pb(a);
  
  
  //adj[b].pb(a);
}
int good=0;
for(int i=1;i<=n;i++)
{
  
  int c=h[i];
  bool f=1;
   for(auto it:adj[i])
   {
     if(c<=h[it])
      f=0;
   }
   //debug2(i,f);
   good+=f;
}
cout<<good;
  
}
int main()
{
   fast();
   // int t;
   // cin>>t;
   // for(int casee=1;casee<=t;casee++)
  { //cout<<"Case #"<<casee<<": ";
    solve();
  }
 
 
 
}

Measured memory_bytes: 9176
#include <stdio.h>
int main()
{
    int k, a, b; scanf("%d%d%d", &k, &a, &b);
    long res1=k+1, res2=1;
    while (k>1) {
        if (res2<a) {
            ++res2;
            --k;
        }
        else {
            res2-=a;
            res2+=b;
            k-=2;
        }
    }
    res2+=k;
    printf("%ld\n", res1<res2 ? res2 : res1);
}


Measured memory_bytes: 128
/*ॐ नमो भगवते वासुदेवाय नमः*/
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(), (x).rend()
#define pb push_back
#define pf push_front
#define fori(i, a, n) for(int i = a; i < n; ++i)
#define MAX(x) (*max_element(all(x)))
#define MIN(x) (*min_element(all(x)))
#define sortarr(a, n) sort(a, a + n)
#define sortvec(V) sort(all(V))

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

typedef unordered_map<int, int, custom_hash> u_map;
typedef unordered_set<int, int, custom_hash> u_set;
typedef vector<int> V;
typedef pair<int , int> pairi;
typedef set<int> seti;
typedef priority_queue<int> p_queue;
typedef deque<int> deqi;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;

int binpow(int a, int b, int m) {
    a %= m;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int inverse(int x){
    return binpow(x, MOD - 2, MOD);
}

void solve()
{
    string s;
    cin >> s;
    if(s[s.size() - 1] == 's')  s += "es";
    else s += 's';
    cout << s << endl;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n ";
}

Measured memory_bytes: 3840
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
typedef pair<lint,int>pli;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

const int N=100100;
vector<pii> g[N];

int main(){
  int n,m,s,t;
  cin>>n>>m>>s>>t;
  s--,t--;
  rep(i,m){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a--,b--,c--;
    g[a].push_back(pii(b,d));
    g[a].push_back(pii(c,d));
    g[b].push_back(pii(a,d));
    g[b].push_back(pii(c,d));
    g[c].push_back(pii(b,d));
    g[c].push_back(pii(a,d));
  }
  priority_queue<pli,vector<pli>,greater<pli> > que;
  que.push(pli(0,s));
  vector<lint> dis(n,1e18);
  while(!que.empty()){
    pli top=que.top();que.pop();
    int v=top.second;
    lint d=top.first;
    if(dis[v]<=d)continue;
    dis[v]=d;
    rep(i,g[v].size()){
      pii wc=g[v][i];
      int w=wc.first,c=wc.second;
      que.push(pli(d+c,w));
    }
  }
  cout<<dis[t]<<endl;
}



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

using ll = long long;
using pii = pair<int, int>;

template <typename T> constexpr T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;
template <> constexpr double inf<double> = 1e18;

template<typename T>
std::vector<T> table(int n, T v) { return std::vector<T>(n, v); }
 
template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return std::vector<decltype(val)>(n, std::move(val));
}

int main() {
    ll N; cin >> N;
    int x = -1;
    for(int i = 0; i < 32; ++i) {
        if((N >> i) & 1) {
            x = i;
        }
    }
    x = max(x, __builtin_popcount(N));
    cout << x << endl;
}


Measured memory_bytes: 3100
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 100000007)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	k, _ := strconv.Atoi(Scanner())
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(Scanner())
	}
	ans := solve(a, k)
	for i := 0; i < n; i++ {
		fmt.Printf("%d ", ans[i])
	}
}

func solve(a []int, k int) []int {
	n := len(a)

	if k >= n {
		for i := 0; i < n; i++ {
			a[i] = n
		}
		return a
	}

	for i := 0; i < k; i++ {
		b := make([]int, n+1)
		for j := 0; j < n; j++ {
			l := max(0, j-a[j])
			r := min(n, j+a[j]+1)
			b[l]++
			b[r]--
		}
		flag := true
		for i := 0; i < n; i++ {
			b[i+1] += b[i]
			if b[i] != n {
				flag = false
			}
		}
		b = b[:n]
		if flag {
			return b
		}
		a = b
	}
	return a
}

func max(x int, y int) int {
	if x >= y {
		return x
	} else {
		return y
	}
}

func min(x int, y int) int {
	if x <= y {
		return x
	} else {
		return y
	}
}

Measured memory_bytes: 13600
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
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);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


ll calc(ll X,ll Y){
    return X*X + Y*Y;
}
ll p_calc(pll p){
    return p.first*p.first + p.second*p.second;
}
double sq_calc(ll X,ll Y){
    return sqrt(X*X+Y*Y);
}
bool cmp(ll X,ll Y,ll x,ll y){
    return (X+x)*(X+x) + (Y+y)*(Y+y) > X*X + Y*Y;
}
template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    
    using pdd = pair<double,double>;
    vector<pdd> ps(N);
    for(int i = 0; i < N;i++){
        cin >> ps[i].first >> ps[i].second;
    }
    auto update = [&](double X,double Y){
        res = max(res,sq_calc(X,Y));
    };
    
    sort(ps.begin(),ps.end(),[](const pdd& l,const pdd& r){
        return atan2(l.second,l.first) < atan2(r.second,r.first);
    });
    
    for(int i = 0; i < N;i++){
        for(int j = 0; j < N;j++){
            
            double X = 0,Y = 0;
            for(int k = i;; (k += 1)%=N){
                X += ps[k].first;
                Y += ps[k].second;
                
                if(k == j) break;
            }
            update(X,Y);
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<double>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int min(int a, int b)
{
    if (a < b)
        return a;
    else
        return b;
}
int main()
{
    int i;
    char s[102], t[102];
    scanf("%s%s", s, t);
    char x;
    for (i = 0; i < strlen(s) - 1; i++)
    {
        if (s[i] > s[i + 1])
        {
            x = s[i];
            s[i] = s[i + 1];
            s[i + 1] = x;
            if (i > 0)
                i -= 2;
        }
    }
    for (i = 0; i < strlen(t) - 1; i++)
    {
        if (t[i] < t[i + 1])
        {
            x = t[i];
            t[i] = t[i + 1];
            t[i + 1] = x;
            if (i > 0)
                i -= 2;
        }
    }
    for (i = 0; i < min(strlen(s), strlen(t)); i++)
    {
        if (s[i] < t[i])
        {
            printf("Yes\n");
            return 0;
        }
        if (s[i] > t[i])
        {
            printf("No\n");
            return 0;
        }
    }
    if (strlen(s) < strlen(t))
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b, ans=0,i=1;
// string a,b;   
    
cin>>a>>b;
    while(i<=b)
    i*=10;
    ans+=a*i+b;
 int   res=sqrt(ans);
    if(res*res==ans)
    cout<<"Yes\n";
    else
cout<<"No\n";
 

}

Measured memory_bytes: 256
attrs = Array.new
while line = $stdin.gets
    attrs << line.chomp.split.map{|v| v.to_i }
end

N, M = attrs.shift
A = attrs.shift
sum = A.inject(&:+)
favored = 0
A.each {|a|
  favored += 1 if a >= (sum / (4.0 * M))
}
if favored >= M then
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <set>
#include <vector>

using namespace std;

struct Range
{
    int64_t left, right;

    Range() {}

    Range(int64_t left, int64_t right)
        : left(left)
        , right(right)
    {
    }
};

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

    vector<Range> vs(n);
    for (auto& v : vs)
    {
        int64_t x, l;
        cin >> x >> l;
        v.left = x - l;
        v.right = x + l;
    }
    sort(vs.begin(), vs.end(), [](const Range& r1, const Range& r2) { return r1.right < r2.right; });

    int64_t right_most = std::numeric_limits<int64_t>::min();

    int64_t count = 0;
    for (auto& r : vs)
    {
        if (right_most <= r.left)
        {
            count++;
            right_most = r.right;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
typedef long long LL;
using namespace std;
auto no = [](){cout << "NO"; exit(0);};
auto read = [](){int x; cin >> x; return x;};
#define maxn 240000
LL A[maxn];
LL f[5][maxn];
int main(){
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	for(int i = 1; i <= N; i += 1) cin >> A[i];
	for(int i = 1; i <= N; i += 1){
		LL m = 1E18;
		for(int j = 0; j < 5; j += 1){
			m = min(f[j][i - 1], m);
			f[j][i] = m;
			if(j == 0) f[j][i] += A[i];
			if(j == 1) f[j][i] += A[i] ? A[i] % 2 : 2;
			if(j == 2) f[j][i] += (A[i] + 1) % 2;
			if(j == 3) f[j][i] += A[i] ? A[i] % 2 : 2;
			if(j == 4) f[j][i] += A[i];
		}
	}
	LL ans = 1E18;
	for(int j = 0; j < 5; j += 1) ans = min(ans, f[j][N]);
	cout << ans;
}

Measured memory_bytes: 10880
loop do
  a, b, c = gets.split.map(&:to_i)
  break if a == 0
  n = gets.to_i
  r = []
  resa = []
  resb = []
  resc = []
  n.times do
    x = gets.split.map(&:to_i)
    u = [x[0] - 1, x[1] - a - 1, x[2] - a - b - 1, x[3]]
    if u[3] == 1
      resa[u[0]] = 1
      resb[u[1]] = 1
      resc[u[2]] = 1
    else
      r << u[0..2]
    end
  end

  r.each do |(ra, rb, rc)|
    if resa[ra] == 1 && resb[rb] == 1 && resc[rc] != 1 # C ?????????
      resc[rc] = 0
      next
    end
    if resa[ra] != 1 && resb[rb] == 1 && resc[rc] == 1 # A ?????????
      resa[ra] = 0
      next
    end
    if resa[ra] == 1 && resb[rb] != 1 && resc[rc] == 1 # B ?????????
      resb[rb] = 0
      next
    end

    if resa[ra] == 1
      resb[rb] ||= 2
      resc[rc] ||= 2
      next
    end
    if resb[rb] == 1
      resa[ra] ||= 2
      resc[rc] ||= 2
      next
    end
    if resc[rc] == 1
      resa[ra] ||= 2
      resb[rb] ||= 2
      next
    end

    resa[ra] ||= 2
    resb[rb] ||= 2
    resc[rc] ||= 2
  end

  resa.each { |v| puts v || 2 }
  resb.each { |v| puts v || 2 }
  resc.each { |v| puts v || 2 }

end

Measured memory_bytes: 8884
import numpy as np
N = int(input())
first = np.array([int(i) for i in input().split()])
second = np.array([int(i) for i in input().split()])
fstsum = np.cumsum(first)
scdsum = np.cumsum(second[::-1])[::-1]
lis = []
for i in range(N):
    lis.append(fstsum[i] + scdsum[i])
print(max(lis))

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr ll INF = 1'001'001'001'001'001'001;
int N, M;
ll X[1100], Y[1100], Z[1100];
ll dp[1100][1100];

ll f(ll s1, ll s2, ll s3){
    std::fill(&dp[0][0], &dp[0][0] + 1100 * 1100, -INF);
    dp[0][0] = 0;
    
    for(int i=0;i<N;++i){
        ll v = s1 * X[i] + s2 * Y[i] + s3 * Z[i];

        for(int j=0;j<=M;++j){
            dp[i+1][j] = std::max(dp[i+1][j], dp[i][j]);
            if(j + 1 <= M){
                dp[i+1][j+1] = std::max(dp[i+1][j+1], dp[i][j] + v);
            }
        }
    }

    return dp[N][M];
}

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

    std::cin >> N >> M;

    for(int i=0;i<N;++i){
        std::cin >> X[i] >> Y[i] >> Z[i];
    }

    ll mx = 0;

    for(int s1=-1;s1<=+1;s1+=2){
        for(int s2=-1;s2<=+1;s2+=2){
            for(int s3=-1;s3<=+1;s3+=2){
                mx = std::max(mx, f(s1, s2, s3));
            }
        }
    }

    std::cout << mx << std::endl;
}


Measured memory_bytes: 9728
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();

		// ?????? A ??\???
		int[][] A;
		A = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				A[i][j] = scan.nextInt();
			}
		}
		// ?????? B ??\???
		int[][] B;
		B = new int[m][l];
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < l; j++) {
				B[i][j] = scan.nextInt();
			}
		}

		// ?????? C ??\???
		// long ?????????
		long[][] C;
		C = new long[n][l];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				for (int k = 0; k < m; k++) {
					C[i][j] = C[i][j] + A[i][k] * B[k][j];
				}
			}
		}

		// ?????? C ??????
		for (int i = 0; i < n; i++) {

			// C[i][j]???1???????????????????????????(" " + C[i][j])?????????
			int j = 0;
			System.out.print(C[i][j]);

			for (j = 1; j < l; j++) {
				System.out.print(" " + C[i][j]);
			}
			System.out.println();
		}

	}

}

Measured memory_bytes: 53264
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
#define MAX_N 1010
#define MAX_M 100010
const long long mod = pow(10,9)+7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep1(n) for(ll i = 0; i < (n); ++i)
#define rep2(i, n) for(ll i = 0; i < (n); ++i)
#define rep3(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep4(i, a, b, c) for(ll i = (a); i < (b); i += (c))
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; }
#define INF 1e+9
#define print(x) cout<<x<<endl;
using P = pair<int, int>;
#define PLL pair<ll, ll>;
#define MAX_V 10010
#define PI 3.141592653589793
#define vecP vector<P>
// cout << setprecision(15) << std::fixed;


int main() {
	int a;
	cin >> a;
	map<int,int> m;
	for (int i = 0;i < a;i++) {
		int n;
		cin >> n;
		m[n]++;
		if (m[n] > 1) {
			cout << "NO";
			exit(0);
		}
	}
	print("YES")
} 




Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  if(S.at(0) == S.at(1))
    cout << "No" << endl;
  else if(S.at(1) == S.at(2))
    cout << "No" << endl;
  else if(S.at(0) == S.at(2))
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示


// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<pair<ll,ll>> A;
  for(int i = 0 ; i < N ; i++){
      ll a;
      scanf("%lld",&a);
      A.pb(make_pair(a,i+1));
  }
  sort(all(A));
  for (int i = 0; i < N; i++) {
    cout << A[i].second;
    if(i != N-1)cout << " ";
  }
  cout << endl;

}


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

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

const int INF = 1001001001;

int main() {

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

    vector<pair<int, int>> keys;

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        int s = 0;
        rep(j, b) {
            int c;
            cin >> c;
            c --;
            s |= 1 << c;
        }
        keys.emplace_back(s, a);
    }

    vector<int> dp(1 << n, INF);
    dp[0] = 0;

    rep(s, 1 << n) {
        rep(i, m) {
            int t = s | keys[i].first;
            int cost = dp[s] + keys[i].second;
            dp[t] = min(dp[t], cost);
        }
    }
    int ans = dp.back();
    if (ans == INF) {
        ans = -1;
    }
    cout << ans << endl;

}


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

void fnPrimeNumber(const vector<int> &argviNum, int &argiPrimeCnt)
{
  for (int i = 0; i < argviNum.size(); i++)
  {
    double dSqrt = sqrt((double)argviNum[i]);
    int iMaxDivisor = (int)dSqrt;

    bool bPrimeNo = true;
    for (int iDivisor = 2; iDivisor <= iMaxDivisor; iDivisor++)
    {
      if (argviNum[i] % iDivisor == 0)
      {
        bPrimeNo = false;
        break;
      }
    }
    if (bPrimeNo) argiPrimeCnt++;
  }
}

int main()
{
  vector<int> viNum;
  int iMaxSize;
  int iPrimeCnt = 0;
  
  cin >> iMaxSize;
  for (int i = 0; i < iMaxSize; i++)
  {
    int iNum;
    cin >> iNum;
    viNum.push_back(iNum);
  }

  fnPrimeNumber(viNum, iPrimeCnt);
  cout << iPrimeCnt << endl;

  return 0;
}

Measured memory_bytes: 1320
/*     ####   ####  #               ####  #        ##   #    # #    # ###### #####
      #      #    # #              #      #       #  #  ##  ## ##  ## #      #    #
       ####  #    # #               ####  #      #    # # ## # # ## # #####  #    #
           # #  # # #                   # #      ###### #    # #    # #      #####
      #    # #   #  #              #    # #      #    # #    # #    # #      #   #
       ####   ### # ###### #######  ####  ###### #    # #    # #    # ###### #    #
*/
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef vector<long long> VLL;
typedef vector<string> VS;
typedef vector<pair<LL, LL> > VP;
 
 
#define For(in) for (LLi i = 0; i < (n); i++)
#define FOR(in) for(LLi i=1; i <= (n); i++)
#define pb push_back
#define sr(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define uniq(v) v.erase(unique(v.begin(), v.end()), v.end());
#define exit(); return 0;
#define no "NO"
#define yes "YES"
#define con continue;
 

 
 
int main()
{
	
	string str;
	cin>>str;
	for(int i=0; i<str.size(); i++)
	{
		if(str[0]=='B')
		{
			str.erase(str.begin()+i);
			i=-1;
			
		}
		if(str[i]=='B')
		{
			str.erase(str.begin() + (i-1), str.begin()+(i+1));
			//str.erase(str.begin() + i);
			i=-1;
		}
	}
	cout<<str<<endl;
			
    exit()
 
 
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(void){
    vector<vector<int>> t(3,vector<int>(3));
    vector<int> a(3,9999);
    int i,j,k,q,mn;
    for(i=0;i<3;i++){
        mn=999;
        for(j=0;j<3;j++){
            cin>>t[i][j];
            mn=min(t[i][j],mn);
        }
        a[i]=mn;
    }
    
    for(i=0;i<=a[0];i++){
        for(j=0;j<=a[1];j++){
            for(k=0;k<=a[2];k++){
                for(q=0;q<3;q++){
                    if(!(t[0][q]-i==t[1][q]-j&&t[1][q]-j==t[2][q]-k)){
                        break;
                    }
                }
                if (q==3){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
solve s = h s 0 0
          where h [] _ m = show m
                h (c:cs) n m = case c of
                                 'I' -> h cs (n+1) (max (n+1) m)
                                 'D' -> h cs (n-1) m

main = do getLine
          s <- getLine
          putStrLn $ solve s


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 505;
int a[N][N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, m, q;
	cin>>n>>m>>q;
	memset(a, 0, sizeof(a));
	for(int i = 0; i < m; i++){
		int l, r;
		cin>>l>>r;
		a[l][r]++;
	}
	for(int len = 2; len <= n; len++){
		for(int i = 1, j = len; j <= n; i++, j++){
			a[i][j] += a[i + 1][j] + a[i][j - 1] - a[i + 1][j - 1];
		}
	}
	while(q--){
		int l, r;
		cin>>l>>r;
		cout<<a[l][r]<<'\n';
	}

	return 0;
}

Measured memory_bytes: 1920
from collections import Counter
n = int(input())
l = list(map(int, input().split()))
memo = [[0] for i in range(n)]
for j in range(n):
    c = Counter(l[j:])
    tmp = 0
    for i in range(1000):
        if c[i+1]:
            tmp  += c[i+1]
        memo[j].append(tmp)

ans = 0
for i in range(n):
    for j in range(i+1, n - 1):
        b = l[i]
        c = l[j]
        lo = abs(b - c)
        up = min(b + c, 1001)
        ans += memo[j+1][up-1] - memo[j+1][lo]
print(ans)


Measured memory_bytes: 66268
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
    int N,L;
    cin>>N>>L;
    string S[2000];
    for(int i=0;i<N;i++)cin>>S[i];
    sort(S,S+N);
    for(int i=0;i<N;i++)cout<<S[i];
    puts("");
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;
int ary[40][40] = {-1};

int main() {
    int n,m;
    cin >> n >> m;
    for(int i=0; i<n; i++) {
        int k;
        cin >> k;
        for(int j=0; j<k; j++) {
            int a;
            cin >> a;
            ary[i][a] = 1;
        }
    }
    int j, v = 0;
    for(int i=1; i<=m; i++) {
        for(j=0; j<n; j++) {
            if(ary[j][i] != 1) break;
        }
        if(j == n) v++;
    }
    cout << v << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;


lint N;
constexpr int D = 44;
vector<int> cou(D);


int main()
{
    cin >> N;
    N++;
    while (N)
    {
        int d = 0;
        while ((1LL << (d + 1)) <= N) d++;
        cou[d]++;
        N -= (1LL << d);
    }

    int la = -1;
    REP(d, D - 1) if (cou[d]) la = d;
    cou[la]--;

    dbg(cou);
    dbg(la);

    vector<int> ans, ans2inv;
    int i = 1;
    REP(d, la + 1)
    {
        REP(_, cou[d]) ans2inv.push_back(i++);
        if (d < la) ans.push_back(i++);
    }

    reverse(ans2inv.begin(), ans2inv.end());
    for (auto v : ans2inv) ans.push_back(v);

    cout << ans.size() * 2 << endl;
    REP(i, ans.size()) cout << ans[i] << " ";
    REP(i, ans.size()) cout << i + 1 << " ";
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;
const int  N=1e5+9;
char s[N];
string str;
int main()
{
    while(~scanf("%s",s)){
        str="";
        for(int i=0;i<strlen(s);i+=2){
            str+=s[i];
        }
        cout<<str<<endl;
    }
    return 0;
}


Measured memory_bytes: 512
#![allow(unused_imports)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};

fn main() {
    input! {
        s: String,
    }
    let mut counter = vec![0; 3];
    for c in s.chars() {
        match c {
            'a' => { counter[0] += 1; },
            'b' => { counter[1] += 1; },
            _ => { counter[2] += 1; },
        }
    }
    if counter.iter().max().unwrap() - counter.iter().min().unwrap() < 2 { println!("YES"); }
    else { println!("NO"); }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
typedef long long ll;
typedef long double ld;
const int MAXN = 1000005;
ll F[MAXN];
ll fac[MAXN], invfac[MAXN];
const ll MOD = 1000000007;
ll binom(int a, int b) {
	if (b < 0) return 0;
	if (b > a) return 0;
	return (((fac[a] * invfac[b]) % MOD) * invfac[a - b]) % MOD;
}
ll modex(ll a, ll p, ll m = MOD) {
	if (!p) return 1;
	if (p & 1) return a * modex(a, p - 1, m) % m;
	ll v = modex(a, p >> 1, m);
	return v * v % m;
}
int main() {
	fac[0] = 1;
	for (int i = 1; i < MAXN; ++i)
		fac[i] = (fac[i - 1] * i) % MOD;
	invfac[MAXN - 1] = modex(fac[MAXN - 1], MOD - 2);
	for (int i = MAXN - 2; i >= 0; --i)
		invfac[i] = (invfac[i + 1] * (i + 1)) % MOD;
	int N;
	scanf("%d", &N);
	ll ans = 0;
	for (int k = 1; k < N; ++k) {
		F[k] = binom(k - 1, N - k - 1) * fac[k] % MOD * fac[N - 1 - k] % MOD;
		ll val = F[k] - F[k - 1];
		val %= MOD;
		ans += k * val;
		ans %= MOD;
	}
	if (ans < 0) ans += MOD;
	printf("%lld\n", ans);
}


Measured memory_bytes: 23808
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int n,m;
    cin >> n;
    vector<string> s, t;
    map<string, int> mp;
    rep(i,n){
        string k;
        cin >> k;
        s.push_back(k);
        mp[k]++;
    }
    cin >> m;
    rep(i,m){
        string k;
        cin >> k;
        t.push_back(k);
        mp[k]--;
    }
    int ans = 0;
    for (auto e:s){
        ans = max(ans, mp[e]);
    }
    cout << ans << endl;
}

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

int main(void) {
  long long K;
  long long N;
  long long count = 0;
  cin >> K;
  vector<bool> r(K, 0);

  N = 7 % K;
  while (true) {
    count++;
    if (r[N]) {
      count = -1;
      break;
    }

    if (N == 0) break;
    r[N] = true;
    N = (N * 10 + 7) % K;
  }
  cout << count << endl;
  return 0;
}

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

int main(){
  string S, T;
  int max=0, a, b, count;
  cin >> S >> T;
  a=S.size();
  b=T.size();
  
  for(int i=0; i<a-b+1; i++){
    count=0; 
    for(int j=0; j<b; j++){
        if(S.at(i+j)==T.at(j)) count++;
    }
    if(count>max) max=count;
  }
  
  cout << b-max << endl;
  
}
    


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

static const int MAX = 10000;
static const int INFTY = (1 << 20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
int n;
vector<pair<int, int>> adj[MAX];

void dijkstra() {
  priority_queue<pair<int, int>> PQ;
  int d[n];
  int color[n];
  for (int i = 0; i < n; i++) {
    color[i] = WHITE;
    d[i] = INFTY;
  }

  PQ.push(make_pair(0, 0));
  d[0] = 0;
  color[0] = GRAY;

  while (!PQ.empty()) {
    pair<int, int> f = PQ.top(); PQ.pop();
    int u = f.second;
    color[u] = BLACK;
    if (d[u] < f.first * (-1)) continue;

    for (int j = 0; j < adj[u].size(); j++) {
      int v = adj[u][j].first;
      if (color[v] == BLACK) continue;
      if (d[v] > d[u] + adj[u][j].second) {
        d[v] = d[u] + adj[u][j].second;
        PQ.push(make_pair(d[v] * (-1), v));
        color[v] = GRAY;
      }
    }
  }

  for (int i = 0; i < n; i++) {
    cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
  }
}

int main() {
  cin >> n;
  int k, u, v ,c;

  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      cin >> v >> c;
      adj[u].push_back(make_pair(v, c));
    }
  }

  dijkstra();
  return 0;
}



Measured memory_bytes: 8004