akhauriyash/Code-Regression huggingface dataset:
def main():
    #import sys
    #input = sys.stdin.readline
    N = int(input())
    
    prime = []
    primecount = []
    
    for i in range(1,N+1):
        count = 0
        for j in range(1,i+1):
            if i%j == 0:
                count += 1
        if count == 2:
            prime.append(i)
    
    for i in range(len(prime)):
        tmp = 0
        tmpN = N
        powP = prime[i]
        while tmpN // powP > 0:
            tmp += tmpN//powP
            powP *= prime[i]
        primecount.append(tmp+1)
    
    n3 = 0
    n5 = 0
    n15 = 0
    n25 = 0
    n75 = 0
    for i in range(len(primecount)):
        k = primecount[i]
        if k >= 75:
            n75 += 1
        if k >= 25:
            n25 += 1
        if k >= 15:
            n15 += 1
        if k >= 5:
            n5 += 1
        if k >= 3:
            n3 += 1
    #print(primecount)
    #print(n3,n5,n15,n25,n75)
    
    ans = n25*(n3 - 1) + n5*(n5 - 1)*(n3 - 2)//2 + n15*(n5 - 1) + n75
    print(ans)
    
main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int H, W, N; cin >> H >> W >> N;
    cout << min((N + H - 1) / H, (N + W - 1) / W) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import Counter
def main():
    S = input().rstrip()
    C = Counter(S)
    n = C['N']
    s = C['S']
    w = C['W']
    e = C['E']
    if (n != 0 and s != 0) or (n == 0 and s == 0):
        if (w != 0 and e != 0) or (w == 0 and e == 0):
            print('Yes')
        else:
            print('No')
    else:
        print('No')

if __name__ == '__main__':
    main()

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int sz, ans=0;
	string s, t;
	cin>> s >> t;

	sz=s.size();

	rep(i, sz){
		if(s[i]!=t[i]) ans++;
	}

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

Measured memory_bytes: 3916
#include <iostream>
#include <vector>

using namespace std;

struct data_t {
	int x;
	int y;
	int z;
};


int main(void) {
	int N,Y;
	cin >> N >> Y;
	int lim = Y/1000;
	vector<data_t> dp(lim+1);
	for (int i = 0; i < lim+1; ++i) {
		dp[i].x = dp[i].y = dp[i].z = -1;
	}
	dp[0].x = dp[0].y = dp[0].z = 0;

	for (int i = 0; i < N; ++i) {
		for (int j = lim; j > -1; --j) {
			if (dp[j].x != -1) {
				if (j+1 < lim+1) {
					dp[j+1].x = dp[j].x;
					dp[j+1].y = dp[j].y;
					dp[j+1].z = dp[j].z + 1;
				}
				if (j+5 < lim+1) {
					dp[j+5].x = dp[j].x;
					dp[j+5].y = dp[j].y + 1;
					dp[j+5].z = dp[j].z;
				}
				if (j+10 < lim+1) {
					dp[j+10].x = dp[j].x + 1;
					dp[j+10].y = dp[j].y;
					dp[j+10].z = dp[j].z;
				}
				dp[j].x = dp[j].y = dp[j].z = -1;
			}
		}
	}
	cout << dp[lim].x << " ";
	cout << dp[lim].y << " ";
	cout << dp[lim].z << endl;
	return 0;
}


Measured memory_bytes: 512
// Chocolate

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int main() {
    int n,d,x;
    cin >> n;
    cin >> d >> x;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    for (int i = 0; i < n; i++) {
        x += ((d - 1) / a[i]) + 1;
    }

    cout << x << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()

int n, m, x;
vector <vector <int> > a;
int lvl[14];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> x;
    a.resize(n + 3);
    for(int i = 1; i <= n; ++i) {
        a[i].resize(m + 3);
        cin >> a[i][0];
        for(int j = 1; j <= m; ++j) cin >> a[i][j];
    }
    ll ans = 1e18;
    for(int mask = 1; mask < (1 << n); ++mask) {
        memset(lvl, 0, sizeof(lvl));
        vector <vector <int> > cur;
        for(int i = 0; i < n; ++i) if((mask >> i) & 1) cur.pb(a[i + 1]);
        ll price = 0;
        for(int i = 0; i < cur.sz; ++i) {
            price += cur[i][0];
            for(int j = 1; j <= m; ++j)
                lvl[j] += cur[i][j];
        }
        bool ch = 0;
        for(int i = 1; i <= m; ++i) if(lvl[i] < x) ch = 1;
        if(!ch) ans = min(ans, price);
    }
    cout << (ans == 1e18 ? -1 : ans);
    return 0;
}


Measured memory_bytes: 3664
#include<cstdio>
#include<cstring>
#include<algorithm>
typedef long long ll;
using namespace std;
const int maxn=2e5+5;

