akhauriyash/Code-Regression huggingface dataset:
from collections import deque
import sys
input = sys.stdin.readline

h,w = map(int,input().rstrip().split())
sy,sx = map(int,input().rstrip().split())
gy,gx = map(int,input().rstrip().split())
a = [list(input().rstrip())for _ in range(h)]

sx -= 1
sy -= 1
gx -= 1
gy -= 1

dx=[1,0,-1,0]
dy=[0,1,0,-1]

def bfs():
    d = [[float("inf")]*w for _ in range(h)]
    q = deque([])
    q.append((sx,sy))
    d[sy][sx] = 0 #warp回数
    goal = False
    local_area = deque([])

    while q:
        p = q.popleft()
        local_area.append((p[0],p[1]))
        if p[0] == gx and p[1] == gy:
            goal = True
            break

        for i in range(4):
            nx = p[0]+dx[i]
            ny = p[1]+dy[i]
            if 0<=nx<w and 0<=ny<h and a[ny][nx] != "#" and d[ny][nx] == float("inf"):
                q.append((nx,ny))
                d[ny][nx] = d[p[1]][p[0]]
        if len(q) == 0 and goal == False:
            while local_area:
                p = local_area.popleft()
                for i in range(-2,3):
                    for j in range(-2,3):
                        nx = p[0]+i 
                        ny = p[1]+j
                        if 0<=nx<w and 0<=ny<h and a[ny][nx] != "#" and d[ny][nx] == float("inf"):
                            q.append((nx,ny))
                            d[ny][nx] = d[p[1]][p[0]] + 1                        

    if goal == False:
        return -1
    else:
        return d[gy][gx]
        
print(bfs())

Measured memory_bytes: 145416
import java.io.PrintWriter
import java.util.*

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val A = nextIntList().groupBy { it }.mapValues { it.value.size }
    val B = ((N + 1) % 2 until N step 2).associate { Pair(it, if (it == 0) 1 else 2) }
    if (A == B) {
        println(A.values.fold(1L) { a, b -> (a * b) % 1000000007L })
    } else {
        println(0)
    }
}

Measured memory_bytes: 61892
N, M = map(int, input().split())
KS = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    status = [0] * N
    for j in range(N):
        if i >> j & 1:
            status[N - 1 - j] = 1

    possible = True
    for j in range(M):
        cnt_sw = sum(1 if status[k-1] == 1 else 0 for k in KS[j][1:])
        if cnt_sw%2 != P[j]:
            possible = False
    if possible:
        ans += 1
    
print(ans)

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

