akhauriyash/Code-Regression huggingface dataset:
#include <queue>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int N=2.5e3+5;
const int M=2e4+5;
const int inf=1e9+7;

template <typename _Tp> inline void IN(_Tp&x) {
	char ch;bool flag=0;x=0;
	while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	if(flag) x=-x;
}

namespace NetworkFlow {
	int S,T,cnt=1,vis[N],head[N];ll dis[N];
	struct Pre {int last,edge;} pre[N];
	struct Edge {int nxt,to,val;ll cot;} G[M];
	inline void addedge(int u,int v,int val,ll cot) {
		G[++cnt]=(Edge){head[u],v,val,cot},head[u]=cnt,
		G[++cnt]=(Edge){head[v],u,0,-cot},head[v]=cnt;
	}
	queue <int> q;
	inline bool Spfa() {
		memset(pre,0,sizeof(pre)),memset(vis,0,sizeof(vis));
		for(int i=1;i<=T;++i) dis[i]=-1e17;
		q.push(S),vis[S]=true,dis[S]=0;
		while(!q.empty()) {
			int u=q.front(),v;q.pop();
			for(int i=head[u];i;i=G[i].nxt)
				if(v=G[i].to,G[i].val>0&&dis[v]<dis[u]+G[i].cot) {
					dis[v]=dis[u]+G[i].cot,pre[v]=(Pre){u,i};
					if(!vis[v]) q.push(v),vis[v]=true;
				}
			vis[u]=false;
		}return dis[T]!=-1e17;
	}
	inline ll EK() {
		int tmp=0;ll cost=0;
		while(Spfa()) {
			tmp=inf;
			for(int i=T;i!=S;i=pre[i].last) tmp=min(tmp,G[pre[i].edge].val);
			for(int i=T;i!=S;i=pre[i].last) G[pre[i].edge].val-=tmp,G[pre[i].edge^1].val+=tmp;
			cost+=1ll*tmp*dis[T];
		}return cost;
	}
}using namespace NetworkFlow;

int n,P1,P2,P3,P4,rx[N],ry[N],rc[N],bx[N],by[N],bc[N];
int main() {
	IN(n),P1=2*n+1,P2=P1+1,P3=P2+1,P4=P3+1,S=P4+1,T=S+1;
	for(int i=1;i<=n;++i) IN(rx[i]),IN(ry[i]),IN(rc[i]);
	for(int i=1;i<=n;++i) IN(bx[i]),IN(by[i]),IN(bc[i]);
	for(int i=1;i<=n;++i) addedge(S,i,rc[i],0),addedge(i+n,T,bc[i],0);
	for(int i=1;i<=n;++i)
		addedge(i,P1,inf,rx[i]+ry[i]),addedge(P1,i+n,inf,-by[i]-bx[i]),
		addedge(i,P2,inf,rx[i]-ry[i]),addedge(P2,i+n,inf,by[i]-bx[i]),
		addedge(i,P3,inf,ry[i]-rx[i]),addedge(P3,i+n,inf,bx[i]-by[i]),
		addedge(i,P4,inf,-ry[i]-rx[i]),addedge(P4,i+n,inf,bx[i]+by[i]);
	printf("%lld\n",EK());
	return 0;
}

Measured memory_bytes: 896
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<cmath>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

int main(){
  ll ans=0;
  bool flag=true;
  ll N,i,j;
  ll M;
  cin>>N>>M;
  //cout<<(int)sqrt(81)<<endl;
  for(i=(ll)sqrt(M);i>=1;i--){
    //cout<<i<<endl;
    if(M%i==0){
      //cout<<i<<endl;
      if(M/i>=N) ans=max(ans,i);
      j=M/i;
      if(M/j>=N) ans=max(ans,j);
          
    } 
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,m;
  int i,j,k;
  int mat[100][100]={{}};
  int ve[100]={};
  cin >> n >> m;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      cin >> mat[i][j];
    }
  }
  for(j=0;j<m;j++) cin >> ve[j];
  for(i=0;i<n;i++){
    int x=0;
    for(j=0;j<m;j++) x+=mat[i][j]*ve[j];
    cout << x << endl;		       
  }
  
  return 0;
}



