akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;

int main(){
    int a,b,ans;
    cin >> a >> b;
    ans=a;
    if (b==1) {cout << 0 << endl;return 0;}
    if (a>=b) {cout << 1 << endl;return 0;}
    rep(i,1000000){
        ans+=a-1;
        if (ans>=b) {cout << i+2 << endl;return 0;}
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

int main(){
	int a=0,b=0;
	int ans=0;
	char op;

	

	while(1){
		cin >> a >> op >> b;
	if(op == '+'){
		ans = a + b;
		cout << ans << endl;
	}
	
	else if(op == '-'){
		ans = a - b;
		cout << ans << endl;
	}

	else if(op == '*'){
		ans = a * b;
		cout << ans << endl;
	}

	else if(op == '/'){
		ans = a / b;
		cout << ans << endl;
	}
	else{
		break;
	}
	}
	
	return 0;

}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	string s[20];
	while(cin>>s[5]){
		s[5]="00000"+s[5];
		for(int i=6;i<13;i++){
			cin>>s[i];
			s[i]="00000"+s[i];
		}
		for(int i=5;i<13;i++){
			for(int j=5;j<13;j++){
				if(s[i][j]=='1'){
					if(s[i+1][j+1]=='1'&&s[i+1][j]=='1'&&s[i][j+1]=='1'){cout<<'A'<<endl;goto L;}
					if(s[i+1][j]=='1'&&s[i+2][j]=='1'&&s[i+3][j]=='1'){cout<<'B'<<endl;goto L;}
					if(s[i][j+1]=='1'&&s[i][j+2]=='1'&&s[i][j+3]=='1'){cout<<'C'<<endl;goto L;}
					if(s[i+1][j]=='1'&&s[i+1][j-1]=='1'&&s[i+2][j-1]=='1'){cout<<'D'<<endl;goto L;}
					if(s[i+1][j+1]=='1'&&s[i][j+1]=='1'&&s[i+1][j+2]=='1'){cout<<'E'<<endl;goto L;}
					if(s[i+1][j]=='1'&&s[i+1][j+1]=='1'&&s[i+2][j+1]=='1'){cout<<'F'<<endl;goto L;}
					if(s[i+1][j]=='1'&&s[i+1][j-1]=='1'&&s[i][j+1]=='1'){cout<<'G'<<endl;goto L;}
				}
			}
		}L:;
	}
}

Measured memory_bytes: 3184
def readinput():
    a,b=map(int,input().split())
    return a,b

def main(a,b):
    for i in range(20000):
        if i*108//100 - i ==a and i*110//100 - i ==b:
            return i
    return -1

if __name__=='__main__':
    a,b=readinput()
    ans=main(a,b)
    print(ans)


Measured memory_bytes: 9144
n = gets.to_i
b = gets.split.map(&:to_i)

a = Array.new(n)
a.fill(10000000)

for i in 0...n-1
    a[i]   = [a[i], b[i]].min
    a[i+1] = [a[i+1], b[i]].min
end

puts a.inject(:+)

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

#define LL long long
int main()
{
    
    LL t = 1;
    //cin >> t;
    
    LL N , x;
    
    while(t--)
    {
        cin >> N;
        LL x = 1000;
        
        while(x < N)
        {
            x += 1000;
        }
        
        cout << abs(N - x);
    }
    
    return 0;
    
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	cout << s.front() << s.size()-2 << s.back() << endl;
	return 0;
}


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

int main() {
    int n,sum=0,mx=0;
    cin>>n;
    while (n--) {
        int a;
        cin>>a;
        sum+=a;
        mx=max(mx,a);
    }
    cout<<sum-mx/2<<endl;
    return 0;
}

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

int main(void)
{
	int x, y, s;
	while(cin >> x >> y >> s)
	{
		if(x == 0 && y == 0 && s == 0)
			break;

		int max = 0;
		int i, j,sum_x = 0, sum_y = 0;
		double to_x = 1 + x/100.0;
		double to_y = 1 + y/100.0;
		
		for (i = 1; i <= s-1; i++)
		{
			for(j = 1; j <= s-1; j++)
			{
				sum_x = (int)(i*to_x + 0.000001) + (int)(j*to_x + 0.000001);
				if(sum_x == s)
				{
					sum_y = (int)(i*to_y + 0.000001) + (int)(j*to_y + 0.000001);
					
					if(max <= sum_y)
						max = sum_y;
				}
			}
		}
		cout << max << endl;
	}

	return 0;
}


Measured memory_bytes: 3100
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
bool check(string s){
	rep(i,0,s.size()/2)if(s[i]!=s[s.size()-i-1])RE 0;
	RE 1;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	int n=s.size();
	string t,p;
	t=s.substr(0,(n-1)/2);
	p=s.substr((n+1)/2);
	if(check(s)&&check(t)&&check(p)){
		cout<<"Yes";
	}else cout<<"No";
	RE 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main () {
    long long int n,count=0;cin>>n;
  string s;cin>>s;
  for (long long int i=1;i<n;i++) {
      if (s[i]!=s[i-1]) {count++;}
  }
  cout<<count+1<<endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

  if(T[u].p == NIL) printf("root, ");
  else if(T[u].l == NIL /*&& T[u].r == NIL*/) printf("leaf, ");
  else printf("internal node, ");
  
  printf("[");
  for (i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
  
}

void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].l != NIL) calcDepth(T[u].l,p+1);
  if(T[u].r != NIL) calcDepth(T[u].r,p);
}

