akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

int main() {
    int a, p;
    cin >> a >> p;

    p += a * 3;

    cout << p / 2 << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <queue>
#define inf 100000000

using namespace std;

int w, h;
char c[25][25];

int N;
int X[15], Y[15];
int dist[15][15];

int d[25][25];

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

void bfs(int sx, int sy)
{
	for(int x = 0; x < w; x++){
		for(int y = 0; y < h; y++){
			d[x][y] = inf;
		}
	}
	queue<int> Q;
	Q.push(sx * 1000 + sy);
	d[sx][sy] = 0;
	
	int x, y, nx, ny;
	while(Q.size()){
		x = Q.front() / 1000;
		y = Q.front() % 1000;
		Q.pop();
		
		for(int dir = 0; dir < 4; dir++){
			nx = x + dx[dir];
			ny = y + dy[dir];
			if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
			if(d[nx][ny] < inf) continue;
			if(c[nx][ny] == 'x') continue;
			Q.push(nx * 1000 + ny);
			d[nx][ny] = d[x][y] + 1;
		}
	}
}


int main(void)
{
	while(1){
		cin >> w >> h;
		if(w == 0 && h == 0) break;
		
		N = 0;
		for(int y = 0; y < h; y++){
			for(int x = 0; x < w; x++){
				cin >> c[x][y];
				if(c[x][y] == 'o') X[0] = x, Y[0] = y;
				if(c[x][y] == '*') X[N+1] = x, Y[N+1] = y, N++;
			}
		}
		
		for(int i = 0; i <= N; i++){
			bfs(X[i], Y[i]);
			for(int j = 0; j <= N; j++){
				dist[i][j] = d[X[j]][Y[j]];
			}
		}
		
		int perm[10], sum, ans = inf;
		for(int i = 0; i < N; i++) perm[i] = i+1;
		
		do{
			sum = dist[0][perm[0]];
			
			for(int i = 0; i < N-1; i++){
				sum += dist[perm[i]][perm[i+1]];
			}
			ans = min(ans, sum);
			
		}while(next_permutation(perm, perm+N));
		
		if(ans >= inf) ans = -1;
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3024
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <functional>

using namespace std;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,int> pli;
const lli inf=1e16,mod=1e9+7;

struct edge{
	int t,c,rev;
	lli w;
	edge() {}
	edge(int t,lli w)
	:t(t),c(0),rev(-1),w(w) {}
};

int n,m,s,t;
vector<edge> adj[100001];
lli dist[100001];
int vis[100001];

void dijk(int s,int t) {
	fill(dist,dist+n+1,inf);
	priority_queue<pli,vector<pli>,greater<pli>> que;
	que.push(pli(0,s));
	dist[s]=0;
	while(!que.empty()) {
		lli cost=que.top().first;
		int cur=que.top().second;
		que.pop();
		if(vis[cur]) continue;
		vis[cur]=1;
		for(auto &it:adj[cur]) {
			if(!vis[it.t] && dist[it.t] > cost+it.w) {
				dist[it.t]=cost+it.w;
				que.push(pli(dist[it.t],it.t));
			}
		}
	}
}

lli sc[100001],tc[100001];
int color[100001];
void getsc() {
	fill(vis,vis+n+1,0);
	priority_queue<pli,vector<pli>,greater<pli>> que;
	que.push(pli(0,s));
	vis[s]=1;
	sc[s]=1;
	
	while(!que.empty()) {
		lli cost=que.top().first;
		int cur=que.top().second;
		que.pop();
		color[cur]++;
		for(auto &it:adj[cur]) {
			if(dist[it.t]==cost+it.w) {
				it.c++;
				adj[it.t][it.rev].c++;
				sc[it.t]=(sc[it.t]+sc[cur])%mod;
				if(!vis[it.t]) {
					vis[it.t]=1;
					que.push(pli(cost+it.w,it.t));
				}
			}
		}
	}
}
void gettc() {
	fill(vis,vis+n+1,0);
	priority_queue<pli> que;
	que.push(pli(dist[t],t));
	tc[t]=1;
	vis[t]=1;
	
	while(!que.empty()) {
		lli cost=que.top().first;
		int cur=que.top().second;
		que.pop();
		color[cur]++;
		
		for(auto &it:adj[cur]) {
			if(dist[it.t]==cost-it.w) {
				it.c++;
				adj[it.t][it.rev].c++;
				tc[it.t]=(tc[it.t]+tc[cur])%mod;
				if(!vis[it.t]) {
					vis[it.t]=1;
					que.push(pli(cost-it.w,it.t));
				}
			}
		}
	}
}
lli find() {
	lli res=0;
	for(int i=1;i<=n;i++) {
		if(color[i]==2 && dist[i] <= dist[t]/2) {
			if(dist[t]%2==0 && dist[i]==dist[t]/2) {
				res = (res + sc[i]*tc[i]%mod*sc[i]%mod*tc[i]%mod)%mod;
			}
			else {
				for(auto &it:adj[i]) {
					if(color[it.t]==2 && it.c && dist[it.t] >= dist[t]/2+1) {
						res = (res + sc[i]*tc[it.t]%mod*sc[i]%mod*tc[it.t]%mod)%mod;
					}
				}
			}
		}
	}
	return res;
}

int main() {
	scanf("%d%d",&n,&m);
	scanf("%d%d",&s,&t);
	for(int i=0;i<m;i++) {
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		adj[a].push_back(edge(b,c));
		adj[b].push_back(edge(a,c));
		adj[a].back().rev=adj[b].size()-1;
		adj[b].back().rev=adj[a].size()-1;
	}

	dijk(s,t);
	getsc();
	gettc();
	
	lli ans=sc[t]*sc[t]%mod;
	ans = (ans-find())%mod;
	ans= (ans+mod)%mod;
	printf("%lld\n",ans);
	
	return 0;
}


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

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

	vector<pair<int,int>> pa;
	for (int i = 0; i < n; i++) {
		int tmp; cin >> tmp;
		pa.push_back({ tmp,i + 1 });
	}	

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

	for (int i = 0; i < n; i++) {
		cout << pa[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 1780
#include<cstdio>
#include<algorithm>
using namespace std;

int n;
long long x,y,t,a,tmp;

long long ce(long long p,long long q) {
	return (p+q-1)/q;
}
int main() {
	scanf("%d",&n);
	scanf("%lld %lld",&x,&y);
	for(int i=2;i<=n;++i) {
		scanf("%lld %lld",&t,&a);
		tmp=max(ce(x,t),ce(y,a));
		x=t*tmp,y=a*tmp;
	}
	printf("%lld\n",x+y);
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b,a);
  } else if (b==0) {
    return a;
  } else {
    return gcd(b,a%b);
  }
}
int main() {
  ll a,b;
  ll ans=1;
  cin >> a>>b;
  ll g=gcd(a,b);
  ll h=g;
  while(g%2==0){
    g/=2;
  }
  if (h>g) {
    ans++;
	h=g;
  }
  ll lim=g;
  for(ll i=3; i*i<=lim; i+=2) {
    while(g%i==0) {
      g /= i;
    }
    if (h>g) {
      ans++;
      h=g;
    }
  }
  if (h!=1) {
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N, K = LI()
    if K == 1: print(0)
    else: print(N-K)

main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    string s;
    int n;
    cin >> n >> s;
    rep(i, s.size())
    {
        s[i] = (s[i] - 'A' + n) % ('Z' - 'A' + 1) + 'A';
    }
    cout << s << endl;
    return 0;
}


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

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

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

int main(void)
{
	char s[100+2];
	while(scanf("%100[a-z]\n", s)==1)
	{
		for(int i=0;s[i];i++) s[i]='x';
		printf("%s\n", s);
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cstdlib>
 
using namespace std;
 
#define PI 3.14159265359

int main(){
    int R;
    cin >> R;
    double res = (double)(R + R ) * (double)PI;
    cout << res << endl;
 
    return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
int jl[11];
int main(){
	int a,b,c,d,e,k;
	cin>>a>>b>>c>>d>>e>>k;
	jl[1]=b-a;
	jl[2]=c-a;
	jl[3]=d-a;
	jl[4]=e-a;
	jl[5]=c-b;
	jl[6]=d-b;
	jl[7]=e-b;
	jl[8]=d-c;
	jl[9]=e-c;
	jl[10]=e-d;
	bool ans=true;
	for(int i=1;i<=10;i++){
		if(jl[i]>k) ans=false;
	}
	if(ans==true) cout<<"Yay!";
	else cout<<":(";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
long long countmatrix[1001][1001];
int h,w;
#define M  1000000007
long long countways(vector<vector<char> >&matrix, int i, int j)
{
   if (i == h-1 && j == w-1)
     return 1;
   if (i >= h || j >= w)
     return 0;
   if(matrix[i][j] == '#')
     return 0;
   if(countmatrix[i][j] != -1)
     return  countmatrix[i][j];

   countmatrix[i][j] = (countways(matrix, i+1, j)%M + countways(matrix, i, j+1)%M)%M;
   return countmatrix[i][j];
}
int main()
{
    scanf("%d %d", &h, &w);
    vector<vector<char> > matrix(h);
    for(auto &x: matrix)
      x = vector<char> (w);
    for(auto&x: matrix)
      for(auto&y: x)
        cin >> y;
    
    for(int i = 0;i<1001;++i)
      for (int j = 0;j < 1001;++j)
        countmatrix[i][j] = -1;
    cout << countways(matrix, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 9216
n=int(input())
t=list(map(int,input().split()))
a=0
b=0
c=0
for i in range(n):
    if t[i]%4==0:#4の倍数
        a+=1
    elif t[i]%2==0 and t[i]%4!=0:#2の倍数かつ4の倍数でない
        b+=1
    else:
        c+=1
if b==0:
    if c<=a+1:
        print("Yes")
    else:
        print("No")
elif b!=0:
    if c<=a:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 14252
/*二分木*/
#include <stdio.h>
#define N 25

typedef struct node{
  int No;
  int depth;
  int height;
  int nchild;
  int sibling;
  int parent;
  struct node *left;
  struct node *right;
} Node;


void depth(Node *);
void height(Node *, Node *);

void depth(Node *temp){
  if(temp->left !=NULL && temp->right == NULL){
    temp->left->depth = temp->depth + 1;
    depth(temp->left);
  }
  else if(temp->right !=NULL &&  temp->left == NULL){
    temp->right->depth = temp->depth + 1;
    depth(temp->right);
  }
  else if(temp->left !=NULL && temp->right != NULL){
    temp->left->depth = temp->depth + 1;
    temp->right->depth = temp->depth + 1;
    depth(temp->left);
    depth(temp->right);
  }
}

void height(Node *a, Node *temp){
  if(a[temp->parent].height <= temp->height+1){
    a[temp->parent].height = temp->height+1;
  }
  if (temp->parent != -1){
    temp = &a[temp->parent];
    height(a,temp);
  }
  else return;
  
}


int main(){
  Node a[N];
  int i, j, n, l, r, num;

  scanf("%d", &n);

  for (i=0; i<n; i++){
    a[i].No = i;
    a[i].parent = -1;
    a[i].sibling = -1;
    a[i].depth = -2;
    a[i].height = -1;
  }

  /*以下のループによりsibling, degreeを決定*/
  for (i=0; i<n; i++){
    scanf("%d%d%d", &num, &l, &r);
    
    if(l != -1 && r != -1){
      a[num].nchild = 2;
      a[num].left = &a[l];
      a[num].right = &a[r];
      a[l].sibling = r;
      a[r].sibling = l;
      a[l].parent = a[num].No;
      a[r].parent = a[num].No;
    }
    
    else if (l != -1 && r == -1){
      a[num].nchild = 1;
      a[num].left = &a[l];
      a[num].right = NULL;
      a[l].sibling = -1;
      a[l].parent = a[num].No;
    }
    
    else if (l == -1 && r != -1){
      a[num].nchild = 1;
      a[num].right = &a[r];
      a[num].left = NULL;
      a[r].sibling = -1;
      a[r].parent = a[num].No;
    }
    
    else if (l == -1 && r == -1){
      a[num].nchild = 0;
      a[num].left = NULL;
      a[num].right = NULL;
      a[num].height = 0;
    }
  }

  /*rootのdepthを決定するループ*/
  for (i=0; i<n; i++){
    if(a[i].parent == -1){
      a[i].depth = 0;
      break;
    }
  }
  depth(&a[i]);/*depthを決定する関数*/

  /*heightを決定するループ*/
  for (i=0; i<n; i++){
    if (a[i].left == NULL && a[i].right == NULL){
      height(a, &a[i]);/*heightを決定する関数*/
    }
  }
  
  for (i=0; i<n; i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", a[i].No, a[i].parent, a[i].sibling, a[i].nchild, a[i].depth, a[i].height);
    if (a[i].parent == -1) printf("root\n");
    else if (a[i].height == 0) printf("leaf\n");
    else printf("internal node\n");
  }
  

  return 0;
}




Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<int> v;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }

  v[0]--;
  REP(i,1,N){
    if(v[i-1]<=v[i]-1){
      v[i]--;
    }
    else if(v[i-1]<=v[i]){
      ;
    }
    else{
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
    
  return 0;
}


Measured memory_bytes: 892
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 55;

int n, m, A, B, C, D, E, F, x = 1, y = 1;

int main() {
#ifdef LOCAL_DEBUG
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
#endif
  scanf("%d%d%d%d%d%d", &A, &B, &C, &D, &E, &F);
  for (int i = 0; i <= F / (100 * A); ++i) {
    int a = i * 100 * A;
    if (a > F)
      break;
    for (int j = 0; j <= F / (100 * B); ++j) {
      int b = j * 100 * B;
      if (a + b > F)
        break;
      for (int k = 0; k < F / C; ++k) {
        int c = k * C;
        if (a + b + c > F)
          break;
        for (int l = 0; l < F / D; ++l) {
          int d = l * D;
          if ((a + b + c + d > F) || (c + d) > (a + b) / 100 * E)
            break;
          int tz = (c + d), tm = (a + b);
          if (x * (tm + tz) <= tz * (y + x)) {
            x = tz, y = tm;
          }
        }
      }
    }
  }
  printf("%d %d\n", x + y, x);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
  {
   int n,temp,r,sum=0;
   cin>>n;
   temp = n;
   while(temp!=0)
   {
     r = temp%10;
     sum=sum+r;
     temp=temp/10;
     
   }
   
   if(n%sum==0)
   cout<<"Yes"<<endl;
   else
   cout<<"No"<<endl;
  } 

Measured memory_bytes: 3628
#include <iostream>

int x[100];

int main(){
    int n;
    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        std::cin >> x[i];
    }
    int min = 10000000;
    for (int i = 1; i <= 100; ++i) {
        int sum = 0;
        for (int j = 0; j < n; ++j) {
            sum += (i-x[j])*(i-x[j]);
        }
        min = std::min(min,sum);
    }
    std::cout << min;
}

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

int gce(int a, int b){
  int x, y, reminder;
  x = a >= b ? a : b;
  y = a >= b ? b : a;
  reminder = x % y;
  if(reminder == 0){
    return y;
  }
  else return gce(y, reminder);
}

int main(){
  int a, b, res;
  cin >> a >> b;

  res = gce(a, b);
  cout << res << endl;
}

Measured memory_bytes: 3092
#include <stdio.h>
#include <string.h>
//char s[200],t[200],s1[200],d,s2[200];
int main(){
	int n,i=0,a;
	scanf("%d",&n);
	while(n--){
	scanf("%d",&a);
	i+=a-1;
	}
	printf("%d",i);
    	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define ll long long
#define pp pair<ll,ll>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
ll max(ll x, ll y)
{
    return x>y ? x : y;
}
ll min(ll x, ll y)
{
    return x<y ? x : y;
}
void _(ll&a , ll b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll n,x,y;
vector<ll> a[2010];bool vis[2010];ll d[2010];
ll ans[2010];
void bfs(ll s)
{
	memset(vis, 0, sizeof(vis));vis[s]=1;
	memset(d, -1, sizeof(d));
	d[s]=0;
	queue<ll> q;q.push(s);
	while(!q.empty())
	{
		ll u=q.front();q.pop();
		for(auto i : a[u])
		{
			if(!vis[i])
			{
				d[i]=d[u]+1;vis[i]=1;q.push(i);ans[d[i]]++;
			}
		}
	}
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> x >> y;x--;y--;
    for (int i = 0; i < n-1; ++i)
    {
    	a[i].push_back(i+1);a[i+1].push_back(i);
    }
    a[x].push_back(y);a[y].push_back(x);
    for (int i = 0; i < n; ++i)
    {
    	bfs(i);
    }
    for(ll i=1;i<n;i++)cout << ans[i]/2 << "\n";
    }

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    int c=0;    // c=1 1 vertical c=2 2 horizontal

    string s1,s2;
    cin>>s1>>s2;

    ll ans=1;
    int i=0;
    if(s1[0]==s2[0]){
        ans*=3;
        c=1;
        i=1;
    }
    else{
        ans*=6;
        c=2;
        i=2;
    }
    for(i;i<n;){
        if(c==1){
            if(s1[i]==s2[i]){
                ans*=2;
                c=1;
                i+=1;
            }
            else if(s1[i]!=s2[i]){
                ans*=2;
                c=2;
                i+=2;
            }
        }
        else if(c==2){
            if(s1[i]==s2[i]){
                c=1;
                i+=1;
            }
            else{
                ans*=3;
                c=2;
                i+=2;
            }
        }
        if(ans>mod)
            ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
Sa = list(input())
Sb = list(input())
Sc = list(input())
card = Sa.pop(0)
while True:
    if card == 'a':
        S = Sa
    if card == 'b':
        S = Sb
    if card == 'c':
        S = Sc
    try:
        card = S.pop(0)
    except:
        print(card.upper())
        break

Measured memory_bytes: 8972
#include <algorithm>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cmath>
using namespace std;

class Solution {
public:
    long long n, a, b;
    vector<long long> h;

    bool enough(long long t)
    {
        long long sum = 0;
        for (int i = 0; i < n; i++)
        {
            if (h[i] > b * t)
            {
                sum += (long long)ceil((h[i] - b * t) / (double)(a - b));
            }
        }
        if (sum <= t)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    void solve(std::istream& in, std::ostream& out) {
        in >> n >> a >> b;
        for (int i = 0; i < n; i++)
        {
            long long tmp;
            in >> tmp;
            h.push_back(tmp);
        }

        long long l, c, r;
        l = 1;
        r = 1000000000;
        while (l < r)
        {
            c = (l + r) / 2;
            if (enough(c))
            {
                r = c;
            }
            else
            {
                l = c + 1;
            }
        }

        c = (l + r) / 2;

        out << c;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll X; cin >> X;
    for (ll A = -200; A < 200; A++) {
        for (ll B = -200; B < 200; B++) {
            ll AA = A*A, BB = B*B;
            if (AA*AA*A - BB*BB*B == X) {
                cout << A << " " << B << endl;
                return 0;
            }
        }
    }       
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

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

int n;
cin>>n;

while(n>0)
{
    int res=n%10;
    n=n/10;
    if(res==7){
        cout<<"Yes"<<endl;
        return 0;
        }
}
cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 3644
using System;

namespace _4_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var a = ab[0];
            var b = ab[1];
            var d = a / b;
            var m = a % b;
            double f = (double)a / (double)b;
            Console.WriteLine("{0} {1} {2}", d, m, String.Format("{0:F8}", f));
        }
    }
}



Measured memory_bytes: 17952
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl a(n);
	bool zero=false;
	rep(i,n){
		cin>>a[i];
		if(a[i]==0)zero=true;
	}
	if(zero){
		puta(0);
	}
	else{
		ll ans=1;
		rep(i,n){
			if(a[i]>1000000000000000000/ans){
				puta(-1);
				return 0;
			}
			ans*=a[i];
		}
		puta(ans);
	}
}


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

vi a;
int n;

void solve(ll x) {
    int right = 0;
    ll sum = 0;
    ll ans = 0;
    for (int left = 0; left < n; ++left) {
        while (right < n && sum + a[right] <= x) {
            sum += a[right++];
        }
        ans += right - left;
        sum -= a[left];
    }
    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int q;
    cin >> n >> q;
    a.resize(n);
    rep(i, n) cin >> a[i];
    rep(i, q) {
        ll x;
        cin >> x;
        solve(x);
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int64_t> L(87, 0);
  L[0] = 2;
  L[1] = 1;
  for (int i = 2; i <= N; i++) L[i] = L[i - 1] + L[i - 2];
  cout << L[N] << endl;
}


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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

const int mod = 1e9 + 7;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> pos, neg;
  rep(i, n) {
    cin >> a[i];
    if (a[i] < 0)
      neg.push_back(a[i]);
    else
      pos.push_back(a[i]);
  }

  int P = pos.size(), N = neg.size();
  bool ok = false;
  if (P > 0) {
    if (n == k)
      ok = (N % 2 == 0);
    else
      ok = true;
  } else {
    ok = (k % 2 == 0);
  }

  ll ans = 1;
  if (!ok) {
    sort(a.begin(), a.end(), [](int x, int y) { return abs(x) < abs(y); });
    rep(i, k) {
      ans = ans * a[i] % mod;
      ans = (ans + mod) % mod;
    }
  } else {
    sort(pos.begin(), pos.end());
    sort(neg.rbegin(), neg.rend());

    if (k % 2 == 1) {
      ans = ans * pos.back() % mod;
      pos.pop_back();
    }

    vector<ll> p;
    while (pos.size() >= 2) {
      ll x = pos.back();
      pos.pop_back();
      x *= pos.back();
      pos.pop_back();
      p.push_back(x);
    }
    while (neg.size() >= 2) {
      ll x = neg.back();
      neg.pop_back();
      x *= neg.back();
      neg.pop_back();
      p.push_back(x);
    }
    sort(p.rbegin(), p.rend());
    rep(i, k / 2) {
      ans = ans * (p[i] % mod) % mod;
      ans = (ans + mod) % mod;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6340
#include<iostream>
using namespace std;
#include<vector>
#include<functional>
template<typename T>
struct dualsegtree{
	function<T(T,T)>lazycalcfn,updatefn;
	int n;
	T lazydefvalue;
	vector<T>dat,lazy;
	vector<bool>lazyflag;
	dualsegtree(int n_=0,T defvalue=0,
		function<T(T,T)>lazycalcfn_=[](T a,T b){return a+b;},
		function<T(T,T)>updatefn_=[](T a,T b){return a+b;},
		T lazydefvalue_=0
	):lazydefvalue(lazydefvalue_),
		lazycalcfn(lazycalcfn_),updatefn(updatefn_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(n,defvalue);
		lazy.assign(n-1,lazydefvalue);
		lazyflag.assign(n-1,false);
	}
	void copy(const vector<T>&v)
	{
		for(int i=0;i<v.size();i++)dat[i]=v[i];
		lazy.assign(n-1,lazydefvalue);
		lazyflag.assign(n-1,false);
	}
	void update(int a,int b,T x,int k=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		if(b<=l||r<=a)return;
		else if(a<=l&&r<=b)
		{
			if(k<n-1)
			{
				lazy[k]=lazycalcfn(lazy[k],x);
				lazyflag[k]=true;
			}
			else dat[k-n+1]=updatefn(dat[k-n+1],x);
		}
		else
		{
			if(lazyflag[k])
			{
				update(0,n,lazy[k],k*2+1,l,(l+r)/2);
				update(0,n,lazy[k],k*2+2,(l+r)/2,r);
				lazy[k]=lazydefvalue;
				lazyflag[k]=false;
			}
			update(a,b,x,k*2+1,l,(l+r)/2);
			update(a,b,x,k*2+2,(l+r)/2,r);
		}
	}
	T query(int i)
	{
		T ret=dat[i];
		i+=n-1;
		while(i>0)
		{
			i=(i-1)/2;
			if(lazyflag[i])ret=updatefn(ret,lazy[i]);
		}
		return ret;
	}
};
main()
{
	int N,T;
	cin>>N>>T;
	dualsegtree<int>P(T);
	for(int i=0;i<N;i++)
	{
		int l,r;cin>>l>>r;
		P.update(l,r,1);
	}
	int ans=0;
	for(int i=0;i<T;i++)
	{
		int now=P.query(i);
		if(ans<now)ans=now;
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 3884
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define mod 10000007
typedef unsigned long long ull;
int main()
{
    ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    int n;
    string s;
   map<string,int> status={{"AC",0},{"WA",0},{"TLE",0},{"RE",0}};
   cin>>n;
   for (int i = 0; i < n; i++)
   { 
       cin>>s;
       status[s]++;
       
   }
       cout << "AC" << " x " << status["AC"] << '\n';
       cout << "WA" << " x " << status["WA"] << '\n';
       cout << "TLE" << " x " << status["TLE"] << '\n';
       cout << "RE" << " x " << status["RE"]<<'\n';
   
   
    return 0;

}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;



int main(){
    int N,X;
    cin >> N >> X;
    vector<int> m;
    for(int i=0;i<N;i++){
        int t;
        cin >> t;
        m.pb(t);
    }
    cout << (X-accumulate(ALL(m),0)) / *min_element(ALL(m))+N << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 #define SPEED ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(0)
int main() 
{
	SPEED; 
	int n,m,count=0;
    cin>>n>>m;
    while(n>0){
      n=n-m;
      count++;
    }
  cout<<count;
    
    
     
     return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 100020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

struct node2{
	ll d; int id;
	bool operator < (node2 a)const{
		return d < a.d;
	}
}dt[maxn];
ll d[maxn],f[maxn];
struct node{
	int next,to;
}e[maxn * 2];
int head[maxn],cnt;
int n,fa[maxn],sz[maxn],dth[maxn];

inline void adde(int x,int y){
	e[++cnt].to = y;
	e[cnt].next = head[x];
	head[x] = cnt;
}	
void dfs(int x){
	fore(i,x){
		dth[e[i].to] = dth[x] + 1;
		dfs(e[i].to);
	}
}
bool check(){
	dfs(1);
	rep(i,1,n) f[1] += dth[i];
	if ( f[1] != d[1] ) return 0;
	rep(i,2,n){
		f[i] = f[fa[i]] + n - sz[i] * 2;
		if ( f[i] != d[i] ) return 0;
	}
	return 1;
}
bool solve(){
	rep(i,1,n) d[i] = dt[i].d;
	repd(i,n,2){
		sz[i]++;
		ll curd = d[i] - n + 2 * sz[i];
		int id = lower_bound(d + 1,d + n + 1,curd) - d;
		if ( d[id] != curd || id >= i ) return 0;
		fa[i] = id , sz[id] += sz[i];
	}
	rep(i,2,n) adde(fa[i],i);
	return check();
}
int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%lld",&dt[i].d) , dt[i].id = i;
	sort(dt + 1,dt + n + 1);
	if ( solve() ){
		rep(i,2,n) printf("%d %d\n",dt[fa[i]].id,dt[i].id);
	}
	else{
		printf("-1\n");
	}
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
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;
}
int main() {
    ll N, C, K;
    cin >> N >> C >> K;
    vector<ll> passengersTime(N);
    for (ll i = 0; i < N; ++i) {
        cin >> passengersTime[i];
    }

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

    ll busNum       = 1;
    ll busLeaveTime = 1 + K;
    for (ll i = 0; i < N;) {
        ll indexNext = i;
        for (ll j = 0; j < C; ++j) {
            if (i + j >= N) break;
            if (passengersTime[i + j] <= busLeaveTime) {
                indexNext = i + j;
            }
        }
#ifdef SOURCE_TEST
        cout << "busLeaveTime:" << busLeaveTime << endl;
        for (ll j = i; j <= indexNext && j < N; ++j) {
            cout << passengersTime[j] << " ";
        }
        cout << endl;
#endif
        i = indexNext + 1;
        if (i < N) {
            busNum++;
            busLeaveTime = passengersTime[i] + K;
        }
    }

    cout << busNum << endl;

    return 0;
}

Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll a,b,n;
	cin>>a>>b>>n;
	ll x=min(n,b-1);
	cout<<(a*x)/b-a*(x/b)<<endl;
}

Measured memory_bytes: 3612
import java.util.Scanner;
import java.lang.Math;

public class Main{
  public static void main(String[] args){
  	Scanner stdn = new Scanner(System.in);
	int x = 0;
  	double y = 0.0;
 		x = stdn.nextInt();
	  	if(x > 0 && x < 101){
	  		y = Math.pow((double)x,3d);
	  		x = (int)y;
	  	}
	    System.out.println(x);
  }
}

Measured memory_bytes: 26376
import collections


class UnionFind():
    def __init__(self, N):
        self.rank = [0] * N
        self.par = [i for i in range(N)]

    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.rank[x] > self.rank[y]:
            self.par[y] = x
        else:
            self.par[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def same(self, x, y):
        return self.root(x) == self.root(y)


N, K, L = map(int, input().split())
graph_road = UnionFind(N)
graph_train = UnionFind(N)
for k in range(K):
    p, q = map(int, input().split())
    graph_road.unite(p-1, q-1)

for l in range(L):
    r, s = map(int, input().split())
    graph_train.unite(r-1, s-1)

pair = collections.defaultdict(int)
for i in range(N):
    road = graph_road.root(i)
    train = graph_train.root(i)
    pair[(road, train)] += 1

for i in range(N):
    road = graph_road.root(i)
    train = graph_train.root(i)
    print(pair[(road, train)])

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

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

  rep(i, n) rep(j, n) {
    if (i * 4 + j * 7 == n) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
}


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

int main() {
	
	int n;
	cin >> n;
	vector<int> a(n+1);
	rep(i, n){
		cin >> a[i];
	}
	a[n] = 1001001001;
	sort(all(a));
	int cnt = 1, ans = 0;
	for(int i=0; i<n; i++){
		if(a[i] != a[i+1]){
			if(a[i] < cnt) ans += cnt - a[i];
			else if(a[i] > cnt) ans += cnt;
			// cout << cnt << endl;
			cnt = 1;
		}else{
			cnt++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cctype>
#include<cstring>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string s;
	cin>>s;
	vector<string> spot;
	vector<int> parent;
	vector<int> root;
	while(s.size()){
		root.push_back(0);
		parent.push_back(0);
		if(s[0]=='e'){
			spot.push_back(s.substr(0,3));
			s=s.substr(3,s.size()-3);
		}else if(s[0]=='c'){
			spot.push_back(s.substr(0,7));
			s=s.substr(7,s.size()-7);
		}
	}
	parent[spot.size()-1]=spot.size()-1;
	root[spot.size()-1]=0;
	int cnt=0;
	for(int i=spot.size()-1;i>0;i--){
		if(spot[i]==spot[i-1]){
			parent[i-1]=i-1;
			cnt=0;
			root[i-1]=cnt;
		}else{
			parent[i-1]=i;
			cnt++;
			root[i-1]=cnt;
		}
	}
	vector<int> re(spot.size());
	int r=0;
	rep(i,spot.size()){
		if(i!=0 && root[i-1]==0)r=0;
		re[i]=r;
		r++;
	}
	int maxnum=-1;
	string ans;
	rep(i,spot.size()){
		if(maxnum<re[i]){
			ans=spot[i];
			maxnum=re[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

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

int main() {
  long long int k;cin>>k;long long int a,b,c,sum=0;
  
  
  for(int l=1;l<k+1;l++){a=l;
    for(int m=1;m<k+1;m++){b=m;
      for(int n=1;n<k+1;n++){c=n;
        
  for (int i = 1; i < 3; i++) {
    if(i==1){a=l;b=m;}   
    else b=c;
    a = gcd(a, b);
  }
  sum+=a;
                          }
                    }
                      }
  cout<<sum;
  return 0;
}




Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>

typedef long long ll;

using namespace std;
int c[1000000];

int main() {
	ll div =1000000000 + 7;
	ll ans = 1;
	int n;
	scanf("%d", &n);
	int a;
	int s = n % 2;
	if (s == 0) {
		for (int i = 0; i < n; i++) {
			cin >> a;
			if(a % 2 == 0) {
				printf("0\n");
				return 0;				
			}
			c[a]++;
			if(c[a] > 2) {
				printf("0\n");
				return 0;
			}
		}
	} else {
		for (int i = 0; i < n; i++) {
			cin >> a;
			if(a % 2 == 1) {
				printf("0\n");
				return 0;				
			}
			c[a]++;
			if(c[a] > 2) {
				printf("0\n");
				return 0;
			} else if(c[0] > 1){
				printf("0\n");
				return 0;		
			} 
		}
	}
	

	for (int i = 0; i < n/2; i++ ) {
		ans *=2;
		ans %= div;
	}

	cout << ans << endl;
	
	
	return 0;
	
}

Measured memory_bytes: 888
n = int(input())
s = []
for i in range(n):
   s.append(input())
m = int(input())
t = []
for i in range(m):
   t.append(input())

score = [s.count(x) - t.count(x) for x in s]
smax = max(score)
if (smax < 0):
   print(0)
else:
   print(smax)


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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            if((str[0] + str[1]) % 3 == 0  || str[0] % 3 == 0 || str[1] % 3 == 0)
            {
                Console.WriteLine("Possible");
            }
            else
            {
                Console.WriteLine("Impossible");
            }

        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }

  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  ll tmp = 20000000000;
  for (ll i = 0; i < N; i++)
  {
    if (A.at(i) == tmp)
    {
      cout << "NO" << endl;
      return 0;
    }
    tmp = A.at(i);
  }

  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define Inf 100000000000ll
#define MAXN 100000
#define ll long long
using namespace std;

int main() {
    string S;
    cin>>S;
    
    
    
    ll answer = 0;
    int L = S.size();
    for(int mask = 0;mask<(1<<(L-1));mask++) {
        vector<string> all_strs;
        string prev = S.substr(0,1);
        for(int j=0;j<S.size()-1;j++) {
            if ((mask>>j)&1) {
                all_strs.push_back(prev);
                prev = S.substr(j+1,1);
            } else {
                prev.push_back(S[j+1]);
            }
        }
        
        all_strs.push_back(prev);
        
        ll curr_sum = 0;
        for(int j=0;j<all_strs.size();j++) {
            ll x = 0;
            for(int k=0;k<all_strs[j].size();k++)
                x=x*10+all_strs[j][k]-'0';
            curr_sum += x;
        }
        
        answer += curr_sum;
        
    }
    
    cout << answer  << endl;
}

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

using namespace std;



class Node{
//ノードはポインタでもっておこう
public:
  ///ノードの番号
  int num;
  //そのノードの親
  //rootの場合はnullptr
  Node* p=nullptr;
  //そのノードの子
  //葉でなければ少なくとも一つ持つ
  Node* l=nullptr;Node*r=nullptr;
  //rootもしくは片側のみノードでなければ持つ
  Node* s=nullptr;
  //そのノードの深さ(-1は未定義)
  //0で初期化
  int dep;
  int height;
};

//空の配列を先に用意しておく
void pre_calc(Node n,vector<int>& v){
  v.push_back(n.num);
  if(n.l!=nullptr){
    pre_calc(*(n.l),v);
  }
  if(n.r!=nullptr){
    pre_calc(*(n.r),v);
  }
}

void in_calc(Node n,vector<int>& v){
  if(n.l!=nullptr){
    in_calc(*(n.l),v);
  }
  v.push_back(n.num);
  if(n.r!=nullptr){
    in_calc(*(n.r),v);
  }
}


void pos_calc(Node n,vector<int>& v){
  if(n.l!=nullptr){
    pos_calc(*(n.l),v);
  }
  if(n.r!=nullptr){
    pos_calc(*(n.r),v);
  }
  v.push_back(n.num);
}




Node root_Node(vector<Node> vn){
  int lv=(int)(vn.size());
  for(int i=0;i<lv;i++){
    if(vn[i].p==nullptr){return vn[i];}
  }
}


int main(){
  int n;cin >> n;
  vector<Node> tree(n);
  for(int i=0;i<n;i++){
    int num,l,r;cin >> num >> l >> r;
    tree[num].num=num;
    //-1の場合の場合分け
    if(l!=-1){
      tree[num].l=&tree[l];
      tree[l].p=&tree[num];
    }
    if(r!=-1){
      tree[num].r=&tree[r];
      tree[r].p=&tree[num];
    }
    if(l!=-1 and r!=-1){
      tree[l].s=&tree[r];
      tree[r].s=&tree[l];
    }
  }
  vector<int> pre_vec;
  pre_calc(root_Node(tree),pre_vec);
  vector<int> in_vec;
  in_calc(root_Node(tree),in_vec);
  vector<int> pos_vec;
  pos_calc(root_Node(tree),pos_vec);

  cout << "Preorder" << endl;
  for(int i=0;i<n;i++){
    cout << " " << pre_vec[i];
  }
  cout << endl;

  cout << "Inorder" << endl;
  for(int i=0;i<n;i++){
    cout << " " << in_vec[i];
  }
  cout << endl;

  cout << "Postorder" << endl;
  for(int i=0;i<n;i++){
    cout << " " << pos_vec[i];
  }
  cout << endl;


}



Measured memory_bytes: 3148
#include <stdio.h>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
using namespace std;

const long long mod = 998244353 ;



int main()
{
    int a,b;scanf("%d%d",&a,&b);
    if (a<10 && b<10) printf("%d\n",a*b);
    else printf("-1\n");



}


Measured memory_bytes: 128
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    int N;
    cin >> N;

    vll Ap, An;
    rep(i, N)
    {
        ll a;
        cin >> a;

        if (a >= 0)
        {
            Ap.push_back(a);
        }
        else
        {
            An.push_back(a);
        }
    }

    sort(all(Ap), greater<ll>());
    sort(all(An));

    if (An.empty())
    {
        An.push_back(Ap.back());
        Ap.pop_back();
    }

    if (Ap.empty())
    {
        Ap.push_back(An.back());
        An.pop_back();
    }

    vector<pair<ll, ll>> v;
    ll ans = An[0];
    rep(i, Ap.size() - 1)
    {
        v.emplace_back(ans, Ap[i]);
        ans -= Ap[i];
    }

    v.emplace_back(Ap.back(), ans);
    ans = Ap.back() - ans;

    repl(i, 1, An.size())
    {
        v.emplace_back(ans, An[i]);
        ans -= An[i];
    }

    cout << ans << endl;
    for (auto x : v)
    {
        cout << x.first << " " << x.second << endl;
    }

    return 0;
}

Measured memory_bytes: 7188