int a[maxn];
int main()
{
    int k,n,x;
    scanf("%d%d",&k,&n);
    x=0;
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    a[n+1]=a[1]+k;
    for(int i=2;i<=n+1;i++)
        x=max(x,a[i]-a[i-1]);
    printf("%d\n",k-x);
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int N = scanner.nextInt();
            int[] vs = new int[N];
            for (int i = 0; i < N; i++) {
                vs[i] = scanner.nextInt();
            }
            Map<Integer, Integer> oddMap = new HashMap<>();
            Map<Integer, Integer> evenMap = new HashMap<>();
            for (int i = 0; i < N; i++) {
                if (i % 2 == 0) {
                    evenMap.compute(vs[i], (k,v) -> v == null ? 1 : v + 1);
                } else {
                    oddMap.compute(vs[i], (k,v) -> v == null ? 1 : v + 1);
                }
            }
            int result = Math.min(compute(N, evenMap, oddMap), compute(N, oddMap, evenMap));
            System.out.println(result);
        }
    }

    static int compute(int n, Map<Integer, Integer> firstMap, Map<Integer, Integer> secondMap) {
        Map.Entry<Integer, Integer> firstKv = firstMap.entrySet().stream().sorted((lhs, rhs) -> rhs.getValue() - lhs.getValue())
                .findFirst().get();
        final int firstVal = firstKv.getKey();
        int change = n / 2 - firstKv.getValue();

        Optional<Map.Entry<Integer, Integer>> secondKv = secondMap.entrySet().stream()
                .filter(kv -> kv.getKey() != firstVal)
                .sorted((lhs, rhs) -> rhs.getValue() - lhs.getValue())
                .findFirst();
        if (secondKv.isPresent()) {
            change += n / 2 - secondKv.get().getValue();
        } else {
            change += n / 2;
        }
        return change;
    }
}


Measured memory_bytes: 55888
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない



int main() {

	ll x;
	cin >> x;
	if (x <= 6) {
		cout << 1 << endl;
	}
	else if (x%11==0) {
		cout << x / 11 * 2 << endl;
	}
	else if(x%11<=6){
		cout << x / 11 * 2 + 1 << endl;
	}
	else {
		cout << x / 11 * 2 + 2 << endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string str;
	cin >> str;
	long long one = 0, two = 0;
	long long arr1[str.size() + 50] = {0}, arr2[str.size() + 50] = {0};
	for(int i=0; i<str.size(); i++)
	{
		if(str[i] == '<') one ++;
		else			  one = 0;
		arr1[i + 1] = one;
	}
	for(int i=str.size() - 1; i >= 0; i --)
	{
		if(str[i] == '>') two ++;
		else			  two = 0;
		arr2[i] = two;
	}
	long long ans = 0;
	for(int i=0; i<=str.size(); i++)
	{
//		cout << arr1[i] << ' ' << arr2[i] << '\n';
		ans += max(arr1[i], arr2[i]);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 8708
#include<iostream>
#include<set>
#include<map>
using namespace std;

typedef pair<int,int> P;

int dir(char a){
  if(a=='E')return 0;
  if(a=='N')return 1;
  if(a=='W')return 2;
  if(a=='S')return 3;
  return -1;
}

char inv_dir(int a){
  if(a==0)return 'E';
  if(a==1)return 'N';
  if(a==2)return 'W';
  return 'S';
}

int main(){
  int h,w;
  string grid[30];
  bool use[30][30];
  int dx[] = {1,0,-1,0},dy[] = {0,-1,0,1};

  while(cin >> w >> h && (w||h)){
    for(int i=0;i<h;i++)cin >> grid[i];

    int ans = 0;
    while(ans<=180){
      set<P> s;
      int num = 0;
      for(int i=0;i<h;i++){
	for(int j=0;j<w;j++){
	  int d = dir(grid[i][j]);
	  if(0<=d){
	    num++;
	    for(int k=-1;k<3;k++){
	      int dd = (d+k+4)%4;
	      int sy = i+dy[dd], sx = j+dx[dd];
	      if(sy<0 || sx<0 || h<=sy || w<=sx)continue;
	      if(grid[sy][sx] == '.' || grid[sy][sx] == 'X'){
		grid[i][j] = inv_dir(dd);
		s.insert(P(sy,sx));
		break;
	      }
	    }
	  }
	}
      }
      if(!num)break;
      for(int i=0;i<h;i++)
	for(int j=0;j<w;j++)use[i][j] = false;

      set<P>::iterator ite;
      for(ite=s.begin();ite!=s.end();ite++){
	int i=(*ite).first,j=(*ite).second;
	if(!use[i][j] && (grid[i][j] == '.' || grid[i][j] == 'X')){
	  for(int k=0;k<4;k++){
	    int sy = i+dy[k], sx = j+dx[k];
	    if(sy<0 || sx<0 || h<=sy || w<=sx || use[sy][sx])continue;
	    int d = dir(grid[sy][sx]);
	    if(d<0)continue;
	    int dd = (k+2)%4;
	    if(d==dd){
	      grid[sy][sx] = '.';
	      if(grid[i][j]!='X')grid[i][j] = inv_dir(d);
	      use[sy][sx] = true;
	      break;
	    }
	  }
	}
	use[i][j] = true;
      }
      ans++;
    }
    if(ans>180)cout << "NA\n";
    else cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>

using namespace std;

int main(void){
	string s;
	int w;

	cin >> s;

	cin >> w;

	for (int i = 0; i < s.size(); i++){
		if (i % w == 0)
			cout << s[i];
	}

	cout << endl;
}


Measured memory_bytes: 256
S = input()
answer = 'Yes'
for i in range(len(S)):
    if S[i] == 'R' and i % 2 == 1:
        answer = 'No'
        break
    elif S[i] == 'L' and i % 2 == 0:
        answer = 'No'
        break
print(answer)

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, M;
    vector<pair<ll, ll>> AB;
    ll count = 0;
    ll money = 0;
    cin >> N >> M;
    rep(i, N) {
        ll A, B;
        cin >> A >> B;
        AB.push_back({A, B});
    }
    sort(AB.begin(), AB.end());
    iter(i, AB) {
        count += i.second;
        money += i.first * i.second;
        if(count >= M) {
            ll temp = count - M;
            money -= i.first * temp;
            break;
        }
    }
    cout << money << endl;
    return 0;
}


Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

	Scanner sc = new Scanner(System.in);

	int aliceOn = sc.nextInt();
	int aliceOff = sc.nextInt();
	int bobOn = sc.nextInt();
	int bobOff = sc.nextInt();

	int ans;

	if(aliceOff < bobOn){
		ans = 0;
	} else if(bobOff < aliceOn) {
		ans = 0;
	} else if(aliceOn <= bobOn && aliceOff >= bobOff) {
		ans = bobOff - bobOn;
	} else if(aliceOn >= bobOn && aliceOff <= bobOff) {
		ans = aliceOff - aliceOn;
	} else if(aliceOn > bobOn) {
		ans = bobOff - aliceOn;
	} else {
		ans = aliceOff - bobOn;
	}

	System.out.println(ans);

	sc.close();

	}

}

Measured memory_bytes: 23380
n, m, c = gets.chomp.split(" ").map(&:to_i)
b = gets.chomp.split(" ").map(&:to_i)
ans = 0
n.times do
    a = gets.chomp.split(" ").map(&:to_i)
    res = 0
    m.times do |i|
        res += a[i] * b[i]
    end
    ans += 1 if res+c > 0
end
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
ll m,n;
cin>>m>>n;
char arr[m][n];
for(ll i=0;i<m;i++){
    for(ll j=0;j<n;j++){
        cin>>arr[i][j];
    }
}
ll dp[m][n];
memset(dp,0,sizeof(dp));
ll i=0;
while(arr[0][i]!='#' && i<n){
    dp[0][i++]=1;
}
ll k=0;
while(arr[k][0]!='#' && k<m){
    dp[k++][0]=1;
}
ll mod=1000000007;
for(ll i=1;i<m;i++){
    for(ll j=1;j<n;j++){
        if(arr[i-1][j]!='#')dp[i][j]=(dp[i][j]%mod+dp[i-1][j]%mod)%mod;
        if(arr[i][j-1]!='#')dp[i][j]=(dp[i][j]%mod+dp[i][j-1]%mod)%mod;
    }
}
cout<<dp[m-1][n-1];
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int A[101010];

int main(){
    
    // 1. 入力情報.
    int N, K, S;
    scanf("%d %d %d", &N, &K, &S);
    
    // 2. 数列 A[1], ... , A[N] を 構成.
    rep(i, N){
        if(i < K) A[i] = S;
        else      A[i] = (S > 1e5) ? 1 : S + 1;
    }
    
    // 3. 出力.
    rep(i, N){
        printf("%d", A[i]);
        if(i < N - 1) printf(" ");
    }
    puts("");
    return 0;
    
}

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

int main(){
	ll n,k;cin>>n>>k;
	ll M = -1;
	vector<ll> a(n);
	for(int i = 0; i < n; i++) {
		cin>>a[i];
		M = max(M,a[i]); 
	}
	ll G = a[0];
	for(int i = 1; i < n; i++) {
		G = __gcd(G,a[i]);
	}
	if(k <= M && k % G == 0){
		cout << "POSSIBLE" << endl;
	}
	else{
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
//#pragma GCC optimize("O3") 
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") 
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
//#define TASK "triangle"
#define pb push_back
#define fi first
#define se second
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) (void)42
#endif

// every true-boy doesn't read statement!

typedef long long ll;
typedef vector < ll > vi;
typedef pair < ll, ll > pll;
typedef long double ld;

int X;
set < int > st;
	
bool check(int val) {
	st.clear();
	int x = X, d;
	while (x > 0) {
		while (val > 0) {
			d = min(val, x);
			val--;
			if (!st.count(d)) {
				x -= d;
				st.insert(d);
				break;
			}
		}
		if (val <= 0)
			break;
	}
	return (x == 0);
}

void solve() {
	cin >> X;
	int l = 0, r = min((int)1e9, X), mid;
	while (r - l > 1) {
		mid = l + ((r - l) >> 1);
		if (check(mid))
			r = mid;
		else
			l = mid;
	}
	cout << r << "\n";
}

int main() {
	//ios_base::sync_with_stdio(0);
	//cin.tie(0);
#ifdef LOCAL
	assert(freopen("xxx.in", "r", stdin));
	assert(freopen("xxx.out", "w", stdout));
#else
	//assert(freopen(TASK".in", "r", stdin));
	//assert(freopen(TASK".out", "w", stdout));
#endif
	solve();
	return 0;
}


Measured memory_bytes: 2432
n = int(input().split()[0])

point_list = []

for i in range(n):
    r, p = list(map(str, input().split()))
    data = dict(index=i+1, city=r, point=int(p))
    point_list.append(data)

sorted_list = sorted(point_list, key=lambda x: (x['city'], -x['point']))

for data in sorted_list:
    print(data['index'])



Measured memory_bytes: 3060
import queue

k=int(input())

q = queue.Queue()


for i in range(1,10):
    q.put(i)


for n in range(1,k+1):
    a = q.get()
    c = a % 10
    if c != 0:
       q.put(10*a + c-1)
    q.put(10*a + c)
    if c != 9:
       q.put(10*a + c+1)

print(a)
    

Measured memory_bytes: 18776
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10, 18);
const int MOD = pow(10, 9) + 7;
/* contest template */
int N, M, X, cost0, costn;
int A[100];

int main() {
  cin >> N >> M >> X;
  for (int i = 0; i < M; i++) {
    cin >> A[i];
  }

  for (int i = X; i >= 0; i--) {
    for (int j = 0; j < M; j++) {
      if (A[j] == i) cost0++;
    }
  }
  for (int i = X; i <= N; i++) {
    for (int j = 0; j < M; j++) {
      if (A[j] == i) costn++;
    }
  }

  cout << min(cost0, costn) << endl;
  return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N, M; cin >> N >> M;
  vector<int> d(3, -1);
  bool bad = 0;
  rep(i, M) {
    int s, c; cin >> s >> c; s--;
    if (d[s] >= 0 && d[s] != c) {
      bad = 1;
    }
    d[s] = c;
  }
  if ((N > 1 && d[0] == 0) || (N > 2 && d[0] == -1 && d[1] == 0)) {
    bad = 1;
  }
  if (bad) {
    cout << "-1\n";
  } else {
    rep(i, N) {
      if (d[i] >= 0) {
        cout << d[i];
      } else if (N > 1 && i == 0) {
        cout << "1";
      } else {
        cout << "0";
      }
    }
    cout << "\n";
  }
}


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

int main() {
    string s;
    cin >> s;
    while(1) {
        int size = s.size();
        if (size < 5) break;
        string five_letters = s.substr(size-5, size);
        if(five_letters == "dream" || five_letters == "erase"){
            for(int i=0; i<5; i++) s.pop_back();
            continue;
        }
        string six_letters = s.substr(size-6, size);
        if(six_letters == "eraser"){
            for(int i=0; i<6; i++) s.pop_back();
            continue;
        }
        string seven_letters = s.substr(size-7, size);
        if(seven_letters == "dreamer"){
            for(int i=0; i<7; i++) s.pop_back();
            continue;
        }
        break;
    }
    if(s == "") cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
a = Counter(A)
q = int(input())
bc = [list(map(int, input().split())) for _ in range(q)]

ans = sum(A)
for b,c in bc:
    ans -= b*a[b]
    ans += c*a[b]
    if b in a:
        if c in a: a[c] += a[b]
        else: a[c] = a[b]
        a.pop(b)
    print(ans)

Measured memory_bytes: 36748
#include<bits/stdc++.h>
#define eps 5e-7
using namespace std;
int n,k;
double x[62],y[62],c[62];
queue<tuple<double,double,double> > q;
double xp,yp,ap,lb;
double opt(double xx,double yy,double aa){
	vector<double> aux;
	for(int i=1;i<=n;i++){
		aux.push_back(c[i]*hypot(max(abs(xx-x[i])-aa,0.00),max(abs(yy-y[i])-aa,0.00)));
	}
	nth_element(aux.begin(),aux.begin()+k-1,aux.end());
	return aux[k-1];
}
double rel(double xx,double yy){
	vector<double> aux;
	for(int i=1;i<=n;i++){
		aux.push_back(c[i]*hypot(xx-x[i],yy-y[i]));
	}
	nth_element(aux.begin(),aux.begin()+k-1,aux.end());
	return aux[k-1];
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>x[i]>>y[i]>>c[i];
	q.emplace(0.0,0.0,1000.0);
	double res=1e9;
	while(q.size()){
		tie(xp,yp,ap)=q.front();
		q.pop();
		lb=opt(xp,yp,ap);
		if((res-lb)<=(eps*max(1.0,lb)))
			continue;
		res=min(res,rel(xp,yp));
		for(double dx:{-0.5,0.5}){
			for(double dy:{-0.5,0.5}){
				q.emplace(xp+dx*ap,yp+dy*ap,ap/2.00);
			}
		}
	}
	cout<<fixed<<setprecision(15)<<res<<endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.*;

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

        String S = sc.next();

        if(S.equals("Sunny")){
            System.out.println("Cloudy");
        }
        else if(S.equals("Cloudy")){
            System.out.println("Rainy");
        }
        else if(S.equals("Rainy")){
            System.out.println("Sunny");
        }
    }
}

Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <utility>
#include <complex>
#include <stack>
#include <climits>
#include <set>
#include <numeric>

using namespace std;

typedef complex<double> P;
double sq(double x){return x*x;}

double cross(P x,P y){
	return x.real() * y.imag() - x.imag() * y.real();
}

int main(){
	double x[4],y[4];
	while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",x,y,x+1,y+1,x+2,y+2,x+3,y+3)){
		P p[4];
		for (int i = 0; i < 4; i++)
			p[i] = P(x[i],y[i]);
		bool f[4];
		memset(f,0,4);
		for (int i = 0; i < 4; i++)
			if(cross(p[(i+2)&3] - p[(i+1)&3],p[i] - p[(i+1)&3]) < 0)
				f[i] = true;
		int sum = accumulate(f,f+4,0);
		if(sum == 0 || sum == 4) puts("YES");
		else puts("NO");

	}

	return 0;
}

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

typedef long long ll;
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
#define all(a) a.begin(),a.end()
#define MOD 1000000007
using namespace std;
ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}
ll lcm(ll n, ll m) {return m / gcd(n, m) * n;}