int main(){
  int i, j, k;
  int n;
  int id, sib, child;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;
  
  for(i=0; i<n; i++){
    scanf("%d %d", &id, &k);
    for(j = 0, sib = NIL; j<k; j++){ //子を入力する (input children)
      scanf("%d", &child);
      T[child].p = id;
      if(j == 0)T[id].l = child; //idの一番左の子 (the most left child of id)
      else T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)
      sib = child;//次の子供の左の兄弟 (the left sibling of the next child)
    }
  }

  //根を求める (find the root)
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }
  
  //それぞれのノードの深さを求める (find depth of each node)
  calcDepth(root, 0);

  //出力 (output)
  for(i=0; i<n; i++) print(i);
  
  return 0;
}



Measured memory_bytes: 3284
N = int(input())

c = [[0]*10 for i in range(10)]

for i in range(1,N+1):
    a = i % 10
    b = 0
    while i > 0:
        b = i
        i = i // 10
    c[a][b] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += c[i][j]*c[j][i]

print(ans)

Measured memory_bytes: 3064
homeNum = int(input())
coordinate = list(map(int, input().split()))

maxCoordinate, minCoordinate = 0, 1000
for i in range(homeNum):
  if maxCoordinate < coordinate[i]:
    maxCoordinate = coordinate[i]
  if minCoordinate > coordinate[i]:
    minCoordinate = coordinate[i]

ans = maxCoordinate - minCoordinate
print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#ifdef ONLINE_JUDGE
#define getchar gc
inline char gc(){
	static char buf[1<<16],*p1=buf,*p2=buf;
	if(p1==p2){
		p2=(p1=buf)+fread(buf,1,1<<16,stdin);
		if(p2==p1) return EOF;
	}
	return *p1++;
}
#endif
template<class t> inline t read(t &x){
    char c=getchar();bool f=0;x=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return x;
}
template<class t> inline void write(t x){
    if(x<0) putchar('-'),write(-x);
    else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int B=1000;
int p[B*2+5],x;

signed main(){
	for(int i=-B;i<=B;i++)
		p[i+B]=i*i*i*i*i;
	read(x);
	for(int i=-B;i<=B;i++)
		for(int j=-B;j<=B;j++) if(p[i+B]-p[j+B]==x){
			printf("%lld %lld",i,j);
			return 0;
		}
}

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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    vector<char> ans;
    ans.push_back(S[0]);
    for (int i = 0; i < N; i++) {
        if (ans[ans.size()-1] == S[i]) {
            continue;
        } else {
            ans.push_back(S[i]);
        }
    }
    cout << ans.size() << endl;

}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
 
int main(){
  int k;
  string s;
  cin >> k >> s;
  string ans;
  if(s.size() <= k ){
    ans = s;
  }
  else {
    ans = s.substr(0, k) + "...";
  }
  
  cout  << ans << endl;
 
  return 0;
}

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

