akhauriyash/Code-Regression huggingface dataset:
import sys
N, Q = map(int, input().split())

par = list(range(N))

def find(x):
    if x == par[x]:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
    
def union(x,y):
    rx, ry = find(x), find(y)
    par[ry] = rx
    
for _ in range(Q):
    p,a,b = map(int, sys.stdin.readline().split())
    if p == 0:
        union(a, b)
    if p == 1:
        if find(a) != find(b):
            print(0)
        else:
            print(1)

Measured memory_bytes: 8800
#include <bits/stdc++.h>
#define MAX_N 100000
using namespace std;
typedef long long lnt;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n; lnt a[MAX_N+5], s, c1, c2;
int main() {
	read(n);
	for (int i = 1; i <= n; i++) read(a[i]);
	s = a[1];
	for (int i = 1; i <= n; s += a[++i])
		if ((i&1) && s >= 0) c1 += s+1, s = -1;
		else if (!(i&1) && s <= 0) c1 += -s+1, s = 1;
	s = a[1];
	for (int i = 1; i <= n; s += a[++i])
		if ((i&1) && s <= 0) c2 += -s+1, s = 1;
		else if (!(i&1) && s >= 0) c2 += s+1, s = -1;
	return printf("%lld\n", min(c1, c2)), 0;
}


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

using namespace std;

#define int long long
#define pii pair<int, int>
#define pb push_back
int n;
int ans = 0;    
vector<string> v;
int a[10][10];
signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    int ans = 0;    
    for(int i = 1; i <= n; i++) v.pb(to_string(i));
    for(auto x: v){
        a[x.front() - '0'][x.back() - '0']++;
    }
    for(int i = 1; i <= 9; i++) {
        for(int j = 1; j <= 9; j++){
            ans += a[i][j] * a[j][i];
        }
    }
    cout << ans << endl;
    return 0;
}



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

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

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);

    int n, m, a, b;
    cin >> n >> m >> a >> b;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cout << (i < b ^ j < a);
        }
        cout << '\n';
    }
}


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

int ceiling_div(int a, int b){ // ceiling(a/b)= floor((a+b-1)/b)
  return (a+b-1)/b;
}