int main() {
    ll N;
    ll K;
    cin >> N >> K;
    vector<double> E(N);
    rep(i, N){
        double a;
        cin >> a;
        E[i] = (1.0+a)/2;
    }
    double max = 0.0;
    double tmp = 0.0;
    rep(i, K){
        tmp += E[i];
    }
    if(max < tmp) max = tmp;
    rep(i, N-K){
        tmp = tmp - E[i] + E[i+K];
        if(max < tmp) max = tmp;
    }
    printf("%.12lf\n",max);
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<cstdio>
#include<math.h>
#include<stack>
#include<queue>
#include<cstring>
#include<vector>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef long long int ll;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}

//------------------変数-----------------------//
ll n, m;
typedef pair<ll, ll> P;
vector<vector<ll>> way(2001), money(2001);
ll maxa = 0, moto = 0;
ll howmuch[11451] = {};
queue <ll>q;
ll bitmax = 0;
//-------------------関数----------------------//

struct G {
	ll from;
	ll to;
	ll cost;
};
G g[10001];
ll weight[10001];
bool vis[114541] = { false };
int main() {
	fill_all(weight, (ll)MIN);
	fill_all(howmuch, (ll)MIN);
	fill_all(vis, false);
	weight[0] = 0;
	cin >> n >> m;
	REP(i, m) {
		ll a, b, c; cin >> a >> b >> c; a--; b--;
		g[i].from = a; g[i].to = b; g[i].cost = c;
	}
	ll j = 0;
	REP(i, n - 1) {
		bool flag = true;
		REP(i, m) {
			G a = g[i];
			if (weight[a.from] != MIN&&weight[a.to] < weight[a.from] + a.cost) {
				flag = false;
				weight[a.to] = weight[a.from] + a.cost;
			}
		}
		if (flag) { break; }
	}
	ll ans = weight[n - 1];
	REP(j, n - 1) {
		REP(i, m) {
			G a = g[i];
			if (weight[a.from] != MIN&&weight[a.to] < weight[a.from] + a.cost) {
				vis[a.to] = true;
				weight[a.to] = weight[a.from] + a.cost;
			}
		}
		if (vis[n - 1]) {
			cout << "inf" << endl;
		}
		else {
			cout << ans << endl;
		}
		return 0;
	}
}

Measured memory_bytes: 640
from heapq import heappush, heappop
from collections import deque
import itertools
from itertools import permutations
import sys
import bisect
sys.setrecursionlimit(10**6)
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
YNeos='YNeos'
GYN=['Yes','trumpet']
mo=10**9+7
imp='IMPOSSIBLE'

#a,b,c=MI()
n=I()
a=0
for i in range(1,n+1):
    if len(str(i))%2==1:
        a+=1
print(a)


Measured memory_bytes: 38896
#include <stdio.h>
int main()
{
long a;
while(scanf("%ld",&a)!=EOF)
{
long i,t=1;
long f();
long b=0;
for(i=1;i<=a;i++)
if(f(i)>b)
{
b=f(i);
t=i;
}
printf("%d\n",t);
}
return 0;
}
long f(long n)
{
long c=0;
while(n/=2)
{
c++;
}
return c;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int A,B;
    cin >> A >> B;
    if ((A+B)%2 == 0)
    {
        cout << (A+B)/2;/* code */
    }else{
        cout << "IMPOSSIBLE";
    }
        
}

Measured memory_bytes: 256
from sys import stdin

def main():

    input = stdin.readline

    K = int(input())

    num_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    
    print(num_list[K-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
N, K = map(int, input().split())
MOD = 10 ** 9 + 7
dp = [[[0] * 2600 for i in range(N + 5)] for j in range(N + 5)]
dp[0][0][0] = 1

for i in range(N):
    for j in range(N + 1):
        for k in range(K + 1):
            if dp[i][j][k] == 0:
                continue
            a = k + 2 * j
            dp[i + 1][j][a] += dp[i][j][k]
            dp[i + 1][j][a] += dp[i][j][k] * j
            if j > 0:
                dp[i + 1][j - 1][a] += dp[i][j][k] * j * j
            dp[i + 1][j][a] += dp[i][j][k] * j
            dp[i + 1][j + 1][a] += dp[i][j][k]
            dp[i + 1][j][a] %= MOD
            dp[i + 1][j - 1][a] %= MOD
            dp[i + 1][j + 1][a] %= MOD

print(dp[N][0][K])


Measured memory_bytes: 104028
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <map>
#include <string>
#include <math.h>
using namespace std;


int main() {

    int i=0;
    int N,M;
    cin >> N >> M;
    if(N==M){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  const double EPS=1e-8;
  int i,j,k,a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  double ans=0;
  int a1=100*a,a2=0;
  vector<int> x(3010,0);
  for(i=0;i<=f;i+=c){
    for(j=0;j<=f;j+=d){
      if(i+j<=f){
        x[i+j]=1;
      }
    }
  }
  vector<int> y;
  for(i=0;i<=f;i++){
    if(x[i]==1){
      y.push_back(i);
    }
  }
  for(i=0;i<=f/(100*a);i++){
    for(j=0;j<=f/(100*b);j++){
      for(k=0;k<y.size();k++){
        if(100*a*i+100*b*j+y[k]>f){
          continue;
        }
        if(e*(100*a*i+100*b*j)<100*y[k]){
          continue;
        }
        if(ans<100*(double)y[k]/(double)(y[k]+100*a*i+100*b*j)-EPS){
          ans=100*(double)y[k]/(double)(y[k]+100*a*i+100*b*j);
          a1=100*a*i+100*b*j+y[k],a2=y[k];
        }
      }
    }
  }
  cout << a1 << ' ' << a2 << endl;
}

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

#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define inf (long long int) 1e18
#define eps 0.000001
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define mod 1000000007
#define MAXN 100001
ll spf[MAXN]; 
ll gcd(ll a,ll b);
ll palindrome(string s);
ll modexp(ll a,ll b,ll m);
void sieve();
ll ceil(ll a, ll b);
vl getFactorization(ll x);
void getZarr(string str, ll Z[]);


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/

    ll n,m;
    cin>>n>>m;
    ll sq=sqrt(m);
    ll ans=INT_MIN;
    for(ll i=1;i<=sq;i++){
        if(m%i==0){
            ll x=m/i;
            if(i>=n){
                ans=max(ans,x);
            }
            if(x>=n){
                ans=max(ans,i);
            }
        }
    }
    cout<<ans<<endl;
    
}

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

ll palindrome(string s){
    ll l = 0;
    ll h = s.length() - 1;
    while (h > l){
        if (s[l++] != s[h--]){
            return 0;
        }
    }
    return 1;
}

ll modexp(ll a, ll b, ll m){
    if (b==0)
        return 1;
    ll temp = modexp(a,b/2,m);
    temp = (temp*temp)%m;
    if (b&1)
        return (temp*(a%m))%m; // if b is odd a^b = a^(b/2)*a^(b/2)*a
    return temp;
}

void sieve() { 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 

vl getFactorization(ll x) 
{ 
    vl ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 

ll ceil(ll a,ll b){
    return a/b+(a%b!=0);
}

void getZarr(string str, ll Z[]){
    ll n = str.length();
    ll L, R, k;
    L = R = 0;
    for (ll i = 1; i < n; ++i){
        if (i > R){
            L = R = i;
            while (R<n && str[R-L] == str[R])
                R++;
            Z[i] = R-L;
            R--;
        } else {
            k = i-L;
            if (Z[k] < R-i+1)
                Z[i] = Z[k];
            else {
                L = i;
                while (R<n && str[R-L] == str[R])
                    R++;
                Z[i] = R-L;
                R--;
            }
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n,x;
   while(cin >> n >>x){
       if(n == 0 && x == 0) break;
       
    int i, j, k, ans=0;
    for ( i = 1; i<=n; i++) {
        for ( j = i+1; j<=n; j++ ) {
            for ( k = j+1; k<=n; k++) {
            if(i+j+k==x) ans++;
            }
        }
    }
    cout << ans << endl;
   }
   return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>
#include<string.h>
#include<vector>
using namespace std;

int a[5001][5001], b[5001][5001];
int c[5001][5001];
signed main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y, z; cin >> x >> y >> z; x--; y--;
		a[x][y]++;
		a[x+z+1][y]--;
		b[x][y + 1]--;
		b[x+z+1][y + z + 2]++;
	}
	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= n; j++) {
			a[i][j] += a[i - 1][j];
		}
	}
	for (int i = 1; i < n; i++) {
		for (int j = 1; j <= i; j++) {
			b[i][j] += b[i - 1][j - 1];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= i; j++) {
			if(j)c[i][j] = c[i][j-1] + a[i][j] + b[i][j];
			else c[i][j] = a[i][j] + b[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= i; j++) {
			if (c[i][j]) { ans++;  }
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 234320
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;


void solve(){
  string s;
  cin>>s;
  rep(i,2){
    if(s[i]!=s[i+1]){
      cout<<"Yes\n";
      return;
    }
  }
  cout<<"No\n";
}

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


Measured memory_bytes: 256
def bubble_sort(c, n):
    x = c[:]
    for i in range(n):
        for k in range(n-1, i, -1):
            if x[k][1] < x[k-1][1]:
                x[k], x[k-1] = x[k-1], x[k]
    return x

def selection_sort(c, n):
    x = c[:]
    for i in range(n):
        mink = i
        for k in range(i, n):
            if x[k][1] < x[mink][1]:
                mink = k
        x[i], x[mink] = x[mink], x[i]
    return x

n = int(input())
c = []
for i in list(input().split()):
    c.append((i[0], int(i[1]))) # tupleで渡す

b = bubble_sort(c, n)
print(" ".join(map(str, [i[0]+str(i[1]) for i in b])))
# bubble_sortは常に安定なソート
stable = True
print("Stable")

s = selection_sort(c, n)
print(" ".join(map(str, [i[0]+str(i[1]) for i in s])))
if b != s:
    stable = False
if stable:
    print("Stable")
else:
    print("Not stable")


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

int main() {
  int N;
  int K;
  cin >> N >> K;
  
  int result = 1;
  for (int i = 0; i < N; i++) {
    if (result + K < result * 2) {
      result += K;
    } else {
      result *= 2;
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,m,ans=0;
  cin >> n >> m;
  ll dp[n+1][m+1];
  fill(dp[0],dp[n+1],0);
  ll s[n],t[m];
  for(int i=0;i<n;i++){
    cin >> s[i];
  }
  for(int i=0;i<m;i++){
    cin >> t[i];
  }
  for(int i=0;i<=n;i++){
    dp[i][0]=1;
  }
  for(int i=0;i<=m;i++){
    dp[0][i]=1;
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      dp[i+1][j+1] = dp[i][j+1]+dp[i+1][j];
      if(s[i]!=t[j]){
        dp[i+1][j+1] -= dp[i][j];
      }
      dp[i+1][j+1] %= MOD;
    }
  }
  while(dp[n][m]<0){
    dp[n][m] += MOD;
    dp[n][m] %= MOD;
  }
  cout << dp[n][m] << endl;
}


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

int main(){
    string s;
    cin >> s;
    bool isbad = false;
    rep(i,3){
        if(s.at(i) == s.at(i + 1)) isbad = true;
    }
    cout << (isbad ? "Bad" : "Good") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
using namespace std;
long long int MOD = 1000000000 + 7;
using ll = long long;

int main() {
	char c;
	cin >> c;
	cout << char(c + 1) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)

int main()
{
    int a, b;
    cin >> a >> b;
    for (int i = 0;i <= 1000;i++)
    {
        if (i * 8 / 100 == a&&i * 10 / 100 == b)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long int
int main() {
  ll w, h, x, y;
  std::cin >> w >> h >> x >> y;
  std::cout << w*h/2.0 << " " << (x*2==w && y*2==h?1:0) << std::endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int n; cin >> n;
    if(n==1) cout << "Hello World" << ln;
    else{
        int a, b; cin >> a >> b;
        cout << a+b << ln;
    }
}



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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

ll a[MX], b[MX], N;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N;
    FOR(i,1,N+1) cin >> a[i] >> b[i];
    ll cur = 0;
    FORd(i,1,N+1) {
        ll z;
        if (a[i]+cur == 0) z = 0;
        else z = (a[i]+cur-1)/b[i]+1;
        cur = z*b[i]-a[i];
    }
    cout << cur;
}

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

Measured memory_bytes: 1792
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n;cin >> n;
    string s;cin >> s;
    string S = s;
    rep(j, 120) {
        rep(i, n-1) {
            if(s[i]=='('&&s[i+1]==')') {
                s.erase(s.begin()+i,s.begin()+i+2);
            }
        }
    }
    int right = 0,left = 0;
    rep(i, s.size()) {
        if(s[i]==')')left++;
        else right++;
    }
    rep(i, left)cout << '(';
    cout << S;
    rep(i, right)cout << ')';
    cout << endl;
}

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

// flagを用いたバブルソート
int bubbleSort(int A[], int N)
{  int sw = 0;
   bool flag = 1;
   for( int i = 0; flag; i++ ){
      flag = 0;
      for( int j = N - 1; j >= i + 1; j-- ){
	 if( A[j] < A[j - 1] ){
	    // 隣接要素を交換する
	    swap(A[j], A[j - 1]);
	    flag = 1;
	    sw++;
	 }
      }
   }
   return sw;
}

int main()
{
   int A[100], N, sw;
   cin >> N;
   for( int i = 0; i < N; i++ ) cin >> A[i];

   sw = bubbleSort(A, N);

   for( int i = 0; i < N; i++ ){
      if( i ) cout << " ";
      cout << A[i];
   }
   cout << endl;
   cout << sw << endl;

   return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cmath>

using namespace std;

int main(){
  int N, i;
  double s;
  cin >> N;
  double A[N];
  for(i = 0; i < N; i++){
    cin >> A[i];
    A[i] = 1 / A[i];
    s += A[i];
  }
  s = 1 / s;
  cout << s << endl;
}

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

int main() {
	int N,C; cin>>N>>C;
	vector<vector<int>> d(C+1,vector<int>(C+1));
	vector<vector<int>> c(N+1,vector<int>(N+1));
	for (int i=1; i<=C; i++)
		for (int j=1; j<=C; j++)
			cin>>d[i][j];

	vector<vector<int>> groups(3,vector<int>(C+1));
	for (int i=1; i<=N; i++) {
		for (int j=1; j<=N; j++) {
			cin>>c[i][j];
			groups[(i+j)%3][c[i][j]]++;
		}
	}

	int ans = 1e9+7;
	for (int i=1; i<=C; i++) {
		for (int j=1; j<=C; j++) {
			if (i==j) continue;
			for (int k=1; k<=C; k++) {
				if (k==i or k==j) continue;
				int wrong=0;
				
				for (int l=1; l<=C; l++) {
					wrong += groups[0][l]*d[l][i];
					wrong += groups[1][l]*d[l][j];
					wrong += groups[2][l]*d[l][k];
				}

				if (wrong < ans) ans = wrong;
			}
		}
	}

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

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
ll m,d;
 
void input(void){
   cin>>m>>d;
}
 
void solve(void){
    ll ans=0,a,b;
    for(ll i=1;i<d+1;i++){
        a=i%10;
        b=i/10;
        if(a>1&&b>1&&a*b>0&&a*b<m+1){
            ans++;
        }
    }
    cout<<ans<<endl;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

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

int main() {
  vector<int> vec(5);
  int answer;
  for (int i=0;i<5;i++){
    cin >> vec.at(i);
    if (vec.at(i) == 0) answer = i;
  }
  
  cout << answer+1 <<endl;
  
  
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
#include<queue>
using namespace std;
 
#define what_is(x) cerr << #x << " is " << x << endl; 
#define PI acos(-1)
#define hell 1000000007
#define HELL 998244353
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define mset(a,n) memset(a,n,sizeof a)
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define renn(i,a,b,p) for(__typeof((a) i=(a);i>=(b);i-=p)
#define ADD(a,b,c) ((a)%c+(b)%c)%c
#define SUB(a,b,c) ((a)%c-(b)%c+c)%c
#define MUL(a,b,c) (((a)%c)*((b)%c))%c
#define lbd lower_bound
#define ubd upper_bound
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
// #define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define bug(n) {outl(n);return;}
#define pii pair<int,int>
#define lim 9223372036854775805
#define ninf -9223372036854775802
#define M 10000000009
#define eps 1e-9
#define MAX 10
//#define N 100001
#define db(a) for(auto it:a) {cout<<it<<" ";}cout<<endl;
ll prime[MAX]; 
ll fact[MAX];

const long long INF64 = 1e18;
ll vpow(ll a,ll b,ll p){
    if(b==0)
        return 1;
    if(b==1)
            return a;
    ll temp=vpow(a,b/2,p);
    temp*=temp;
    temp%=p;
    if(b%2==0)
        return temp;
    temp=temp*a;
    temp%=p;
    return temp;
}

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

 
ll inverseMod(ll a,ll b,ll p){
    if(b==0)
        return 1;
    ll temp=vpow(b,p-2,p);
    ll ans=temp*a;
    ans%=p;
    return ans;
}
void sieve() 
{ 
    prime[0] = prime[1] = 1; 
    for (ll i = 2; i < MAX; i++) { 
        if (prime[i] == 0) {
            for (int j = i * 2; j < MAX; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
}

void factorial(){
    fact[0]=1;
    fact[1]=1;
    rep(i,2,MAX){
        fact[i]=(fact[i-1]*i);
        // fact[i]%=M;
    }
}
ll rand(ll a,ll b){
    return a+rand()%(b-a+1);
}
const int p = 31; 
const ll m = 1e10 + 9;

void solve(ll ttt){
    ll n;
    cin>>n;
    if(n>=30){
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;

}
int main(){
    io;
    // sieve();
    // factorial();
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
     // freopen("output1.txt","w",stdout);
#endif
    ll t=1;
     // cin>>t;
    fix(12);
    rep(q,1,t+1){
        // cout<<"Case #"<<q<<": ";
         solve(q);
        //solve2();
    }
    return 0;
    
}        




Measured memory_bytes: 3612
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
    int a, b, x;
    cin >> a >> b >> x;
    if (a + b >= x && a <= x)YES;
    else NO;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp14
{
    class Class34
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var H = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ans = 0;
            int count = 0;
            for(int i = 0; i < N-1; i++)
            {
                if (H[i] >= H[i + 1])
                {
                    count++;
                }
                else
                {
                    ans = Math.Max(ans, count);
                    count = 0;
                }
            }
            ans = Math.Max(ans, count);
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 28124
import java.util.Scanner;

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

        int inH, inW;

        while (true) {
            inH = Integer.parseInt(scan.next());
            inW = Integer.parseInt(scan.next());

            if (inH == 0 && inW == 0) {
                break;
            }
            func.printf(inH, inW);
        }
    }
}

class Function3 {
    public void printf(int h, int w) {
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (i % 2 == 0) {
                    if (j % 2 == 0) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                } else {
                    if (j % 2 == 0) {
                        System.out.print(".");
                    } else {
                        System.out.print("#");
                    }
                }
            }
            System.out.print("\n");
        }
        System.out.print("\n");
    }
}


Measured memory_bytes: 38664
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace AtCoder.ABC171
{
    public class Problem2
    {
        public static void Main(string[] args)
        {
            var a = Console.ReadLine().Split(" ");

            var N = int.Parse(a[0]);

            var K = int.Parse(a[1]);

            var ps = Console.ReadLine().Split(" ");

            var prices = new List<int>();

            foreach(var p in ps)
            {
                prices.Add(int.Parse(p));
            }

            var price = prices.OrderBy(x => x).ToList().GetRange(0, K).Sum();

            Console.WriteLine(price.ToString());
        }
    }
}


Measured memory_bytes: 28464
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    char c;
    cin >> c;
    char ans = c+1;
    cout << ans << endl;
}

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



int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int ans = A - B;
	ans = C -ans;

	if (ans < 0) {
		cout << 0 << endl;
		return 0;
	}
	else {
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
/*
    ALWAYS REMMEMBER:
        NEVER GIVE UP !
        DON'T MESS WITH ME !!!
        "" THE EXPERT IN ANYTHING WAS ONCE A BEGINNER ""
*/

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;

void solve()
{
    ld a,b;
    cin >> a >> b;

    f(i,1,10000)
    {
        // cout <<  i << " " << floor(i*0.08) << " " << floor(i*0.1) << endl;
        if(floor(i*0.08)==a && floor(i*0.1)==b)
        {
                cout << i ;
                return;
        }
    }
    cout << -1;
    return;
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

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

template<class c> auto try_out(c a) -> decltype(cerr << a, 0);
char try_out(...);

struct debug {
#ifdef LOCAL
template<class c, class d> debug& operator << (pair<c, d> e) {
	return *this << "(" << e.first << ", " << e.second << ")";
}
template<class c> typename enable_if<sizeof(try_out(declval<c>())) != 1, debug&>::type operator << (c a) {
	cerr << boolalpha << a;
	return *this;
}
template<class c> typename enable_if<sizeof(try_out(declval<c>())) == 1, debug&>::type operator << (c a) {
	*this << "[";
	for (auto it = a.begin(); it != a.end(); ++it)
		*this << ","[1 - (it != a.begin())] << *it;
	return *this << "]";
}
#else
template<class c> debug& operator << (c) {
	return *this;
}
#endif
};

#define aty(x) " [" << #x ": " << x << "] "

using ll = long long;




int main() {
    
    int n;
    cin >> n;
    
    int ans = 0;
    
    for (int i = 1; i <= n; ++i) 
    {
        int cn = 0;
        for (int j = 1; j <= i; ++j)
        {
            if (i % j == 0)
                cn++;
        }
        if (cn == 8 && i % 2 == 1) 
        {
            ans++;
        }
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long  n,s[1000009];
long long sum=0;
cin>>n;
for(int i=1;i<=n;i++)
{
    if(i%3==0||i%5==0)
        s[i]=0;
        else
            s[i]=i;

}
    for(int i=1;i<=n;i++)
        sum+=s[i];
    cout<<sum<<endl;
}


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

int main (int argc, char **argv) {
  int a, b, c;
  cin >> a >> b >> c;

  int cnt = 0; // counter
  int x = a;
  while (x <= b) {
    if (c % x == 0) cnt++;
    x++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1164
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> l = new ArrayList<>();
        List<Integer> r = new ArrayList<>();
        IntStream.range(0, n).forEach(i -> {
            l.add(sc.nextInt());
            r.add(sc.nextInt());
        });

        int count = 0;
        for (int i = 0; i < n; i++) {
            count += r.get(i) - l.get(i) + 1;
        }
        System.out.println(count);
    }

}


Measured memory_bytes: 27312
# -*- coding: utf-8 -*-
import math


def trial_division(n):
    factor_set = set()
    factor_set.add(1)
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor_set.add(num)
    if not factor_set:
        factor_set.add(n)
        return factor_set
    else:
        factor_set.add(n)
        return factor_set


a, b = map(int, input().split())
td_a = trial_division(a)
td_b = trial_division(b)
count = len(td_a & td_b)
print(count)



Measured memory_bytes: 3064
program main;
var N,i,x,y:integer;
begin
    readln(N);
    i:=0; x:=1000; y:=1;
    if N mod 1000 = 0 then writeln('0')
    else begin
    while x<N do begin
    y:=y+1; x:=x+1000;
    end;
    writeln(y*1000-N);
end;
end.

Measured memory_bytes: 1384
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <ctime> 
using namespace std;

#define pb push_back
#define All(a) a.begin(), a.end()
#define met(a, b) memset(a, b, sizeof(a))
#define rep1(i, l, r) for(int i = l; i <= r; ++i)
#define rep2(i, l, r) for(int i = l; i < r; ++i) 
#define per(i, r, l) for(int i = r; i >= l; --i)
typedef long long ll;
typedef double db;
typedef long double ldb;
const int NIL = -1;
const int oo = 0x3f3f3f3f;
const ll INF = 2e18;
const db eps = 1e-8;
const db PI = acos(-1.0);

inline int read(void)
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9')	{ if(ch == '-') f = -1; ch = getchar(); } 
	while(ch >= '0' && ch <= '9') {	x = (x << 1) + (x << 3) + ch - '0';	ch = getchar();	}
	return x * f;
}

inline void write(int x)
{
	if(x < 0) { putchar('-'); x = -x; }
    if(x >= 10) write(x/10); 
	putchar(x%10+'0'); 
}

int main(void)
{
	int a, b, c;
	scanf("%1d%1d%1d", &a, &b, &c);
	int m = max(max(a, b), c);
	int ans = a;
	if(m > a) ans++;
	printf("%d%d%d", ans, ans, ans);
	
	return 0;
} 

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;

string solve(string s){
	int n = sz(s);
	vi f(n);
	rep(i , n){
		if(i > 0){
			f[i] = f[i - 1];
		}
		if(s[i] == '(')++f[i];
		else --f[i];
	}
/*	rep(i , n){
		cout << f[i] << " ";
	}*/
	string ans = "";
	bool flag = 0;
	rep(i , n){
		if(f[i] < 0 && !flag){
			ans = "(" + ans;
			flag = 1;
		}
		ans += s[i];
	}
	if(f[n - 1] > 0){
		ans += ')';
	}
	return ans;
}

bool is_correct(string & s){
	int cnt = 0;
	rep(i , sz(s)){
		if(s[i] == '(')++cnt;
		else --cnt;
		if(cnt < 0)return 0;
	}
//	return 1;
	return cnt == 0;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n;
	cin >> n;
	string s;
	cin >> s;
	
	while(!is_correct(s)){
		s = solve(s);
	}
	
	cout << s;
	
//	string s1 = "()(())()";
//	cout << nl << (s < s1);
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  vector<P> d(n, P(0, 0));
  rep(i, 0, n) { cin >> d[i].fi >> d[i].se; }
  rep(i, 0, n - 2) {
    if (d[i].fi == d[i].se && d[i + 1].fi == d[i + 1].se &&
        d[i + 2].fi == d[i + 2].se)
      ans++;
  }
  if (ans > 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
using System;

class main
{
    public static int Main()
    {
        string x = Console.ReadLine();
        string[] str = x.Split(' ');
        int a = int.Parse(str[0]);
        int b = int.Parse(str[1]);
        int c = int.Parse(str[2]);

        
        
        if (a < b && b < c)
        {
            Console.WriteLine("Yes");
        }

        else 
        {
            Console.WriteLine("No");
        }




        return 0;
    }
}

Measured memory_bytes: 9028
#include<bits/stdc++.h>
using namespace std;
long long cntR,cntB,cntG;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='R')cntR++;
		if(s[i]=='B')cntB++;
		if(s[i]=='G')cntG++;
	}
	long long ans=cntR*cntB*cntG;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(s[i]==s[j])continue;
			if(2*j-i<n&&s[i]!=s[j]&&s[i]!=s[2*j-i]&&s[j]!=s[2*j-i]){
				ans--;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			char[] s = in.nextString().toCharArray();

			int count = 0;

			for (int i = 1; i < n-1; i++) {
				int tmp = 0;
				int[] s1 = new int[26];
				int[] s2 = new int[26];

				for (int j = 0; j < i; j++) {
					s1[s[j]-'a']++;
				}
				for (int j = i; j < n; j++) {
					s2[s[j]-'a']++;
				}

				for (char j = 'a'; j <= 'z'; j++) {
					if (s1[j-'a'] >= 1 && s2[j-'a'] >= 1) {
						tmp++;
					}
				}

				count = Math.max(count, tmp);
			}

			out.println(count);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 22868
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> p;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template <class T> bool chmax(T &a, const T &b) {
  if(a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if(b < a) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  ll h;
  cin >> h;
  int log = log2(h) + 1;
  ll ans = pow(2, log) - 1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main (void){
	
	int N, A, B;

	scanf("%d", &N);
	scanf("%d", &A);
	scanf("%d", &B);

	int i, sum = 0, SUM = 0;
	int sum4 = 0, sum3 = 0, sum2 = 0, sum1 = 0, sum0 = 0;

	for(i = 1; i <= N; i++){
		sum4 = i / 10000;
		sum3 = (i - 10000 * sum4) / 1000;
		sum2 = (i - 10000 * sum4 - 1000 * sum3) / 100;
		sum1 = (i - 10000 * sum4 - 1000 * sum3 - 100 * sum2) / 10;
		sum0 = (i - 10000 * sum4 - 1000 * sum3 - 100 * sum2 - 10 * sum1);

		sum = sum4 + sum3 + sum2 + sum1 + sum0;

		if( A <= sum && sum <= B){
			SUM = SUM + i;
		}
	}

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

	return 0;

}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		int num = 0;
		int result1 = 1;
		int result2 = 0;
		boolean flag;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			num = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		}

		for (int i = 1; i <= num; i++) {
			int count = 0;
			int temp = i;
			flag = true;
			do {
				if (temp % 2 != 0) {
					if (result2 < count) {
						result1 = i;
						result2 = count;
					}
					flag = false;
				} else {
					temp = temp / 2;
					count++;
				}
			} while(flag);
		}

		System.out.println(result1);

	}
}


Measured memory_bytes: 23252
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main(void){
  int L, R, d; cin >> L >> R >> d;
  int res = 0;
  for (int i = L; i <= R; ++i)
    if (i % d == 0) ++res;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
constexpr int MOD = 998244353;

template <int N>
struct Eratosthenes
{
    int w[N + 1];
    bool is_not_prime[N + 1];
    constexpr Eratosthenes() : w(), is_not_prime()
    {
        w[0] = 0;
        w[1] = 1;
        for (int i = 2; i <= N; i++)
        {
            w[i] = MOD - 1LL * w[MOD % i] * (MOD / i) % MOD;
        }
        for (int prime = 2; prime <= N; prime++)
        {
            if (is_not_prime[prime])
            {
                continue;
            }
            for (int k = N / prime; k > 1; --k)
            {
                is_not_prime[k * prime] = true;
                w[k * prime] -= w[k];
                if (w[k * prime] < 0)
                {
                    w[k * prime] += MOD;
                }
            }
            w[prime] -= w[1];
        }
    }
};

int main()
{
    constexpr int M = 1000000;
    constexpr auto e = Eratosthenes<M>();
    long long ans = 0;
    int count[1000001] = {};
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
    {
        int j;
        scanf("%d", &j);

        count[j] += j;
        if (count[j] >= MOD)
        {
            count[j] -= MOD;
        }
        ans -= j;
        if (ans < 0)
        {
            ans += MOD;
        }
    }

    for (int prime = 2; prime <= M; prime++)
    {
        if (e.is_not_prime[prime])
        {
            continue;
        }
        for (int k = M / prime; k > 0; --k)
        {
            count[k] += count[k * prime];
            if (count[k] >= MOD)
            {
                count[k] -= MOD;
            }
        }
    }

    for (int i = 1; i <= M; i++)
    {
        ans += 1LL * count[i] * count[i] % MOD * e.w[i] % MOD;
    }
    ans %= MOD;
    if ((ans & 1) == 1)
    {
        ans = (ans + MOD) >> 1;
    }
    else
    {
        ans = ans >> 1;
    }
    printf("%ld\n", ans);
}


Measured memory_bytes: 8960