int main() {
    int N;
    cin>>N;
    int a[N];
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    sort(a,a+N);
    int ans=1;
    for(int i=0;i<N-1;i++){
        if(a[i]!=a[i+1])
            ans++;
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
n, w = map(int, input().split())
wts = []

for i in range(n):
    wts.append(list(map(int, input().split())))
    
dp = [[0]*(w+1) for i in range(n)]
dp[0][wts[0][0]] = wts[0][1]

for i in range(1, n):
    for j in range(1+w):
        if j >= wts[i][0]:
            if dp[i-1][j-wts[i][0]] != 0:
                dp[i][j] = max(dp[i-1][j], wts[i][1]+dp[i-1][j-wts[i][0]])
            else:
                dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = dp[i-1][j]
            
    dp[i][wts[i][0]]= max(dp[i-1][wts[i][0]], wts[i][1])

print(max(dp[-1]))

Measured memory_bytes: 119148
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

//sは初めの点、vは頂点size、dは最短距離を求める(初期化はINF),Gは有向グラフ
void dijkdtra(int s,int v,vector<int>&d,whei(edge)&G) {
	priority_queue<Pint, vector<Pint>, greater<Pint>> que;//firstが距離、secondが頂点
	d[s] = 0;//スタートの距離はもちろんzero
	que.push(Pint(0, s));
	while (!que.empty()) {
		Pint p = que.top();
		que.pop();
		int V = p.second;
		if (d[V] < p.first)continue;
		for (int i = 0; i < G[V].size();i++) {
			edge e = G[V][i];
			if (d[e.to] > d[V] + e.cost) {
				d[e.to] = d[V] + e.cost;
				que.push(Pint(d[e.to], e.to));
			}
		}
	}
}

int main() {
	int n;
	cin >> n;
	hei(int) s;
	for (int i = 11; i; i+=5) {
		if (s.size() == n)break;
		bool z = true;
		for (int j = 2; j <= sqrt(i); j++) {
			if (i%j==0)z = false;
		}
		if (z)s.push_back(i);
	}
	rep(i, 0, n-1)cout << s[i] << " ";
	cout << s[n-1] << endl;
	return 0;
}

Measured memory_bytes: 256
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	string a,b;
	cin>>a>>b;
	ll f=0;
	if(a.size()+1!=b.size()){
		cout<<"No";return 0;
	}
	for(ll i=0;i<a.size();i++)
		if(a[i]!=b[i])
			f=1;
		if(f)cout<<"No";else cout<<"Yes";
	return 0;
}

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

using namespace std;

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

const int N = 100010;
const double eps = 1e-6;

int n, k;

int main()
{
    cin >> n >> k;
    if(k & 1)
    {
        LL res = n / k;
        cout << res * res * res << endl;
    }
    else
    {
        LL res = n / k;
        LL ans = res;
        if(n % k >= k / 2) ans++;
        cout << res * res * res + ans * ans * ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char S[12],N;
  int c=0,i=0,cap=1;

  scanf("%s",S);

  while(S[++i]!='\0') ;
  cap = (S[--i]>='a' && S[i--]<='z');
  for(i=i;i>1;i--)
    if(S[i]=='C')
      c++;
    else
      cap &= (S[i]>='a' && S[i]<='z'); 
  cap &= (S[1]>='a' && S[1]<='z'); 
  
  if(S[0]=='A' && cap && c==1)
    printf("AC\n");
  else
    printf("WA\n");

  return 0;
}


Measured memory_bytes: 128
S=input()
len_S=len(S)
len_SS=len_S-7
ans='keyence'

if len_S==7:
    if S==ans:
        print('YES')
        exit()
    else:
        print('NO')
        exit()

S_lst=list(S)

for i in range(len_S):
    for j in range(len_SS+1):
        lst=S_lst[:]
        del lst[i:i+j]
        if ''.join(lst)==ans:
            print('YES')
            exit()
print('NO')

Measured memory_bytes: 3064
def ints():
  return [int(x) for x in input().split()]
def ii():
  return int(input())

x = ii()
N = x*10

p = [True]*(N)
p[0] = p[1] = False

for i in range(2, N):
  if not p[i]:
    continue

  for j in range(2*i, N, i):
    p[j] = False

for i in range(x, N):
  if p[i]:
    print(i)
    exit()


Measured memory_bytes: 49612
import math as m
from statistics import mean

n = int(input())
lp = []
for i in range(n):
    lp.append(list(map(int, input().split())))


def dfs(j, lp, prev):
    # print("dpth: {}, lp:{}, prev:{}".format(j, lp, prev))

    k = len(lp)
    ll = []
    for j in range(k):
        lr = dfs(j+1, lp[0:j]+lp[j+1:k], lp[j])
        length = m.sqrt((lp[j][0]-prev[0])**2 + (lp[j][1] - prev[1])**2)
        if len(lr) == 0:
            ll.append(length)
        else:
            for p in range(len(lr)):
                lr[p] += length
            ll += lr

    # print(ll)
    return ll


gll = []

for i in range(n):
    gll += dfs(1, lp[0:i]+lp[i+1:n], lp[i])

print(mean(gll))

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

template <class T>
vector<pair<T, T>> prime_factorization(T n) {
    vector<pair<T, T>> ret;
    for (T i = 2; i * i <= n; i++) {
        T cnt = 0;
        while(n % i == 0) {
            n /= i; cnt++;
        }
        if(cnt != 0) ret.emplace_back(i, cnt);
    }
    if (n != 1) ret.emplace_back(n, 1);
    return ret;
}

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

    map<int64_t, int64_t> f;
    for (auto i = 2; i <= n; i++) {
        auto p = prime_factorization(i);
        for (auto & elm : p) f[elm.first] += elm.second;
    }

    int64_t ans = 1;
    const int64_t mod = 1e9 + 7;
    for (auto & elm : f) ans = ((elm.second + 1) * ans) % mod;

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

Measured memory_bytes: 3616
I=lambda:list(map(int,input().split()))
n,m=I()
l=I()
s=sum(l)
te=1/(4*m)
c=0
for i in l:
    if (i/s)>=te:
        c+=1
if c>=m:
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <stack>
#include <queue>
#include <utility>
#include <bitset>
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define per(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,a,b) for (int i=(a);i<=(b);i++)
#define PER(i,a,b) for (int i=(b);i>=(a);i--)
#define de(x) cout<<">> "<<#x<<" = "<<x<<endl;
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
const int INF = 0x3f3f3f3f;
const int MAXN = 1005; // 1e6;
int h,w,a[MAXN][MAXN];
int c[MAXN][MAXN];
int d[MAXN];
priority_queue<P, vector<P>, greater<P> > que;

int main()
{
	// freopen("in.txt","r",stdin);
	scanf("%d%d",&h,&w);
	rep(i,0,10) rep(j,0,10) scanf("%d",&c[i][j]);
	rep(i,0,h) rep(j,0,w) scanf("%d",&a[i][j]);
	
	memset(d,INF,sizeof d);
	d[1]=0;
	que.push(mkp(0, 1));
	while(!que.empty())
	{
		int v = que.top().se, w = que.top().fi;
		que.pop();
		if (d[v] < w) continue;
		rep(i, 0, 10)
		{
			if (d[i] > c[i][v]+w)
			{
				d[i]=c[i][v]+w;
				que.push(mkp(d[i],i));
			} 
		}
	}
	LL ans = 0;
	rep(i, 0, h) rep(j, 0, w)
	{
		if (a[i][j]!=-1) 
		{
			ans += d[a[i][j]];
		}
 	}
 	printf("%lld\n",ans);
	return 0;
}



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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll inf = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

const int N = 55;

int A[N];

int main(){
    fIO

    int n;
    cin >> n;

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

    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            ans += A[i] * A[j];
        }
    }

    cout << ans;
}