int main(){ 
  using pii= pair<int,int>;

  int N,H;
  cin >> N >> H;

  vector<pii> data(N);
  for(int i=0; i<N; i++){ // bでソートする必要があり、aは最大値のみ必要
    cin >> data.at(i).second >> data.at(i).first;
  }
  auto comp = [](pii a, pii b) { return a.first > b.first; };
  sort(data.begin(), data.end(), comp);

  int rep_max= -1; int rep_max_id= -1;
  for(int i=0; i<N; i++){
    if(rep_max < data.at(i).second){ // bの降順にソートされているので、aが同率ならスルーしていい
      rep_max= data.at(i).second;
      rep_max_id= i;
    }
  }

  int H_tmp= H; int cnt= 0;
  int idx= 0;
  while(H_tmp > 0){
    if(idx < N && data.at(idx).first > rep_max){
      H_tmp-= data.at(idx).first;
      cnt++;
      idx++;
    }
    else{
      cnt+= ceiling_div(H_tmp, rep_max);
      H_tmp-= rep_max* ceiling_div(H_tmp, rep_max);
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli h, ans = 1;
	double cnt=1;
	cin >> h;
	while(h > 1){
		h /= 2;
		ans += pow(2.0, cnt);
		cnt++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 2*1e18;

//累積和は関数化しておくと脳へのダメージが少ない
vector<long long> A,Al,Ar;
void regist(vector<long long> D){
    A=D;
    Al=D;
    for(long long i=0;i<((long long)D.size())-1;i++){
        Al[i+1]=Al[i]+D[i+1];
    }
    Ar=D;
    for(long long i=((long long)D.size())-2;i>=0;i--){
        Ar[i]=Ar[i+1]+D[i];
    }
}

long long accu(long long l,long long r){
    if(l<=r){
        if(l==0){
            return Al[r];
        }else{
            return Al[r]-Al[l-1];
        }
    }else{
        return Al[r]+Ar[l];
    }
}

long long sum(void){
    return Ar[0];
}
//累積和ここまで


signed main(void){
    
    long long N,K,a;
    vector<long long> P,C;
    
    cin >> N >> K;
    for(int i=0;i<N;i++){
        cin >> a;
        a--;
        P.push_back(a);
    }
    for(int i=0;i<N;i++){
        cin >> a;
        C.push_back(a);
    }
    
    vector<bool> visited(N,false);
    long long Ans = -INF;
    
    for(int i=0;i<N;i++){
        if(visited[i])continue;
        long long k = i;
        vector<long long> now={};
        while(1){
            if(visited[k])break;
            visited[k]=true;
            now.push_back(C[k]);
            k = P[k];
        }
        
        //念の為空のときは避けておく
        if(now.size()==0)continue;
        regist(now);
        
        long long S = sum();
        
        if(S<=0){
            //1~min(K,L)の中に最大がある
            long long num=-INF;
            long long L = now.size();
            for(long long i=0;i<L;i++){
                for(long long j=0;j<L;j++){
                    long long s;
                    if(i<=j){
                        s = j-i+1;
                    }else{
                        s = L-(i-j-1);
                    }
                    //sは区間に含まれる要素の数
                    if(s<=K){
                        num = max(num,accu(i,j));
                        //accuはi~jまでの和
                    }
                }
            }
            Ans = max(Ans,num);
            
        }else{
            long long num = -INF;
            long long L = now.size();
            for(long long i=0;i<L;i++){
                for(long long s=max(1ll,K-L+1);s<=K;s++){
                    long long temp = accu(i,(i+s-1)%L);
                    long long R;
                    if(i <= (i+s-1)%L){
                        R = (s-1)/L;
                    }else{
                        R = (s-1)/L;
                    }
                    temp += S*R;
                    num = max(num,temp);
                }
            }
            Ans = max(Ans,num);
        }
        
    }
    cout << Ans << endl;
    
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repf(i, j, n) for (int i = (j); i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

signed main() {
  int n;
  cin >> n;
  vector<int> p(n);
  int ret = 0;
  for (auto&& u : p) cin >> u;
  for (int i = 0; i < n - 2; i++) {
    if ((p[i] < p[i + 1] && p[i + 1] < p[i + 2])||(p[i] >p[i + 1] && p[i + 1] > p[i + 2])) ret++;
  }
  cout << ret << endl;
}

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

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

typedef long long ll;
const int maxn = 100005;

int n;
struct edge
{
	int to, next, w;
} e[maxn * 2];
int h[maxn], tot;
int siz[maxn], mxsz[maxn], rt;
ll dis[maxn], ans;

inline void add(int w, int u, int v)
{
	e[++tot] = (edge) {v, h[u], w}; h[u] = tot;
	e[++tot] = (edge) {u, h[v], w}; h[v] = tot;
}

void dfs1(int u, int fa)
{
	siz[u] = 1;
	for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
		if (v != fa) {
			dfs1(v, u); siz[u] += siz[v];
			mxsz[u] = max(mxsz[u], siz[v]);
		}
	mxsz[u] = max(mxsz[u], n - siz[u]);
	if (mxsz[u] < mxsz[rt] || !rt) rt = u;
}

void dfs2(int u, int fa)
{
	for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
		if (v != fa) {
			dis[v] = dis[u] + e[i].w;
			dfs2(v, u);
		}
}

int main()
{
	n = gi();
	for (int i = 1; i < n; ++i) add(gi(), gi(), gi());
	
	dfs1(1, 0);
	dfs2(rt, 0);

	for (int i = 1; i <= n; ++i) ans += dis[i] * 2;
	ll tmp = 1e18;
	for (int i = h[rt], v; v = e[i].to, i; i = e[i].next)
		if (mxsz[v] == mxsz[rt]) {tmp = dis[v]; break;}
		else tmp = min(tmp, dis[v]);

	printf("%lld\n", ans - tmp);
	
	return 0;
}


Measured memory_bytes: 8576
// In The Name of ALLAH
// Saiful Islam Tarek
//CSECU

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define _er(i,x,y) for(ll i=x;i<y;i++)
#define _ero(i,x,y) for(ll i=x;i<=y;i++)
#define _inf(i,x) for(ll i=x;;i++)
#define S(n) string n
#define sr(absd) sort(absd.begin(),absd.end())
#define srt(x) sort(arr,arr+x)
#define in(n) scanf("%lld",&n)
#define inn(n,m) scanf("%lld %lld",&n,&m)
#define inr(i) cin>>arr[i]
#define pr(n) cout<<n<<endl
#define par(i) cout<<arr[i]<<" "
#define SL(asd) (int)asd.length()
#define endl '\n'
#define INF 1000000000000
#define MX 1000000
#define pb                  push_back


struct NODE
{
    int u, w;
};
ll parent[MX];
ll dist[MX];
bool vis[MX];

vector<NODE> G[MX];

ll isprime( ll a0)
{
    ll n=a0,a=0;
    if (n==2)
    {
        return 1;
    }
    if (n==1)
    {
        return 0;
    }

    for(ll i=2; i*i<=n; i++)
    {
        if (n%i==0)
        {
            a=1;
            break;
        }
    }
    if (a==1)
    {
        return 0;
    }
    else
    {
        return 1;
    }
}

void _init()
{
    _er(i,0,MX)
    {
        parent[i]=i;
        dist[i]=INF;
    }
}
class cmp
{
public:
    bool operator () (NODE &A, NODE &B)
    {
        if (A.w > B.w)
            return true;
        return false;
    }
};
void FIND(ll node)
{
    if(node==parent[node])
    {
        cout<<node;
        return;
    }
    FIND(parent[node]);
    cout<<" "<<node;
}
void Dijkstra(int s)
{
    priority_queue < NODE, vector <NODE>, cmp > PQ;
    PQ.push({s, 0});
    while(!PQ.empty())
    {
        int u = PQ.top().u;
        int w = PQ.top().w;
        PQ.pop();
        if (vis[u])
            continue;
        vis[u] = 1;
        dist[u] = w;
        int x = G[u].size();
        _er(i,0,x)
        {
            int v = G[u][i].u;
            int z = G[u][i].w;
            if (!vis[v])
            {
                if (w+z < dist[v])
                {
                    dist[v] = w + z;
                    parent[v] = u;
                }
                PQ.push({v, w+z});
            }
        }
    }
}

int main()
{
    fast;
   int a;
   cin>>a;
   int arr[a],k=0;
   _er(i,0,a)
   {
       cin>>arr[i];
       if(arr[i]%2==0)
       {
           if(arr[i]%5!=0 && arr[i]%3!=0)
            k=1;
       }
   }
   if(k==1) cout<<"DENIED\n";
   else cout<<"APPROVED\n";




    return 0;
}


Measured memory_bytes: 24960
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define rep(I,N) up(I,0,N-1)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<"\n";}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<"\n";}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<"\n";}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<"\n";}
inline void                                              out(ld p){printf("%.12Lf\n",p);}
template<class T>inline void outml(T p){for_each(all(p),out<decltype(p[0])>);}//ml=multi line
template<class T>inline void outol(T V){auto n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}//ol=one line
ld A,B,H,M;
inline void solve(void){
  in(A,B,H,M);
  out(sqrt(A*A+B*B-2*A*B*cos(2.0*(M/60.0-(60*H+M)/720.0)*M_PI)));
}
int main(void){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 4180
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <stack>
#include <utility>
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)
using namespace std;

typedef pair<int,int> pii;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
int sx,sy,gx,gy;
int w,h,n;
int g[1000][1000];
bool valid(int y, int x){ return 0<=x && x<w && 0<=y && y<h; }

int main(){
    while(cin>>w>>h && w){
        cin>>sx>>sy>>gx>>gy;
        sx--,sy--,gx--,gy--;
        rep(i,h)rep(j,w)g[i][j]=0;
        cin>>n;
        rep(i,n){
            int c,d,x,y;
            cin>>c>>d>>x>>y;
            x--,y--;
            for(int j=0;j<4;j++)g[y+j%2][x+j/2]=c;
            if(d==0)x+=2;else y+=2;
            for(int j=0;j<4;j++)g[y+j%2][x+j/2]=c;
        }
        int C=g[sy][sx];
        // cout<<C<<endl;
        // rep(i,h){
        //     rep(j,w){
        //         cout<<g[i][j];
        //     }
        //     cout<<endl;
        // }
        rep(i,h)rep(j,w)g[i][j]= (g[i][j]==C) ? C : 0;

        bool vis[1000][1000]={};
        vis[sy][sx]=true;
        if(C){
            stack<pii> s;
            vis[sy][sx]=true;
            s.emplace(sy,sx);
            while(s.size()){
                int y,x;
                tie(y,x) = s.top();s.pop();
                rep(d,4){
                    int nx=x+dx[d],ny=y+dy[d];
                    if(!valid(ny,nx))continue;
                    if(vis[ny][nx])continue;
                    if(!g[ny][nx])continue;
                    vis[ny][nx]=true;
                    s.emplace(ny,nx);
                }
            }
            // rep(i,h){
            //     rep(j,w){
            //         cout<<vis[i][j];
            //     }
            //     cout<<endl;
            // }
        }
        puts(C && vis[gy][gx] ? "OK" : "NG");
    }
}

Measured memory_bytes: 2524
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#pragma GCC optimize("Os")
#pragma GCC target("avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("Os")
*/
 
#include <bits/stdc++.h>
//#include <windows.h>
 
#define ll long long
#define X first
#define Y second
#define MP make_pair
 
using namespace std;
 
             /*    
const int MAX_MEM = 1e8;
int mpos=0;
char mem[MAX_MEM];
inline void * operator new(size_t n){
	char *res = mem + mpos;
	mpos += n;
	assert(mpos <= MAX_MEM);
	return (void *)res;
}
 
inline void operator delete(void *){}
             */   

const int N = 5e2 + 123;
const ll mod = 1e9 + 7;             

int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    
    ll a, b, c;
    cin >> a >> b >> c;
    if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
    	cout << 0;
    }
    else{
    	if(a > b)
    		swap(a, b);
    	if(a > c)
    		swap(a, c);
    	if(b > c)
    		swap(b, c);
    	cout << a * b;
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	int n;
	cin >> n;
	int cnt = 0;
	rep(i,n){
		int a;
		cin >> a;
		if(a==cnt+1) cnt++;
	}
	printf("%d", cnt==0?-1:n-cnt);
}

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

int a[500], b[500];
string S, T;

int main(){
    fill(a, a + 500, -1);
    cin >> S >> T;
    auto j = T.begin();
    for(auto i : S){
        if(a[i] > 0 || b[*j] > 0){
            if(a[i] != *j || b[*j] != i)return 0 & puts("No");
        }else{
            a[i] = *j;
            b[*j] = i;
        }
        ++j;
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 776
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 998244353;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}



int main(void) {

  int k, n, a[200100];
  cin >> k >> n;
  rep(i, n) cin >> a[i];

  int b[200100];
  b[0] = a[0] + (k - a[n - 1]);
  for (int i = 1; i < n; i++) b[i] = a[i] - a[i - 1];
  int ma = 0;
  rep(i, n) ma = max(ma, b[i]);
  cout << k - ma << endl;
}


Measured memory_bytes: 1792
int main(void)
{
  int n,h,w,i=0,x,y,accept=0;
  scanf("%d %d %d",&n,&h,&w);
  while(i<n)
  {
    scanf("%d %d",&y,&x);
    if(y>=h&&x>=w) accept++;
    i++;
  }
  printf("%d",accept);
  return 0;
}
  

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<cstdio>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n;
    cin >> n;

    LL bitsize = 1;
    while((n >> bitsize) > 0)bitsize++;

    vector<vector<LL>> dp(bitsize+1,vector<LL>(3,0));
    dp[bitsize][0] = 1;

    for(int i = bitsize - 1; i >= 0; i--){
        if((n >> i)&1){
            dp[i][0] = dp[i+1][0];
            dp[i][1] = (dp[i+1][0] + dp[i+1][1])%MOD;
            dp[i][2] = (dp[i+1][1]*2 + dp[i+1][2]*3)%MOD;
        }else{
            dp[i][0] = (dp[i+1][0] + dp[i+1][1])%MOD;
            dp[i][1] = dp[i+1][1];
            dp[i][2] = (dp[i+1][1] + dp[i+1][2]*3)%MOD;
        }
    }

    cout << (dp[0][0] + dp[0][1] + dp[0][2])%MOD << endl;
    
    return 0;
}

Measured memory_bytes: 256
#ifdef _LOCAL
#	include <dbg_print.h>
#else
#	define NDEBUG
#	define dprint(...)
#endif

#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#include <assert.h>
using namespace std;
typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);
	
	ll h;
	cin >> h;

	ll ans = 1;
	while(h)
	{
		ans *= 2;
		h /= 2;
	}
	ans -= 1;

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<vector>
#include<set>
#include<queue>
#define int long long
using namespace std;
int n,a[200005],ans[100005],o1[100004],m1[100005];
signed main(){
    cin>>n;
    int sum=0;
    for(int i=1;i<=n;i++)scanf("%lld",&a[i]),a[n+i]=a[i];
    for(int i=1;i<=n;i++)sum+=a[i];
    for(int i=1;i<=n;i++)o1[i]=o1[i-1]+a[i*2-1],m1[i]=m1[i-1]+a[i*2];
    for(int i=1;i<=n;i++){
      if(i%2==1)ans[i]=m1[(i+n-1)/2]-m1[i/2];
      else ans[i]=o1[(i+n-1)/2]-o1[i/2];
      cout<<sum-2*ans[i]<<" ";
    }
    puts("");
}

