akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <string.h>

#undef max
#undef min

int memo[1 << 15][15] = {0}; // [接続済み都市][最後の都市] = 文字数
int overlaps[15][15] = {0};

int main() {
	int n;
	while (std::cin >> n && n) {
		std::vector<std::string> cities;
		memset(memo, 0, sizeof(memo));
		memset(overlaps, 0, sizeof(overlaps));
		for (int i = 0; i < n; i++) {
			std::string s; std::cin >> s;
			cities.push_back(s);
		}

		{
			// 完全に他都市の文字列と重なる都市を削除
			std::vector<std::string> newCities;
			for (auto& city : cities) {
				bool isOverlap = false;
				for (auto& otherCity : cities) {
					if (city == otherCity) continue;
					// 他都市より文字数が少なければ完全に重なる可能性あり
					if (city.size() < otherCity.size()) {
						for (int i = 0; i < otherCity.size() - city.size() + 1; i++) {
							std::string s1 = otherCity.substr(i, city.size());
							if (s1 == city) {
								isOverlap = true;
								break;
							}
						}
					}
				}

				if (!isOverlap) {
					newCities.push_back(city);
				}
			}

			cities = newCities;
		}

		// 重複している長さを調べる
		for (int city = 0; city < cities.size(); city++) {
			for (int otherCity = 0; otherCity < cities.size(); otherCity++) {
				if (city == otherCity) continue;
				int maxLen = 0;
				for (int l = 1; l < cities[city].size(); l++) { // 重なる文字数
					std::string s1 = cities[city].substr(cities[city].size() - l);
					std::string s2 = cities[otherCity].substr(0, l);

					if (s1 == s2) {
						maxLen = l;
					}
				}
				overlaps[city][otherCity] = maxLen;
			}
		}

		// 適当に探索
		std::stack<std::pair<int, int>> s; // first:接続済み都市 second:最後の都市
		for (int i = 0; i < cities.size(); i++) {
			s.push(std::make_pair(1 << i, i));
			memo[1 << i][i] = cities[i].size();
		}

		while (!s.empty()) {
			auto now = s.top();
			bool isUpdated = false;
			for (int nextCity = 0; nextCity < cities.size(); nextCity++) {
				if (now.first & 1 << nextCity) continue; // 接続済み

				auto next = now;
				next.first = now.first | 1 << nextCity;
				next.second = nextCity;
				int nextStrLen = memo[now.first][now.second] + cities[nextCity].size() - overlaps[now.second][nextCity];
				if (memo[next.first][nextCity] != 0 && memo[next.first][nextCity] <= nextStrLen) continue; // 更新できない
				// 更新
				memo[next.first][nextCity] = nextStrLen;
				s.push(next);
				isUpdated = true;
			}
			if (!isUpdated) s.pop();
		}

		int result = 1e9;
		int all = std::pow(2, cities.size()) - 1;
		for (int i = 0; i < cities.size(); i++) {
			result = std::min(memo[all][i], result);
		}

		std::cout << result << std::endl;
	}
	return 0;
}