Measured memory_bytes: 256
A=input()
B=input()
a=len(A)
b=len(B)
if a>b:
  print("GREATER")
elif b>a:
  print("LESS")
else:
  i=0
  while i<a:
    if A[i]>B[i]:
      print("GREATER")
      break
    elif B[i]>A[i]:
      print("LESS")
      break
    else:
      i=i+1
      if i==a:
        print("EQUAL")

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int n,m,p;
main()
{
	while(cin>>n>>m>>p,n)
	{
		int cnt=0,x[100];
		for(int i=0;i<n;i++)
		{
			cin>>x[i];
			cnt+=x[i];
		}
		cout<<(x[m-1]?cnt*(100-p)/x[m-1]:0)<<endl;
	}
}


Measured memory_bytes: 3000
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

int main()
{
	string a, b;
	cin >> a >> b;
	int al = a.length(), bl = b.length();
	
	if (al > bl)
	{
		cout << "GREATER";
		return 0;
	}
	if (al < bl)
	{
		cout << "LESS";
		return 0;
	}
	if (a.compare(b) == 0)
	{
		cout << "EQUAL";
		return 0;
	}

	for (int i = 0; i < al; i++)
	{
		if (a[0] < b[0])
		{
			cout << "LESS";
			return 0;
		}
		else if (a[0] > b[0])
		{
			cout << "GREATER";
			return 0;
		}
	};
}

Measured memory_bytes: 3560
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k; cin>>n>>k;
    if(n%k==0) print(0);
    else print(1);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

const int maxN = 200000 + 5;
const double PI = acos(-1);
#define ll long long

class TaskC {
private:
	Debugger debugger;
public:
	void solveOne(int it){
		ll a;
		cin >> a;
		string s;
		cin >> s;
		ll b = 0;
		for(char c : s){
			if(c == '.'){
				continue;
			}
			b = b * 10 + c - '0';
		}
		ll ans = a*b;
		cout << ans/100 << endl;

	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskC solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc060_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

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

  bool ok = false;
  repi(i, 1, B + 1) {
    if (A * i % B == C) {
      ok = true;
      break;
    }
  }

  cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(i = p;i < q;i++)
#define ll long long

using namespace std;

int v, e;



int main(void) {
	cin >> v;

	int i;
	ll d[100][100];
	int j;
	rep(i, 0, 100) {
		rep(j, 0, 100) {
			d[i][j] = i == j ? 0 : 1e11;
		}
	}
	rep(i, 0, v) {
		int u,k;
		cin >> u >> k;
		int i2;
		rep(i2, 0, k) {
			int t, c;
			cin >> t >> c;
			d[i][t] = c;
		}
		
		
	}

	int k;
	bool negative = false;
	rep(i, 0, v) {
		rep(j, 0, v) {
			rep(k, 0, v) {
				if (d[j][i] != 1e11 && d[i][k] != 1e11) {
					d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
				}

			}
		}
	}

	rep(i, 0, v) {
		cout << i << " " << d[0][i] << endl;
	}



}


Measured memory_bytes: 3144
def isRightTri(list):
    list.sort()
    if list[2]**2 == list[0]**2 + list[1]**2:
        return True
    else:
        return False

n = int(input())
ans = []
for i in range(n):
    a = list(map(int,input().split()))
    ans.append(isRightTri(a))
for i in range(n):
    if ans[i]:
        print("YES")
    else:
        print("NO")


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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 998244353;
 
////////////////////////////////////////////////////////////////////
 
const int N = 1e6 + 5;

int C[N], S[N];

int Power(int a, int b) {
	int res = 1;
	for (; b; b >>= 1, a = 1LL * a * a % MOD) if (b & 1) res = 1LL * res * a % MOD;
	return res;
}

int main() {
 
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));

	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		C[x]++;
	}
	for (int i = 1; i < N; i++) {
		int sum = 0, tmp = 0;
		for (int j = i; j < N; j += i) {
			sum = (sum + 1LL * j * C[j] % MOD) % MOD;
			tmp = (tmp + 1LL * j * j % MOD * C[j] % MOD) % MOD;
		}
		S[i] = ((1LL * sum * sum % MOD - tmp + MOD) % MOD) * Power(2, MOD - 2) % MOD;
	}
	for (int i = N - 1; i >= 1; i--) for (int j = i + i; j < N; j += i) S[i] = (S[i] - S[j] + MOD) % MOD;
	int ans = 0;
	for (int i = 1; i < N; i++) ans = (ans + 1LL * S[i] * Power(i, MOD - 2) % MOD) % MOD;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 11424