Measured memory_bytes: 3120
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int max_n = 0;
    int ren = 0;
    for(int i = 0;i < n;i++){
        int d1;
        int d2;
        cin >> d1 >> d2;
        if(d1 == d2){
            ren ++;
        }else{
            ren = 0;
        }
        max_n = max(ren,max_n);
    }
    if(max_n >= 3){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 3632
import sys

N=int(input())
A=[[0]*2 for i in range(N)]

for i in range(N):
    A[i][0],A[i][1]= map(int,input().split())
sortsecond=lambda val:val[1]

A.sort(key=sortsecond)
sum=0
for i in range(N):
    sum+=A[i][0]
    if sum>A[i][1]:
        print("No")
        sys.exit()
print("Yes")


    

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

int n, A[101], x, ans;
ll sum, now;
int main(){
	cin>>n>>x;
	for(int i=1; i<=n; i++) cin>>A[i], sum+=A[i];
	if(x==sum){ cout<<n<<'\n'; return 0; }
	sort(A+1, A+n+1);
	for(int i=1; i<=n-1; i++){
		now+=A[i];
		if(now<=x) ans=i;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
// AtCoDeerくんと変なじゃんけん
#include <iostream>
#include <string>
using namespace std;
typedef long long INT;

string s;

int main(){
    cin>>s;
    INT p=s.size()/2;
    for(INT i=0;i<s.size();i++){
        if(s[i]=='p') p--;
    }
    cout<<p<<endl;
}

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

const ll INF = 1LL << 60;

ll N, H, W;
vector<ll> A, B;
int main() {
    cin >> N >> H >> W;
    A.resize(N); B.reserve(N);
    rep(i, N) cin >> A[i] >> B[i];

    ll ans = 0;
    rep(i, N) {
        if (A[i] < H) continue;
        if (B[i] < W) continue;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = [list(map(int,input().split())) for i in range(n)]
b = [int(input()) for _ in range(m)]
for i in range(n):
    res = 0
    for j in range(m):
        res += a[i][j] * b[j]
    print(res)


Measured memory_bytes: 6016
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL
#define rep(i,a,n) for (int i=a ; i<n ; i++)
#define per(i,a,n) for (int i=n-1 ; i>=a ; i--)
#define INF (llong)1e9+5

using namespace std;
using llong = long long;
using VI = vector<int>;
using VLL = vector<long long>;
using PII = pair<int, int>;

int n, w;
VLL wei, val;
vector<vector<llong>> dp;

// dp[i] = i번째 물건까지 최대 value 
// dfs - 현재꺼 안고르거나 고르거나 해서 
llong dfs(int t, int leftWeight)
{
	if (leftWeight < 0) return -INF;
	// leftWeight 0 미만이면 가방에 못담음
	if (t == n) return 0;
	// n-1번째까지 다 결정하고 끝까지 넘어가면 curVal return
	if (dp[t][leftWeight] != -1) return dp[t][leftWeight];
	return dp[t][leftWeight] = max(dfs(t + 1, leftWeight), dfs(t + 1, leftWeight - wei[t]) + val[t]);
	//t번째 물건 안고르고 넘어가기 vs t번째 물건 고르고 넘어가기
}

int main()
{
	IOS;

	cin >> n >> w;
	wei.resize(n), val.resize(n);
	dp.resize(n);

	rep(i, 0, n) cin >> wei[i] >> val[i];
	rep(i, 0, n)
	{
		dp[i].resize(w + 1);
		fill(all(dp[i]), -1);
	}
	cout << dfs(0, w);
	return 0;
}



Measured memory_bytes: 81476
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

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

int main(){
    string a, b;
    cin >> a >> b;
    if ( a.size() > b.size() ) {
        cout << "GREATER" << endl;
    }
    else if ( b.size() > a.size() ) {
        cout << "LESS" << endl;
    }
    else {
        rep(i, a.size()) {
            if ( a[i] - '0' > b[i] - '0' ) {
                cout << "GREATER" << endl;
                return 0;
            }
            else if ( b[i] - '0' > a[i] - '0' ) {
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var L = new int[4]; var r = new int[4];
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            var a = Array.ConvertAll(line.Trim().Split(' '), decimal.Parse);
            goEyeTest(a[0], L);
            goEyeTest(a[1], r);
        }
        for (int i = 0; i < 4; i++)
            Console.WriteLine("{0} {1}", L[i], r[i]);
    }
    public static void goEyeTest(decimal a, int[] b)
    {
        if (a >= 1.1m) b[0]++;
        else if (a >= 0.6m && a < 1.1m) b[1]++;
        else if (a >= 0.2m && a < 0.6m) b[2]++;
        else b[3]++;
    }
}

Measured memory_bytes: 9376
#include <algorithm>
#include <cstdio>
typedef long long lld;
const lld INFN = 1LL<<60;
const int MAXN = 305;
lld graph[MAXN][MAXN]{ };
bool skip[MAXN][MAXN]{ };
int E, N, size=0;
lld M, mst=0;


void print()
{
	puts("---");
	for(int i = 1; i <= N; ++i)
	for(int j = 1; j <= N; ++j)
		printf("%lld%c", (graph[i][j] == INFN) ? -1 : graph[i][j], (j==N)?'\n':' ');
}

int main()
{
	scanf("%d", &N);
	for(int i = 1; i <= N; ++i)
	for(int j = 1; j <= N; ++j)
		scanf("%d", &graph[i][j]);
	for(int k = 1; k <= N; ++k)
	for(int i = 1; i <= N; ++i) if(k != i)
	for(int j = 1; j <= N; ++j) if(k != j && i != j)
		if(graph[i][k] + graph[k][j] < graph[i][j])
			return puts("-1"), 0;
		else if(graph[i][k] + graph[k][j] == graph[i][j])
			skip[i][j] = skip[j][i] = true;
	for(int i = 1; i < N; ++i)
	for(int j = i+1; j <= N; ++j)
		if(!skip[i][j]) mst += graph[i][j];
	printf("%lld\n", mst);
	return 0;
}

Measured memory_bytes: 1024
n, m = map(int, input().split())
if n >= m:
    print(0)
    exit()

a = list(map(int, input().split()))
a.sort()
mark = []
d = []
for i in range(m-1):
    d.append(a[i+1] - a[i])
d.sort()
ans = sum(d)

for i in range(n-1):
    ans -= d[-1-i]

print(ans)

Measured memory_bytes: 13968
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll mod = 1000000000+7;
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll n;
    string s;
    std::cin >> n;
    std::cin >> s;
    std::map<char, ll> alpha;
    
    COMinit();
    
    string aaa = "abcdefghijklmnopqrstuvwxyz";
    for (int i = 0; i < aaa.length(); i++) {
        alpha[aaa[i]]=0;
    }
    for (int i = 0; i < n; i++) {
        alpha[s[i]]++;
    }
    ll result = 1;
    
    
    for (int i = 0; i < aaa.length(); i++) {
        result = result * (alpha[aaa[i]]+1) %mod;
    }
    std::cout << result%mod -1 << std::endl;
}


Measured memory_bytes: 12416
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int l[] = new int[m];
        int r[] = new int[m];
        int d[] = new int[m];
        List<Info>[] list = new ArrayList[n];
        for (int i = 0; i < n; i++) {
            list[i] = new ArrayList<Info>();
        }
        for (int i = 0; i < m; i++) {
            l[i] = sc.nextInt();
            r[i] = sc.nextInt();
            d[i] = sc.nextInt();
            Info ri = new Info(r[i] - 1, d[i]);
            Info le = new Info(l[i] - 1, -d[i]);
            list[l[i] - 1].add(ri);
            list[r[i] - 1].add(le);
        }
        int x[] = new int[n];
        Arrays.fill(x, Integer.MAX_VALUE);
        boolean ans = true;
        for (int i = 0; i < n; i++) {
            if (x[i] == Integer.MAX_VALUE) {
                x[i] = 0;
                ans &= DFS(i, x, list);

            }
        }
        if (ans) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    static boolean DFS(int i, int[] x, List<Info>[] lists) {
        List<Info> xlist = lists[i];
        for (int j = 0; j < xlist.size(); j++) {
            int to = xlist.get(j).to;
            int cost = xlist.get(j).cost;
            if (x[to] == Integer.MAX_VALUE) {
                x[to] = x[i] + cost;
                if (!DFS(to, x, lists)) {
                    return false;
                }
            } else {
                if (x[to] != x[i] + cost) {
                    return false;
                }
            }

        }
        return true;
    }
}

class Info {
    int to;
    int cost;

    Info(int to, int cost) {
        this.to = to;
        this.cost = cost;
    }
}

Measured memory_bytes: 178472
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   string s; cin >> s;
   bool N, W, S, E;
   N=W=S=E=false;
   for (auto &&i : s){
      switch (i){
      case 'N':N=true;break;
      case 'W':W=true;break;
      case 'S':S=true;break;
      case 'E':E=true;break;
      }
   }
   if ((N==S)&&(W==E))cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 3648
#include <stdio.h>
void ReverseSequence(char *s)
{
  if(*s == '\0') return;
  ReverseSequence(s + 1);
  putchar(*s);
}
int main()
{
  char s[8191];
  gets(s);
  ReverseSequence(s);
  putchar('\n');
  return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll X, a, b, A, B;

    cin >> X;

    for(a=-1000; a<=1000; a++){
        for(b=-1000; b<=1000; b++){
            A = powl(a,5);
            B = powl(b,5);

            if(A-B==X){
                cout << a << " " << b << endl;
                return 0;
            } 
        }
    }

    return 0;
}

Measured memory_bytes: 3688
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int S = sc.nextInt();
    if (S <= 2) {
      System.out.println(0);
      return;
    }
    if (S <= 5) {
      System.out.println(1);
      return;
    }
    int[] dp = new int[S + 1];
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = 0;
    dp[3] = 1;
    dp[4] = 1;
    dp[5] = 1;
    int mod = 1000000007;
    for (int i = 6; i <= S; i++) {
      int sum = 1;
      for (int j = i - 3; j >= 3; j--) {
        sum += dp[j];
        sum %= mod;
      }
      dp[i] = sum;
    }
    System.out.println(dp[S]);
  }
}


Measured memory_bytes: 27324
n=int(raw_input())
a=[int(raw_input()) for _ in xrange(n)]
mxlba=0
for i in xrange(n):
    mxlba=max(mxlba,a[i].bit_length())

exist=[False]*(mxlba+5)
for i in xrange(n):
    bit=bin(a[i])[2:]
    lb=len(bit)
    for j in xrange(lb-1,-1,-1):
        if bit[j]=="1":
            exist[lb-1-j]=True
            break

axor=0
for i in xrange(n):
    axor^=a[i]
if axor==0:
    print(0)
    exit()
la=axor.bit_length()
axor=bin(axor)[2:]
ans=0
i=0
while i<la:
    if axor[i]=="1":
        if not exist[la-i-1]:
            print(-1)
            exit()
        else:
            ans+=1
            if la-i-1==0:
                break
            tmp=int("1"*(la-i-1),2)
            axor=int(axor,2)^tmp
            axor=bin(axor)[2:]
    i+=1

print(ans)


Measured memory_bytes: 5892
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int status[]=new int[1000100];
		status[0]=1;
		status[1]=1;
		for(int i=4;i<=1000000;i=i+2)
		{
			status[i]=1;
		}
		for(int i=3;i*i<=1000000;i=i+2)
		{
			if(status[i]==1)continue;
			for(int j=i*i;j<=1000000;j=j+i*2)
			{
				status[j]=1;
			}
		}
		while(sc.hasNext())
		{
			int a=sc.nextInt();
			int p=0;
			for(int i=1;i<=a;i++)
			{
				if(status[i]==0)p++;
			}
			System.out.println(p);
		}
	
			
		

	}

}