Measured memory_bytes: 5080
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int a[100010];
    rep(i, n) cin >> a[i];
    int ans = INF2;
    rep(k, 2) {
        int sum[100010] = {};
        int tmp = 0;
        rep(i, n) {
            sum[i + 1] += sum[i] + a[i];
            
            bool isplus = ((i + k) % 2 == 0);
            //cout << k << " " << i << " " << sum[i + 1] << " " << tmp << " " << isplus << " ";
            if(isplus && sum[i + 1] <= 0) {
                tmp += 1 - sum[i + 1];
                sum[i + 1] = 1;
            } else if (!isplus && sum[i + 1] >= 0) {
                tmp += sum[i + 1] + 1;
                sum[i + 1] = -1;
            }
            //cout  << tmp << endl;
            
        }
        
        ans = min(ans, tmp);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1792
#Atocoder ABC 157 B "Bingo"

a = list(map(int,input().split()))
b  = list(map(int,input().split()))
c  = list(map(int,input().split()))
box = [a,b,c]

N = int(input())
for i in range(N):
    s = int(input())
    for j in range(3):
        if s == a[j]:
            a[j] = 0
        if s == b[j]:        
            b[j] = 0
        if s == c[j]:        
            c[j] = 0

if box[1][1] == 0:
    if box[0][1] == 0 and box[2][1] == 0:
        print("Yes")
        exit()
    elif box[1][0] == 0 and box[1][2] == 0:
        print("Yes")
        exit()
    elif box[0][0] == 0 and box[2][2] == 0:
        print("Yes")
        exit()
    elif box[0][2] == 0 and box[2][0] == 0:
        print("Yes")
        exit()
        
if box[0][0] == 0 and box[0][1] == 0:
    if box[0][2] == 0:
        print("Yes")
        exit()
if box[2][0] == 0 and box[2][1] == 0:
    if box[2][2] == 0:
        print("Yes")
        exit()
if box[0][0] == 0 and box[1][0] == 0:
    if box[2][0] == 0:
        print("Yes")
        exit()
if box[0][2] == 0 and box[1][2] == 0:
    if box[2][2] == 0:
        print("Yes")
        exit()

print("No")

Measured memory_bytes: 62000
Mod = 10**9+7
n,m = map(int,input().split())
a = [int(input()) for i in range(m)]

v = [-1]*(n+1)
v[0] = 1

for t in a:
  v[t] = 0

if v[1] == -1:
  v[1] =1
  
for i in range(2,n+1):
  if v[i] == 0:
    continue
  v[i] = (v[i-1] + v[i-2])%Mod
#print(v)  
print(v[n])

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

using namespace std;
typedef long long ll;

// #define DEBUG

const int maxint = 1e9;
struct timestamp;
vector<int> shortest;
vector<vector<pair<int, int>>> connective;

void djkstra(int x)
{
    vector<int> search = {x};
    vector<int> new_search;
    shortest[x] = 0;
    int v, d;
    while (!search.empty())
    {
        for (auto itr = search.begin(); itr != search.end(); itr++)
        {
            for (auto itr2 = connective[*itr].begin(); itr2 != connective[*itr].end(); itr2++)
            {
                v = itr2->first, d = itr2->second;
                if (shortest[v] > d + shortest[*itr])
                {
                    shortest[v] = d + shortest[*itr];
                    new_search.push_back(v);
                }
            }
        }
        search.clear();
        search = new_search;
        new_search.clear();
    }
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, m, r, s, t, d;
    cin >> n >> m >> r;
    connective.resize(n);
    for (int i = 0; i < n; i++)
    {
        shortest.push_back(maxint);
    }
    for (int i = 0; i < m; i++)
    {
        cin >> s >> t >> d;
        connective[s].push_back(make_pair(t, d));
    }
    djkstra(r);
    for (int i = 0; i < n; i++)
    {
        if (shortest[i] == maxint)
        {
            cout << "INF" << endl;
        }
        else
        {
            cout << shortest[i] << endl;
        }
    }

    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)
// for (int j = 0; j < m; j++)


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

using namespace std;
 
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
 
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#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 all(c) (c.begin(),c.end())
#define in(x, a, b) (a <= x && x < b)
const int inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
//const ll mod = 1000000009;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p <<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);


int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int sei = 0, gyaku = 0;
  int ma = inf;
  rep1 (i, n - 1) {
    if (s[i] == 'W') {
      sei++;
    }
    else {
      gyaku++;
    }
  }
  ma = min(ma, gyaku);
  rep1 (i, n - 1) {
    if (s[i - 1] == 'W') {
      gyaku++;
    }
    else {
      sei++;
    }
    if (s[i] == 'W') {
      sei--;
    }
    else {
      gyaku--;
    }
    ma = min(ma, gyaku);
  }
  cout << ma << endl;
  
}


Measured memory_bytes: 900
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int H, W;
    cin >> H >> W;
    char s[H][W];
    REP(i, H) REP(j, W) cin >> s[i][j];

    deque< pair<int, int> > dq;
    dq.push_back(make_pair(0, 0));

    int visited[H][W];
    REP(i, H) REP(j, W) visited[i][j] = -1;
    visited[0][0] = 0;

    int dh[4] = {0, 0, -1, 1};
    int dw[4] = {-1, 1, 0, 0};
    while (dq.size() != 0) {
        int h = dq.front().first;
        int w = dq.front().second;
        dq.pop_front();
        REP(i, 4) {
            if (h + dh[i] >= 0 && h + dh[i] < H && w + dw[i] >= 0 && w + dw[i] < W) {
                if (visited[h + dh[i]][w + dw[i]] == -1) {
                    if (s[h + dh[i]][w + dw[i]] == '.') {
                        visited[h + dh[i]][w + dw[i]] = visited[h][w] + 1;
                        dq.push_back(make_pair(h + dh[i], w + dw[i]));
                    }
                }
            }
        }
    }
    if (visited[H - 1][W - 1] == -1) {
        cout << -1 << endl;
    }
    else {
        int nWhites = visited[H - 1][W - 1] + 1;
        int nBlacks = 0;
        REP(i, H) REP(j, W) {
            if (s[i][j] == '#') nBlacks++;
        }
        cout << (H * W - nWhites - nBlacks) << endl;
    }

    return 0;
}


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

int main()
{
    int a,b;
    std::cin>> a >> b;
    int c = a + b;
    int e = a - b;
    int f = a * b;

    if( c < e )
    {
        if( f < e )
        {
            std::cout<< e;
        }
        else
        {
            std::cout<< f;
        }
    }
    else
    {
        if( f < c )
        {
            std::cout<< c;
        }
        else
        {
            std::cout<< f;
        }
    }
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)