n = int(input())
alis = list(map(int, input().split()))
blis = list(map(int, input().split()))
ans = 0
cross = 0
for i in range(n):
    front = min(alis[i]-cross, blis[i])
    cross = min(alis[i+1], blis[i]-front)
    ans += front + cross
print(ans)    

Measured memory_bytes: 18624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
 int X,Y,Z,N;
 cin >> X;
 cin >> Y;
 cin >> Z;
 N = X;
 X = Y;
 Y = N;
 N = X;
 X = Z;
 Z = N;
 cout << X << endl;
 cout << Y << endl;
 cout << Z << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll Q;
  cin >> Q;
  vector<ll> A(Q), B(Q);
  REP(i, 0, Q) cin >> A[i] >> B[i];

  REP(i, 0, Q) {
    ll a = A[i], b = B[i];

    if(a > b) swap(a, b);

    if(a == b || a + 1 == b) {
      cout << a * 2 - 2 << endl;
    } else {
      ll c = sqrt(a * b);
      if(c * c == a * b) c--;
      if(c * (c + 1) >= a * b) {
        cout << c * 2 - 2 << endl;
      } else {
        cout << c * 2 - 1 << endl;
      }
    }
  }
}


Measured memory_bytes: 256
N, M = map(int, input().split()) 
HEIGHT = list(map(int, input().split()))
MA = []
for i in range(N):
    MA.append(0)
for i in range(M):
    hasi1, hasi2 = map(int, input().split())
    #print(max(MA[hasi1-1], HEIGHT[hasi2-1]))
    MA[hasi1-1] = max(MA[hasi1-1], HEIGHT[hasi2-1])
    MA[hasi2-1] = max(MA[hasi2-1], HEIGHT[hasi1-1])
    #間違い：リストの要素　〇LIST[i]　×LIST(i)
    #MA.insert(hasi1-2,max(MA[hasi1-2], HEIGHT(hasi1-1)))
result = 0
for i in range(N):
    if HEIGHT[i] > MA[i]:
        result += 1
print(result)

Measured memory_bytes: 19972
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

ll f(ll b, ll n){
    ll res=0;
    while(n!=0){
        res+=n%b;
        n/=b;
    }
    return res;
}

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

    ll n, s; cin >> n >> s;

    if(n<s) { cout << -1 << endl; return 0; }
    if(n==s) { cout << n+1 << endl; return 0; }

    for(ll b=2; b*b<=n; ++b){
        if(f(b, n)==s) { cout << b << endl; return 0;}
    }

    ll ans=1LL<<60;
    for(ll p=1; p*p<n; ++p){
        if((n-s+p)%p==0){
            ll b=(n-s+p)/p;
            if(f(b, n)==s) chmin(ans, b);
        }
    }
    if(ans==1LL<<60) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}


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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(int _##i = (t), i = (f); i <  _##i; i++)
#define downto(f, t, i)  for(int _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(int _##i = (t), i = (f); i >  _##i; i--)
typedef long double ld;
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
    #define debug true
    #define ln << endl
#else
    #define debug false
    #define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '

const int MOD = 1e9+7;

long powSq(long x, long n) {
    long ans = 1;
    while(n) {
        if(n & 1) (ans *= x) %= MOD;
        (x *= x) %= MOD;
        n >>= 1;
    }
    return ans;
}

signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

    int N; scanf("%d",&N);
    vector<int> A(N+1); times(N+1, i) scanf("%d",&A[i]);
    vector<int> used(N+1, -1);
    int a, b;
    times(N+1, i) {
        if(~used[A[i]]) {
            a = used[A[i]];
            b = N - i;
        } else {
            used[A[i]] = i;
        }
    }
    if(debug) cout << a sp << b ln;

    long n1Ck = 1, abCk1 = 1;
    upto(1, N+1, k) {
        n1Ck = n1Ck * (N+1 - k + 1) % MOD * powSq(k, MOD - 2) % MOD;
        cout << (n1Ck + MOD - abCk1) % MOD ln;
        abCk1 = abCk1 * (a+b - k + 1) % MOD * powSq(k, MOD - 2) % MOD;
    }

    return 0;
}