Measured memory_bytes: 24580
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>
#include <complex>
#include <stack>
#include <set>
#include <map>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i,n) for (int i = (n)-1; i >= 0; i--)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define allof(c) c.begin(), c.end()
#define partof(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define EPS 1e-9
#define INF 1000000000
using namespace std;

typedef complex<int> POINT;
template <class T>
class vevector : public vector<vector<T>>
{
public:
	using vector<vector<T>>::operator []; 
	T& operator [](const POINT &index) { return (*this)[index.real()][index.imag()]; }
};

template <class T> T read() { T t; cin >> t; return t; }
template <> POINT read<POINT>() { int x, y; cin >> x >> y; return POINT(x, y); }
template <class T> vector<T> read(int n) { vector<T> v; REP(i,n) { v.push_back(read<T>()); } return v; }
template <class T> vevector<T> read(int n, int m) { vevector<T> v; REP(i,n) v.push_back(read<T>(m)); return v; }
template <class T> void write(const T &t) { cout << t << endl; }
template <class T> void write(const T &t, const T &t2) { cout << t << ' ' << t2 << endl; }

template <class T> void write(const vector<T> &v)
{
	ostringstream ss; 
	for (auto x : v) ss << x << ' ';
	auto s = ss.str();
	cout << s.substr(0, s.length() - 1) << endl;
}