ds = Hash.new(0)
for id in 1..n
  ds[id - a[id-1]] += 1 if id - a[id-1] > 0
end

cnt = 0
for id in 1..n
  if ds[id + a[id-1]] > 0
    cnt += ds[id + a[id-1]]
  end
end
puts cnt

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

using namespace std ; 

unsigned long long mlimit = 1000000000000000000ULL; 

int main()
{
	int n ; 
	unsigned long long a, m = 1ULL ; 
	bool flag = false ; 
	bool isZero = false ; 

	cin >> n ; 
	for(int i = 0 ; i < n ; ++i )
	{
		cin >> a ; 
		
		if(a==0ULL)
		{
			m = 0ULL ; 
			flag = false ;
			isZero = true ;
			continue; 
		}
		
		if(isZero)continue ; 

		if(m == 0 || a > (mlimit/m)){
			flag = true ;
			m = 0ULL ; 
		}
		else m *= a ; 	
	}
	if(isZero)
	{
		cout << "0\n" ; 
		return 0 ; 
	}
	if(flag) cout << "-1\n"; 
	else cout << m << "\n" ; 
	return 0 ; 
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   long long n, k, x, y;
   cin >> n >> k >> x >> y;
   if(k>n) {
       cout << n*x << endl;
   } else {
       cout << k*x+(n-k)*y << endl;
   }
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.sort() 
alice_sum=0
bob_sum=0
if len(a)%2==0:
  for i in range(0,n,2):
    bob_sum+=a[i]
  for l in range(1,n,2):
    alice_sum+=a[l]
else:
  for i in range(0,n,2):
    alice_sum+=a[i]
  for k in range(1,n,2):
    bob_sum+=a[k]
    
print(alice_sum-bob_sum)



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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int mod = 2019;

int main()
{
    int L,R;
    while (cin >> L >> R) {
        VI A;
        for (int i = 0; i < min(mod,R+1-L); i++)
            A.push_back((L+i)%mod);
        const int n = A.size();
        int ans = mod;
        FOR(i,0,n) FOR(j,i+1,n)
            ans = min(ans, A[i]*A[j] % mod);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int righttriangle(int a,int b,int c){
	a*=a;b*=b;c*=c;
	if(a+b==c||b+c==a||a+c==b)return 1;
	else return 0;}
int main(){
	int n,a,b,c,i,j[1000];
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a>>b>>c;
		j[i]=righttriangle(a,b,c);}
	for(i=0;i<n;i++){
		if(j[i])cout<<"YES"<<endl;
		else cout<<"NO"<<endl;}
	return 0;}


Measured memory_bytes: 3060
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;

int main() {
	
	string str;
	int k;

	cin >> k;
	cin >> str;

	rep(i, str.size()) {
		str.at(i) = str.at(i) + k;
		if (str.at(i) > 'Z') {
			int j = str.at(i) - 'Z' - 1;
			str.at(i) = 'A' + j;
		}
	}
	
	cout << str << endl;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

LL t[2][200005];
int n;

int check(int p){
	if(p>=n)p-=n;
	if(p<0)p+=n;
	if(t[0][p]==t[1][p])return 0;
	LL a,b,c;
	int i,j,k;
	a=p-1,b=p+1;
	if(a<0)a+=n;
	if(b>=n)b-=n;
	if(t[1][a]>=t[1][p] || t[1][p]<=t[1][b])return 0;
	a=t[1][a]+t[1][b];
	c=(t[1][p]-t[0][p])/a;
	t[1][p]-=c*a;
	return check(p-1)+check(p+1)+c;
}

int main(){
	LL a,b,c;
	int i,j,k;
	LL s=0;
	cin>>n;
	
	for(j=0;j<2;j++){
		for(i=0;i<n;i++){
			cin>>t[j][i];
		}
	}
	for(i=0;i<n;i++){
		a=check(i);
		if(a==-1){
			cout<<-1<<endl;
			return 0;
		}
		s+=a;
	}
	for(i=0;i<n;i++){
		if(t[0][i]!=t[1][i]){
			cout<<-1<<endl;
			return 0;
		}
	}
	cout<<s<<endl;
}


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

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define FILE "parade"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const ull ULLINF = numeric_limits<ull>::max();
const double PI = acos(-1.0);


int main()
{
//    freopen(FILE".in", "r", stdin);
//    freopen(FILE".out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2;
    return 0;
}


Measured memory_bytes: 764
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  [a, b, c] <- getInts
  putStrLn $ if a + b >= c then "Yes" else "No"

readInts :: BC.ByteString -> [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words

getInts :: IO [Int]
getInts = readInts <$> BC.getLine


Measured memory_bytes: 380
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<map>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
const int mod=1000000007;
long long qpow(long long a,long long b)
{
	long long ans=1;
	while(b)
	{
		if(b&1)	ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
int dig[30000005];
int n;
int main()
{
	int las=1;
	for(int i=1;i<=8;i++)
	{
		int mx=min(las*10,30000000);
		for(int j=las;j<mx;j++)
			dig[j]=i;
		las*=10;
	}
	for(int i=1;i<=29999999;i++)
		dig[i]+=dig[i-1];
	read(n);
	long long ans=0;
	int r=0;
	for(int i=1;i<10000000;i++)
	{
		while(dig[r]-dig[i-1]<n)	r++;
		if(dig[r]==dig[i-1]+n)	ans++;
	}
	int mxx=n/8;
	ans+=mxx;
	for(int i=1;i<=mxx;i++)
		if(n%i==0)
		{
			int nn=n/i;
			long long sb=9*qpow(10,nn-1)%mod;
			ans+=sb-i;
			ans=(ans+mod)%mod;
		}
	ans=(ans+mod)%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 117504
#include <iostream>
#include <string.h>
#include <utility>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <queue>
#include <set>
#include <math.h>
#define pp pair<int, int>
#define vpp vector<pp>
#define vecto vector<ll>
#define ll long long
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
using namespace std;
#define ull unsigned long long int
#define f(i, n) for (int i = 0; i < n; i++)
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;
#define mod 1000000007
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
ll max(ll a, ll b)
{
    if (a > b)
        return a;
    return b;
}

int main()
{
    IOS;
    ll n;
    cin >> n;
    ll arr[n];
    ll max = -1;
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
        if (arr[i] >= max)
        {
            max = arr[i];
            continue;
        }

        ans += abs(max - arr[i]);
    }
    cout << ans;

    ll a, b, c;
    //cin >> a >> b >> c;
    float x = (float)c / b;
    //cout << x << endl;
    //cout << (int)ceil(x * a);
}

Measured memory_bytes: 5212
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
 
int main(void){
 
	int a,b,c;
	int h;
	int p;

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

	h = a + b;

	if(h + 1 >= c){
		p = c;
	}
	else{
		p = h + 1;
	}
	
	printf("%d\n",p + b);


	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int max = 0;
        for (int i = 1; i < n; i++) {
            List<String> s1 = Arrays.asList(s.substring(0, i).split(""));
            List<String> s2 = Arrays.asList(s.substring(i).split(""));
            Set<String> set = new HashSet<>(s1);
            set.retainAll(s2);
            if (set.size() > max) {
                max = set.size();
            }
        }
        System.out.println(max);
    }

}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};

//ユークリッドの互除法
ll gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}

//3項以上の場合
ll gcd(vector<ll>a) {
  int ans = a[0];
  for (int i=1; i<sz(a); i++) {
    ans = gcd(ans, a[i]);
  }
  return ans;
}

ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

int f(int x) {
    int res = 0;
    while (x%2==0) {
        x /= 2;
        res++;
    }
    return res;
}

int main() {
    int n,m; cin >> n >> m;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    
    rep(i,n) {
        a[i] /= 2;
    }

    int t = f(a[0]);
    rep(i,n) {
        if (f(a[i]) != t) {
            cout << 0 << endl;
            return 0;
        }
        a[i] >>= t;
    }
    m>>=t;

    ll l = 1;
    rep(i,n) {
        l = lcm(l, a[i]);
        if (l>m) {
            cout << 0 << endl;
            return 0;
        }
    }

    m /= l;
    int ans = (m+1)/2;
    cout << ans << endl;

    // int cnt = 0; //因数2の個数
    // ll num = 2;
    // ll tmp = 2;
    // while (a[0]%tmp==0) {
    //     cnt++;
    //     tmp *= 2;
    // }
    // //tmp /= 2;

    // rep(i,n-1) { //存在するか判定
    //     num = 2;
    //     while (a[i+1]%num==0) {
    //         num *= 2;
    //     }
    //     if (num != tmp) {
    //         cout << 0 << endl;
    //         return 0;
    //     }
    // }

    // ll GCD = gcd(a);
    // rep(i,n) a[i] /= GCD;
    // ll LCM = GCD;
    // set<ll> st;
    // rep(i,n) st.insert(a[i]);
    // for (ll x : st) LCM *= x;
    // LCM /= 2;

    // ll ans = 0;
    // for (ll i=1;;i+=2) {
    //     ll tmp2 = LCM;
    //     tmp2 *= i;
    //     if (tmp2 > m) break;
    //     ans++;
    // }
    // cout << ans << endl;
}

Measured memory_bytes: 3932
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <limits.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    std::vector<int> vs;
    for(int i=0; i<n; i++){
        int tmp;
        scanf("%d", &tmp);
        vs.push_back(tmp);
    }
    int q;
    cin >> q;
    std::vector<int> vt;
    for(int i=0; i<q; i++){
        int tmp;
        scanf("%d", &tmp);
        vt.push_back(tmp);
    }
    int sum = 0;
    for(int i=0; i<vt.size(); i++){
        int left = 0;
        int right = n;
        int key = vt[i];
        while(left < right){
            int mid = (left+right)/2;
            if(vs[mid] == key){
                sum++;
                break;
            }else if(key > vs[mid]){
                left = mid + 1;
            }else{
                right = mid;
            }
        }
    }
    cout << sum << endl;
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N, A, B;
    ll temp;
    cin >> N >> A >> B;
    temp = B - A;
    if(temp % 2) {
        temp = min(A - 1, N - B) + 1 + (B - A - 1) / 2;
    } else {
        temp /= 2;
    }
    cout << temp << endl;
    return 0;
}


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

#define all(x) (x).begin(), (x).end()
using lli = long long int;

int main() {
  ios_base::sync_with_stdio(false);
  size_t n; cin >> n;
  vector<int> v(3 * n);
  for (auto& a : v) cin >> a;
  multiset<int> m, r, backup;
  lli ans = 0;
  for (auto a : v) {
    if (r.size() < n || a < *r.rbegin()) {
      if (r.size() >= n) {
        backup.insert(*r.rbegin());
        ans += *r.rbegin();
        r.erase(--r.end());
      }
      ans -= a;
      r.insert(a);
    } else {
      backup.insert(a);
    }
  }
  lli answer = std::numeric_limits<lli>::min() / 10;
  for (auto a : v) {
    if (m.size() < n || a > *m.begin()) {
      if (m.size() >= n) {
        ans -= *m.begin();
        m.erase(m.begin());
      }
      m.insert(a);
      ans += a;
    }
    auto bit = backup.find(a) ;
    if (bit != backup.end()) {
      backup.erase(bit);
    } else {
      auto rit = r.find(a);
      ans += *rit;
      r.erase(rit);
      if (backup.size()) {
        ans -= *backup.begin();
        r.insert(*backup.begin());
        backup.erase(backup.begin());
      }
    }
    if (m.size() == n && r.size() == n) {
      answer = std::max(answer, ans);
    }
  }
  cout << answer;
  return 0;
}

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

int main(){
	string S;
	cin >> S;
	bool flag=false;
	for(int i=0;i<3;i++)if(S[i]==S[i+1])flag=true;
	if(flag)cout << "Bad" << endl;
	else cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
# Aizu Problem 0002: Digit Number
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


for line in sys.stdin:
    a, b = [int(_) for _ in line.split()]
    print(len(str(a + b)))

Measured memory_bytes: 7784
#include<bits/stdc++.h>
using namespace std;
bool visited[100001];
vector<int> v[100001];
int dp[100001];
void dfs(int u){
    visited[u]=true;
    for(int i=0;i<v[u].size();i++){
       if(!visited[v[u][i]]){dfs(v[u][i]);}
        dp[u]=max(dp[u],1+dp[v[u][i]]);
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;
        v[a].push_back(b);
    }
    for(int i=1;i<=n;i++){dp[i]=0;visited[i]=false;}
    for(int i=1;i<=n;i++){
        if(!visited[i]){
            dfs(i);
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
       // cout<<dp[i]<<" ";
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
    
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;
  s[5] = s[13] = ' ';
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()


class SegTree:
    X_unit = 0

    def __init__(self, N, X_f=min):
        self.N = N
        self.X = [self.X_unit] * (N + N)
        self.X_f = X_f

    def build(self, seq):
        for i, x in enumerate(seq, self.N):
            self.X[i] = x
        for i in range(self.N - 1, 0, -1):
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def set_val(self, i, x):
        i += self.N
        self.X[i] = x
        while i > 1:
            i >>= 1
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def fold(self, L, R):
        L += self.N
        R += self.N
        vL = self.X_unit
        vR = self.X_unit
        while L < R:
            if L & 1:
                vL = self.X_f(vL, self.X[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.X_f(self.X[R], vR)
            L >>= 1
            R >>= 1
        return self.X_f(vL, vR)


def orr(x, y):
    return x | y


def main():
    N = int(input())
    S = input()
    S = list(map(lambda c: 2**(ord(c) - ord('a')), list(S)))
    Q = int(input())
    seg = SegTree(N, orr)
    seg.build(S)
    for _ in range(Q):
        num, x, y = input().split()
        if num == '1':
            seg.set_val(int(x)-1, 2**(ord(y) - ord('a')))
        else:
            bits=seg.fold(int(x)-1, int(y))
            print(sum(map(int, list(bin(bits))[2:])))


if __name__ == '__main__':
    main()

Measured memory_bytes: 142380
#include "bits/stdc++.h"

using namespace std;

int setwiseGcd(const vector<int>& A) {
    int g = A[0];
    for (int i = 1; i < A.size(); ++i) {
        g = __gcd(g, A[i]);
    }
    return g;
}

void Main() {
    int N;
    cin >> N;
    vector<int> orgA(N, 0);
    vector<int> Awo1;
    set<int> setAwo1;
    for (int i = 0; i < N; ++i) {
        cin >> orgA[i];
        if (orgA[i] != 1) {
            setAwo1.insert(orgA[i]);
            Awo1.push_back(orgA[i]);
        }
    }
    if (Awo1.size() == 0) { // all 1
        cout << "pairwise coprime" << endl;
        return;
    }
    else if (setAwo1.size() == Awo1.size()) {
        int maxA = *max_element(Awo1.begin(), Awo1.end());
        vector<int> primes(maxA + 1, 1);
        vector<set<int>> factors(maxA + 1, set<int>());
        primes[0] = 0;
        primes[1] = 0;
        for (int i = 2; i <= maxA; ++i) {
            if (primes[i] == 0) {
                continue;
            }
            factors[i].insert(i);
            for (int j = 2; j <= maxA; ++j) {
                if (i * j <= maxA) {
                    factors[i * j].insert(i);
                    primes[i * j] = 0;
                }
                else {
                    break;
                }
            }
        }

        set<int> primeFactors;
        bool isPairwise = true;
        for (int i = 0; i < Awo1.size(); ++i) {
            for (int p : factors[Awo1[i]]) {
                if (primeFactors.count(p) > 0) {
                    isPairwise = false;
                    break;
                }
                primeFactors.insert(p);
            }
            if (!isPairwise) {
                break;
            }
        }
        if (isPairwise) {
            cout << "pairwise coprime" << endl;
            return;
        }
    }

    sort(orgA.begin(), orgA.end());
    int swG = setwiseGcd(orgA);
    if (swG == 1) {
        cout << "setwise coprime" << endl;
    }
    else {
        cout << "not coprime" << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 242392
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

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

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	i64 from, to, cost;
	edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
	edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

//-----end of template-----//

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	cout << a * b / 2 << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n, k := readInt(), readInt()
	hs := make([]int, n)
	for i := range hs {
		hs[i] = readInt()
	}

	sort.Ints(hs)
	ans := 0
	for i := n - 1; i >= 0; i-- {
		if k <= 0 {
			ans += hs[i]
		} else {
			k--
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4736
#include<stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
  int x, i, j, tmp;
  x = A[r];
  i = p - 1;
  for(j = p; j < r; j++) {
    if(A[j] <= x) {
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  tmp = A[i + 1];
  A[i + 1] = A[r];
  A[r] = tmp;
  return i + 1;
}

int main() {
  int i, q;

  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }

  q = partition(0, n-1);


  for(i = 0; i < n; i++) {
    if(i) printf(" ");
    if(i == q) printf("[");
    printf("%d", A[i]);
    if(i == q) printf("]");
  }

  printf("\n");

  return 0;
}



Measured memory_bytes: 2976
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

res = 0

for i in range(n):
    res += b[a[i] - 1]
    if i > 0:
        if a[i] == a[i-1] + 1:
            res += c[a[i-1]-1]

print(res)


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXD = 105;
const int MAXP = 10005;
const LL MOD = 1000000007;

string K;
int N, D, dp[MAXP][MAXD];

int dfs(int pos, int rem, bool lim) {
	if (pos == N) return rem == 0;
	if (!lim && dp[pos][rem] != -1) return dp[pos][rem];

	int to = lim ? K[pos] + 1 : 10, res = 0;
	for (int i = 0; i < to; i++) {
		res = (res + dfs(pos + 1, (rem + i) % D, lim && i == K[pos])) % MOD;
	}
	
	if (!lim) dp[pos][rem] = res;
	return res;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	memset(dp, -1, sizeof(dp));
	
	cin >> K >> D;
	N = K.size();
	for (char &c : K) c -= '0';
	cout << (dfs(0, 0, true) - 1 + MOD) % MOD << "\n";
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
 
#define ar array 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,a,b) for(int i = a; i < b; i++)
#define deb(x) cout << #x << "=" << x << endl
#define PI 3.1415926535897932384626
#define endl '\n'
 
using namespace std;
 
typedef long long ll; 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
 
 
const  int mxN = 1e5+5;
const  long long INF= 1e18;
const long long mod= 1e9+7;


void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ind = 0;

  for(auto x: s) if(x == 'R') ind++;

  int ans = 0;
  rep(i, 0, ind) {
    if(s[i] == 'W') ans++;
  }
  cout << ans;

}

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

int t = 1;
//cin >> t;
while(t--) {
solve();
}
}



Measured memory_bytes: 3740
def gcd(a, b):
    r = a % b
    if r:
        return gcd(b, r)
    return b


def lcm(a, b):
    if a < b:
        a, b = b, a
    return a * b // gcd(a, b)


def min_weight(m):
    p, q, r, b = bars[m - 1]
    red = p * (min_weight(r) if r else 1)
    blue = q * (min_weight(b) if b else 1)
    equilibrium = lcm(red, blue)
    return equilibrium // p + equilibrium // q


while True:
    n = int(input())
    if not n:
        break

    bars = [tuple(map(int, input().split())) for _ in range(n)]

    root_bar = set(range(1, n + 1))
    for _, _, r, b in bars:
        if r: root_bar.remove(r)
        if b: root_bar.remove(b)

    print(min_weight(root_bar.pop()))

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

using graph=vector<vector<int>>;

void add_undirected_edge(graph& G,int u,int v){
	G[u].emplace_back(v);
	G[v].emplace_back(u);
}

vector<vector<int>> connected_components(const graph& G){
	int n=G.size();
	vector<vector<int>> res;
	vector<bool> vis(n);
	rep(u,n) if(!vis[u]) {
		vis[u]=true;
		res.emplace_back();
		queue<int> Q; Q.emplace(u);
		while(!Q.empty()){
			int v=Q.front(); Q.pop();
			res.back().emplace_back(v);
			for(int w:G[v]) if(!vis[w]) {
				vis[w]=true;
				Q.emplace(w);
			}
		}
	}
	return res;
}

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector<int> a(n);
	rep(u,n) scanf("%d",&a[u]);
	graph G(n);
	rep(i,m){
		int u,v; scanf("%d%d",&u,&v);
		add_undirected_edge(G,u,v);
	}

	auto C=connected_components(G);
	int k=C.size();
	if(k==1)      return puts("0"),0;
	if(2*(k-1)>n) return puts("Impossible"),0;

	lint ans=0;
	priority_queue<int,vector<int>,greater<>> Q;
	rep(i,k){
		vector<int> tmp;
		for(int u:C[i]) tmp.emplace_back(a[u]);
		sort(tmp.begin(),tmp.end());
		ans+=tmp[0];
		for(int j=1;j<tmp.size();j++) Q.emplace(tmp[j]);
	}
	for(int i=k;i<2*(k-1);i++){
		ans+=Q.top(); Q.pop();
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 11712
#include <bits/stdc++.h>
using namespace std;
#define trace1(a) cout << a << 'n';
#define trace2(a, b) cout << a << ' ' << b << 'n';
#define trace3(a, b, c) cout << a << ' ' << b << ' ' << c << 'n';
#define trace4(a, b, c, d) cout << a << ' ' << b << ' ' << c << ' ' << d << 'n';
#define trace5(a, b, c, d, e) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << 'n';
#define trace6(a, b, c, d, e, f) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << ' ' << f << 'n';
#define range(n) for(int i = 0; i < n; i++)
#define printArr(harry, tam) range(tam) cout << harry[i] << " n"[i == tam -1];
#define maxn -2000000 //negative value to break code and force you to put right constraint
#define mod 1000000007
#define md(x) (x) % mod;
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ps push
#define prt(x) cout << (#x) << " is " << (x) << endl
#define EPS 1e-9
#define INF 1000000000
#define INFd 1e9
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<double> vd;

int main(){

ll n;
cin>>n;
  vector<ll> a(n);
  vector<ll> b(n);
  for(ll i=0;i<n;i++)
    cin>>a[i];
  for(ll i=0;i<n;i++)
    cin>>b[i];
    ll c1=0,c2=0;
    for(ll i=0;i<n;i++)
    {
        if(a[i]<=b[i])
          c1+=(b[i]-a[i])/2;
        else
          c2+=a[i]-b[i];

    }
    if(c1>=c2)
      cout<<"Yes";
    else
      cout<<"No";
   return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

struct Edge {
    int to;
    int c;
    Edge(int to, int c): to(to), c(c) {}
};
struct State {
    int u;
    int v;
    int c;
    State(int u, int v, int c): u(u), v(v), c(c) {}
    bool operator < (const State& s) const {
        return c > s.c;
    }
};

vector<Edge> edge[105];
bool used[105][105];
const int INF = 1001001001;

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        edge[a].emplace_back(b, c);
        edge[b].emplace_back(a, c);
    }
    rep(i, n) {
        priority_queue<State> q;
        vector<int> dist(n, INF);
        dist[i] = 0;
        q.emplace(i, i, 0);
        while (!q.empty()) {
            State s = q.top();
            q.pop();
            int u = s.u;
            int v = s.v;
            int c = s.c;
            if (dist[v]!=c) continue;
            used[u][v] = true;
            used[v][u] = true;
            
            for (auto e: edge[v]) {
                int iv = e.to;
                int ic = c + e.c;
                if (dist[iv]<=ic) continue;
                dist[iv] = ic;
                q.emplace(v, iv, ic);
            }
        } 
    }
    int ans = 0;

    rep(i, n) {
        for (auto e: edge[i]) {
            int j = e.to;
            if (i>=j) continue;
            if (!used[i][j]) ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3660
#include<stdio.h>

int main(void)
{
    int r,d;
    int x[11];
    int i;
    scanf("%d %d %d",&r,&d,&x[0]);
    for(i=1;i<11;i++)
    {
        x[i]=r*x[i-1]-d;
        printf("%d\n",x[i]);
    }
    
    return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
  int A,B,x1,x2,x3,x4,x5,count;
  cin >> A>>B;
  
  for(int i=A;i<B+1;i++) 
  {
  
  	x1=(i/10000)%10;
  	x2=(i/1000)%10;
  	x4=(i/10)%10;
  	x5=i%10;
  	
  if ((x1==x5)&&(x2==x4)) count++;
  }
	cout<<count<<endl;
 }
	

Measured memory_bytes: 256
// https://atcoder.jp/contests/m-solutions2019/tasks/m_solutions2019_a

#include <bits/stdc++.h>
#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 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int N;
int main()
{
  cin >> N;
  cout << (N - 2) * 180 << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
typedef vector<vi> vvi;
typedef vector<ll> vl;
 
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n,k;cin>>n>>k;
    vi vis(n+1);
    for(int i=1;i<=k;i++){
        int d;cin>>d;
        for(int j=0;j<d;j++){
            int sn;cin>>sn;
            vis[sn]=1;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(!vis[i])ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 3672
N = int(input())
S = [0] * 4
for i in range(N):
    s = str(input())
    if s == 'AC':
        S[0] += 1
    elif s == 'WA':
        S[1] += 1
    elif s == 'TLE':
        S[2] += 1
    elif s == 'RE':
        S[3] += 1

print('AC x ' + str(S[0]))
print('WA x ' + str(S[1]))
print('TLE x ' + str(S[2]))
print('RE x ' + str(S[3]))

Measured memory_bytes: 9216
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>
using namespace std;
#define MAXN 1000005
int main()
{
	char ch[10];
    scanf("%s",&ch);
	for(int i=0;i<=3;i++)
		if(ch[i]==ch[i+1])
		{
			printf("Bad\n");
			return 0;
		}
	printf("Good\n");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define sameb(str) (!strcmp((str),buf))

int main(void){
    char buf[4];
    scanf("%s",buf);
    if(sameb("RRR"))puts("3");
    else if(sameb("RRS") || sameb("SRR"))puts("2");
    else if(sameb("RSS") || sameb("SRS") || sameb("SSR") || sameb("RSR"))puts("1");
    else puts("0");
}

Measured memory_bytes: 1660
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define REP(i,n) for(int i=0; i<n; i++)
using namespace std;

typedef unsigned long ul;
typedef long long int ll;
typedef pair<ul, ul> P;

void search(char s[400][400], bool memo[400][400], pair<ll, ll>& p, int m, int n, int h, int w) {
    char now = s[m][n];
    memo[m][n] = true;

    if (m != h-1) {
        char down = s[m+1][n];
        if ((down != now) && (memo[m+1][n] == false)) {
            if (down == '#') {
                p.first = p.first + 1;
            } else {
                p.second = p.second + 1;
            }
            search(s, memo, p, m+1, n, h, w);
        }
    }

    if (m != 0) {
        char up = s[m-1][n];
        if ((up != now) && (memo[m-1][n] == false)) {
            if (up == '#') {
                p.first = p.first + 1;
            } else {
                p.second = p.second + 1;
            }
            search(s, memo, p, m-1, n, h, w);
        }
    }

    if (n != w-1) {
        char right = s[m][n+1];
        if ((right != now) && (memo[m][n+1] == false)) {
            if (right == '#') {
                p.first = p.first + 1;
            } else {
                p.second = p.second + 1;
            }
            search(s, memo, p, m, n+1, h, w);
        }
    }

    if (n != 0) {
        char left = s[m][n-1];
        if ((left != now) && (memo[m][n-1] == false)) {
            if (left == '#') {
                p.first = p.first + 1;
            } else {
                p.second = p.second + 1;
            }
            search(s, memo, p, m, n-1, h, w);
        }
    }
}

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

    int h, w;
    cin >> h >> w;
    char s[400][400];
    REP(i, h) {
        REP(j, w) {
            cin >> s[i][j];
        }
    }

    bool memo[400][400];
    REP(i, h) {
        REP(j, w) {
            memo[i][j] = false;
        }
    }

    ll sum = 0;
    REP(i, h) {
        REP(j, w) {
            if (memo[i][j] == false) {
                pair<ll, ll> p = make_pair(0, 0);
                if (s[i][j] == '#') {
                    p.first = p.first + 1;
                } else {
                    p.second = p.second + 1;
                }
                search(s, memo, p, i, j, h, w);
                sum += (p.first * p.second);
            }
        }
    }

    cout << sum << '\n';
}


Measured memory_bytes: 25600