Measured memory_bytes: 2048
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())

N, Ma, Mb = inpl()
INF = 4001

DP = [[INF]*(411) for _ in range(411)]
DP[0][0] = 0

for n in range(N):
    DP2 = [[INF]*(411) for _ in range(411)]
    a, b, c = inpl()
    for i in range(10*(n+1) + 1):
        for j in range(10*(n+1) + 1):
            if DP[i][j] == INF:
                continue
            DP2[i][j] = min(DP[i][j], DP2[i][j])
            DP2[i+a][j+b] = min(DP[i+a][j+b], DP[i][j] + c)
    DP = DP2

x = 1
ans = INF
while Ma*x <= 400 and Mb*x <= 400:
    ans = min(ans, DP[Ma*x][Mb*x])
    
    x += 1

if ans < INF:
    print(ans)
else:
    print(-1)

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

int main(){
    long long t1, t2, a1, a2, b1, b2;
    scanf("%lld%lld%lld%lld%lld%lld", &t1, &t2, &a1, &a2, &b1, &b2);
    if(a1*t1 + a2*t2 == b1*t1 + b2*t2) printf("infinity\n");
    else{
        if(a1*t1 + a2*t2 < b1*t1 + b2*t2){
            swap(a1, b1);
            swap(a2, b2);
        }
        if(a1*t1 < b1*t1){
            long long d1 = (a1*t1 + a2*t2) - (b1*t1 + b2*t2);
            long long d2 = b1*t1 - a1*t1;
            long long ans = d2/d1;
            bool add = 0;
            if(d2%d1 == 0) add = 1;
            printf("%lld\n", ans*2+1-add);
        }
        else printf("0\n");
    }
}

Measured memory_bytes: 3832
#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>;
 
int main() {
  int r,d;
  cin >> r >> d;
  int x;
  cin >> x;
  rep(i,10){
    x = r*x - d;
    cout << x << endl;
  }
}

Measured memory_bytes: 3608
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

readInt = fst . fromJust . BS.readInteger
getIntList = map readInt . BS.words <$> BS.getLine
getIntMatrix = map (map readInt . BS.words) . BS.lines <$> BS.getContents

main = do
  [n,m] <- getIntList
  lrs <- getIntMatrix
  print $ f m lrs

f m lrs
  | max < min = 0
  | otherwise = max - min + 1
  where
    min = maximum (map head lrs)
    max = minimum (map (head . drop 1) lrs)

Measured memory_bytes: 36860
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

const ll MOD = 998244353;

signed main(){
    int n,s; cin >> n >> s;
    ll dp[n+1][3030];
    memset(dp,0,sizeof(dp));
    rep(i,n+1) dp[i][0]=i+1;
    rep(i,n){
        int a; cin >> a;
        for(int j=0;j<3030;j++){
            if(j!=0){
                dp[i+1][j]+=dp[i][j];
                dp[i+1][j]%=MOD;
            }
            if(j+a<3030){
                dp[i+1][j+a]+=dp[i][j];
                dp[i+1][j+a]%=MOD;
            }
        }
    }
    ll ans=0;
    rep(i,n){
        ans+=((dp[i+1][s]-dp[i][s]+MOD)%MOD)*(n-i);
        ans%=MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 71296
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	if (n == 0) return 1;
	if (n % 2) return x * modpow(x * x % mod, n / 2) % mod;
	return  modpow(x * x % mod, n / 2) % mod;
}

int fact(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= (i + 1);
		ans %= mod;
	}
	return ans;
}