template <class T> string toString(const T &t) { stringstream ss; ss << t; return ss.str(); }

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__
#define countof(a) (sizeof(a)/sizeof(a[0]))

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

vector<unsigned char> isPrime;
vector<int> primes;
void initPrimes(int n)
{
	isPrime = vector<unsigned char>(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	FOR(i, 2, n)
	{
		if (!isPrime[i]) continue;
		primes.push_back(i);
		for (int j = i * 2; j <= n; j += i)
			isPrime[j] = false;
	}
}

struct iotait
{
	int n;
	iotait(int n = 0) : n(n) { }
	iotait &operator ++() { ++n; return *this; }
	int operator *() { return n; }
};

/// template end ///

void solve()
{
	REP (testcase, INF)
	{
		READ(int, N, M);
		if (!(N|M)) { break; }

		// 確率高いところからお金使えばいい。

		vector<int> encountDist(11);
		REP(i, N) { READ(int, D, P); encountDist[P] += D; }
		RREP(i, encountDist.size())
		{
			int x = min(M, encountDist[i]);
			M -= x; encountDist[i] -= x;
		}
		write(inner_product(allof(encountDist), iotait(0), 0));
	}
}

Measured memory_bytes: 1196
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max_h = 0;
        int result = 0;
        for(int i=0;i<n;i++){
            int tmp = sc.nextInt();
            if(tmp>=max_h){
                max_h = tmp;
                result++;
            }
        }

        System.out.println(result);
    }
}

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

#define REP(i, a, b)  for(int i = a, _b = b; i < _b; ++i)
#define FOR(i, a, b)  for(int i = a, _b = b; i <= b; ++i)
#define FORD(i, a, b) for(int i = a, _b = b; i >= b; --i)

#define endl          "\n"
#define newline       cout << "\n"
#define puts(_xxx_)   cout << _xxx_ << "\n"
#define db1(x)        cout << #x << " = " << x << "\n"
#define db2(a, i)     cout << #a << "[" << i << "] = " << a[i] << "\n"
using namespace std;

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef long long llong;

const int MOD = 1E9+7;

int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
#ifdef Home
   freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif
	int N;
	string s1, s2;
 	cin >> N >> s1 >> s2;
 	
 	llong ans = (s1[0] == s2[0]) ? 3 : 6;
	 	
 	REP(i, 1, N) {
 		if(s1[i] == s1[i-1] && s2[i] == s2[i-1]) continue;
 		if(s1[i-1] == s2[i-1]) {
 			ans *= 2;
 		}
 		else if(s1[i] != s2[i]){
 			ans *= 3;
 		}
 		ans %= MOD;
 	}
	puts(ans); 	
   return 0;
}

Measured memory_bytes: 256
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1),i=new(r(2))(n.readFileSync("/dev/stdin","utf8").split(/\s+/g));r(4)(i)},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3);t.exports=class{constructor(t){this.inp=new n(t)}n(){return this.inp.deq()}ni(){return parseInt(this.inp.deq(),10)}add(t){this.inp.enq(t)}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=t.ni(),r=new Array(e),n=0;n<e;n++)r[n]=[];for(var i=0;i<e-1;i++){var o=t.ni(),s=t.ni(),u=t.ni();r[o-1].push([s-1,u]),r[s-1].push([o-1,u])}for(var f=t.ni(),a=t.ni(),c=new Array(e).fill(-1),l=[[a-1,0]];l.length>0;)for(var p=l.pop(),d=r[p[0]].length,v=0;v<d;v++){var h=r[p[0]][v];if(-1==c[h[0]]){var y=p[1]+h[1];c[h[0]]=y,l.push([h[0],y])}}for(var b=0;b<f;b++){var g=t.ni()-1,m=t.ni()-1,x=c[g]+c[m];console.log(x)}}}]);