Measured memory_bytes: 5248
import java.util.Scanner;
class Main{
	public static void main(String[] a){
		Scanner scan = new Scanner(System.in);
		int[] data = new int[5];
		for(int i = 0; i < 5; i++){
			data[i] = scan.nextInt();
		}
		for(int i = 0; i < 4; i++){
			for(int j = 4; j > i; j--){
				if(data[j] > data[j - 1]){
					int sub = data[j];
					data[j] = data[j - 1];
					data[j - 1] = sub;
				}
			}
		}
		System.out.println(data[0] + " " + data[1] + " " + data[2]
			+ " " + data[3] + " " + data[4]);
	}
}

Measured memory_bytes: 17168
#include<bits/stdc++.h>
using namespace std;
long long a[300005];
int main()
{
    long long n;
    cin>>n;
    for (int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    long long t=n;
    n--;
    long long ans=0;

    if (n>0) ans+=a[t-1];
    n--;
    if (n>1) {
            ans+=2*a[t-2];
    n-=2;
    }else{
        if (n==1){
            ans+=a[t-2];
    n-=1;
        }
    }
    
    long long i=3;
    while (n>0){
        if (n>=2) {
        ans+=2*a[t-i];
        n-=2;
        i++;
        }else{
            ans+=a[t-i];
            i++;
            n-=1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5164
x = int(input())
s = []
flag = 0

for i in range(-200, 200):
    s.append(i**5)

a = -200

for n in s:
    b = -200
    for m in s:
        if n-m == x:
            print(a,b)
            flag = 1
            break
        if flag:
            break
        b += 1

    a += 1

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


int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int ans = INT_MAX;
    int count;
    for (int i = 0; i < n; i++) {
        count = 0;
        if (a[i]%2 != 0) {
            cout << 0 << endl;
            return 0;
        } else { 
            while (a[i]%2 == 0 && n > 1) {
                count++;
                a[i] /= 2;
            }
            if (ans > count) ans = count;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  int A,B;
  string S="Yes";
  cin>>A>>B;
  if((A*B)%2==0) S="No";
  cout<<S<<endl;
return 0;}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void) {
  vector<vector<char>> c;
  c = {{' '},           {'.', ',', '!', '?', ' '},
       {'a', 'b', 'c'}, {'d', 'e', 'f'},
       {'g', 'h', 'i'}, {'j', 'k', 'l'},
       {'m', 'n', 'o'}, {'p', 'q', 'r', 's'},
       {'t', 'u', 'v'}, {'w', 'x', 'y', 'z'}};

  int num;
  cin >> num;
  REP(s, num) {
    string n;
    cin >> n;

    int kind = -1, cnt = 0;
    REP(i, n.size()) {
      if (n[i] == '0') {
        if (kind != -1) {
          cnt = (cnt - 1) % c[kind].size();
          cout << c[kind][cnt];
        }
        kind = -1;
        cnt = 0;
      } else {
        kind = n[i] - '0';
        cnt++;
      }
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
#define N 100010
ll dp[N][3];
int main(){
	fast;
	ll n;
	cin>>n;
	for(int i=1;i<=n;i++){
		ll a,b,c;
		cin>>a>>b>>c;
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c;
	}cout<<max(max(dp[n][0],dp[n][1]),dp[n][2])<<endl;
	return 0;
}/*『你强归你强，Siyuan比你强』*/

Measured memory_bytes: 2688
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math


n = getN()
ans = 0
for i in range(n):

    if len(str(i+1)) % 2 == 1:
        ans += 1

print(ans)

Measured memory_bytes: 38768
while True:
    try:
        N, D = map(int, input().split())
        P = []
        for i in range(N):
            P.append(list(map(int, input().split())))
            
        ans = 0
        for i in range(N-1):
            for j in range(i+1, N):
                distance = 0
                for k in range(D):
                    distance += (P[i][k] - P[j][k]) ** 2
                if distance == int(distance ** 0.5) ** 2:
                    ans += 1
        print(ans)
    except:
        break

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for(ll i = n-1; i >= 0LL; i--)
#define FOR(i, n, m) for(ll i = n; i < (ll)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define INFD 1e18
#define PI 3.14159265358979
#define MOD 1000000007
#define vl vector<ll>

vector<ll> dx = {-1, 1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main()
{
	ll K;
	cin >> K;

	vector<ll> A(K+1);
	A[0] = 1;
	REP(i, K) cin >> A[i+1];
	if (A.back() != 2) {
		PRINT(-1);
		return 0;
	}
	ll mi = 2;
	ll ma = 2;
	for(ll i = K; i > 0; i--) {
		ll tmin = mi;
		ll tmax = ma;

		mi = ((tmin-1)/A[i-1]+1)*A[i-1];
		ma = ((tmax+A[i]-1)/A[i-1])*A[i-1];
		if (ma < mi) {
			PRINT(-1);
			return 0;
		}
	}
	PRINT(mi << " " << ma);
	return 0;
}




Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	int c0=0,c1=0,c2=0,c3=0;
	while(n--)
	{
		string s;
		cin>>s;
		if(s=="AC")c0++;
		else if(s=="WA")c1++;
		else if(s=="TLE")c2++;
		else c3++;
	}
	cout<<"AC x "<<c0<<endl;
	cout<<"WA x "<<c1<<endl;
	cout<<"TLE x "<<c2<<endl;
	cout<<"RE x "<<c3<<endl;
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;       //     ____   _   _  __   __
#define ll long long       //    / ___| | |_| |   / /
const ll INF = 0x3f3f3f3f; //   | |     |  _  |   V /
const ll N   = 1e5 + 5;    //   | |___  | | | |   | |
const ll MOD = 1e9 + 7;    //    ____| |_| |_|   |_|
ll read() {
  ll   x = 0, f = 1;
  char ch = getchar();

  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1; ch = getchar();
  }

  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0'; ch = getchar();
  }
  return x * f;
}

string s;
int    n, flg;
int main() {
  n = read();
  cin >> s;

  if (s.size() % 2 == 1) flg = 0;
  else {
    flg = 1;

    for (int i = 0, j = s.size() / 2; i < s.size() / 2; i++, j++) {
      if (s[i] != s[j]) flg = 0;
    }
  }

  if (flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int main()
{
	char a, b;
	std::cin >> a >> b;
	if (a == b) std::cout << "H" << std::endl;
	else std::cout << "D" << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) 
{
    int H, W, i, j;
    scanf("%d %d", &H, &W);
    char a[H+3][W+3];
    int h[H+1], w[W+1];
    for(i = 0; i < H; ++i) { h[i] = 1; }
    for(i = 0; i < W; ++i) { w[i] = 1; }
    for(i = 0; i < H; ++i) {
        scanf("%s", a[i]);
    }

    int flag = 0;
    for(i = 0; i < H; ++i) {
        for(j = 0; j < W; ++j) {
            if(a[i][j] == '#') { flag = 1; break; }
        }
        if(!flag) { h[i] = 0; }
        flag = 0;
    }

    flag = 0;
    for(i = 0; i < W; ++i) {
        for(j = 0; j < H; ++j) {
            if(a[j][i] == '#') { flag = 1; break; }
        }
        if(!flag) { w[i] = 0; }
        flag = 0;
    }

    //printf("\n");
    //printf("h: ");
    //for(i = 0; i < H; ++i) { printf(" %d", h[i]); } printf("\n");
    //printf("w: ");
    //for(i = 0; i < W; ++i) { printf(" %d", w[i]); } printf("\n");
    for(i = 0; i < H; ++i) {
        for(j = 0; j < W; ++j) {
            if((h[i] == 1) && (w[j] == 1)) { printf("%c", a[i][j]); }
        }
        if(h[i] == 1) { printf("\n"); }
    }
    return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    cout << s1[0] << s2[1] << s3[2] << endl;

    return 0;
}


Measured memory_bytes: 256
'''
全体からKよりも小さくなる組を引く
(1~N)%iのあまりについて考える。(iは固定)
0<=i<=Kの時、あまりは必ずK-1以下になる(2で割ると余りは[0,1]、3で割ると余りは[0,1,2]、....、Kで割ると余りは[0,1,..,K-1])
i>Kの時、
まず、(1~i)%iについて考える
    ①(1~K-1)%iの余りはK-1以下、個数は(K-1)個     (例:i=K+5の時、1%(K+5)=1、2%(K+5)=2、......、(K-1)%(K+5)=K-1)
    ②(K~i-1)%iの余りはK以上、個数は(i-K)個    (例：i=K+5の時、(K)%(K+5)=K、(K+1)%(K+5)=K+1、.....、(K+4)%(K+5)=K+4)
    ③i%iの余りは0、個数は1個      (例:i=K+5の時、(K+5)%(K+5)=0)

    全部合わせてi個
    このうち、余りがKよりも小さくなるのはK個

では、(i+1~N)%iも上と同様に考える(余りは周期的に繰り返される)と、(N//K)回繰り返されるので、(N//i)*K
あとは余りのところを考えて、min(K-1,N%i)   (maxの部分はK=0対策)
i>Kにおいてはこの和をansから引けば良い。
'''

N,K=map(int,input().split())
ans=N**2
for i in range(1,N+1):
    if i<=K:
        ans-=N
    else:
        ans-=((N//i)*K + max(min(K-1,N%i),0))
print(ans)

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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)

/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	for(int i = 0; i < s.size(); i++) cout<<'x';
	int n;
	// cin>>n;
}

Measured memory_bytes: 256
import javax.swing.plaf.synth.SynthLookAndFeel;
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

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

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static int lowerBound
            (Integer[] array, int length, int value) {
        int l = 0;
        int r = length;
        while (l < r) {
            int mid = (l + r) / 2;
            if (value < array[mid]) {
                r = mid;
            } else {
                l = mid + 1;
            }
        }
        return l;
    }
    public static long gcd(long a, long b){
        if (b == 0)
            return a;
        else return gcd(b, a % b);
    }
    public static void main(String [] args)  {
       // int T = sc.nextInt();while (T--!=0)
        {
            solve();
        }
    }
    public static void solve()  {
//////////////////////////////////////////////////////////////////////
       String s = sc.nextLine();
       String s1 = sc.nextLine();
       long cn=0;
        for (int i = 0; i < s.length(); i++) {
            if(s.charAt(i)!=s1.charAt(i)){
                cn++;
            }
        }
        System.out.println(cn);
///////////////////////////////////////////////////////////////////////
    }

}

Measured memory_bytes: 42400
let () = Scanf.scanf "%d\n" @@ fun n ->
  let ass =
    Array.init n @@ fun _ ->
      Array.init (n - 1) @@ fun _ ->
        Scanf.scanf "%d " @@ fun a -> a - 1 in
  let es = Array.make_matrix n n [] in
  for i = 0 to n - 1 do
    for j = 0 to n - 3 do
      es.(min i ass.(i).(j)).(max i ass.(i).(j)) <-
        (min i ass.(i).(j + 1), max i ass.(i).(j + 1)) ::
        es.(min i ass.(i).(j)).(max i ass.(i).(j))
    done
  done;
  let dp = Array.make_matrix n n (-1) in
  let vs = Array.make_matrix n n false in
  let rec visit i j =
    if vs.(i).(j)
    then raise Not_found
    else if 0 <= dp.(i).(j) then dp.(i).(j)
    else begin
      vs.(i).(j) <- true;
      dp.(i).(j) <-
        1 + List.fold_left (fun acc (i, j) ->
          max acc @@ visit i j) 0 es.(i).(j);
      vs.(i).(j) <- false;
      dp.(i).(j);
    end in
  try
    Printf.printf "%d\n" @@
    Array.fold_left (Array.fold_left max) min_int @@
    Array.init n @@ fun i -> Array.init n @@ visit i
  with Not_found -> print_endline "-1"



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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#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, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << res << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)

int main() {
	int n;
	cin >> n;
	vector<string> res;
	map<string, int> smap;
	int maxcnt = 0;
	FOR(i, 1, n) {
		string s;
		cin >> s;
		smap[s]++;
		if (smap[s] == maxcnt) {
			res.push_back(s);
		}
		else if (smap[s] > maxcnt) {
			maxcnt = smap[s];
			res = { s };
		}
	}
	sort(ALL(res));
	FOR(i, 0, res.size() - 1) {
		pv(res[i]);
	}
	return(0);
}

Measured memory_bytes: 26864
#include <stdio.h>

int main() {

    int a, b;

    scanf("%d %d", &a, &b);

    if (a < b) printf("a < b\n");

    if (a > b) printf("a > b\n");

    if (a == b) printf("a == b\n");

    else;

    return 0;
}

Measured memory_bytes: 2668
import java.util.Scanner;

public class Main {
    private static double[] p;
    private static double[] q;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        p = new double[n+1];
        q = new double[n+1];
        for (int i = 1; i <= n; i++) {
            p[i] = in.nextDouble();
        }
        for (int i = 0; i <= n; i++) {
            q[i] = in.nextDouble();
        }
        System.out.println(minimumCost());
    }

    private static double minimumCost() {
        int n = p.length - 1;
        double[][] weight = new double[n+2][n+1];
        double[][] cost = new double[n+2][n+1];

        for (int i = 1; i <= n + 1; i++) {
            weight[i][i-1] = q[i-1];
            cost[i][i-1] = q[i-1];
        }

        for (int size = 1; size <= n; size++) {
            for (int i = 1; i <= n - size + 1; i++) {
                int j = i + size - 1;
                cost[i][j] = Double.MAX_VALUE;
                weight[i][j] = weight[i][j-1] + p[j] + q[j];
                for (int r = i; r <= j; r++) {
                    double testCost = cost[i][r-1] + cost[r + 1][j] + weight[i][j];
                    if (testCost < cost[i][j]) {
                        cost[i][j] = testCost;
                    }
                }
            }
        }
        return cost[1][n];
    }
}




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

using namespace std;

int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
    char C; cin >> C;
    switch (C)
    {
        case 'A':
            cout << "T\n";
            break;
        case 'T':
            cout << "A\n";
            break;
        case 'G':
            cout << "C\n";
            break;
        case 'C':
            cout << "G\n";
            break;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll h, w, n;
  cin >> h >> w >> n;
  
  if(h>w) swap(h, w);
  cout << (n+w-1)/w << newl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    
    int val = max({a*c,a*d,b*c,b*d});
    
    cout<<val;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(0, min(b, d) - max(a, c)) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


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

    ll n,x;
    cin >> n >> x;
    ll l[n];
    F0R(i,n) cin >> l[i];

    ll curPos = 0;
    F0R(i,n){
      curPos += l[i];
      if(curPos > x)
        {
          cout << i+1 << endl;
          return 0;
        }
    }
    cout << n+1 << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  string s,t;
  cin >>a>>b;
  c=a/b;
  if(a%b!=0)c++;
  cout <<c;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int coin[109];
int dp[3][100002];
int n;
int mx;
int call(int cap,int t)
{
    //cout<<cap<<"  "<<t<<endl;
    if(cap==mx)return t%2+1;
    if(cap>mx)return t;
    if(dp[t][cap]!=-1)return dp[t][cap];
    for(int i=0;i<n;i++)
    {
        int val=call(cap+coin[i],t%2+1);
        if(val==t){
            dp[t][cap]=val;
            return val;
        }
    }
    dp[t][cap]=t%2+1;
    return dp[t][cap];
}
int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n;
    cin>>mx;
    for(int i=0;i<n;i++)
        cin>>coin[i];
    int ans=call(0,1);
    if(ans==1)cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}


Measured memory_bytes: 9216
#include <stdio.h>
#include <string.h>
typedef long long ll;

int main(void) {
  ll i, n, m, q, a, b, c, d;
  char s[100010], t[100010];
  scanf("%s%s%lld", s, t, &q);
  n = strlen(s), m = strlen(t);
  ll sums[n + 1], sumt[m + 1];
  sums[0] = sumt[0] = 0;
  for(i = 0; i < n; ++i) sums[i + 1] = sums[i] + (s[i] == 'A' ? 1 : 2);
  for(i = 0; i < m; ++i) sumt[i + 1] = sumt[i] + (t[i] == 'A' ? 1 : 2);
  for(i = 0; i < q; ++i) {
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    if((sums[b] - sums[--a]) % 3 == (sumt[d] - sumt[--c]) % 3) printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	vector<ll> a(3*n);
	for( auto &k : a ) cin >> k;
	sort( a.begin(), a.end(), greater<ll>() );
	ll ans = 0;
	for( int i = 0; i < n; ++i ) ans += a[2*i+1];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
n, m = gets.split.map(&:to_i)
ps = Array.new(m) { p, s = gets.split; [p.to_i, s.to_sym] }

waac = Array.new(n + 1) { [0, false] }

ps.each do |p, s|
  waac_p = waac[p]
  if s == :AC
    waac_p[1] = true
  else
    waac_p[0] += 1 unless waac_p[1]
  end
end

waac.each { |waac_p| waac_p[0] = 0 unless waac_p[1] }

wa, ac = waac.transpose

puts [ac.count(true), wa.inject(0, :+)].join(" ")


Measured memory_bytes: 13564
s = input()
k = int(input())
if len(s) == 1:
    print(k // 2)
else:

    def counts(s):
        count = 0
        for i in range(len(s) - 1):

            if s[i] == s[i + 1]:
                count += 1
                s = s[: i + 1] + "." + s[i + 2 :]
        return count

    res1 = counts(s)
    res2 = counts(s * 2)
    res3 = counts(s * 3)
    if res3 - res2 == res2 - res1:
        print(res1 + (res2 - res1) * (k - 1))
    else:
        if k % 2 == 1:
            print(res2 * (k // 2) + res1)
        else:
            print(res2 * (k // 2))


Measured memory_bytes: 3064