int comb(int n, int r) {
	if (n < r) swap(n, r);
	if (n - r < r) r = n - r;
	return fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) % mod;
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int n;
int x[114], y[114], h[114];
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> x[i] >> y[i] >> h[i];
	}
	rep(i, 101) {
		rep(j, 101) {
			set<int>H;
			rep(k, n) {
				if (h[k] == 0) continue;
				H.insert(h[k] + abs(x[k] - i) + abs(y[k] - j));
			}
			if (H.size() == 1) {
				int ans;
				for (auto x : H) {
					ans = x;
					break;
				}
				if (ans == 0) continue;
				bool can = true;
				rep(k, n) {
					if (h[k] != max(ans - abs(x[k] - i) - abs(y[k] - j), 0LL)) {
						can = false;
						break;
					}
				}
				if (can) {
					cout << i << " " << j << " " << ans << endl;
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD1			998244353
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//find_by_order kth largest  order_of_key <
const int tam = 100010;
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("qwe.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	string s;
	int k;
	cin>>s>>k;
	int n = s.size();
	set<string> st;
	fore(i, 0, n)
	{
		fore(j, i, min(i + 5, n))
			st.insert(s.substr(i, j - i + 1));
	}
	int con = 0;
	for(set<string>::iterator it = st.begin(); it != st.end(); it++)
	{
		con++;
		if(con == k)
		{
			cout<<*it<<'\n';
		}
	}

	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

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

int GCD( int X, int Y )
{
	while( true )
	{
		X %= Y;
		if( X == 0 ) return Y;

		Y %= X;
		if( Y == 0 ) return X;
	}
}

int main()
{
int i;
int A;
int B;
int K;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> A;
	cin >> B;
	cin >> K;

	i = GCD( A, B );
	if( K == 1 )
	{
		cout << i << endl;

		return 0;
	}

	i--;
	K--;
	for( ; K >= 1; i-- )
	{
		if( A % i == 0 && B % i == 0 )
		{
			K--;
			if( K < 1 )
			{
				cout << i << endl;

				return 0;
			}
		}
	}

	cout << i << endl;
	cout << K << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int x;
		int ans = 0;
		for(int i = 0; i < N; i++) {
			x = sc.nextInt();
			ans += 2 * Math.min(x, K - x);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
n = int(input())
s1 = input()
s2 = input()
mod = 1000000007 

t = 0
dominoes = []
while (t<n):
    if(s1[t]==s2[t]):
        dominoes.append("X")
        t+=1
    else:
        dominoes.append("Y")
        t+=2

ans = 3 if(dominoes[0]=="X") else 6
for i, d in enumerate(dominoes):
    if(i==0):
        temp = d
        continue
    if(temp=="X" and d == "X"):
        ans *= 2 % mod
    elif(temp=="X" and d == "Y"):
        ans *= 2 % mod
    elif(temp=="Y" and d == "Y"):
        ans *= 3 % mod
    temp = d

print(ans % mod)


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

int main(){
    int N; cin >> N;
    vector<long long> X(N),L(N);
    vector<pair<long long,long long>> Z(N);
    for(int i = 0; i < N; i++){
        cin >> X[i] >> L[i];
        Z[i] = {X[i] - L[i],X[i] + L[i]};
    }
    sort(Z.begin(),Z.end(),[](pair<long long,long long> a,pair<long long,long long> b){
        return a.second < b.second; 
    });
    
    long long index = Z[0].second;
    long long ans = 1;
    for(int i = 1; i < N; i++){
        if(index <= Z[i].first){
            index = Z[i].second;
            ans++;
        }
    }
    cout << ans << endl;
    
}




Measured memory_bytes: 6424
for a in iter(input,'0 0'):
 m=[input()for _ in[0]*int(a.split()[0])]
 y=x=0;s={(0,0)}
 while 1:
  u,v=x,y
  c=m[y][x]
  if c=='>':x+=1;
  if c=='v':y+=1;
  if c=='<':x-=1;
  if c=='^':y-=1;
  if c=='.':print(x,y);break
  if(x,y)in s:print('LOOP');break
  else:s|={(x,y)}


Measured memory_bytes: 5628
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int n,ans=0;
vector<int> aa;

bool ch(char x){
	return x=='A'||x=='T'||x=='G'||x=='C';
}

main(){
	string s;
	cin>>s;
	int t=0;
	if(ch(s[0]))t++;
	for(int i=1;i<s.size();i++){
		if(ch(s[i])==0){
			aa.pb(t);
			t=0;
		}else{
			t++;
		}
	}
	aa.pb(t);
	for(auto x:aa)chmax(ans,x);
	dans;
	
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 310
ll dp[N][N], dp2[N][N];
int n, m;
ll mod = 1e9+7;

int main(){
	cin>>n>>m;
	dp[0][1] = 1;
	rep(i, m){
		memcpy(dp2, dp, sizeof(dp));
		mset(dp, 0);
		for(int j = 0; j <= n; j++){
			for(int k = 1; j+k <= n; k++){
				(dp[0][j+k]+=dp2[j][k]*k)%=mod;
				(dp[j+1][k]+=dp2[j][k]*(n-k-j))%=mod;
				(dp[j][k]+=dp2[j][k]*j)%=mod;
			}
		}
	}
	cout<<dp[0][n]<<endl;
	return 0;
}


Measured memory_bytes: 1792
package main

import (
	"fmt"
	"math"
)

func main() {
	var n float64
	var k float64
	fmt.Scan(&n, &k)

	// n を k進数にした時に何桁になるか？
	//ex : 10 を 2進数 = 2^3 + 2^1 = 1010 => 4桁
	//桁数は最上位の位で決まる。この場合2^3 <= 10 < 2^4 であるため 4になった
	//抽象化すると k^x <= n < k^(x+1) を満たすxを見つけ x+1を出力する

	var x float64 = 0.0
	for {
		under := math.Pow(k, x)
		upper := math.Pow(k, x+1)

		if under <= n && n < upper {
			fmt.Println(x + 1)
			return
		}
		x++
	}

}


Measured memory_bytes: 512
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr)
import Control.Monad
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS
import qualified Data.IntMap.Strict as IntMap
import qualified Data.IntSet as IntSet
import Data.Foldable
import Control.Monad.ST

main = do
  [n,m] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  edges <- U.replicateM m $ do
    [u,v] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (u-1,v-1)
  [s,t] <- map (subtract 1) . unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let graph :: IntMap.IntMap IntSet.IntSet
      graph = U.foldl' (\m (u,v) -> insertGraph (3 * u) (3 * v + 1)
                                    $ insertGraph (3 * u + 1) (3 * v + 2)
                                    $ insertGraph (3 * u + 2) (3 * v)
                                    $ m) IntMap.empty edges
      result = runST $ do
        visited <- UM.replicate (3 * n) False
        let !target = 3 * t
        -- bfs :: IntSet -> ST s (Maybe Int)
        let bfs !depth ss = do
              forM_IntSet ss $ \u ->
                UM.write visited u True
              let ts = foldMap_IntSet (\u -> IntMap.findWithDefault IntSet.empty u graph) ss
              ts' <- foldMapM_IntSet (\v -> do
                                         d <- UM.read visited v
                                         pure $ if d then IntSet.empty else IntSet.singleton v
                                     ) ts
              if target `IntSet.member` ts'
                then return $ Just (depth `quot` 3)
                else if IntSet.null ts'
                     then return Nothing
                     else bfs (depth+1) ts'
        bfs 1 (IntSet.singleton (3 * s))
  case result of
    Nothing -> putStrLn "-1"
    Just d -> print d

-- insertGraph key val == IntMap.insertWith IntSet.union key (IntSet.singleton val)
insertGraph :: Int -> Int -> IntMap.IntMap IntSet.IntSet -> IntMap.IntMap IntSet.IntSet
insertGraph !key !val = IntMap.alter (Just . f) key
  where f Nothing = IntSet.singleton val
        f (Just set) = IntSet.insert val set

foldMap_IntSet :: (Monoid n) => (Int -> n) -> IntSet.IntSet -> n
foldMap_IntSet f set = go set
  where
    go set = case IntSet.splitRoot set of
               [] -> mempty
               [x] -> foldMap f (IntSet.toList x)
               xs -> foldMap go xs

forM_IntSet :: Monad m => IntSet.IntSet -> (Int -> m ()) -> m ()
forM_IntSet set f = go set
  where
    go set = case IntSet.splitRoot set of
               [] -> return ()
               [x] -> forM_ (IntSet.toList x) f
               xs -> forM_ xs go

foldMapM_IntSet :: (Monoid n, Monad m) => (Int -> m n) -> IntSet.IntSet -> m n
foldMapM_IntSet f set = go set
  where
    go set = case IntSet.splitRoot set of
               [] -> return mempty
               [x] -> foldlM (\x v -> mappend x <$> f v) mempty (IntSet.toList x)
               xs -> foldlM (\x set' -> mappend x <$> go set') mempty xs


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

int main(void) {
    int n, k; scanf("%d %d", &k, &n);
    map<int, int> m;
    multiset<int> s;
    for (int i = 1; i <= n; ++i)
        m[i] = 0, s.insert(0);
    for (int i = 1; i <= k; ++i) {
        int l, r; scanf("%d %d", &l, &r);
        int x = 0, y = n + 1;
        auto it = m.lower_bound(l);
        while (it != m.end() && it->first <= r + 1) {
            y = min(y, r + 1 - it->first + it->second);
            s.erase(s.find(it->second));
            it = m.erase(it);
        }
        if (y != n + 1 && r < n) {
            m[r + 1] = y;
            s.insert(y);
        }
        printf("%d\n", s.empty() ? -1 : i + *s.begin());
    }
    return 0;
}

Measured memory_bytes: 22520
#include <bits/stdc++.h>
using namespace std;
int main(){
std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test;
    test=1;
    // cin>>test;
    while(test--)
    {
        long i,j,n,m,q,a=0,t,b,c,temp,k,maxpeak=0,peak,d;
        string s;
        cin>>s;
        n=s.length();
        for(i=0;i<n;i++)
        {
            if(s[i]=='A')
            {
                a=i;
                break;
                
            }
        }
        for(i=n-1;i>0;i--)
        {
            if(s[i]=='Z')
            {
                b=i;
                break;
                
            }
        }
        cout<<b-a+1;
        
        
    }
}

Measured memory_bytes: 720