Measured memory_bytes: 113656
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int f(vector<vector<int>> &A, int K, int si, int sj) {
    int H = A.size(), W = A[0].size();
    int ans = 0;
    A[si][sj] = 0;
    int t = 1;
    for (;;) {
        for (int j = 0; j < W; j++) {
            int cnt = 0;
            for (int i = H - 1; i >= 0; i--) {
                if (A[i][j] == 0) cnt++;
                else if (cnt) A[i + cnt][j] = A[i][j], A[i][j] = 0;
            }
        }
        int del = 0;
        for (int i = H - 1; i >= 0; i--) {
            for (int j = 0; j < W - 1; j++) {
                int t = j;
                while (A[i][j] != 0 && t + 1 < W && A[i][t] == A[i][t + 1]) {
                    t++;
                }
                if (t - j + 1 >= K) {
                    del += A[i][j] * (t - j + 1);
                    for (int k = j; k <= t; k++) A[i][k] = 0;
                    j = t;
                }
            }
        }
        if (del == 0) break;
        ans += t * del;
        t *= 2;
    }
    return ans;
}
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int H, W, K; cin >> H >> W >> K;
    vector<vector<int>> A(H, vector<int>(W));
    for (auto &row : A) for (auto &a : row) { char c; cin >> c; a = c - '0'; }
    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            auto B = A;
            int s = f(B, K, i, j);
            ans = max(ans, s);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,i,j;
  char w;
  while(1){
    scanf("%d",&n);
    if(!n)break;
    char c[100000][2]={0};
    for(i=0;i<n;i++){
      scanf(" %c %c",&c[i][0],&c[i][1]);
    }
    scanf("%d",&m);
    for(i=0;i<m;i++){
      scanf(" %c",&w);
      for(j=0;j<n;j++){
	if(c[j][0]==w){
	  printf("%c",c[j][1]);
	  break;
	}
      }
      if(j==n)printf("%c",w);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
#include <set>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    int k;
    cin >> s >> k;
    set <string> a;
    for( int i = 1 ; i <= k ; i++ ) {
        for( int j = 0 ; j < s.length() ; j++ ) {
            if( j + i <= s.length() ) a.insert( s.substr( j , i ) );
        }
    }
    auto j = a.begin();
	for ( int i = 0 ; i < k - 1 ; i++ ) j++;
	cout << *j;
}

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

int A[20];
int Q[200];
int n, q;

bool check(int i, int m){
   if(m==0) return true;
   if(i>=n) return false;
   bool res=check(i+1, m-A[i]) || check(i+1, m);
   return res;
}

int main(){
   cin >> n;
   for(int i=0; i<n; i++) cin >> A[i];
   cin >> q;
   for(int i=0; i<q; i++) cin >> Q[i];

   for(int i=0; i<q; i++){
      bool ans=check(0, Q[i]);
      if(ans) cout << "yes" << endl;
      else cout << "no" << endl;
   }
}


Measured memory_bytes: 3080
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var priceList = new List<int>();
        for(int i=0; i<10; i++){
          var temp = Console.ReadLine();
          if(String.IsNullOrEmpty(temp)){
            break; 
          }else{
            priceList.Add(int.Parse(temp));
          }
        }
        
        var sum = priceList.Sum();
        var max = priceList.Max();
        
        Console.WriteLine(sum - max/2);
    }
}

Measured memory_bytes: 13268
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		int Alice = 0;
		int Bob = 0;
		int N;
		ArrayList<Integer> cards = new ArrayList<Integer>();

		Scanner scan = new Scanner(System.in);
		N = scan.nextInt();

		for(int i = 0; i < N; i++) {
			cards.add(scan.nextInt());
		}

		Collections.sort(cards, Collections.reverseOrder());

		for(int i = 0; i < N; i+=2) {
			Alice += cards.get(i);
		}
		for(int i = 1; i < N; i+=2) {
			Bob += cards.get(i);
		}
		System.out.println(Alice - Bob);
		scan.close();
	}
}

Measured memory_bytes: 22996
#include<iostream>                                        
#include<string>                                          
using namespace std;                                      
                                                          
int main(){                                               
  int n;                                                  
  cin >> n;                                               
  string taro_card;                                       
  string hanako_card;                                     
  int taro_point = 0;                                     
  int hanako_point = 0;                                   
                                                          
  for(int i=0;i<n;i++){                                   
    cin >> taro_card >> hanako_card;                      
                                                          
    if(taro_card > hanako_card){                          
      taro_point += 3;                                    
    } else if(taro_card == hanako_card){                  
      taro_point++; hanako_point++;                       
    } else {                                              
      hanako_point += 3;                                  
    }                                                     
  }                                                       
                                                          
  cout << taro_point << " " << hanako_point << endl;      
                                                          
  return 0;                                               
}

Measured memory_bytes: 3112
#include <cstdio>
#include <algorithm>
#define MAXN 105
#define ll long long
using namespace std;
bool cmp(ll x, ll y) {
	return x > y;
}
ll n, w, a[MAXN], b[MAXN], c[MAXN], d[MAXN];
ll stan, we, va, ca, cb, cc, cd;

