akhauriyash/Code-Regression huggingface dataset:
//gauravsinghh
#include<bits/stdc++.h>
using namespace std;

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve(){
	ll n, m;
	cin >> n >> m;
	ll a, l = 0, r = 0;
	string s;
	map <ll, ll> pk, dk;
	while(m--){
		cin >> a >> s;
		if(dk[a] == 1)	continue;
		if(s == "AC"){
			l++;
			r += pk[a]; 
			dk[a] = 1;
		}
		else{
			pk[a]++;
		}
	}
	cout << l << " " << r << endl;
}

int main(){
    IOS;
    //io_set();
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        solve();
    }
    return 0;
} 


Measured memory_bytes: 12800
def resolve():
    n, x = map(int, input().split())
    ml = list()
    for i in range(n):
        m = int(input())
        ml.append(m)
    ml.sort()
    c = 0
    for g in ml:
        if x-g < 0:
            break
        else:
            c += 1
            x -= g
    a = int(x/ml[0])
    c += a
    print(c)
resolve()

Measured memory_bytes: 9144
def solve():
    N = int(input())
    S = input()
    count = 0

    for i in range(N-2):
        if(S[i] == "A" and S[i+1] == "B" and S[i+2] == "C"):
            count += 1

    print(count)


if __name__ == "__main__":
    solve()

Measured memory_bytes: 61668
#include<iostream>
#include<string.h>

int main() {
	char s[100],ss[200], p[100];

//	scanf("%s", s);
///	scanf("%s", p);
	
	std::cin>>s;
	std::cin>>p;
	

	strcpy(ss, s);
	strcat(ss, s);


	if (strstr(ss, p) == NULL)std::cout << "No\n";
	else std::cout << "Yes\n";
	
	return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>
#include <algorithm>

int main() {
  int A, B;
  scanf("%d %d", &A, &B);
  int m = std::max(A, B);
  for (int i = 0; i < m; i++) {
    if (std::abs(A - i) == std::abs(B - i)) {
      printf("%d", i);
      return 0;
    }
  }
  printf("IMPOSSIBLE");
}


Measured memory_bytes: 128
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))