int main(void) {
	ll n,Max=0;
	string ans = "yes";
	cin >> n;
	vector<ll> d(n);
	for (ll i = 0; i < n; i++)
		cin >> d[i];
	for (ll i = 0; i < n; i++) {
		Max = max(Max,i*10+d[i]);
		
		if (Max < 10 * (i+1))
			ans = "no";
	}
	Max = 0;
	for (ll i = n - 1; i >= 0; i--) {
		Max = max(Max, (n-i-1)*10+d[i]);
		if (Max < 10 * (n-i))
			ans = "no";
	}
	cout << ans << endl;
	return 0;
}


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

const int N = 100005;

int n, a[N];
long long f[N], g[N];

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", a + i);
        f[i] = f[i - 1] + abs(a[i] - a[i - 1]);
    }
    for (int i = n; i >= 1; i--)
        g[i] = g[i + 1] + abs(a[i] - a[i + 1]);
    for (int i = 1; i <= n; i++)
        printf("%lld\n", f[i - 1] + abs(a[i - 1] - a[i + 1]) + g[i + 1]);
}

Measured memory_bytes: 3200
# inputs
text = input()
num = int(input())
orders = []
for i in range(num):
    orders.append(input().split())

# output
for order in orders:
    r1 = int(order[1])
    r2 = int(order[2])
    if order[0] == 'print':
        print(text[r1:r2+1])
    elif order[0] == 'reverse':
        if r1 == 0:
            text = text[:r1] + text[r2::-1] + text[r2+1:]
        else:
            text = text[:r1] + text[r2:r1-1:-1] + text[r2+1:]
    elif order[0] == 'replace':
        text = text[:r1] + order[3] + text[r2+1:]



