akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

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

Measured memory_bytes: 19224
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int d[n];
	for(int q=0;q<n;q++){
		cin>>d[q];
	}
	sort(d,d+n);
	cout<<d[n/2]-d[n/2-1];
}

Measured memory_bytes: 640
from collections import Counter
n = int(input())
A = Counter(list(map(int, input().split())))
l = []
for x,y in A.items():
    if y >= 2:
        for _ in range(y//2):
            l.append(x)
l.sort(reverse=True)
print(l[0]*l[1] if len(l)>=2 else 0)

Measured memory_bytes: 18600
s= input()
u= s[::-1]
 
k=["resare","esare","remaerd","maerd"]
 
l=u.replace("resare","")
d=l.replace("esare","")
h=d.replace("remaerd","")
w=h.replace("maerd","")
  
    
if w:
  print("NO")
  
else:
  print("YES")


Measured memory_bytes: 3316
def solve():
    N, M = [int(_) for _ in raw_input().split()]
    maxL = 0
    minR = N+1
    for i in range(M):
        Li, Ri = [int(_) for _ in raw_input().split()]
        if Li > maxL:
            maxL = Li
        if Ri < minR:
            minR = Ri
    if minR >= maxL:
        ret = minR - maxL + 1
    else:
        ret = 0
    print ret

if __name__ == '__main__':
    solve()


Measured memory_bytes: 33640
#include<iostream>

using namespace std;

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

	int a, b;
	cin >> a >> b;

	string u;
	cin >> u;

	if (u == s) {
		a--;
	}
	else b--;

	cout << a << " " << b;

	return 0;
}

Measured memory_bytes: 256
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n, b, c;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
	if(n==1){
      return cout<<"Hello World"<<"\n",0;
    }
  	cin>>b>>c;
    cout << b+c << "\n";
}



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

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

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

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

using namespace std;

int N, W;
int w[201];
int v[201];
ll dp[201][2 * ten(5) + 1];

int main()
{
    cin >> N >> W;
    FOR(i, 1, N) cin >> w[i] >> v[i];
    FOR(k, 1, N) {
        FOR (weight, 0, W) {
            chmax(dp[k][weight], dp[k-1][weight]);
            if (weight >= w[k]) {
                chmax(dp[k][weight], dp[k-1][weight-w[k]] + v[k]);
            }
        }
    }

    cout << dp[N][W] << endl;
}

Measured memory_bytes: 156416
import math

def is_prime(n):
	if n < 2: return False

	for i in range(2, math.ceil(math.sqrt(n))):
		if n % i == 0:
			return False

	return True

def get_pf(n):
	ans = [1]

	for p in range(2, math.ceil(math.sqrt(n))):
		while n % p == 0:
			n = int(n / p)
			ans.append(p)

	if n != 1:
		ans.append(n)

	return ans

if __name__ == "__main__":
	line = input().split(" ")

	a, b = int(line[0]), int(line[1])

	if a > b:
		a, b = b, a

	primes_a = set(get_pf(a))
	primes_b = set(get_pf(b))

	# if b % a == 0 and is_prime(a):
	# 	primes_a.add(a)
	# 	primes_b.add(a)

	ans = []
	for e in primes_a:
		if e in primes_b:
			ans.append(e)

	# print(ans)
	print(len(ans))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    string S;
    cin >> S;

    cout << (S == "ABC" ? "ARC" : "ABC") << endl;
}


Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<cstring>
//#include<vector>
#include<algorithm>


#ifdef L_JUDGE
#pragma warning(disable:4996)
#endif

using namespace std;
const int MAXN=1005;