int main() {
	long long ans = 0;
	scanf("%lld%lld", &n, &w);
	scanf("%lld%lld", &we, &va);
	stan = we;
	a[++ca] = va;
	for(int i = 2; i <= n; i++) {
		scanf("%lld%lld", &we, &va);
		if(we-stan == 1) b[++cb] = va;
		else if(we-stan == 2) c[++cc] = va; 
		else if(we-stan == 3) d[++cd] = va;
		else if(we == stan) a[++ca] = va;
	}
	sort(a+1, a+1+ca, cmp);
	sort(b+1, b+1+cb, cmp);
	sort(c+1, c+1+cc, cmp);
	sort(d+1, d+1+cd, cmp);
	
	for(int i = 1; i <= ca; i++) a[i] += a[i-1];
	for(int i = 1; i <= cb; i++) b[i] += b[i-1];
	for(int i = 1; i <= cc; i++) c[i] += c[i-1];
	for(int i = 1; i <= cd; i++) d[i] += d[i-1];
	
	for(int i = 0;  i <= ca; i++) 
		for(int j = 0; j <= cb; j++)
			for(int m = 0; m <= cc; m++)
				for(int m1 = 0; m1 <= cd; m1++) 
					if(i*stan + (stan+1)*j + (stan+2)*m + (stan+3)*m1 <= w)
						ans = max(ans, a[i]+b[j]+c[m]+d[m1]);
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
s=input()
A=s.replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","")
B=A.replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","")
C=A.replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("0B","").replace("1B","").replace("B","")
print(C)

Measured memory_bytes: 62624
#include <strings.h>
#include <stdio.h>

int min(int a, int b)
{
    return (a > b ? b : a);
}
 
int max(int a, int b)
{
    return (b > a ? b : a);
}
 
int main(void) {
    int i, j, k, h, w;
    int m[501][501];
    int area, hmin;
    char map[500][501];
    int cnt[500][500];

    while (scanf("%d %d", &h, &w), h + w) {
	area = 0;
#if 0
	getchar();
	bzero(m, sizeof(m));
	for (i = 0; i < h; i++) {
	    for (j = 0; j < w; j++) {
		char c;
		scanf("%c", &c);
		if (c == '*') c = 0;
		else {
		    if (i == 0) c = 1;
		    else c = m[i-1][j]+1;
		}
		m[i][j] = c;
	    }
	    getchar();
	}
#endif
#if 1
        for (i = 0; i < h; i++){
            scanf("%s", map[i]);
        }
         
        for (i = 0; i < h; i++){
            for (j = 0; j < w; j++){
                if (i == 0){
                    cnt[i][j] = map[i][j] == '*' ? 0 : 1;
                }
                else {
                    if (map[i][j] == '.'){
                        cnt[i][j] = cnt[i - 1][j] + 1;
                    }
                    else {
                        cnt[i][j] = 0;
                    }
                }
            }
        }
#endif
/*
	for (i = 0; i < h; i++) {
	    for (j = 0; j < w; j++) {
		printf("%d", m[i][j]);
	    }
	    putchar('\n');
	}
*/
#if 0
	for (i = 0; i < h; i++) {
	    for (j = 0; j < w; j++) {
		hmin = 10000000;
		for (k = j; k < w; k++) {
		    if (m[i][k] < hmin) hmin = m[i][k];
		    if (area < hmin * (k-j+1)) area = hmin * (k-j+1);
		}
	    }
	}
#else
        for (i = 0; i < h; i++){
            for (j = 0; j < w; j++){
                hmin = 10000000;
                for (k = j; k < w; k++){
                    hmin = min(cnt[i][k], hmin);
                    area = max(area, (k - j + 1) * hmin);
                }
            }
        }
#endif
	printf("%d\n", area);
    }
    return 0;
}

Measured memory_bytes: 1824
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define ret return 0
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int NUM = 2e5 + 5;
int main(){
    ios
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        ll n;
        cin>>n;
        map<ll,ll> ma;
        int ans = 0;
        for(ll i=2;i<=1e7;i++){
            int cnt=0;
            if(n%i==0){
                while(n%i==0){
                    n/=i;
                    cnt++;
                }
            }
            if(cnt) ma[i]=cnt;
        }
        if(n!=1) ma[n]=1;
        //for(auto x:ma) cout<<x.F<<" "<<x.S<<endl;
        for(auto x:ma){
            int cnt=0;
            int pow=0;
            for(int i=1;;i++){
                pow+=i;
                if(pow<=x.S) cnt++;
                else break;
            }
            ans+=cnt;
        }
        cout<<ans;
    }
}

Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define SI size()
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PF push_front
#define PB push_back
#define VE vector<int>
#define VP vector<PA>
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int MOD=1e9+7;
const int INF=1e9+7;
//
int main(){
  int C[3][3];
  FOR(i,0,3){
    FOR(j,0,3){
      cin>>C[i][j];
    }
  }
  if(C[0][0]-C[0][1]==C[1][0]-C[1][1]&&C[1][0]-C[1][1]==C[2][0]-C[2][1]&&C[0][1]-C[0][2]==C[1][1]-C[1][2]&&C[1][1]-C[1][2]==C[2][1]-C[2][2]){
    if(C[0][0]-C[1][0]==C[0][1]-C[1][1]&&C[0][1]-C[1][1]==C[0][2]-C[1][2]&&C[1][0]-C[2][0]==C[1][1]-C[2][1]&&C[1][1]-C[2][1]==C[1][2]-C[2][2]){
      Yes(1);
      return 0;
    }
  }
  Yes(0);
  return 0;
}