Measured memory_bytes: 5620
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int N[] = new int[4];
		for(int n=0;n<4;n++){
			N[n] = sc.nextInt();
		}
		boolean a = false;
		boolean b = false;
		boolean c = false;
		boolean d = false;
		for(int n=0;n<4;n++){
			if(N[n]==1){
				a=true;
			}
			if(N[n]==9){
				b=true;
			}
			if(N[n]==7){
				c=true;
			}
			if(N[n]==4){
				d=true;
			}
		}
		if(a&&b&&c&&d){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}

	}
}

Measured memory_bytes: 23252
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int64_t n;
	cin >> n;

	int64_t s = 0;
	for(int i = 1; i <= n; i++) {
		if(i % 3 == 0 or i % 5 == 0) {

		} 
		else {
			s += i;
		}
	}

	cout << s << '\n';
}

Measured memory_bytes: 3640
# 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 <bitset>
# include <complex>
#include<limits.h>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 998244353;
const ll INF = 1LL << 60;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
int main() {
	string s;
	cin >> s;
	vector<ll>st;
	rep(i, s.size()) {
		if (s[i] == '0')st.push_back(0);
		if (s[i] == '1')st.push_back(1);
		if (s[i] == 'B' && !st.empty())st.pop_back();
	}
	rep(i, st.size())cout << st[i];
	cout << "" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<iostream>
#define llong long long
using namespace std;

inline int read()
{
	int x=0; bool f=1; char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=0;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(c^'0');
	if(f) return x;
	return -x;
}

const int N = 2e5;
struct Element
{
	int u,v,typ;
} a[N+3];
int uf[N+3];
int n,q,c; llong m;

int findfa(int u) {return uf[u]==u?u:uf[u]=findfa(uf[u]);}

int main()
{
	scanf("%d%lld%d",&n,&m,&q);
	for(int i=1; i<=n; i++) uf[i] = i;
	for(int i=1; i<=q; i++)
	{
		scanf("%d%d%d",&a[i].u,&a[i].v,&a[i].typ); a[i].u++; a[i].v++;
		if(a[i].typ==0)
		{
			int uu = findfa(a[i].u),vv = findfa(a[i].v);
			if(uu!=vv) {uf[uu] = vv;}
		}
	}
	int cnt1 = 0; c = 0;
	for(int i=1; i<=n; i++) {if(i==findfa(i)) c++;}
	for(int i=1; i<=q; i++)
	{
		if(a[i].typ==1)
		{
			cnt1++;
			int uu = findfa(a[i].u),vv = findfa(a[i].v);
			if(uu==vv) {puts("No"); return 0;}
		}
	}
	llong l = cnt1?max(3ll,(llong)c):c-1ll,r = 1ll*c*(c-1ll)/2ll;
	if(m-(n-c)>=l && m-(n-c)<=r) {puts("Yes");}
	else {puts("No");}
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define int long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second

    using namespace std;
int power(int base, int exp)
{
    if (exp == 0)
       return 1;
    else if (exp == 1)
       return base;
    else
    {
        int calc;
       if (exp % 2 == 0)
       {
         calc = power(base, exp/2);
         calc =(calc* calc)%mod;
       }
       else
       {
         calc = (base*power(base, exp-1))%mod;
       }
       return calc%mod;
    }
}
    int32_t main()
    {
        std::ios::sync_with_stdio(false);
       int a,b,c;
       cin>>a>>b>>c;
       if(a>b)
        swap(a,b);

       if(a>c)
        swap(a,c);
       if(b>c)
        swap(b,c);
       cout<<c*10+b+a<<endl;
        return 0;
    }


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

int main(void){
  int n;
  while(cin>>n,n){
    int in[10] = {0};
    for(int i = 0 ; i < n ; i ++){
      int m;
      cin>>m;
      in[m] ++;
    }
    for(int i = 0 ; i < 10 ; i ++){
      if(in[i]){
	for(int j = 0 ; j < in[i] ; j ++)
	  cout<<"*";
      }
      else 
	cout<<"-";
      cout<<endl;
    }
  }
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <stdio.h>
#include <unistd.h>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl
#define PI 3.14159265359

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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;}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(k);
  rep (i, k) {
    cin >> d[i];
  }

  vector<int> use;
  rep (i, 10) {
    if (find(d.begin(), d.end(), i) == d.end()) {
      use.push_back(i);
    }
  }
  // rep (i, use.size()) {
  //   P(use[i]);
  // }

  vector<string> list;
  list.push_back("0");
  rep (i, 5) {
    vector<string> newList;
    rep (j, list.size()) {
      string tmp = list[j];
      int allZero = 1;
      rep (x, tmp.size()) {
        if (tmp[x] != '0') allZero = 0;
      }
      if (allZero) newList.push_back(tmp + "0");
      rep (j, use.size()) {
        newList.push_back(tmp + to_string(use[j]));
      }
    }
    list = newList;
  }

  sort(list.begin(), list.end());
  rep (i, list.size()) {
    // P(list[i]);
    if (n <= stoi(list[i])) {
      P(stoi(list[i]));
      return 0;
    }
  }
  return 0;
}



Measured memory_bytes: 4852
n = int(input())
if n == 1:
    print(0)
else:
    h_list = [ int(v) for v in input().split() ]

    dh_list = []

    t = 0
    for i in range(n-1):
        if h_list[i] >= h_list[i+1]:
            t += 1
        else:
            t = 0
        dh_list.append(t)
    print(max(dh_list))


Measured memory_bytes: 64228
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <algorithm>
#define R register
#define IN inline
#define W while
#define gc getchar()
#define ll long long
#define MOD 1000000007
#define lbt(i) ((i) & (-(i)))
#define MX 21
int n, m, k, all, last = 1, cur = 0;
int dir[MX][MX], dp[2][1 << MX];
template <class T>
IN void in(T &x)
{
	x = 0; R char c = gc;
	for (; !isdigit(c); c = gc);
	for (;  isdigit(c); c = gc)
	x = (x << 1) + (x << 3) + c - 48;
}
IN void ad(int &x, R int v) {x += v; if (x >= MOD) x -= MOD;}
int main(void)
{
	int x, y, foo, bar, ans = 0;
	in(n), in(m), in(k), --n; all = (1 << n) - 1;
	for (R int i = 1; i <= k; ++i)
	in(x), in(y), in(foo), dir[x][y - 1] = foo + 1;
	dp[0][0] = 1;
	for (R int i = 1; i <= m; ++i)
	for (R int j = 0; j < n; ++j)
	{
		std::swap(last, cur); foo = 1 << j, bar = all ^ ((foo << 1) - 1);
		for (R int s = 0; s <= all; ++s) dp[cur][s] = 0;
		for (R int s = 0; s <= all; ++s)
		{
			if (dp[last][s])
			{
				if (dir[i][j] != 2 && (!(foo & s)))//go left
				ad(dp[cur][s], dp[last][s]);
				if (dir[i][j] != 1)//go right
				{
					if (foo & s) x = s;//must go right
					else
					{
						if (!(bar & s)) x = s | foo;//no more bit 1
						else x = (s | foo) ^ lbt(bar & s);//bit 1 exists in higher bits
					}
					ad(dp[cur][x], dp[last][s]);
				}
			}
		}
	}
	for (R int i = 0; i <= all; ++i) ad(ans, dp[cur][i]);
	printf("%d", ans);
}

Measured memory_bytes: 8320
inp=[]

inp.append(list(map(int,input().split())))
inp.append(list(map(int,input().split())))
inp.append(list(map(int,input().split())))

for i in range(101):
  flag=0
  
  a1=i
  b1=inp[0][0]-a1
  if b1<0:
    flag=1
  a2=inp[0][1]-b1
  if a2<0:
    flag=1
  a3=inp[0][2]-b1
  if a3<0:
    flag=1
  if inp[1][0]-a1!=inp[1][1]-a2 or inp[1][0]-a1 != inp[1][2]-a3:
    flag=1
  if inp[2][0]-a1!=inp[2][1]-a2 or inp[2][0]-a1 != inp[2][2]-a3:
    flag=1
  if flag==0:
    print("Yes")
    exit()
  
  
print("No")

Measured memory_bytes: 38428
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

class UnionFind {
	vector<int>parent;
	vector<int>rank;
public:
	UnionFind(int num) {
		num++;
		parent.resize(num);
		rank.resize(num);
		for (int i = 0; i < num; i++) {
			parent[i] = i;
			rank[i] = 0;
		}
	}
	int Find(int node) {
		if (parent[node] == node)return node;
		else return parent[node] = Find(parent[node]);
	}
	void Unite(int u, int v) {
		u = Find(u);
		v = Find(v);
		if (u == v)return;
		if (rank[u] < rank[v])parent[u] = v;
		else {
			parent[v] = u;
			if (rank[u] == rank[v])rank[u]++;
		}
	}
	bool Check_Same(int u, int v) {
		return Find(u) == Find(v);
	}
};

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

	cin >> N;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	cin >> M;
	vector<int>ans(N, 1);
	vector<int>w(N);
	vector<int>y(N);
	set<pair<int, int>>st;
	vector<vector<pair<int, int>>>edge(N);
	UnionFind uf(N);
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		L--, R--;
		edge[L].push_back({ v[R],R });
		edge[R].push_back({ v[L],L });
		if (v[L] == v[R])uf.Unite(L, R);
	}
	vector<int>p(N);
	for (int i = 0; i < N; i++) {
		sort(edge[i].begin(), edge[i].end());
		for (int j = 1; j < edge[i].size(); j++) {
			if (edge[i][j].first == edge[i][j - 1].first) {
				uf.Unite(edge[i][j].second, edge[i][j - 1].second);
			}
		}
	}
	for (int i = 0; i < N; i++) {
		p[i] = uf.Find(i);
	}
	vector<vector<int>>nedge(N);
	vector<int>in(N);
	for (int i = 0; i < N; i++) {
		for (int j = 1; j < edge[i].size(); j++) {
			if (edge[i][j].first > edge[i][j - 1].first) {
				nedge[p[edge[i][j - 1].second]].push_back(p[edge[i][j].second]);
				in[p[edge[i][j].second]]++;
			}
		}
	}
	for (int i = 0; i < N; i++) {
		for (auto j : edge[i]) {
			if (v[i] < j.first){
				nedge[p[i]].push_back(p[j.second]);
				in[p[j.second]]++;
			}
		}
	}
	queue<int>Q;
	for (int i = 0; i < N; i++) {
		if (!in[i])Q.push(i);
	}
	while(!Q.empty()){
		int cn = Q.front();
		Q.pop();
		for (auto j : nedge[cn]) {
			in[j]--;
			if (!in[j])Q.push(j);
			ans[j] = max(ans[j], ans[cn] + 1);
		}
	}
	long long int ret = 0;
	for (int i = 0; i < N; i++) {
		ret += ans[p[i]];
	}
	cout << ret << endl;
}