int main(){
	#ifdef L_JUDGE
		freopen("in.txt","r",stdin);
//		freopen("out.txt","w",stdout);
	#endif
    int N,A;
    while(EOF!=scanf("%d%d",&N,&A)){
         N%=500;
         if(N<=A)cout<<"Yes"<<endl;
         else cout<<"No"<<endl;
    }

	#ifdef L_JUDGE
		fclose(stdin);
		fclose(stdout);
//		system("out.txt");
	#endif

	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
c = [0]*(n-1)
s = [0]*(n-1)
f = [0]*(n-1)

for i in range(n-1):
    c[i], s[i], f[i] = map(int, input().split())

def dfs(eki,t):
    if eki == n-1:
        return t

    cc = c[eki]
    ss = s[eki]
    ff = f[eki]

    if t <= ss:
        return dfs(eki+1, ss+cc)
    else:
        m = -(-t//ff)
        return dfs(eki+1, ff*m+cc)

for i in range(n):
    print(dfs(i,0))


Measured memory_bytes: 3444
w,h,n = map(int,input().split())
migiue = [w, h]
hidarishita = [0, 0]
for i in range(n):
  x, y, a = map(int,input().split())
  if a == 1:
    if hidarishita[0] < x: hidarishita[0] = x
  if a == 2:
    if migiue[0] > x: migiue[0] = x
  if a == 3:
    if hidarishita[1] < y: hidarishita[1] = y
  if a == 4:
    if migiue[1] > y: migiue[1] = y
      
S = max(migiue[0] - hidarishita[0], 0) * max(migiue[1] - hidarishita[1], 0)
print(S)
  

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

using namespace std;

int main()
{
    int n,m,a,b;
    cin >> n >> m;
    vector<bool> vb(n+1, false);
    bool ans = false;
    for(int i=0;i<m;i++)
    {
      //  int a,b;
        cin >> a >> b;
       // assert(1 <= a && a < b && b <= n);
        if(a==1)
        {
            if(vb[b]==true)
                ans=true;
            vb[b]=true;
        }
        else if(b==n)
        {
            if(vb[a]==true)
                ans=true;
            vb[a]=true;
        }
    }
    if(ans)
        cout << "POSSIBLE\n";
    else
        cout << "IMPOSSIBLE\n";


    return 0;
}



Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

int main() {
	int i = 0;
	int count;
	int x[10000];
	int y[10000];

	while (1) {
		std::cin >> x[i] >> y[i];
		if (x[i] == 0 && y[i] == 0) {
			count = i;
			break;
		}
		i++;
	}

	for (i = 0; i < count; i++) {
		if (x[i] > y[i]) {
			std::cout << y[i] << " " << x[i] << std::endl;
		}
		else {
			std::cout << x[i] << " " << y[i] << std::endl;
		}
	}
	return 0;
}

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

int main()
{

    int n,count=0;

    cin>>n;
    for(int i=1;i<=n;i++)
    {
        string s;
        stringstream ss;
        ss<<i;
        ss>>s;
        if((s.size()%2)!=0)
          {
              count++;
              //cout<<s<<endl;
          }
       // cout<<i<<endl;
    }

    cout<<count<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<sstream>
using namespace std;
inline bool ok(string s);
int main(){
	string s;
	cin >> s;
	int n = s.length();
	for (int i = 1; i < n; i++){
		if (i & 1){ s = s.substr(0, s.length() - 1); continue; }
		s = s.substr(0, s.length() - 1);
		//cout << s << endl;
		if (ok(s)){
			cout << s.length() << endl;
			return 0;
		}
	}
}
inline bool ok(string s){
	string t1 = s.substr(0, s.length() / 2);
	string t2 = s.substr(s.length() / 2, s.length() / 2);
	if (t1 == t2)return 1;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d",&a,&b);
    c=b+b;
    if(b>a)
    {
        printf("0\n");
    }
   else if(c>a)
    {
        printf("0\n");
    }
   else
        printf("%d\n",a-c);

    return 0;
}



Measured memory_bytes: 128
n,m=map(int,input().split())
graph = [[]for _ in range(n)]
for i in range(m):
	    a,b= map(int,input().split())
	    a-=1
	    b-=1
	    graph[a].append(b)
	    graph[b].append(a)
for i in range(n):
	    print(len(graph[i]))

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

int main()
{
    int a , b;
    cin>>a>>b;
    string str;
    cin>>str;
    bool flag = true;
    if(str[a]!='-')
    flag = false;
    for(int i = 0; i < str.size(); i++)
    {
        if(a==i) continue;
        if(str[i]=='-') flag = false;
    }
    if(flag)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string.h>
using namespace std;
int main(){
		int W,H;
		cin >> H >> W; cin.ignore();
		char a[H][W];
		bool isRowHasbl[110];
		bool isColHasbl[110];

		string s;
		memset(isColHasbl, false,sizeof(isColHasbl));
		memset(isRowHasbl, false,sizeof(isRowHasbl));
		for(int i=0;i<H;i++){
				getline(cin,s);
				for(int j=0;j<W;j++){
						a[i][j] = s[j];
						if(s[j]== '#'){
							isRowHasbl[i]=true;
							isColHasbl[j]=true;
						}
				}
		}

		for(int i=0;i<H;i++){
				if (isRowHasbl[i]==false)continue;
				for(int j=0;j<W;j++){
						if(isColHasbl[j] == true){
								cout << a[i][j];
						}
				}
				printf("\n");
		}
}





Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
m = 10**9+7
l = [0 for i in range(n)]
for i in a:
    if i%2 == n%2:
        print(0)
        exit()
    l[i]+=1

if l[0] != n%2:
    print(0)
    exit()

for i in l[1:]:
    if i!=0 and i!=2:
        print(0)
        exit()
print(2**(n//2)%m)

Measured memory_bytes: 13880
n, m = map(int, input().split())
 
A = list(map(int, input().split()))
 
sum = 0
 
for i in range(n):
  sum += A[i]
  
counter = 0
rate = 4 * m
rate = sum / rate
for i in range(n):
  if A[i] >= rate:
    counter += 1
    
if counter >= m:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <stdio.h>


int main(void){
	int W,a,b,c,ans;

	scanf("%d %d %d",&W,&a, &b);

	if(a>b){c=a; a=b;b=c;}

	if(W>b-a){
		ans = 0;
	}else{
		ans = b-a-W;
	}

	printf("%d\n",ans);
}

Measured memory_bytes: 128
S = input()
error = 0

for i in range(len(S)):
    if i%2 == 0:
        if S[i] == 'L':
            error = 1
    else:
        if S[i] == 'R':
            error = 1
            
if error == 1:
    print('No')
else:
    print('Yes')
    

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

int main() {
  
  string T;
  cin >> T;
  
  for (int i; i < T.size(); i++) 
  {
    
    if (T.at(i) == '?')
    {
      
      if (i == 0 || T.at(i - 1) == 'D')
      {
        
        if (i == T.size() - 1)
        {
          T.at(i) = 'D';
        }
         else if (T.at(i + 1) == 'D' || T.at(i + 1) == '?')
         {
           T.at(i) = 'P';
         }
         else
         {
           T.at(i) = 'D';
         }
        
      }
      
      else
      {
        T.at(i) = 'D';
      }
      
    }

    
  }
  
  cout << T << endl;
  
}

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

int main(){
  int N,x,y,flag; //flagが1ならばYes
  flag=0;
  cin >> N;
  x = N/1000;
  if(x==N/100-x*10){
    if(x==N/10-x*100-x*10)flag=1;
  }
  else {
    y = N/100 -x*10;
    if(y==N/10-x*100-y*10){
      if(y==N - (N/10)*10)flag=1;
    }
  }
  if(flag==1)cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {

	int N = 0;
	int X = 0;
	int T = 0;

	do {

		cin >> N >> X >> T;

	} while (N < 1 || N > 10000 || X < 1 || X > 10000 || T < 1 || T > 10000);

	int frequency = N / X;
	int surplus = N % X;


	if (surplus != 0) {
		frequency++;
	}

	cout << T* frequency;

}

Measured memory_bytes: 3628
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d


n,m,l= map(int,input().split()) #n:頂点数　w:辺の数

d=[[float("inf") for i in range(n)] for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(m):
    a,b,c = map(int,input().split())
    d[a-1][b-1]=c
    d[b-1][a-1]=c
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
warshall_floyd(d)

d2=[[float("inf") for i in range(n)] for i in range(n)] 
for i in range(n):
    for j in range(n):
        if d[i-1][j-1]<=l:
            d2[i-1][j-1]=1
            d2[j-1][i-1]=1
warshall_floyd(d2)
q=int(input())
l=[list(map(int, input().split())) for i in range(q)]
for i in range(q):
    if d2[l[i][0]-1][l[i][1]-1]-1!=float('inf'):
        print(d2[l[i][0]-1][l[i][1]-1]-1)
    else:
        print(-1)

Measured memory_bytes: 129628
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int64_t a[300][300];
int64_t w[300][300];

int main()
{
    int n;
    cin >> n;
    rep(i, n) rep(j, n)
    {
        cin >> a[i][j];
    }

    rep(i, n) rep(j, n)
    {
        w[i][j] = 0;
    }

    rep(i, n) rep(j, n)
    {
        bool isNeighbor = true;
        rep(k, n)
        {
            if (a[i][j] > a[i][k] + a[k][j]) {
                cout << -1 << endl;
                return 0;
            }
            if (a[i][j] == a[i][k] + a[k][j]) {
                if (k != i && k != j) {
                    isNeighbor = false;
                }
            }
        }
        if (isNeighbor) {
            w[i][j] = a[i][j];
        }
    }

    int64_t result = 0;
    rep(i, n) rep(j, n)
    {
        result += w[i][j] * (i == j ? 2 : 1);
    }
    cout << result / 2 << endl;

    return 0;
}

Measured memory_bytes: 1664
from functools import reduce
N = int(input())
T = []
for _ in range(N):
    T.append(int(input()))


def lcm(a, b):
    mul = a*b
    if a < b:
        a, b = b, a
    while b:
        r = a % b
        a = b
        b = r
    return mul//a


print(reduce(lcm, T))


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

int main() {
  deque<char> data;
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) != 'B'){
      data.push_back(s.at(i));
    }else{
      if(data.empty()){
        continue;
      }
      data.pop_back();
    }
  }
  int a = data.size();
  for(int i = 0; i < a; i++){
    cout << data.front();
    data.pop_front();
  }
  cout <<endl;
  
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    S = input()
    
    ans = 0
    ps, cs = '', ''
    for si in S:
        cs += si
        if cs != ps:
            ps = cs
            cs = ''
            ans += 1
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3500
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <stack>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
	ll h, w;
	cin >> h >> w;
	
	ll ans = h * w / 2;
	if (h * w % 2)ans++;
	
	if (h == 1 || w == 1)
		ans = 1;
	cout << ans;
}


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

vector<int> G[510];
bool used[510];

void dfs(int v){
	used[v] = true;
	for(int to : G[v]){
		if(!used[to]) dfs(to);
	}
}

signed main(){
	int n,m,k = 0;
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		int a,b;
		cin >> a >> b; a--;b--;
		G[a].push_back(b);
	}
	for(int i = 0;i < n;i++){
		if(!used[i]){
			dfs(i);
			k++;
		}
	}
	cout << m - n + k << endl;
}


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

using namespace std;
const int mod = 1e9 + 7;

long long int judge(int K, const vector< vector<int> >& graph, int now, int from){
    int can_use_color_num;
    if(from == -1){
        can_use_color_num = K - 1;
    }else{
        can_use_color_num = K - 2;
    }
    if(K < graph[now].size()){
        return 0;
    }
    
    long long int case_num = 1;
    for(auto e: graph[now]){
        if(e == from){
            continue;
        }
        case_num *= can_use_color_num;
        can_use_color_num--;
        case_num %= mod;
    }
    for(auto e: graph[now]){
        if(e == from){
            continue;
        }
        case_num *= judge(K, graph, e, now);
        case_num %= mod;
    }
    
    return case_num;
}

int main(){
    int N, K;
    vector< vector<int> > graph(N);
    cin >> N >> K;
    for(int i=0; i < N - 1; i++){
        int a, b;
        cin >> a >> b;
        a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    long long int answer = K * judge(K, graph, 0, -1);
    answer %= mod;
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 156800
N,K = map(int,input().split())
s = input()
s += 'A'
k = 0
con = []
if s[0] == '0':
    con.append(0)
c = 1
for i in range(N):
    if s[i] == s[i+1]:
        c += 1
    else:
        con.append(c)
        c = 1
if s[N-1] == '0':
    con.append(0)
k = len(con)
l = 0
r = 2*K
ans = 0
if k < r:
    ans = sum(con) 
else:
    for i in range(l,r+1):
        ans += con[i]
now = ans        
while(k > r + 1):
    now = now - con[l] - con[l+1] + con[r+1] + con[r+2]
    ans = max(ans,now)
    l += 2
    r += 2
print(ans)


Measured memory_bytes: 4092
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int main()
{
    int n;
    cin >> n;
    pii ab[n];
    rep(i, 0, n) cin >> ab[i].first >> ab[i].second;
    sort(ab, ab + n, cmp);
    //rep(i, 0, n) cout << ab[i].first << " " << ab[i].second << endl;
    int time = 0;
    bool ans = true;
    rep(i, 0, n)
    {
        time += ab[i].first;
        if (time > ab[i].second)
        {
            ans = false;
            break;
        }
    }
    print(ans);
}


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

int main(void)
{
	int old;
	int i, len;
	char ne[100];
	while (1){
		scanf("%d", &old);
		
		if (old == 0){
			break;
		}
		
		i = 0;
		while (old != 0){
			ne[i] = old % 8 + '0';
			old /= 8;
			i++;
		}
		ne[i] = '\0';
		len = strlen(ne) - 1;
	
		for (i = 0; i <= len; i++){
			if ('5' <= ne[len  - i]){
				ne[len - i] += 2;
			}
			else if ('4' <= ne[len - i]){
				ne[len - i]++;
			}
			
			printf("%c", ne[len - i]);
		}
		puts("");
	}
	return (0);
}

Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;

int n, nn, sn, ans = 1000000;

int func(int moto, int x){
  int bai = x;
  while(moto >= bai){
    bai *= x;
  }
  int mae = bai / x;
  int sum = 0;
  while(moto >= x){
    sum += moto / mae;
    moto = (moto % mae);
    mae /= x;
  }
  sum += moto;
  return sum;
}

void solve(){
  cin >> n;
  nn = n / 9;

  for(int i = 0; i <= nn; i++){
    int sum = 0;
    int t = n - 9 * i;
    sum += func(i, 9);
    sn = t / 6;
    sum += func(sn, 6);
    int x = t % 6;
    sum += x;
    ans = min(sum, ans);
  }
  cout << ans << endl;
  return;
}
int main(){
  solve();
  return 0;
}


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

int cnt[50];
int pos[50][100002];
char str[100002];

int main(){
	
	// Init
	for(int i=0;i<50;i++){cnt[i]=0;}
	
	// Input
	cin>>str;
	for(int i=0;i<strlen(str);i++){
		pos[str[i]-'a'][cnt[str[i]-'a']++]=i;
	}

	// Solve
	for(int i='a';i<='z';i++){
		int lk=i-'a';
		for(int j=0;j+1<cnt[lk];j++){
			int len = pos[lk][j+1] - pos[lk][j]+1;
			if(len/2 < 2){
				cout<<pos[lk][j]+1<<" "<<pos[lk][j+1]+1<<endl;
				return(0);
			}
			
		}
	}

	cout<<"-1 -1"<<endl;
	return(0);
}

Measured memory_bytes: 8576
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <string>
#include <math.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int, int> P;
#define PB push_back
#define INF 100000000000000000
using int64 = long long;

int main()
{
  string S;
  cin >> S;
  int i = 0;
  int A = 0;
  int B = 0;

  A = (S.at(0) - 48) * 10 + (S.at(1) - 48);
  B = (S.at(2) - 48) * 10 + (S.at(3) - 48);

  if (A == 0 && B == 0)
  {
    cout << "NA" << endl;
    return 0;
  }

  if (A == 0 && B <= 12)
  {
    cout << "YYMM" << endl;
    return 0;
  }

  if (A == 0 && B > 12)
  {
    cout << "NA" << endl;
    return 0;
  }

  if (A <= 12 && B == 0)
  {
    cout << "MMYY" << endl;
    return 0;
  }

  if (A > 12 && B == 0)
  {
    cout << "NA" << endl;
    return 0;
  }

  if (A <= 12 && B > 12)
  {
    cout << "MMYY" << endl;
  }
  else if (A > 12 && B <= 12)
  {
    cout << "YYMM" << endl;
  }
  else if (A <= 12 && B <= 12)
  {
    cout << "AMBIGUOUS" << endl;
  }
  else
  {
    cout << "NA" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
n, m, l = map(int,input().split())

x = []
y = []

for i in range(n):
    a = list(map(int,input().split()))
    x.append(a)
    
for i in range(m):
    b = list(map(int,input().split()))
    y.append(b)

#print(x)
a = 0
b = []
ans = []

for i in range(n):
    for j in range(l):
        for k in range(m):
            a += x[i][k]*y[k][j]
        #print(a)
        b.append(a)
        a = 0
    b = list(map(str, b))
    b = ' '.join(b)
    ans.append(b)
    b = []
        
[print(ans[i]) for i in range(len(ans))]


Measured memory_bytes: 6508
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#define ll long long
#define FOR(i,a) for(ll i=0;i<(ll)a.size();i++)
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=2e5+500;
const ll mod=1e9+7;


pii a[maxn];
ll v[maxn];

ll vmax[maxn];
ll vmin[maxn];

ll fen[maxn];
void update(ll x,ll v){
	for(x++;x<maxn;x+=(x&(-x))){
		fen[x]+=v;
		fen[x]%=mod;
	}
}
ll find(ll x){
	ll ans=0;
	for(x++;x;x^=(x&(-x))){
		ans+=fen[x];
	}
	return ans%mod;
}
ll find_sum(ll l,ll r){
	return (find(r-1)-find(l-1)+mod)%mod;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++){
		cin>>a[i].F>>a[i].S;
	}
	sort(a,a+n);
	vector<ll> vec;
	for(ll i=0;i<n;i++){
		v[i]=a[i].S;
		vec.pb(v[i]);
	}
	sort(vec.begin(),vec.end());
	for(ll i=0;i<n;i++){
		v[i]=lower_bound(vec.begin(),vec.end(),v[i])-vec.begin()+1;
	}
	ll last=0;
	for(ll i=0;i<n;i++){
		last=max(last,v[i]);
		vmax[i]=last;
	}
	last=mod;
	for(ll i=n-1;i>=0;i--){
		last=min(last,v[i]);
		vmin[i]=last;
	}
	update(0,1);
	for(ll i=0;i<n;i++){
		ll l=vmin[i];
		ll r=vmax[i];
		update(r,find_sum(l-1,r+1));
	}	
	cout<<find_sum(n,n+1);
}	









Measured memory_bytes: 11376
#include<stdio.h>
int main(void)
{
	int x,g;
	while (scanf("%d",&g)!=EOF){
		x=g%39;
		if(x==0) printf("3C39\n");
		else if(x<=9) printf("3C0%d\n",x);
		else printf("3C%d\n",x);
	}
	return 0;
}

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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arrst(s,n);

  map<string, int> mp;
  rep(i,n){
    mp[s[i]]++;
  }
  prt3("AC", "x", mp["AC"]);
  prt3("WA", "x", mp["WA"]);
  prt3("TLE", "x", mp["TLE"]);
  prt3("RE", "x", mp["RE"]);
}


Measured memory_bytes: 6368
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)

//Map<String, Integer> map = new HashMap<String, Integer>(n);
/*for ( キーのデータ型 key : マップの名前.keySet() ) {
	データのデータ型 data = マップの名前.get( key );
	
	// keyやdataを使った処理;
}*/

//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")
//list.set(1,"walk");
public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	//static String eikomoji[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
	static long N;
	public static void main(String[] args) {
		long a=sc.nextLong();
		long b=sc.nextLong();
		for(int i=1;true;i++) {
			if((a*i)%b==0) {
				p(a*i);
				break;
			}
		}
		
		
		
		
	}
	
	
	
	
}


Measured memory_bytes: 22868
#include <stdio.h>


int main() {
	int n;
	int l[105];
	int total = 0, max = 0;

	scanf("%d", &n);
	int i;
	for (i = 0; i < n; i++) {
		scanf("%d", &l[i]);
		if (l[i] > max) total += max, max = l[i];
		else total += l[i];
	}

	if (max < total) printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long int
using namespace std;
int32_t main()
{
	string s;
	cin>>s;
	int n=s.size();
	if(s[n-1]!='s')
	{
		cout<<s<<'s';
	}
	else
	{
		cout<<s<<'e'<<'s';
	}
}


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

int main(){
  int N;
  string S;
  cin >> N;
  cin >> S;
  if(N>=S.size()){
    cout << S <<endl;
  }
  else{
    S=S.substr(0,N)+"...";
    cout << S <<endl;
  }
}


Measured memory_bytes: 3628
#![allow(unused_mut, unused_macros, unused_variables, unused_assignments, non_snake_case, unused_imports)]

use std::cmp::*;
use std::collections::*;

// [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 から拝借
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    // ABC128-C-Switches用に拡張
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, $t);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        N : usize,
        M : usize,
        KS : [[usize]; M],
        P : [usize; M],
    }
    let mut count = 0;
    'o: for f in 0..1 << N {
        for m in 0..M {
            let mut q = 0;
            for t in &KS[m] {
                q += f >> (t - 1) & 1;
            }
            if q % 2 != P[m] {
                continue 'o;
            }
        }
        count += 1;
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        A: i64,
        B: i64,
    }
    println!("{}",if A<=8 && B<=8{"Yay!"}else{":("});
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll l, r, mi = 2000000001,cnt=0;
	cin >> l >> r;
	for (ll i = l; i < r; i++) {
		for (ll j = i+1; j < r+1; j++) {
			mi = min(i * j % 2019, mi);
			if ((mi == 0 && i%2019!=0 && j%2019!=0) || cnt>=2200) {
				cout<<mi<<endl;
				return 0;
			}
			if(mi==0) cnt++;
		}
		cnt=0;
	}
	cout << mi<< endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

	int k, n, tmp, max = 0, sum = 0, ans;
	int a[200001];

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

	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}

	for (int i = 1; i <= n-1; i++) {
		tmp = a[i + 1] - a[i];
		sum += tmp;
		if (tmp > max) max = tmp;
	}

	tmp = k + a[1] - a[n];
	sum += tmp;
	if (tmp > max) max = tmp;

	ans = sum - max;

	printf("%d",ans);

	return 0;
}

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