Measured memory_bytes: 256
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

n, w = map(int, input().split())

edges = []

d = [[float("inf")]*n for _ in range(n)]
for i in range(w):
    x,y,z = map(int, input().split())
    x -= 1
    y -= 1
    d[x][y] = z
    d[y][x] = z
    edges.append((x,y,z))

for i in range(n):
    d[i][i] = 0
# print("d",d)

csr = csr_matrix(d)
dp = floyd_warshall(csr)
ans = 0
# print("dp",dp)

for i, j, c in edges:
    # print(i,j,c)
    if dp[i,j] < c:
        ans += 1
print(ans)

Measured memory_bytes: 17040
//what is going on
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
vl w;
int gcd(int a, int b) {
	if(a == 0) {return b;}
	if(b == 0) {return a;}
	return gcd(b,a%b);
}
int main() {
	int n;
	cin >> n;
	for(int i=0;i<n;i++) {
		ll t;
		cin >> t;
		w.push_back(t);
	}
	int lob = 0;
		for(int j=0;j<n;j++) {
			if(w[j]&(1)) {
				lob++;
			}
		}
	int poss = 0;
	if(lob != 1) {
		poss = (n-lob)&1;
	} else {
		if(n&1) {
			int ct = 0;
			int cob = 0;
			while(1) {
				int mo = 0;
				lob = 0;
				for(int i=0;i<n;i++) {
					if(w[i]&1) {lob++;
						mo = i;
					}
				}
				if(lob != 1) {
					cob = n-lob;
					break;
				}
				if(w[mo] == 1) {
					cob = 0;
					break;
				}
				ct++;
				w[mo]--;
				int g = w[0];
				for(int i=1;i<n;i++) {
					g = gcd(w[i],g);
				}
				for(int i=0;i<n;i++) {
					w[i] /= g;
				}
			}
			poss = (cob+ct)&1;
		} else {
			poss = (n-lob)&1;
		}
	}
	if(poss) {
		cout << "First\n";
	} else {
		cout << "Second\n";
	}
}


Measured memory_bytes: 4256
// Tazoe

