akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
  int a, b;
  cin>>a>>b;
  if(a==b){
    cout<<"a == b"<<endl;
  }else if(a<b){
    cout<<"a < b"<<endl;
  }else if(a>b){
    cout<<"a > b"<<endl;
  }
}



Measured memory_bytes: 3092
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef int keytype;

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

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

int main(){
    int n;
    char s[105];

    scanf("%d %s", &n, s);

    int max = 0;
    int cnt = 0;
    for(int i = 0; i < n; ++i){
        if(s[i] == 'I'){
            cnt++;
            if(max < cnt){
                max = cnt;
            }
        }else if(s[i] == 'D'){
            cnt--;
        }else{
            ;
        }
    }

    printf("%d\n", max);

    return 0;
}


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

int n,num,num1,num2,num3;
int a[100010];

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(a[i]%4==0)num1++;
        else if(a[i]%2==0)num2++;
        else num3++;
    }
    if(num2>1){
        if(num1>=num3)puts("Yes");
        else puts("No");
    }else{
        if(num1>=num3-1+num2)puts("Yes");
        else puts("No");
    }
    return 0;
}


Measured memory_bytes: 640
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_num(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, a[51][6], ans, h, m;
vector<int>v;
int main() {
	cin >> n;
	REP(i, n) {
		REP(j, 6) {
			cin >> h >> m;
			a[i][j] = h * 60 + m;
			if (j % 2 == 0) v.emplace_back(a[i][j]);
		}
	}
	sort(ALL(v));
	for (int i = 0; i < v.size(); i++) {
		for (int j = i + 1; j < v.size(); j++) {
			for (int k = j + 1; k < v.size(); k++) {
				int cnt = 0;
				REP(l, n) if (a[l][0] <= v[i] && v[i] <= a[l][1] && a[l][2] <= v[j] && v[j] <= a[l][3] && a[l][4] <= v[k] && v[k] <= a[l][5]) cnt++;
				ans = max(ans, cnt);
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3168
#!/usr/bin/env python3
import itertools

(n, m, q), *r = [[*map(int, t.split())] for t in open(0)]
ans = 0
for i in list(itertools.combinations_with_replacement(range(1, m + 1), n)):
    sub = 0
    for a, b, c, d in r:
        sub += d * (i[b - 1] - i[a - 1] == c)
    ans = max(ans, sub)
print(ans)


Measured memory_bytes: 21492
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>
#include<map>
#include<queue>

using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector<pair<int, int>>ab(n);
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		ab[i] = make_pair(b, a);
	}
	sort(ab.begin(), ab.end());
	
	int count = 0;
	for (int i = 0; i < n; i++) {
		//cout << ab[i].second << endl;
		count += ab[i].second;
		if (count > ab[i].first) {
			count = -1;
			break;
		}
	}
	if (count == -1) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}
}

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

int main() {
    string s;
    cin>>s;
    for(int i=0;i<=12;i++){
        if(i<=3){
            cout<<s.at(i);
        }else if(i==4){
            cout<<" ";
        }else{
            cout<<s.at(i-1);
        }
    }
    cout<<endl;
return 0;}
/*
g++ code.cpp
./a.out
*/

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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define pb push_back
#define rep(i, l, n) for (int i = (l); i < n; i++)
#define rep_cs(i, l, n) for (int i = (l); i <= n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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

const int MOD = 1000000007;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

using Graph = vector<vector<int>>;
Graph G;
vector<bool> seen;
void dfs(const Graph &G, int v)
{
    seen[v] = true;

    for (auto next_v : G[v])
    {
        if (seen[next_v])
            continue;
        dfs(G, next_v);
    }
}

ll dp[110][110000] = {0};
ll w[110];
ll v[110];

int main()
{
    int N, W;
    cin >> N >> W;
    rep(i, 0, N) cin >> w[i] >> v[i];
    rep(i, 0, N)
    {
        rep_cs(sum_weight, 0, W)
        {
            if (sum_weight - w[i] >= 0)
            {
                chmax(dp[i + 1][sum_weight], dp[i][sum_weight - w[i]] + v[i]);
            }
            chmax(dp[i + 1][sum_weight], dp[i][sum_weight]);
        }
    }
    cout << dp[N][W] << endl;
}

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

int n,a[200004],ans;
int now;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ans=-1000000000;
    now=a[n-1];
    for(int i=n-2;i>=0;i--){
        ans=max(ans,now-a[i]);
        now=max(now,a[i]);
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 3860
package main

import (
    "bufio"
    "fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var N,K int
	fmt.Scan(&N,&K)
	flag := make([]int, N)
	for  i := 0; i < K; i++ {
		var D int
		fmt.Scan(&D)
		for j := 0; j < D; j++ {
			var A int
			fmt.Scan(&A)
			flag[A- 1]++
		}
	}
	count := 0
	for _,v := range flag {
		if v == 0 {
			count += 1
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 2520
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
long long h,w;
int main(){
	scanf("%lld%lld", &h, &w);
	if(h == 1 || w == 1) return puts("1") * 0;
	printf("%lld\n",(h*w+1)/2);
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <vector>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll nmax=50;

bool visited[nmax+1][nmax+1];
ll field[nmax+1][nmax+1];

ll h,w;

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

void dfs(ll x,ll y,ll h,ll w){
    field[x][y]=0;
    stack<P> stk;
    stk.push(P(x,y));
    visited[x][y]=true;

    while(!(stk.empty())){
        P p=stk.top();stk.pop();
        for(ll i=0;i<8;i++){
            ll nx=p.first+dx[i];
            ll ny=p.second+dy[i];
            if(0<=nx&&nx<h&&0<=ny&&ny<w&&field[nx][ny]==1&&(!visited[nx][ny])){
                field[nx][ny]=0;
                stk.push(P(nx,ny));
                visited[nx][ny]=true;
            }
        }
    }
}

int main() {
    while(true){
    ll w,h,ans;
    cin>>w>>h;
    if(w==0&&h==0)break;

    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
            cin>>field[i][j];
            visited[i][j]=false;
        }
    }
    ans=0;
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
            if(field[i][j]==1){
                dfs(i,j,h,w);
/*
                for(ll k=0;k<h;k++){
                    for(ll l=0;l<w;l++){
                        cout<<field[k][l]<<" ";
                    }
                    cout<<endl;
                }
*/
                ans++;
            }
        }
    }

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



Measured memory_bytes: 3180
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		long N = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();
		
		// 結果の出力
		System.out.println((N / (A+B)) * A + Math.min(A, N % (A+B)));

		sc.close();
	}
}


Measured memory_bytes: 23764
def rot(s):
  ret = s[-1]+s[:-1]
  return ret

s1=input()
s2=input()

tmp=s1
flag=False

for i in range(len(s1)):
  tmp=rot(tmp)
  if tmp == s2:
    flag=True
    
if flag:
  print('Yes')
else:
  print('No')

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

using namespace std;
using namespace __gnu_pbds;

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

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll a[3001];
vi adj[3001];
bool dp[3001];

void dfs(int u, int p)
{
	dp[u] = 0;
	ll sum = 0;
	bool leaf=1;
	bool exp1 = 0;
	ll mini = -1;
	for(int i = 0; i < adj[u].size(); i++)
	{
		int v = adj[u][i];
		if(v==p) continue;
		dfs(v,u);
		if(!dp[v]&&a[v]<a[u]) 
		{
			exp1=1;
		}
		leaf=0;
	}
	//cerr<<u<<' '<<sum<<' '<<mini<<' '<<'\n';
	
	if(leaf) 
	{
		dp[u]=0;
		return ;
	}
	if(!exp1) return ;
	dp[u]=1;
	//cerr<<u<<' '<<dp[u]<<'\n';
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i = 0; i < n; i++)
	{
		cin>>a[i];
	}
	for(int i = 0; i < n - 1; i++)
	{
		int u, v;
		cin>>u>>v;
		u--; v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	vi vec;
	for(int i = 0; i < n; i++)
	{
		dfs(i,-1);
		if(dp[i]) vec.pb(i);
	}
	for(int i = 0; i < vec.size(); i++)
	{
		cout<<vec[i]+1;
		if(i+1<vec.size()) cout<<' ';
	}
	cout<<'\n';
}


Measured memory_bytes: 768
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		int M, T, P, R;
		cin >> M >> T >> P >> R;
		if (M == 0) break;
		vector<int> a(T), b(T);
		vector< vector<int> > c(T, vector<int>(P));
		while (R--) {
			int m, t, p, j;
			cin >> m >> t >> p >> j;
			t--; p--;
			if (j == 0) {
				a[t]++;
				b[t] += m + c[t][p] * 20;
			}
			else c[t][p]++;
		}
		vector< pair<i_i, int> > v(T);
		for (int i = 0; i < T; i++)
			v[i] = make_pair(i_i(a[i], -b[i]), i);
		sort(v.begin(), v.end());
		reverse(v.begin(), v.end());
		for (int i = 0; i < T; i++) {
			if (i > 0) cout << (v[i - 1].first == v[i].first ? '=' : ',');
			cout << v[i].second + 1;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
/////////////////////////////////
int main(){
    int n;
    cin >> n;
    vector<int> a(n,0),b(n-1);
    rep(i, n-1) cin >> b[i];
    a[0] = b[0];
    a[n - 1] = b[n - 2];
    for (int i = 1; i < n - 1;i++)
            a[i] = min(b[i - 1], b[i]);
    int ans = 0;
    rep(i, n) ans += a[i];
    cout << ans << endl;
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n; string s;
    cin >> n >> s;

    if (n % 2 > 0) {
        cout << "No" << endl;
        return 0;
    }

    string subs = s.substr(0, n / 2);
    if (subs == s.substr(n / 2, n / 2)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

int main(){
  string a;
  cin >> a;
  if(a == "A" || a == "B" || a == "C" || a == "D" || a == "E" || a == "F" || a == "G" || a == "H" || a == "I" || a == "J" || a == "K" || a == "L" || a == "M" || a == "N" || a == "O" || a == "P" || a == "Q" || a == "R" || a == "S" || a == "T" || a == "U" || a == "V" || a == "W" || a == "X" || a == "Y" || a == "Z"){
    cout << "A" << endl;
  }else{
    cout << "a" << endl;
  }  
  
  
  
  return 0;
}


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

int main(){
  int w, h;
  
  int qi[10000], qj[10000];
  for(;;){
     char m[30][30];
     for(int i=0; i<30; i++){
       for(int j=0; j<30; j++){
         m[i][j] = '#';
       }
     }
    cin >> w >> h;
    if(w==0 && h==0) break;
    for(int i=0; i<h; i++){
      string s;
      cin >> s;
      for(int j=0; j<w; j++){
        m[i+1][j+1] = s[j];
        if(s[j]=='@'){
          qi[0] = i+1;
          qj[0] = j+1;
          m[i+1][j+1] = '.';
        }
      }
    }
    int nl=0, nr=1;
    int count = 0;
    while(nr-nl>0){
      int i = qi[nl];
      int j = qj[nl];
      if(m[i][j]=='@'){
        nl++;
      }else{
        m[i][j] = '@';
        count++;
        if(m[i+1][j]=='.'){
          qi[nr] = i+1;
          qj[nr] = j;
          nr++;
        }
        if(m[i-1][j]=='.'){
          qi[nr] = i-1;
          qj[nr] = j;
          nr++;
        }
        if(m[i][j+1]=='.'){
          qi[nr] = i;
          qj[nr] = j+1;
          nr++;
        }
        if(m[i][j-1]=='.'){
          qi[nr] = i;
          qj[nr] = j-1;
          nr++;
        }
        nl++;
      }
    }
    /*
    for(int i=0; i<h+2; i++){
      for(int j=0; j<w+2; j++){
        cout << m[i][j];
      }
      cout << endl;
    }
  */
    
    cout << count << endl;
  }

	return 0;
}

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

int main()
{
    long long X, Y;
    cin >> X >> Y;

    if (abs(X - Y) <= 1)
    {
        cout << "Brown" << endl;
    }
    else
    {
        cout << "Alice" << endl;
    }

    // vector<vector<bool>> dp(X + Y + 1, vector<bool>(X + Y + 1, false));
    // dp[0][0] = false;
    // dp[1][0] = false;
    // dp[0][1] = false;
    // dp[1][1] = false;
    // dp[2][0] = true;
    // dp[0][2] = true;
    // for (int distance = 3; distance <= X + Y; distance++)
    // {
    //     for (int x = 0; x <= distance; x++)
    //     {
    //         int y = distance - x;
    //         for (int i = 1; 2 * i <= x; i++)
    //         {
    //             if (!dp[x - 2 * i][y + i])
    //             {
    //                 dp[x][y] = true;
    //                 break;
    //             }
    //         }
    //         for (int i = 1; 2 * i <= y; i++)
    //         {
    //             if (!dp[x + i][y - 2 * i])
    //             {
    //                 dp[x][y] = true;
    //                 break;
    //             }
    //         }
    //     }
    // }
    // for (auto a : dp)
    // {
    //     for (auto b : a)
    //     {
    //         cout << b << " ";
    //     }
    //     cout << endl;
    // }
    // if (dp[X][Y])
    // {
    //     cout << "Alice" << endl;
    // }
    // else
    // {
    //     cout << "Brown" << endl;
    // }
}


Measured memory_bytes: 256
use std::io::Read;
use std::collections::HashMap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut counts: HashMap<(isize, usize, usize), usize> = HashMap::new();
    let mut zero: usize = 0;
    for _ in 0..n {
        let mut ai: isize = iterator.next().unwrap().parse().unwrap();
        let mut bi: isize = iterator.next().unwrap().parse().unwrap();
        if ai == 0 && bi == 0 {
            zero += 1;
            continue;
        }
        let mut sign: isize = 1;
        if ai < 0 {
            sign *= -1;
            ai *= -1;
        }
        if bi < 0 {
            sign *= -1;
            bi *= -1;
        }
        if ai == 0 || bi == 0 {
            sign = 1;
        }
        let ai: usize = ai as usize;
        let bi: usize = bi as usize;
        let g: usize = gcd(ai, bi);
        let ai = ai / g;
        let bi = bi / g;
        *counts.entry((sign, ai, bi)).or_insert(0) += 1;
    }

    let mut pairs: Vec<(usize, usize)> = Vec::new();
    let keys: Vec<(isize, usize, usize)> = counts.keys().into_iter().map(|it| *it).collect();
    for key in keys {
        if let Some(count1) = counts.get(&key) {
            let key2 = if key.1 != 0 && key.2 != 0 {
                (-key.0, key.2, key.1)
            } else {
                (key.0, key.2, key.1)
            };
            if let Some(count2) = counts.get(&key2) {
                pairs.push((*count1, *count2));
                counts.remove(&key2);
            } else {
                pairs.push((*count1, 0));
            }
            counts.remove(&key);
        }
    }

    let mut ans: usize = 1;
    for pair in pairs {
        let mut now: usize = 1;
        let s = pair.0;
        let t = pair.1;
        now += mod_pow(2, s) - 1;
        now %= MOD;
        now += mod_pow(2, t) - 1;
        now %= MOD;

        ans *= now;
        ans %= MOD;
    }
    ans += zero;
    ans %= MOD;
    if ans > 0 {
        ans -= 1;
    } else {
        ans = MOD - 1;
    }

    return ans.to_string();
}

fn gcd(mut x: usize, mut y: usize) -> usize {
    while y > 0 {
        let r = x % y;
        x = y;
        y = r;
    }
    return x;
}

const MOD: usize = 1000000007;

fn mod_pow(a: usize, b: usize) -> usize {
    let mut result = 1;
    for _ in 0..b {
        result = result * a % MOD;
    }
    return result
}


Measured memory_bytes: 25872
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main() {
  Cin(int, n);
  map<int, int> mp;
  for (int i = 0; i < n; ++i) {
    Cin(int, d);
    mp[d]++;
  }
  Cin(int, m);
  for (int i = 0; i < m; ++i) {
    Cin(int, t);
    if (mp[t] == 0) {
      puts("NO");
      return;
    }
    mp[t]--;
  }
  puts("YES");
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

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

	public static void main(String[] args) {
		int[] Num = new int[4];
		Scanner n=new Scanner(System.in);
		
		Num[0]=n.nextInt();
		Num[1]=n.nextInt();
		Num[2]=n.nextInt();
		
		for (int a = 1; a >= 0; a--){
			for (int b = 0; b <= 1; b++){
					if (Num[b] > Num[b+1]){
					Num[3]=Num[b];
					Num[b]=Num[b+1];
					Num[b+1]=Num[3];
					}//if終了
			}//内ループ終了
		}//外ループ終了
		System.out.println(Num[0]+" "+Num[1]+" "+Num[2]);
	}

}

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

int main(){
	priority_queue< pair<int,char> > PQ;

	int X,Y,A,B,C;	cin>>X>>Y>>A>>B>>C;
	for(int i=0;i<A;i++){
		int p;	cin>>p;
		PQ.push( {p,'R'} );
	}
	for(int i=0;i<B;i++){
		int q;	cin>>q;
		PQ.push( {q,'G'} );
	}
	for(int i=0;i<C;i++){
		int r;	cin>>r;
		PQ.push( {r,'x'} );
	}

	int R=0,G=0,x=0;
	long long ans=0;

	//cout<<"?"<<endl;
	while(R+G+x<(X+Y)){
		int p=PQ.top().first;
		char c=PQ.top().second;
		//cout<<p<<endl;
		PQ.pop();

		if(c=='R'&&R<X){
			++R;
			ans+=p;
		}else if(c=='G'&&G<Y){
			++G;
			ans+=p;
		}else if(c=='x'){
			++x;
			ans+=p;
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 6512
import sys

n = int(input())
h = list(map(int,input().split()))
h = h[::-1]

for i in range(n-1):
	if h[i] < h[i+1]:
		h[i+1] -= 1
		if h[i] < h[i+1]:
			print('No')
			sys.exit()

print('Yes')


Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ri register int
const long double PI=3.141592653589793238462643383279;
const int N=500005,M=998244353;
int n,i,s[N],d;
long long ans;
long long qpow(long long a,long long b)
{
	long long s=a,ans=1;
	while(b)
	{
		if(b&1)
			ans=ans*s%M;
		s=s*s%M;
		b>>=1;
	}
	return ans;
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)
	{
		scanf("%d",&d);
		if(i==1&&d!=0)
		{
			puts("0");
			return 0;
		}
		++s[d];
	}
	if(s[0]>1)
	{
		puts("0");
		return 0;
	}
	ans=1;
	for(i=1;i<=n;++i)
		ans=ans*qpow(s[i-1],s[i])%M;
	cout<<ans%M;
}


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

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

  int ans = 0;
  int size = (int)s.size();
  for (int i = 0; i < size; i++) {
    for (int j = i; j < size; j++) {
      bool is_acgt_only = true;

      for (int k = i; k <= j; k++) {
        char c = s.at(k);
        if (c != 'A' && c != 'C' && c != 'G' && c != 'T') {
          is_acgt_only = false;
        }
      }

      if (is_acgt_only) {
        ans = max(ans, (j-i+1));
      }
    }
  }

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

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

using namespace std;

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

struct UnionFind {
    //各要素が属する集合の代表(根)を管理する
    //もし、要素xが根であればdata[x]は負の値を取り、-data[x]はxが属する集合の大きさに等しい
    vector<int> data;

    UnionFind(int sz) : data(sz, -1) {}

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        bool is_union = (x != y);
        if (is_union) {
            if (data[x] > data[y]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return is_union;
    }

    int find(int x) {
        if (data[x] < 0) { //要素xが根である
            return x;
        } else {
            data[x] = find(data[x]); //data[x]がxの属する集合の根でない場合、根になるよう更新される
            return data[x];
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return -data[find(x)];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, K, L;
    cin >> n >> K >> L;
    UnionFind uf1(n), uf2(n);
    for (int i = 0; i < K; i++) {
        int p, q;
        cin >> p >> q;
        p--; q--;
        uf1.unite(p, q);
    }
    for (int i = 0; i < L; i++) {
        int p, q;
        cin >> p >> q;
        p--; q--;
        uf2.unite(p, q);
    }

    map<P, int> memo;
    vector<P> v;
    for (int i = 0; i < n; i++) {
        P tar(uf1.find(i), uf2.find(i));
        v.push_back(tar);
        memo[tar]++;
    }

    for (int i = 0; i < n; i++) {
        cout << memo[v[i]] << " \n"[i + 1 == n];
    }
    return 0;
}

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

int main()
{
	char youbi[3];
	int i;
	int result = 0;
	for (i = 0;i < 3;i++)
	{
		cin >> youbi[i];
	}
	switch (youbi[0])
	{
		case 'S':
			result = 7;break;
		case 'M':
			result = 6;break;
		case 'T':
			result = 5;break;
		case 'W':
			result = 4;break;
		case 'F':
			result = 2;break;
	}
	if (youbi[2] == 'U')
		result = 3;
	if (youbi[2] == 'T')
		result = 1;
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,m;cin>>n>>m;
    vector<int>a(n+1),b(m+1);
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<m;i++)cin>>b[i];
    sort(all(a));sort(all(b));
    reverse(all(a));reverse(all(b));
    ll ans=1;
    int big_x_a=0,big_x_b=0;
    for(int x=n*m;x>=1;x--){
        if(a[big_x_a]>x){
            cout<<0<<endl;
            return 0;
        }
        if(b[big_x_b]>x){
            cout<<0<<endl;
            return 0;
        }
        ll tmp=1;
        if(a[big_x_a]==x&&b[big_x_b]==x){
            tmp=1;
            big_x_b++;big_x_a++;
        }
        else if(a[big_x_a]==x){
            tmp=big_x_b;
            big_x_a++;
        }
        else if(b[big_x_b]==x){
            tmp=big_x_a;
            big_x_b++;
        }
        else{
            tmp=big_x_b*big_x_a-(n*m-x);
            if(tmp<=0){
                cout<<0<<endl;
                return 0;
            }
        }
        ans*=tmp;
        ans%=MOD;
        
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------









Measured memory_bytes: 256
N, M = map(int, input().split())
B = [False] * (N + 1)

for i in range(M):
    B[int(input())] = True


dp = [0 for i in range(N + 1)]

dp[0] = 1
dp[1] = 1
mod = 1000000007
for i in range(2, N + 1):
    if not B[i - 1]:
        dp[i] = (dp[i] + dp[i - 1]) % mod
    if not B[i - 2]:
        dp[i] = (dp[i] + dp[i - 2]) % mod
    if dp[i] == 0:
        break

print(dp[N])


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

int main() {
  string A;
  cin >> A;
  
  if ( A.at(0) == '7' ) {
    cout << "Yes" << endl;
  }
  else if ( A.at(1) == '7' ) {
    cout << "Yes" << endl;
  }  
  else if ( A.at(2) == '7' ) {
    cout << "Yes" << endl;
  }  
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }
 
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
 
inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}
 
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  if(s.size()==1){
    cout<<s<<endl;
    return 0;
  }
  
  bool flg=true;
  irep(i,1,s.size()){
    if(s[i]!='9') flg=false;
  }
  
  ll ans=9*(s.size()-1);
  if(!flg)ans+=s[0]-'0'-1;
  else ans+=s[0]-'0';
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<iterator>
#include<iostream>
#include<sstream>
#include<cctype>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<list>
#include<stack>
#include<functional>
#include<utility>
#include<numeric>
#include<bitset>
#include<iterator>
#define INF (int)1e9
#define MOD 1000000007
#define tr(c, it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define debug(x) cout<<#x" = "<<(x)<<endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz size
#define ll long long
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MEM(a, b) memset(a, (b), sizeof(a))
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?"\n":" ")
#define printv(a) printa(a,0,a.size())
#define print2d(a,r,c) for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?"\n":" ")
#define PRE(i, m, n, in) for(int (i)=(m);(i)<(n);i+=in)
#define RFOR(i, n) for(int i=n ; i>=0 ; i--)
#define RPRE(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define ERS(A, P) A.erase(A.begin() + P)
#define CPY(A, B) memcpy(A, B, sizeof(A))
#define INS(A, P, B) A.insert(A.begin() + P, B)
#define rev(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define grtsrt(v) sort(v.begin(),v.end(),greater<int>())
#define mnv(v) *min_element(v.begin(),v.end())
#define mxv(v) *max_element(v.begin(),v.end())
#define countv(v,a) count(v.begin(),v.end(),a)
#define toint(a) atoi(a.c_str())
using namespace std;
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
typedef vector <int> VI;
typedef vector <ll> VL;
typedef vector<string> VS;
typedef vector <VS> VSS;
typedef vector <II> VII;
typedef vector <LL> VLL;
typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VII> VVII;
typedef vector <VLL> VVLL;
typedef map<int,int> MPII;
typedef map<ll,ll> MPLL;
typedef map<string, int>MPSI;
typedef map<string, ll>MPSL;
typedef map<int, string>MPIS;
typedef map<ll, string> MPLS;
typedef map<string, string> MPSS;
typedef set<int> SETI;
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.txt", "r", stdin);
    string s; cin >> s;
    int num_1 = 0; // 2k: 0, 2k + 1: 1
    int num_2 = 0; // 2k: 1, 2k + 1: 0
    FOR(i, s.length()) {
      if(i % 2 == 0) {
        if(s[i] == '0') {
          num_2 += 1;
        }
        else {
          num_1 += 1;
        }
      }
      else {
        if(s[i] == '0') {
          num_1 += 1;
        }
        else {
          num_2 += 1;
        }
      }
      // std::cout << num_1 << " " << num_2 << '\n';
    }
    cout << min(num_1, num_2) << "\n";
    return 0;
}


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

typedef long long lint;
#define M 1000000007

int main(){
    lint N;
    cin >> N;

    pair<lint,bool> *map;
    map=new pair<lint,bool>[2*N];
    for(int i=0;i<2*N;i++){
        lint x;
        cin >> x;
        map[i]=make_pair(x,i<N);
    }

    sort(map,map+2*N);
    
    lint cnt=0,addr=0;
    bool isPC;

    lint ptn=1;
    while(addr<2*N){
        if(cnt==0){
            isPC=map[addr].second;
            cnt++;
            addr++;
        }else{
            if(isPC==map[addr].second) cnt++;
            else{
                ptn=ptn*cnt%M;
                cnt--;
            }
            addr++;
        }
    }

    cout << ptn << endl;

    delete[] map;
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int w[105];
int main(){
	int n,maxw=0,ans=1e9;
	cin>>n;
	for(int i=1;i<=n;i++)
	 cin>>w[i],maxw=max(w[i],maxw);
	for(int i=1;i<=maxw;i++)
	 {int s1=0,s2=0;
	 for(int j=1;j<=n;j++)
	  if(j<=i)s1+=w[j];
	  else s2+=w[j];
	 ans=min(ans,abs(s1-s2));
	 }
	 cout<<ans<<endl;
}

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

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

	if (a < b)
	{
		int tmp = a;
		a = b;
		b = tmp;
	}

	int c = a - b;

	if (c <= 1)
	{
		cout << "Yay!" << endl;
		return 0;
	}

	int d = 16 - 2 * b;
	
	if (d >= c * 2 + 1)
	{
		cout << "Yay!" << endl;
	}
	else
	{
		cout << ":(" << endl;
	}

	return 0;
}


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

struct Set
{
    ll a, b;
    bool operator<(const Set& rhs) const
    {
        return a > rhs.a;
    }
};

int main() 
{
   int n, m;
   cin >> n >> m;
   priority_queue<Set> que;
   rep(i, n) {
       Set set;
       cin >> set.a >> set.b;
       que.push(set);
   }
   ll money = 0;
   while (m > 0) {
       Set set = que.top();
       que.pop();
       ll a, b;
       a = set.a;
       b = set.b;
       if (m >= b) {
           m -= b;
           money += a * b;
       }
       else {
           money += a * m;
           break;
       }
   }
   cout << money << endl;
   return 0;
}

Measured memory_bytes: 2420
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_120
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            string s = Read();
            int rCnt = 0;
            int bCnt = 0;
            int res = 0;
            for(int i = 0; i < s.Length; i++)
            {
                if (s[i] == '0')
                {
                    if (bCnt > 0)
                    {
                        bCnt--;
                        res += 2;
                    }
                    else
                    {
                        rCnt++;
                    }
                }
                else
                {
                    if (rCnt > 0)
                    {
                        rCnt--;
                        res += 2;
                    }
                    else
                    {
                        bCnt++;
                    }
                }
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
import sys

class Solution(object):
    def __init__(self):
        self.n = int(sys.stdin.readline())
        a = sys.stdin.readline().split()
        self.d = [int(x) for x in a]

    def get_takoyaki_combo_sum(self):
        #option 1 Brute Force
        sum = 0
        for i in range(len(self.d)-1):
            for j in range(i+1, len(self.d)):
                sum += self.d[i] * self.d[j]
        return sum


if __name__ == "__main__":
    s = Solution()
    print(s.get_takoyaki_combo_sum())

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

int GetDigit(int num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main(){
    int n, dig;
    int x;
    
    cin >> n;
    //331 is overlaps
    for(int i = 3; i <= n; i++){
        dig = GetDigit(i);
        if((i % 3) == 0){
            cout << " " << i;
        }
        else{
            x = i;
            if((x % 10) == 3){
                cout << " " << i;
            }
            else{
                for(int j = 0; j < dig; j++){
                    x /= 10;
                    if((x % 10) == 3){
                        cout << " " << i;
                        break;
                    }
                }
            }
        }
        
    }
    
    cout << endl;
    
    return 0;
    
}


Measured memory_bytes: 3096
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		ArrayList<String> list = new ArrayList<>();
		Map<String, Integer> map = new HashMap<>();
		
		for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String str = new String(s);
			list.add(str);
			
			Integer v = map.get(str);
			map.put(str, v == null ? 1 : v + 1);
		}
		
		long cnt = 0;
		
		for ( Entry<String, Integer> en : map.entrySet() ) {
			Integer n1 = en.getValue();
			cnt += nCr(n1, 2);			
		}
		
		System.out.println(cnt);
		in.close();
	}
	
	private static long nCr(int n, int r) {
		if ( r == 0 ) return 1;
		return n * nCr(n - 1, r - 1) / r;
	}
}


Measured memory_bytes: 59996
#include<iostream>
using namespace std;
#define rep(a,b) for(int a=1;a<b;a++)
int gcd(int a,int b){
	if(a%b==0){
		return b;
	}else{
		return gcd(b,a%b);
	}
}
int main(){
	int num;
	cin >> num;
	num ++;
	int sum=0;
	rep(i,num){
		rep(j,num){
			rep(k,num){
				sum+=gcd(i,gcd(j,k));
			}
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 3544
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

int q;
string s1,s2;
int ans;
int dp[1510][1501];
int main()
{
	cin>>q;
	rep(i,q){
		cin>>s1>>s2;
		rep(i,s1.size()){
			rep(j,s2.size()){
				dp[i][j]=0;
			}
		}
		if(s1[0]==s2[0]) dp[0][0]=1;
		rep1(i,s1.size()-1){
			if(s1[i]==s2[0]) dp[i][0]=1;
			dp[i][0]=max(dp[i][0],dp[i-1][0]);
		}
		rep1(i,s2.size()-1){
			if(s1[0]==s2[i]) dp[0][i]=1;
			dp[0][i]=max(dp[0][i],dp[0][i-1]);
		}
		rep1(i,s1.size()-1){
			rep1(j,s2.size()-1){
				dp[i][j]=max( dp[i-1][j], dp[i][j-1] );
				if(s1[i]==s2[j]) dp[i][j]= max(dp[i][j],dp[i-1][j-1]+1);
			}
		}
		cout<<dp[s1.size()-1][s2.size()-1]<<endl;
	}
}


Measured memory_bytes: 8940
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstring>

using namespace std;

const int N = 100000 + 5;
const int MOD = 1000000000 + 7;

int n;
int x[N];

void solve()
{
    cin >> n;
    for(int i = 0; i < n; ++ i) {
        scanf("%d", x + i);
    }
    long long ans = 1;
    int cur = 1;
    int cnt = 1;
    for(int i = 0; i < n; ++ i) {
        if (x[i] >= cur) {
            cnt ++;
            cur += 2;
            continue;
        }
        ans = ans * cnt % MOD;
    }
    for(int i = 1; i <= cnt - 1; ++ i) {
        ans = ans * i % MOD;
    }
    cout << ans << endl;
}

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


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

int main()
{
	int x,y;
	cin>>x>>y;
	char a[105][105];
	bool s[105][105];
	for(int i=1;i<=x;i++)
		for(int j=1;j<=y;j++)
		{
			cin>>a[i][j];
			s[i][j]=1;
		}	
	for(int i=1;i<=x;i++)
	{
		int f=1;
		for(int j=1;j<=y;j++)
		{
			if(a[i][j]=='#'){
				f=0;
				break;
			} 
		}
		if(f){
			for(int j=1;j<=y;j++)
				s[i][j]=false;
		}
	}
	for(int j=1;j<=y;j++)
	{
		int f=1;
		for(int i=1;i<=x;i++)
		{
			if(a[i][j]=='#'){
				f=0;
				break;
			} 
		}
		if(f){
			for(int i=1;i<=x;i++)
				s[i][j]=false;
		}
	}
	for(int i=1;i<=x;i++)
	{
		int f=0;
		for(int j=1;j<=y;j++)
		{
			if(s[i][j]){
				cout<<a[i][j];
				f=1;
			} 
		}
		if(f) cout<<endl;
	}
	return 0;
}


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

const int di[] = {-1, 0, 1, 0};
const int dj[] = { 0,-1, 0, 1};

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    rep(i,H) cin >> s.at(i);
    int ans = 0;
    rep(si,H) rep(sj,W){
        if(s.at(si).at(sj) == '#') continue;
        vector<vector<int>> cost(H, vector<int>(W, INF));
        queue<P> q;
        auto update = [&](int i, int j, int c){
            if(cost[i][j] != INF) return;
            cost[i][j] = c;
            q.push(P(i,j));
        };
        update(si, sj, 0);
        while(!q.empty()){
            int i = q.front().first;
            int j = q.front().second;
            q.pop();
            rep(k,4){
                int ni = i + di[k];
                int nj = j + dj[k];
                if(ni < 0 || H <= ni || nj < 0 || W <= nj) continue;
                if(s[ni][nj] == '#') continue;
                update(ni, nj, cost[i][j] + 1);
            }
        }
        rep(ci,H) rep(cj,W){
            if(cost[ci][cj] == INF) continue;
            ans = max(ans, cost[ci][cj]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256