int main (void){
  int k,ans;
  cin >> k;

  if(k % 2 == 1){
    ans = (k - 1) / 2 * (k + 1) / 2;
    cout << ans << "\n";
  }else{
    ans = k/2 * k/2;
    cout << ans << "\n";
  }

  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long//宏定义
using namespace std;
ll n,k;
ll ans;
int main(){
    cin>>n>>k;
    ans=k*pow(k-1,n-1);//按照推出的公式直接得出答案
    cout<<ans<<endl;//AT不换行，爆零两行泪！
    return 0;//happy ending~
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    one = l[i]
    for j in range(i+1, n):
        two = l[j]
        if one == two:
            continue
        for k in range(j+1, n):
            three = l[k]
            if two == three:
                continue
            if one < two + three and two < one + three and three < one + two:
                ans += 1
print(ans)


Measured memory_bytes: 9192
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

char board[105][105];

int main(void){
    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>board[i][j];
        }
    }
    for(int i=0;i<h;i++){
        int num = 0;
        for(int j=0;j<w;j++){
            if(board[i][j]!='#')num++;
        }
        if(num==w){
            for(int j=0;j<w;j++)board[i][j]='1';
        }
    }
    for(int j=0;j<w;j++){
        int num = 0;
        for(int i=0;i<h;i++){
            if(board[i][j]!='#')num++;
        }
        if(num==h){
            for(int i=0;i<h;i++)board[i][j]='1';
        }
    }
    for(int i=0;i<h;i++){
        bool flag = false;
        for(int j=0;j<w;j++){
            if(board[i][j]!='1')cout<<board[i][j],flag=true;
        }
        if(flag)cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
// ABC075C - Bridge

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

struct UnionFind {
	vector<int> par;
	vector<int> rank;
	vector<int> count;

	// n要素で初期化
	UnionFind(int n) {
		par.resize(n);
		rank.resize(n, 0);
		count.resize(n, 1);
		for (int i = 0; i < n; i++) {
			par[i] = i;
		}
	}

	// 木の根を求める。
	int find(int x) {
		if (par[x] == x) {
			return x;
		} else {
			return par[x] = find(par[x]);
		}
	}

	// xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) {
			return;
		}
		
		count[x] += count[y];
		count[y] = count[x];
		if (rank[x] < rank[y]) {
			par[x] = y;
		} else {
			par[y] = x;
			if (rank[x] == rank[y]) {
				rank[x]++;
			}
		}
	}

	// xとyが同じ集合に属するか否か
	bool same(int x, int y) {
		return find(x) == find(y);
	}

	// xと同じ集合の要素数を返す。
	int getCount(int x) {
		return count[x];
	}
};