Measured memory_bytes: 20876
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, greater<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define endl ('\n')
//#define MOD 1000000007LL
#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
//inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
//inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[](auto f,auto... args){return f(f,args...);};

int main(){
    lint n;
    cin>>n;
    set<string>s;
    rep(i,n){
        string t;
        cin>>t;
        s.insert(t);
    }
    cout<<s.size()<<endl;
}

Measured memory_bytes: 19248
#include <cassert>
#include <map>
#include <cstring>
#include <vector>
#include <iostream>
using namespace std;

long long p[200200][61];

int main() {
    long long n, K; cin >> n >> K;
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    int prv[200200];
    fill(prv, prv+200200, -1);
    for (int i = 0; i < n; i++) prv[a[i]] = i;
    for (int i = 0; i < n; i++) {
        int j = prv[a[i]];
        p[j][0] = i > j ? i - j + 1: i - j + 1 + n;
        prv[a[i]] = i;
    }
    for (int j = 1; j < 61; j++) {
        for (int i = 0; i < n; i++) {
            if (p[i][j-1] < 0) continue;
            p[i][j] = p[i][j-1] + p[(i + p[i][j-1])%n][j-1];
        }
    }
    // for (int i = 0; i < n; i++) cerr << i << " -> " << p[i][0] << endl;
    // for (int j = 1; j < 61; j++)
    //     for (int i = 0; i < n; i++)
    //         cerr <<  i << ' ' << j << " -> " << p[i][j] << endl;
    long long x = n * K;
    int i = 0;
    while (p[i][0] <= x) {
        int k = 0;
        while (p[i][k+1] <= x) k++;
        // cerr << i << ' ' << k <<  ' ' << x << endl;
        // cerr << "p[i][k] = " <<  p[i][k] << endl;
        x -= p[i][k];
        i = (i + p[i][k]) % n;
    }
    if (x > 0) {
        vector<int> ans;
        bool flg[200200] = {};
        while (i < n) {
            if (flg[a[i]]) {
                while (ans.back() != a[i]) {
                    flg[ans.back()] = false;
                    ans.pop_back();
                }
                flg[a[i]] = false;
                ans.pop_back();
            } else {
                ans.push_back(a[i]);
                flg[a[i]] = true;
            }
            // cerr << j << ' ' << i << ": ";
            // for (int x : ans) cerr << x << ' ';
            // cerr << endl;
            i++;
        }
        for (int x : ans) cout << x << ' '; cout << endl;
    }
}


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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = 0;
    while(1) {
        c -= b;
        if ( c <= 0 ) {
            ans = 1;
            break;
        }
        a -= d;
        if ( a <= 0 ) {
            break;
        }
    }
    cout << ( ans ? "Yes" : "No" ) << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <array>
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