int main()
{
	int M,D;
	cin>>M>>D;
	int res = 0;
	REP(month,1,M+1)
	REP(day, 1,D+1){
		int d1 = day%10;
		int d10 = day/10;
		if(d1>=2 && d10>=2 && d1*d10==month){
			res++;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

/*
    00000
    00001
    00010
    00011
    00100
    00101
    00110
    00111
    01000


*/

ll f(ll x, int i) {
    ll ret = 0LL;
    ll d = 1LL<<(i+1);
    ll h = 1LL<<i;
    ++x;
    ret += (x/d)*h;
    ret += max(0LL, x - h - (x/d)*d);
    return ret;
}

int main(){
    ll a, b;
    cin >> a >> b;
    ll ans = 0LL;
    rep(i, 60) {
        bool x = (f(b, i)&1LL);
        if(a > 0) x ^= (f(a-1, i)&1LL);
        if(x) ans |= (1LL << i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)

int main(){
    int N;
    cin >> N;
    long long cnt=0;
    int n = N;
    int d = 0;
    while(n>0){
        n /= 10;
        d++;
    }
    //if(pow(10,d-1) == double(N)){
    //    d++;
    //}
    //cout << d <<endl;
    for(int i=1;i<=d;i+=2){
        if(pow(10,i) < double(N)){
            cnt += pow(10, i) - pow(10, i-1);
        }else if(int(pow(10,i)) == N){
            cnt += N - pow(10,i-1);
        }else{
            cnt += N - pow(10,i-1) +1;
        }
    }

    cout << cnt << endl;
    

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
using namespace std;

int main(void) {
	string t;
	int n = 0, w = 0, s = 0, e = 0;
	cin >> t;
	FOR(i, 0, t.size() - 1) {
		if (t[i] == 'N') {
			n++;
		}else if (t[i] == 'W') {
			w++;
		}
		else if (t[i] == 'S') {
			s++;
		}
		else if (t[i] == 'E') {
			e++;
		}
	}
	if ((n >=1) && (s >=1) && (w ==0) && (e== 0)) {
		cout << "Yes" << endl;
	}
	else if ((n == 0) && (s == 0) && (w >= 1) && (e >= 1)) {
		cout << "Yes" << endl;
	}
	else if ((n == s) && (w == e)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

_n = int(input())
_xylist = [list(map(int, input().split())) for _ in range(_n)]


def fac(n):
    ans = 1
    while n > 1:
        ans *= n
        n -= 1

    return ans


def distance(a, b):
    return(abs(a[0] - b[0]) ** 2 + abs(a[1] - b[1]) ** 2) ** 0.5


def chker(xylist):
    now = xylist[0]
    remain = xylist[1:]
    pathsum = 0

    while remain:
        for item in remain:
            pathsum += distance(now, item)

        now, remain = remain[0], remain[1:]

    return pathsum


print(chker(_xylist) * 2 / _n)


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define maxll(a, b) (a > b ? a : b)

int main() {
  int n;
  cin >> n;
  vector<int> xv(n), yv(n);
  vector<ll> hv(n);
  REP(i, n) {
    cin >> xv[i] >> yv[i] >> hv[i];
  }
  ll h;
  ll tmp;
  bool flag = true;
  int tmpx, tmpy;
  ll hoge;
  REP(cx, 101) {
    REP(cy, 101) {
      flag = true;
      REP(i, n) if (hv[i] > 0) tmp = hv[i] + abs(xv[i] - cx) + abs(yv[i] - cy);
      REP(i, n) {
        hoge = tmp - abs(xv[i] - cx) - abs(yv[i] - cy);
        //if (cx == 2 && cy == 2) cout << maxll(hoge, 0) << endl;
        if (hoge < 0) hoge = 0;
        if (hoge != hv[i]) flag = false;
      }
      //if (cx == 2 && cy == 2) cout << tmp;
      if (flag) {
        h = tmp;
        tmpx = cx;
        tmpy = cy;
      }
    }
  }
  cout << tmpx << " " << tmpy << " " << h << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003,INF=1<<30;
vector<int> S[MAX],seen(MAX);
vector<ll> sum(MAX);

void BFS(){
    seen[0]=1;
    queue<int> Q;
    Q.push(0);
    
    while(!Q.empty()){
        int a=Q.front();
        Q.pop();
        for(int i=0;i<S[a].size();i++){
            int b=S[a][i];
            if(seen[b]) continue;
            sum[b]+=sum[a];
            seen[b]=1;
            Q.push(b);
        }
    }
}

int main(){
    
    int N,Q;cin>>N>>Q;
    
    for(int i=0;i<N-1;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        S[a].push_back(b);
        S[b].push_back(a);
    }
    
    for(int i=0;i<Q;i++){
        int a;
        ll b;cin>>a>>b;
        a--;
        sum[a]+=b;
    }
    
    BFS();
    
    for(int i=0;i<N;i++){
        if(i) cout<<" ";
        cout<<sum[i];
    }
    
    cout<<endl;
}




Measured memory_bytes: 17140
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    s,t = LS()
    a,b = LI()
    u = S()
    if s == u:
        print(a - 1, b)
    else:
        print(a, b - 1)
    return


#main
if __name__ == '__main__':
    solve()


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

int main(){

  int W, H;
  cin>>W>>H;

  int x, y, r;
  cin>>x>>y>>r;

  if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3120
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<climits>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<string.h>
#include<algorithm>
#include<unordered_map>
#pragma GCC optimize "trapv"
using namespace std;

#define ld long double
#define ll long long int
#define pb push_back
#define mp make_pair
#define f(i,a,b) for(int i=a;i<b;i++)
#define pp pair<int,pair<int,int>>
#define ppp pair<pair<int,int>,pair<int,int>>

const ll M=998244353,N=2e5+2;

struct hash_pair{
	template <class T1, class T2>
	size_t operator()(const pair<T1, T2>& p) const{
		auto hash1 = hash<T1>{}(p.first);
		auto hash2 = hash<T2>{}(p.second);
		return hash1 ^ hash2;
	}
};

void sieve(){
	bool prime[N+1];
	memset(prime,true,sizeof(prime));
	for(ll p=2;p*p<=N;p++){
		if(prime[p] == true){
			for(ll i=p*p;i<=N;i+=p)
				prime[i] = false;
		}
	}
}

ll power(ll x,ll y,ll p){
	ll res = 1;
	x = x%p;
	while(y > 0){
		if(y&1)
			res = (res*x)%p;
		y = y>>1;
		x = (x*x)%p;
	}
	return res;
}

int root(int i,int A[]){
	while(A[i] != i){
		A[i] = A[A[i]];
		i = A[i];
	}
	return i;
}

void unite(int a,int b,int A[],int B[]){
	int c = root(a,A);
	int d = root(b,A);
	if(c == d)
		return;
	if(B[c] < B[d]){
		A[c] = d;
		B[d] += B[c];
	}
	else{
		A[d] = c;
		B[c] += B[d];
	}
}

inline ll in()
{
	ll n=0;
	bool check=0;
	register char c=getchar();
	while(c<'0' || c>'9')
	{
		if(c=='-')
			check=1;
		c=getchar();
	}
	while(c>='0' && c<='9')
	{
		n = (n<<1)+(n<<3)+c-'0';
		c=getchar();
	}
	return n-2*n*check;
}

string ip()
{
    string i="";
    int temp=getchar();
    while(temp<'a'||temp>'z')
        temp=getchar();
    while(temp>='a'&&temp<='z')
    {
        i+=(char)temp;
        temp=getchar();
    }
    return i;
}

int A[N];

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


	ll n,res=0,temp;
	cin>>n;
	unordered_map<ll,ll> U;
	for(int i=0;i<n;i++){
		cin>>A[i];
		if(U.find(A[i]) == U.end())
			U[A[i]] = 1;
		else
			U[A[i]]++;
	}
	for(auto x: U)
		res += (x.second*(x.second-1))/2;
	for(int i=0;i<n;i++){
		temp = U[A[i]];
		cout<<res-(temp*(temp-1))/2+((temp-1)*(temp-2))/2<<"\n";
	}

	return 0;
}

Measured memory_bytes: 8392
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
long long bio[30];
long long z;
int main()
{
    string t;
    cin >> t;
    z = t.size() * (t.size()-1) / 2 + 1;
    for(int i = 0; i < t.size(); i++)
    {
        bio[t[i]-'a']++;
    }
    for(int i = 0; i < 30; i++)
    {
        z -= bio[i] * (bio[i]-1) / 2;
    }
    cout << z << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#define M 1000000007
using namespace std;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int i,a[100000],flag=0,b[100000];
    long long dp[100000]={1,1,2};
    for(i=0;i<=n;i++) b[i]=i;
    for(i=0;i<m;i++)
        {scanf("%d",&a[i]);b[a[i]]=0;}
    sort(a,a+m);
    for(i=1;i<m;i++)
        if(a[i]-a[i-1]<=1)
          {flag=1;break;}
    if(b[1]==0) dp[2]=1;
    for(i=3;i<=n;i++)
    {
        if(b[i]!=0)
        {
            if(b[i-1]!=0&&b[i-2]!=0) dp[i]=(dp[i-1]%M+dp[i-2]%M)%M;
            else if(b[i-1]==0&&b[i-2]!=0) dp[i]=dp[i-2]%M;
            else if(b[i-1]!=0&&b[i-2]==0) dp[i]=dp[i-1]%M;
        }
    }
    if(flag) printf("0\n");
    else
        printf("%lld\n",dp[n]);
    return 0;
}


Measured memory_bytes: 1664
from heapq import heappush, heappop

while True:
  n, m = map(int, input().split())
  if n == 0: break

  mp = ["X" + input() + "X" for _ in range(m)]
  mp.insert(0, "X" * (n + 2))
  mp.append("X" * (n + 2))
  
  que = []
  visited = [[False] * (n + 2) for _ in range(m + 2)]
  sur_flag = False
  for i in range(1, n + 1):
    if mp[1][i] =="&" or mp[m][i] == "&":
      sur_flag = True
      break
    c1, s1 = (1, 0) if mp[1][i] == "#" else (0, 1)
    c2, s2 = (1, 0) if mp[m][i] == "#" else (0, 1)
    heappush(que, (c1, s1, (i, 1)))
    heappush(que, (c2, s2, (i, m)))
    visited[1][i] = True
    visited[m][i] = True
  
  for i in range(1, m + 1):
    if mp[i][1] == "&" or mp[i][n] == "&":
      sur_flag = True
      break
    c1, s1 = (1, 0) if mp[i][1] == "#" else (0, 1)
    c2, s2 = (1, 0) if mp[i][n] == "#" else (0, 1)
    heappush(que, (c1, s1, (1, i)))
    heappush(que, (c2, s2, (n, i)))
    visited[i][1] = True
    visited[i][n] = True
  
  if sur_flag:
    print(0)
    continue
  
  direct = ((0, 1), (0, -1), (1, 0), (-1, 0))
  reached = False
  
  """
  到達コストの低い順で、堀の中にいるものを優先に幅優先探索
  """
  while que and not reached:
    cost, status, point = heappop(que)
    x, y = point
    for dx, dy in direct:
      newx, newy = x + dx, y + dy
      if not visited[newy][newx]:
        visited[newy][newx] = True
        sym = mp[newy][newx]
        if sym == "&":
          print(cost)
          reached = True
          break
        elif sym == "#":
          if status == 1:
            heappush(que, (cost + 1, 0, (newx, newy)))
          else:
            heappush(que, (cost, 0, (newx, newy)))
        elif sym == ".":
          heappush(que,(cost, 1, (newx, newy)))


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

const int Maxn = 111111;

int n, l, t, pos[Maxn];

int main() {
	scanf("%d%d%d", &n, &l, &t);
	int first = 0;
	for (int i = 0, x, w; i < n; ++i) {
		scanf("%d%d", &x, &w);
		if (w == 1) {
			pos[i] = (x+t)%l;
			first = (first+(x+t)/l)%n;
		} else {
			pos[i] = ((x-t)%l+l)%l;
			first = ((first-(l-x-1+t)/l)%n+n)%n;
		}
	}
	sort(pos, pos+n);
	for (int i = 0; i < n; ++i) {
		printf("%d\n", pos[(i+first)%n]);
	}
	return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    int ans = 0;
    if(n!=1){
        ans += n*(n-1)/2;
    }
    if(m!=1){
        ans += m*(m-1)/2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b%mod;
}
signed main(){
	int a,b,z=1;
	cin>>a;
	f(i,a){
		cin>>b;
		if(b==z)z++;
	}
	if(z==1)puts("-1");
	else cout<<a-z+1<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map>       // pair
#include <string>
#include<stdio.h>
using namespace std;

int main(int argc, const char *argv[])
{
    vector<vector<int> > mat(5, vector<int>(3, 0));
    
    for(int i = 0; i < 5 ; i ++)
    {
        cin>>mat[i][0];
        mat[i][1] = mat[i][0] + 10 - mat[i][0]%10;
        if (mat[i][0] % 10 == 0)
        {
            mat[i][1] = mat[i][1] -10;
        }
        mat[i][2] = mat[i][1] - mat[i][0];
    }
    int max_i,max_val = 0;
    for(int i = 0; i < 5 ; i ++)
    {
        if(mat[i][2]>max_val)
        {
            max_val = mat[i][2];
            max_i = i;
        }
    }
    int sum = 0;
    for(int i = 0 ; i < 5 ; i ++)
    {
        if(i != max_i)
        {
            sum += mat[i][1];
        }
        else
        {
            sum += mat[i][0];
        }
    }
    
    cout<<sum;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

  int N;
  int X;
  int T;
  cin>>N>>X>>T;
  if(N%X==0){
    cout<<(N/X)*T;
    return 0;
  }
  else{
  
    cout<<(N/X+1)*T;
    return 0;
  }
}

Measured memory_bytes: 3620
'use strict'

function main(input) {
  input = Number(input)
  const divider = 1000000007

  let power = 1
  for (let i=1; i<=input; i++) {
    power = power * i
    power = power % divider
  }

  console.log(power)
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21192
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	aa := make([]int, n)
	sum := 0
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
		sum += aa[i]
	}
	mm := m
	sort.Ints(aa)
	for i := n - 1; i >= 0 && m > 0; i-- {
		m--
		if aa[i]*4*mm < sum {
			fmt.Fprintln(writer, "No")
			return
		}
	}
	fmt.Fprintln(writer, "Yes")
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int main(void)
{
    char a[100][101],b[100][101];
    int h,w,t,i,j;
    scanf("%d%d",&h,&w);
    for(i=0;i<h;i++)scanf("%s",a[i]);
    for(i=0;i<h;i++)strcpy(b[i],a[i]);
    for(i=0;i<h;i++){
        t=0;
        for(j=0;j<w;j++)if(a[i][j]=='#')t=1;
        if(1>t)for(j=0;j<w;j++)b[i][j]='0';
    }
    for(i=0;i<w;i++){
        t=0;
        for(j=0;j<h;j++)if(a[j][i]=='#')t=1;
        if(t==0)for(j=0;j<h;j++)b[j][i]='0';
    }
    for(i=0;i<h;i++){
        t=0;
        for(j=0;j<w;j++){
            if(b[i][j]=='0')continue;
            else if(a[i][j]=='#')t=1;
            printf("%c",a[i][j]);
        }
        if(t>0)puts("");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint n; cin >> n;
  lint B = 26;

  string ans = "";
  while (n > 0) {
    n--;
    int com = n % B;
    ans += (char)(com + 'a');
    n /= B;
  }

  reverse(ALL(ans));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
#include <vector>
#include <cstring>

using namespace std;

struct Circle {
    int x, y, r, c;
    Circle() {}
    Circle(int x, int y, int r, int c)
        : x(x), y(y), r(r), c(c) {}
};

int n;
char dp[1 << 24];
//char up[24];
//vector<char> dp, up;
//vector<Circle> c;
Circle c[24];

inline bool isOverlap(const Circle &a, const Circle &b)
{
    int r = (a.r + b.r) * (a.r + b.r);
    int d = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
    return r > d;
}

bool isUp(int s, int v)
{
    for (int i = 0; i < v; ++i)
        if ((s >> i & 1) && isOverlap(c[v], c[i]))
            return false;
//            return true;
//    return false;
    return true;
}

int Rec(int s)
{
    if (~dp[s])
        return dp[s];

    int res = 0;
    // 取り除く2つの円の選択
    for (int i = 0; i < n; ++i) {
        // c[i]がないか取り除けない
        // if (!(s >> i & 1) || isUp(s, i))
        //     continue;
        // if (!(s >> i & 1) || s & up[i])
        //     continue;

        for (int j = i + 1; j < n; ++j) {
            // c[i]とc[j]の色が異なる
            // if (c[i].c != c[j].c)
            //     continue;
            // c[j]がないか取り除けない
            // if (!(s >> j & 1) || s & up[j])
            //     continue;
            // if (!(s >> j & 1) || isUp(s, j))
            //     continue;
            if ((s >> i & 1) && isUp(s, i) && c[i].c == c[j].c
                && (s >> j & 1) && isUp(s, j))
//            int nxt = s & ~(1 << i) & ~(1 << j);
            res = max(res, Rec(s & ~(1 << i) & ~(1 << j)) + 2);
        }
    }

    return dp[s] = res;
}

int main()
{
    while (cin >> n, n) {
        memset(dp, -1, sizeof(dp));
//        memset(up, 0, sizeof(up));
//        c.resize(n);

        // 円の入力
        for (int i = 0; i < n; ++i)
            cin >> c[i].x >> c[i].y >> c[i].r >> c[i].c;

        // // 円の重なり，上下関係
        // for (int i = 0; i < n; ++i)
        //     for (int j = i + 1; j < n; ++j)
        //         if (isOverlap(c[i], c[j]))
        //             up[j] |= (1 << i);

        cout << Rec((1 << n) - 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 17552
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    ll H,W,N;//tate h yoko w
    cin >> H >> W >> N;
    vector<ll> color(N);
    rep(i,N)cin >> color[i];
    vector<ll> ans;
    rep(i,N){
        rep(j,color[i]){
            ans.push_back(i + 1);
        }
    }
    vector<vector<ll>> res(H,vector<ll>(W));
    rep(i,H){
        rep(j,W){/*
            if(i % 2 == 0){
                res[i][j] = ans[i * H + W];
            }
            else{
                res[i][W - j - 1] = ans[i * H + W];
            }*/
            res[i][j] = ans[i * W + j];
        }
        if(i % 2 == 1)reverse(all(res[i]));
    }
    rep(i,H){
        rep(j,W)cout << res[i][j] << " ";
        cout << endl;
    }
//    rep(i,H * W)cout << ans[i] << endl;
}


Measured memory_bytes: 512
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 20;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

char in[105];
int main() {
	scanf("%s", in);

	int t1 = (in[0] - '0') * 10 + (in[1] - '0');
	int t2 = (in[2] - '0') * 10 + (in[3] - '0');

	if (t1 >= 1 && t1 <= 12 && t2 >= 1 && t2 <= 12) return !printf("AMBIGUOUS\n");
	if (t1 >= 1 && t1 <= 12) return !printf("MMYY\n");
	if (t2 >= 1 && t2 <= 12) return !printf("YYMM\n");
	return !printf("NA\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//using ll = long long;
#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3,ans;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;
//void swap(ll *x,ll *y){
//  ll z = *x;
//  *x = *y;
//  *y = z;
//}
//ll gcd(ll x,ll y){
//  if(y == 0){
//    return x;
//  }
//  return gcd(y,x%y);
//}
int main(){
  ll n;
  string s;
  cin >> n;
  cin >> s;
  ll x;
  ll sum = 0;
  rep(i,n){
    if(i == 0){
      x = s[i];
      sum++;
    }else {
      if(s[i] == x){

      }else{
        sum++;
        x = s[i];
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;
 
double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}
 
std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}
 
std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}
 
bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }
 
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;
 
typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;
const int mod = 1000000007;
 
 
int main() {
    double r;
    cin >> r;
 
    printf("%.20f\n", r * 2 * PI);
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

//Ｏ(log(max(a,b))
//aとbの最大公約数
int gcd(lint a,lint b){
  if(b==0)return a;
  return gcd(b,a%b);
}

//aとbの最小公倍数
int lcm(lint a,lint b){
  int x=gcd(a,b);
  return (a*b)/x;
}

signed main(){
  int N,M;
  string S,T;
  cin>>N>>M>>S>>T;

  int L=lcm(N,M);

  if(gcd(N,M)==1){
    if(S[0]==T[0]){
      cout<<L<<"\n";
      return 0;
    }
  }else{
    if(N==M){
      cout<<L<<"\n";
      return 0;
    }

    if(N>M){
      int l=L/M;
      int s=L/N;
      bool flag=true;
      int x=lcm(l,s);
      for(int t=0;x*t<L;t++){
        if(T[x*t/l]!=S[x*t/s]){
          flag=false;
          break;
        }
      }

      if(flag==true){
        cout<<L<<"\n";
        return 0;
      }
    }else if(M>N){
      int l=L/N;
      int s=L/M;
      bool flag=true;
      int x=lcm(l,s);
      for(int t=0;x*t<L;t++){
        if(S[x*t/l]!=T[x*t/s]){
          flag=false;
          break;
        }
      }

      if(flag==true){
        cout<<L<<"\n";
        return 0;
      }
    }
  }

  cout<<"-1"<<"\n";
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
const int Nmax=200010;
int main() {
	int N,K;
	cin >> N >> K;
	
	ll ans=0;
	//bを固定 i=b
	for(int i=1;i <= N;i++){
		ans += N/i * max(0, i-K) + max(0, N%i-K+1);
	}
  	if(K==0) ans -= N;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (a, b, c): (i64, i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let ans = vec![a, b, c].iter().collect::<std::collections::HashSet<_>>().len();

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <map>
using namespace std;
typedef long long  ll;
char s[200009];
int main()
{
    int n;
    cin >> n;
    scanf("%s", s+1);
    int ans = 0, l = 1, r = n;
    while (l<r)
    {
        while (s[l] == 'R')
            l++;
        while (s[r] == 'W')
            r--;
        if (l >= r)
            break;
        ans++;
        swap(s[l], s[r]);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N,A,B,ans;
  cin >> N >> A >> B;
  for (int i = 1; i <= N; i++){
    int a,s = i,sum = 0;
    while(s != 0){
      a = s % 10;
      sum += a;
      s /= 10;
    }
    if(A <= sum && sum <= B)
      ans += i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>

#define rep(i) for (int i = 0; i != n; i += 1)

using std::cin;
using std::cout;
using std::vector;
using std::swap;
using vi = vector<int>;

template<class T>
void transpose(int n, vector<vector<T>>& a) {
  rep(i) {
    for (int j = 0; j != i; j += 1) {
      swap(a[i][j], a[j][i]);
    }
  }
}

vector<vi> solve(int n, vi s, vi t, vi u, vi v) {
  vector<vi> a(n, vi(n, 0));
  rep(i) {
    rep(j) {
      if (s[i] == 1) {
        if (t[j] == 1) {
          if (u[i] != v[j]) {
            return a;
          }
        }
        else {
          if (u[i] == v[j]) {
            v[j] = 2;
          }
        }
        a[i][j] = u[i];
      }
      else {
        if (t[j] == 1) {
          if (u[i] == v[j]) {
            u[i] = 2;
          }
          a[i][j] = v[j];
        }
      }
    }
  }
  vi fs, ft;
  rep(i) {
    if (s[i] == 0) {
      fs.push_back(i);
    }
    if (t[i] == 0) {
      ft.push_back(i);
    }
  }
  bool td = false;
  if (fs.size() > ft.size()) {
    td = true;
    swap(s, t);
    swap(u, v);
    swap(fs, ft);
    transpose(n, a);
  }

  if (fs.size() == 1) {
    int i = fs[0];
    for (int j : ft) {
      if (v[j] == 2) {
        a[i][j] = u[i];
      }
      else {
        a[i][j] = v[j];
      }
    }
  }
  if (fs.size() >= 2) {
    int cs = 0;
    rep(i) {
      if (s[i] == 1) continue;
      int ct = 0;
      rep(j) {
        if (t[j] == 1) continue;
        a[i][j] = cs ^ ct;
        ct ^= 1;
      }
      cs ^= 1;
    }
  }

  if (td) {
    transpose(n, a);
  }
  return a;
}

int main() {
  using u64 = unsigned long long;

  int n;
  cin >> n;
  vi s(n), t(n);
  vector<u64> u(n), v(n);
  for (auto& e : s) cin >> e;
  for (auto& e : t) cin >> e;
  for (auto& e : u) cin >> e;
  for (auto& e : v) cin >> e;

  vector<vector<u64>> ans(n, vector<u64>(n, 0));
  for (int i = 0; i != 64; i += 1) {
    vi s_ = s, t_ = t;
    vi u_(n), v_(n);
    rep(j) {
      u_[j] = u[j] >> i & 1;
      v_[j] = v[j] >> i & 1;
      s_[j] ^= u_[j];
      t_[j] ^= v_[j];
    }
    auto ans_ = solve(n, s_, t_, u_, v_);
    rep(j) {
      rep(k) {
        ans[j][k] |= u64(ans_[j][k]&1) << i;
      }
    }
  }
  bool f = true;
  const auto ch = [&]() {
    rep(i) {
      if (s[i] == 0) {
        u64 a = ~u64(0);
        rep(j) {
          a &= ans[i][j];
        }
        f &= a == u[i];
      }
      else {
        u64 a = 0;
        rep(j) {
          a |= ans[i][j];
        }
        f &= a == u[i];
      }
    }
  };
  ch();
  transpose(n, ans);
  swap(s, t);
  swap(u, v);
  ch();
  transpose(n, ans);
  if (not f) {
    std::cout << "-1\n";
    return 0;
  }
  rep(i) {
    rep(j) {
      cout << ans[i][j] << " ";
    }
    cout << "\n";
  }
  return 0;
}


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

int main(){
  int N;
  string S, T;
  cin >> N >> S >> T;
  vector<char> ans(2*N);
  
  for(int i=0; i<N; i++){
    ans.at(2*i) = S.at(i);
    ans.at(2*i+1)= T.at(i);
  }
  
  for(int j=0; j<ans.size(); j++){
    cout << ans.at(j);
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int A;
int B;
int main(){
  rd(A);
  rd(B);
  if(A+B<10){
    wt_L(A+B);
    wt_L('\n');
  }
  else{
    wt_L("error");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int A, B;
// {
//   rd(A,B);
//   wt( if[A+B<10, A+B, "error"] );
// }


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int n, d, x;
  scanf("%d%d %d", &n, &d, &x);
  int a[n];
  int i;
  for (i = 0; i < n; i++)
    scanf("%d", &a[i]);

  int sum = x;
  for (i = 0; i < n; i++)
    for (int k = 1; k <= d; k += a[i])
      sum++;
  printf("%d", sum);
  return 0;
}

Measured memory_bytes: 128
package main

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

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

var writer = bufio.NewWriter(os.Stdout)

func next() string {
	return reader.next()
}

func nextInt64() int64 {
	i, err := strconv.ParseInt(reader.next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextInt() int {
	return int(nextInt64())
}

func nextLine() string {
	return reader.nextLine()
}

func out(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	return int(max64(int64(x), int64(y)))
}

func min64(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func min(x, y int) int {
	return int(min64(int64(x), int64(y)))
}

func abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func abs(x int) int {
	return int(abs64(int64(x)))
}

func joinInt64s(a []int64, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.FormatInt(v, 10)
	}
	return strings.Join(b, sep)
}

func joinInts(a []int, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.Itoa(v)
	}
	return strings.Join(b, sep)
}

func divUp64(x, y int64) int64 {
	return (x + y - 1) / y
}

func divUp(x, y int) int {
	return int(divUp64(int64(x), int64(y)))
}

func gcd64(x, y int64) int64 {
	if x < y {
		x, y = y, x
	}
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func gcd(x, y int) int {
	return int(gcd64(int64(x), int64(y)))
}

func lcm64(x, y int64) int64 {
	return x * y / gcd64(x, y)
}

func lcm(x, y int) int {
	return int(lcm64(int64(x), int64(y)))
}

func pow64(x, y int64) int64 {
	return int64(math.Pow(float64(x), float64(y)))
}

func pow(x, y int) int {
	return int(pow64(int64(x), int64(y)))
}

func main() {
	solve()
	writer.Flush()
}

func solve() {
	a, b := next(), next()
	if len(a) > len(b) {
		out("GREATER")
	} else if len(a) < len(b) {
		out("LESS")
	} else {
		for i := 0; i < len(a); i++ {
			if a[i] > b[i] {
				out("GREATER")
				return
			} else if a[i] < b[i] {
				out("LESS")
				return
			}
		}
		out("EQUAL")
	}
}


Measured memory_bytes: 640
N, A = map(int, input().split())
# 予め-Kした状態で用意しておく
X = [A-int(x) for x in input().split()]
MAX = N*A*2
# dp[i][k] := i枚目までのカードで、合計をkにする通り数
dp = [[0]*(MAX+1) for _ in range(N+1)]
# 負の数を考慮して、N*K位置を0とする
dp[0][N*A] = 1
for i in range(N):
  x = X[i]
  for k in range(MAX+1):
    dp[i+1][k] += dp[i][k]
    if 0 <= k+x <= MAX:
      dp[i+1][k+x] += dp[i][k]
      
# N回終わって合計が0になっている通り数 - 1枚も取らないケース      
print(dp[N][N*A]-1)

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

typedef long long ll;
const int INF = 1001001001;


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

    int n = sz(s), m = sz(t);


    vector<vector<int>> is(26);
    rep(i, n) {
        is[s[i] - 'a'].push_back(i);
    }
    rep(i, n) {
        is[s[i] - 'a'].push_back(i + n);
    }
    ll ans = 0;
    int p = 0;

    rep(i, m) {
        int c = t[i] - 'a';
        if (sz(is[c]) == 0) {
            puts("-1");
            return 0;
        }
        p = *lower_bound(is[c].begin(), is[c].end(), p) + 1;
        if (p >= n) {
            p -= n;
            ans += n;
        }
    }

    ans += p;
    cout << ans << endl;

}


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

using namespace std;

int a[4][4], n, b[11], c[4][4];

int main() {
    for (int i = 1; i <= 3; i++)
        for (int j = 1; j <= 3; j++)
            cin >> a[i][j];
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
        for (int x = 1; x <= 3; x++) {
            for (int y = 1; y <= 3; y++) {
                if (a[x][y] == b[i]) {
                    c[x][y] = 1;
                }
            }
        }
    }
    if (c[1][1] + c[1][2] + c[1][3] == 3) {
        puts("Yes");
        return 0;
    }
    if (c[2][1] + c[2][2] + c[2][3] == 3) {
        puts("Yes");
        return 0;
    }
    if (c[3][1] + c[3][2] + c[3][3] == 3) {
        puts("Yes");
        return 0;
    }
    if (c[1][1] + c[2][1] + c[3][1] == 3) {
        puts("Yes");
        return 0;
    }
    if (c[1][2] + c[2][2] + c[3][2] == 3) {
        puts("Yes");
        return 0;
    }
    if (c[1][3] + c[2][3] + c[3][3] == 3) {
        puts("Yes");
        return 0;
    }
    if (c[1][1] + c[2][2] + c[3][3] == 3) {
        puts("Yes");
        return 0;
    }
    if (c[1][3] + c[2][2] + c[3][1] == 3) {
        puts("Yes");
        return 0;
    }
    puts("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    vector<string> v;
    string word;
    bool flag = true;

    cin >> n;
    cin >> word;
    char last = word[word.length() - 1];
    v.push_back(word);

    for (int i = 1; i < n; i++) {
        cin >> word;

        auto itr = find(v.begin(), v.end(), word);
        size_t idx = distance(v.begin(), itr);
        if (idx != v.size()) flag = false;
        if (word[0] != last) flag = false;

        last = word[word.length() - 1];
        v.push_back(word);
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,k;
   cin>>n>>k;
   vector<int>a(n+1);
   for(int i=0;i<=n;i++)
    a[i]=i;
   vector<int>lef(N);
   vector<int>righ(N);
   //debug(a);
   lef[0]=0;
   righ[0]=0;
   for(int i=1;i<=(n+1);i++)
   {
       lef[i]=lef[i-1]+a[i-1];
       lef[i]%=M;
   }
   reverse(all(a));
   for(int i=1;i<=(n+1);i++)
   {
       righ[i]=righ[i-1]+a[i-1];
       righ[i]%=M;
   }
   int sum=0;
   for(int i=k;i<=(n+1);i++)
   {
       sum+=(righ[i]-lef[i]+1);
       sum%=M;
   }
   cout<<(sum + M)%M<<endl;
}


Measured memory_bytes: 9440
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+5;
int n,m,q,color[MAXN],h[MAXN],nx[MAXN<<1],to[MAXN<<1],tot;
int v[MAXN],d[MAXN],c[MAXN],mxd[MAXN];
void link(int x,int y){to[++tot]=y;nx[tot]=h[x];h[x]=tot;}
void lk(int x,int y){link(x,y);link(y,x);}
int queue1[MAXN],queue2[MAXN],l,r;
void bfs(int x,int y,int z){
	l=r=1;
	queue1[r]=x;
	queue2[r]=y;
	while(l<=r){
		int cx=queue1[l],cy=queue2[l];
		l++;
		if(mxd[cx]>=cy)continue;
		mxd[cx]=cy;
		if(!color[cx])color[cx]=z;
		for(int i=h[cx];i;i=nx[i]){
			if(mxd[to[i]]<cy-1){
				queue1[++r]=to[i];
				queue2[r]=cy-1;
			}	
		}
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		mxd[i]=-1;
	for(int i=1;i<=m;i++){
		int a,b;
		cin>>a>>b;
		lk(a,b);
	}
	cin>>q;
	for(int i=1;i<=q;i++){
		cin>>v[i]>>d[i]>>c[i];	
	}
	for(int i=q;i>=1;i--){
		bfs(v[i],d[i],c[i]);
	}
	for(int i=1;i<=n;i++){
		cout<<color[i]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<cstdio>
#include<algorithm>
#define int long long
using namespace std;
int mi=1000000000,N,M,D[1001],C[1001],dp[1001][1001];
signed main(){
    cin>>N>>M;
    for(int i=0;i<N;++i){
        cin>>D[i];
    }
    for(int i=0;i<M;++i){
        cin>>C[i];
    }
    fill(dp[0],dp[0]+1001*1001,1000000000);
    dp[0][0]=0;
    for(int i=0;i<N;++i){
        for(int j=0;j<M;++j){
            dp[i][j+1]=min(dp[i][j],dp[i][j+1]);
            dp[i+1][j+1]=min(dp[i][j]+D[i]*C[j],dp[i+1][j+1]);
        }
    }
    for(int i=1;i<=M;++i){
        mi=min(mi,dp[N][i]);
    }
    cout<<mi<<endl;
    return 0;
}

Measured memory_bytes: 9000
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int MR = 2e5 + 10;
const int MOD = 1e9 + 7;

int dp[MR], psum[MR];

int main()
{
    int N;
    scanf("%d", &N);

    dp[0] = 1;
    int prev = 0;
    FORQ(i, 1, N)
    {
        int C;
        scanf("%d", &C);

        if (C != prev)
        {
            dp[i] = (dp[i - 1] + psum[C]) % MOD;
            psum[C] = (psum[C] + dp[i - 1]) % MOD;
        }
        else
            dp[i] = dp[i - 1];

        prev = C;
    }

    printf("%d\n", dp[N]);

    return 0;
}

Measured memory_bytes: 1792