int main() {
	int N, M;
	cin >> N >> M;

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

	int ans = 0;
	for (int i = 0; i < M; i++) {
		UnionFind tree(N+1);
		for (int j = 0; j < M; j++) {
			if (i == j) {
				continue;
			}
			tree.unite(A[j], B[j]);
		}
//		cout << tree.getCount(1) << endl;
//		if (tree.getCount(1) != N) {
//			ans++;
//		}
		set<int> s;
		for (int j = 1; j <= N; j++) {
			if (tree.find(j) == j) {
				s.insert(j);
			}
		}
		if (s.size() > 1) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3600
function main(input) {
  input=input.trim();
  var M = input.split(" ")[0];
  var D = input.split(" ")[1];
  var ans=0
  if(D<22){
    console.log(0);
  }else{
    for(var i=22; i<=D; i++){
      if(i%10>1){
        var temp=Math.floor(i/10)*(i%10);
        if(M>=temp){
          ans++
        }
      }
    }
    console.log(ans);
  }
  

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

Measured memory_bytes: 21064
//Beta tumse na ho payega
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
//#define ll long long int
#define ld long double
#define int long long
#define pb push_back 
#define mod 1000000007
#define mod2 998244353
#define Z(c) (int)(c).size()
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
//#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define clber cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);(i)++)
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define pi 3.1415926536
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define FO find_by_order
#define OK order_of_key
#define tr(it,ct) for(auto &(it) : (ct))
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef vector< pii > vp;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    baap;
 
int power(int a,int n,int lelo)
{
        if(n==0)
                return 1;
        if(n==1)
                return a;
        if(n==2)
                return (a*a)%lelo;
        if(n%2)
                return (a*power(a,n-1,lelo))%lelo;
        else
                return power(power(a,n/2,lelo),2,lelo)%lelo;
}
ld dpower(ld a,int n)
{
        if(n==0)
                return 1;
        if(n==1)
                return a;
        if(n==2)
                return (a*a);
        if(n%2)
                return (a*dpower(a,n-1));
        else
                return dpower(dpower(a,n/2),2);
}
 
 
void swap(int &a,int &b)
{ auto tm=a; a=b; b=tm; }
 
 const int N=1e5+1;   //Take care of duplicates
 const int INF=1e16;
 
 void solve()
 { 
  int n; cin>>n;
  cout<<(n*(n-1))/2;
 } 
signed main()
{  
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
  
 
 
  int t=1;
   
 // cin>>t;
  rep(i,1,t+1)
  { // cout<<"Scenario #"<<i<<":\n";
   solve();
 
   if(i<t)
   cout<<nl;
  }
  
 
 return 0; 
}


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

int main() {
    long A;long B;long K;
    cin>>A>>B>>K;
    if(A>=K){
        cout<<A-K<<" "<<B; return 0;
    }
    if(A<=K){
    if((A+B)<=K){
    cout<<0<<" "<<0;
    }else{cout<<0<<" "<<(A+B)-K;}
    }

    return 0;
}

Measured memory_bytes: 256
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=5e6+69, INF=1e9+6969;

int n,dp[R],t[R],k;

int main()
{
	scanf("%d%d", &n, &k);
	for(int i=0;i<n;++i)
	{
		scanf("%d", &t[i+1]);
	}
	dp[1]=0;
	dp[0]=INF;
	for(int i=2;i<=n;++i)
	{
		int h=t[i];
		int op=INF;
		for(int j=i-1;j>=max(0,i-k);--j)
		{
			op=min(op,dp[j]+abs(h-t[j]));
			//  dp[i]=min(dp[i-1]+abs(t[i-1]-h),dp[i-2]+abs(t[i-2]-h));
		}
		dp[i]=op;
	}
	printf("%d\n", dp[n]);
	return 0;
}


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



int main() {
    using vi = vector<int>;
    
    int n;
    cin >> n;
    set<string> s;
    rep(i,n){
        string ss;
        cin >> ss;
        s.insert(ss);
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 19260
#include<stdio.h>

int gcd(int,int);

int main(){
  int x,y;

  scanf("%d %d",&x,&y);
  
  while(x>y) x=x%y;
  printf("%d\n",gcd(x,y));

  return 0;
}

int gcd(x,y){
  int r;
  
  r = x % y;
  while(r!=0){
    x = y;
    y = r;
    r = x % y;
  }

  return y;
}




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

const int maxn=2010;
const int maxm=100010;
int n, k;
int x[maxm], y[maxm], c[maxm];
char s[10];
int f[maxn][maxn], g[maxn][maxn];

void chkmax(int& x,int y){ if(x<y) x=y; }
void chkmin(int& x,int y){ if(x>y) x=y; }

int ans;
int calc(int op,int x1,int y1,int x2,int y2){
	chkmin(x2, k*2), chkmin(y2, k*2);
	// x1++, y1++, x2++, y2++;
	if(x1>x2 || y1>y2) return 0;
	if(op) return f[x2][y2]-f[x2][y1-1]-f[x1-1][y2]+f[x1-1][y1-1];
	return g[x2][y2]-g[x2][y1-1]-g[x1-1][y2]+g[x1-1][y1-1];
}

int main(){

	scanf("%d%d", &n, &k);
	for(int i=1;i<=n;i++){
		scanf("%d%d%s", &x[i], &y[i], s);
		if(s[0]=='B') c[i]=1; else c[i]=2;
	}
	for(int i=1;i<=n;i++) x[i]%=2*k, y[i]%=2*k;
	for(int i=1;i<=n;i++) x[i]++, y[i]++;
	// for(int i=1;i<=n;i++) printf("%d %d\n", x[i], y[i]);
	for(int i=1;i<=n;i++) if(c[i]==1) f[ x[i] ][ y[i] ]++; else g[ x[i] ][ y[i] ]++;
	for(int i=1;i<=k*2;i++) for(int j=1;j<=k*2;j++) f[i][j]+=f[i-1][j]+f[i][j-1]-f[i-1][j-1];
	for(int i=1;i<=k*2;i++) for(int j=1;j<=k*2;j++) g[i][j]+=g[i-1][j]+g[i][j-1]-g[i-1][j-1];
	int sum1=f[k*2][k*2], sum2=g[k*2][k*2];
	for(int i=1;i<=k;i++) for(int j=1;j<=k;j++){
		//i=1; j=2;
		int t1=0, t2=0;
		t1=f[i][j]+calc(1,i+1,j+1,i+k,j+k)+calc(1,i+k+1,j+k+1,k*2,k*2)+calc(1,i+k+1,1,k*2,j)+calc(1,1,j+k+1,i,k*2);
		t2=calc(0,i+1,1,i+k,j)+calc(0,1,j+1,i,j+k)+calc(0,i+1,j+k+1,i+k,k*2)+calc(0,i+k+1,j+1,k*2,j+k);

		chkmax(ans, t1+t2); chkmax(ans, n-t1-t2);
		// printf("i = %d j = %d\n", i, j);
		// printf("%d t2 = %d\n", t1, t2);
		// printf("ans = %d\n", ans);
		//return 0;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 32896
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	string s;
	cin >> s;
	while (s.size() != 1) {
		s.erase(s.size() - 1);
		if (s.size() % 2 == 0) {
			string s1 = s.substr(0, s.size() / 2);
			string s2 = s.substr(s.size() / 2, s.size() / 2);
			if (s1 == s2) {
				cout << s.size() << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256