#include <iostream>
using namespace std;

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

		if(n==0)
			break;

		int cnt[7] = {0};

		for(int i=0; i<n; i++){
			int age;
			cin >> age;

			if(age>=0&&age<10){
				cnt[0]++;
			}
			else if(age<20){
				cnt[1]++;
			}
			else if(age<30){
				cnt[2]++;
			}
			else if(age<40){
				cnt[3]++;
			}
			else if(age<50){
				cnt[4]++;
			}
			else if(age<60){
				cnt[5]++;
			}
			else if(age>=60){
				cnt[6]++;
			}
		}

		for(int i=0; i<7; i++){
			cout << cnt[i] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 864
#include <iostream>

using namespace std;

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

  int ans = n;
  for(int i = 0;i < n;i++){
    if(s.substr(i, n) == t.substr(0, n - i)){
      ans += i;
      cout << ans << endl;
      return 0;
    }
  }
  cout << ans * 2 << endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

using namespace std;

class InputConsole {
public:
	template<typename T>
	static void inputs(vector<T>& vec,int N) {
		string inputString;
		for (int i = 0; i < N; ++i) {
			T input;
			cin >> input;
			vec.push_back(input);
		}

	}
};

void Main()
{
	string S;
	cin >> S;
	if (S[S.size()-1] == 's') {
		S.push_back('e');
	}
	S.push_back('s');
	cout << S << endl;
}

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




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

int move_count(vector<vector<int>> &vec, int &n, int &m, int r, bool fla) {
}
 
int main() {
  while(true){
    
    int N,M;
    cin >> N >> M;
    if( N==0 && M ==0) break;
    
    vector<vector<int>> abc(3, vector<int>(1, 0));
    int b_t = 0;
    for (int i=0; i<3; i++){
      int m; cin >> m;
      for (int j=0; j<m; j++) {
        int g; cin >> g;
        abc.at(i).push_back(g);
        if( i == 1 && j == m-1 ) b_t = g;
      }
    }
    
    
    queue<vector<vector<int>>> q;
    queue<int> num;
    queue<bool> tgl;

    if( b_t == N) {
      abc.at(1).pop_back();
      
      vector<vector<int>> abc1 = abc;
      abc1.at(0).push_back(N);
      q.push( abc1 );
      
      vector<vector<int>> abc2 = abc;
      abc2.at(2).push_back(N);
      q.push( abc2 );
      
      num.push(1); num.push(1);
      tgl.push(false); tgl.push(false);

    } else {
      q.push( abc ); q.push( abc );
      num.push(0); num.push(0);
      tgl.push(true); tgl.push(false);
    }
    int r = 0;
    while(true){
      
      vector<vector<int>> vec = q.front();
      q.pop();
      r = num.front();
      num.pop();
      bool fla = tgl.front();
      tgl.pop();
      
      if(vec.at(0).size() == N + 1 ) break;
      if(vec.at(2).size() == N + 1 ) break;
      if( r > M ) {
        r = -1; break;
      }
        
      int a = vec.at(0).at( vec.at(0).size()-1 );
      int b = vec.at(1).at( vec.at(1).size()-1 );
      int c = vec.at(2).at( vec.at(2).size()-1 );
      if(fla) {
        if(a == N) { c = a; a = -1; }
        else { a = c; c = -1; }
        b = 0; r += 2; fla = false;
      } else {
        if(a == N) {
          a = 0;
          if( c < b ) { c = b; b = -1; }
          else { b = c; c = -1; }
        } else {
          c = 0;
          if( a < b ) { a = b; b = -1;}
          else { b = a; a = -1;}
        }
        r++; fla = true;
      }
      
      vector<int> p_vec = {a,b,c};
      for (int i=0; i<3; i++) {
        if( p_vec.at(i) ) {
          if( p_vec.at(i) == -1) vec.at(i).pop_back();
          else vec.at(i).push_back( p_vec.at(i) );
        }
      }
      q.push(vec);
      num.push(r);
      tgl.push(fla);
    }
    cout << r << endl;
  }
}


Measured memory_bytes: 3056
#include <vector>
#include<stdio.h>
#include<string.h>
#include <cstring>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <set>
#include<cstring>
#define ll long long
#define MODD 1000000007
#define  pii  pair<int,int>
#include<stdio.h>
#include<queue>
//#include<bits/stdc++.h>
using namespace std;
struct node {
    int x , y;
    int kk;
}p[100000];
int cmp(node a ,node b){
    if(a.y==b.y)return a.x<b.x;
    return a.y<b.y;
}
int main(){
   int n , m;cin >>n>>m;
   int mi = 9999;
   for(int i=0;i<m;i++){
        int a, b;cin >>a>>b;
        p[i].x = a;
        p[i].y = b;
        mi = min(mi,b);
   }
   sort(p,p+m,cmp);

   int sum =1;
   for(int i=1;i<m;i++){
        if(mi<=p[i].x){
            sum++;
            mi = p[i].y;
        }

   }
   cout<<sum<<endl;
    return 0;
}
/*
5 300
4 200
4 100
3 156
3 44
2 100
*/


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int N;
  cin >> N;
  Vl table(100010);
  for (int i = 1; i < 100; i++) {
    for (int j = 1; j < 100; j++) {
      for (int k = 1; k < 100; k++) {
        ll x = (i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (i * k);
        table.at(x)++;
      }
    }
  }

  for (int i = 1; i <= N;i++){
    cout << table.at(i) << endl;
  } }

Measured memory_bytes: 3984
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;
 
const string YES = "Yes";
const string NO = "No";
 
signed main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    while(1){
        C-=B;
        if(C<=0){
            cout<<"Yes"<<endl;
            break;
        }
        A-=D;
        if(A<=0){
            cout<<"No"<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3804
#include <stdio.h>

int main(void){

  int n,k;
  scanf("%d\n%d", &n, &k);
  int x[n];
	for (int i = 0; i < n; i++) {
		scanf("%d", &x[i]);
	}
	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += x[i];
		if (k-x[i] < x[i]) {
			sum += k-x[i]*2;
		}
	}
	printf("%d\n", sum*2);

  return 0;
}

Measured memory_bytes: 128
n = int(input())

a = [int(input()) for _ in range(n)]

pushed = []

button = 0
count = 0
flag = False

while count < n + 1:
	if button == (2 - 1):
		flag = True
		break
	
	pushed.append(button)
	button = a[button] -1
	count += 1
	
if flag:
	print(count)
else:
	print(-1)

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

int main(){
  long n,cnt=0;
  cin >> n;
  map<long,int> v;
  for(long i=2;i*i<=n;i++) {
    while(n%i==0) {
      v[i]++;
      n /= i;
    }
  }
  if(n!=1) v[n] = 1;
  for(auto i:v){
    int k=1,d = i.second;
    while(0<=d-k){
      d-= k;
      k++;
    }
    cnt += k-1;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {


	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		String relation;

		if(a < b) {
			relation = "<";
		}
		else if(a > b) {
			relation = ">";
		}
		else {
			relation = "==";
		}
		System.out.printf("a %s b\n", relation);
	}
}





Measured memory_bytes: 26136
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n';
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
LL inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
int main()
{
LL a,b;
while(cin>>a>>b){



    LL ans=0;
    set<LL>num;
    for(int i=1;i<=sqrt(b);i++){
        if(b%i==0){
            num.insert(i);
            num.insert(b/i);
        }
    }
    for(set<LL>::iterator i=num.begin();i!=num.end();i++){
        if(*i *a<=b){
            ans=*i;
        }
    }
    cout<<ans<<endl;



}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

struct UnionFind {
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)
 
    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
 
    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }
 
    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }
 
    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }
 
    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    int N,M; cin >> N >> M;
    veci p(N);
    REP(i,N) {
        cin >> p[i];
        p[i]--;
    }
    UnionFind UF(N); UF.init(N);
    REP(i,M) {
        int x,y; cin >> x >> y; --x; --y;
        UF.merge(x, y);
    }
    int ans = 0;
    REP(i, N) {
        if(UF.issame(p[i],i))
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2176