int judge(array<int, 30>& cards, int rem) {
    if (rem == 0) return 1;
    for (int i = 0; i < 30; i++) {
        if (cards[i] >= 3) {
            cards[i] -= 3;
            int res = judge(cards, rem - 3);
            if (res) return res;
            cards[i] += 3;
        }
        if (i >= 2 && cards[i] > 0 && cards[i - 1] > 0 && cards[i - 2] > 0) {
            for (int j = i - 2; j <= i; j++) cards[j]--;
            int res = judge(cards, rem - 3);
            if (res) return res;
            for (int j = i - 2; j <= i; j++) cards[j]++;
        }
    }
    return 0;
}

void solve() {
    array<int, 9> n;
    array<char, 9> c;
    for (int& x : n) cin >> x;
    for (char& x : c) cin >> x;

    array<int, 30> cards;
    cards.fill(0);
    for (int i = 0; i < 9; i++) {
        int m = 0;
        switch (c[i]) {
        case 'R': m = 0; break;
        case 'G': m = 10; break;
        case 'B': m = 20; break;
        }
        cards[n[i] + m]++;
    }
    cout << judge(cards, 9) << endl;
}

int main() {
    int n;
    for (cin >> n; n; n--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1160
def c():
    n = int(input())
    div = make_divisors(n)
    mid = len(div) // 2
    i = div[mid]
    j = n // i
    print(i + j - 2)

    return


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


if __name__ == '__main__':
    c()

Measured memory_bytes: 38640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(int i=(l);i<(r);i++)
int main(){
    int a,b;
    cin>>a>>b;
    if(b==100)b++;
    rep(i,0,a)b*=100;
    cout<<b;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int N = Integer.parseInt(in.nextLine());
    Map<String, Integer> map = new HashMap<>();
    for (int i = 0; i < N; i++) {
      char[] s = in.nextLine().toCharArray();
      Arrays.sort(s);
      String str = String.valueOf(s);
      map.put(str, map.getOrDefault(str, 0) + 1);
    }
    long ans = 0;
    for (String str : map.keySet()) {
      int cnt = map.get(str);
      if (cnt > 1) {
        ans += ((long)cnt * (long)(cnt - 1)) / 2L;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 105200
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n, m; cin >> n >> m;
	std::string s; cin >> s;
	std::vector<std::vector<int>> h(n, std::vector<int>(2, 0)), g(n);
	for(int i = 0; i < m; i++) {
		int a, b; cin >> a >> b; a--; b--;
		
		g[a].push_back(b);
		g[b].push_back(a);
		h[a][s[b] == 'B']++;
		h[b][s[a] == 'B']++;
	}
	
	std::queue<int> qu;
	std::vector<bool> used(n, false);
	for(int i = 0; i < n; i++) {
		if(!h[i][0] or !h[i][1]) {
			qu.push(i);
			used[i] = true;
		}
	}
	
	while(!qu.empty()) {
		auto p = qu.front(); qu.pop();
		
		for(auto e : g[p]) {
			if(used[e]) continue;
			h[e][s[p] == 'B']--;
			
			if(!h[e][s[p] == 'B']) {
				used[e] = true;
				qu.push(e);
			}
		}
	}
	
	for(int i = 0; i < n; i++) {
		if(used[i]) continue;
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 21124
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 10;
int dat[N];

int main(void){
    for(ull n; cin >> n; cout << dat[0] << endl){
        rep(i, N) dat[i] = n % N, n /= N;
        for(int i = N - 1; 0 < i; i --)
            rep(j, i) dat[j] = (dat[j] + dat[j + 1]) % N;
    }

    return 0;
}

Measured memory_bytes: 1156