akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll INF = 1e10;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    vector<int> dp(n+1, INF);
    dp[0] = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = 1; j <= k; j++)
        {
            if(i+j < n)
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
        }
    }
    cout << dp[n-1] << endl;
}


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

using namespace std;
 
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector <string> vs;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pi;

//#define int ll
#define forl(i,a,b) for (int i = a; i < b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(), x.end())
#define sumup(x) accumulate(x.begin(), x.end(), 0)
#define PI 3.141592653589793238
#define MOD 1000000007
#define loop(n) for(int i = 0; i < n; i++)
#define rloop(n) for(int i = n-1; i >= 0; i--)

void io() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

void solve() {
    string s;
  cin>>s;
  if(s=="ARC") cout<<"ABC\n";
  else cout<<"ARC\n";
    return;
}
int32_t main() {
    io();
    int t=1;
    //cin>>t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
N  = int(input())
A = list(map(int, input().split()))
count = [0]*(N)
for i in range(N):
  count[A[i]-1] += 1
total = 0
for i in range(N):
  s = count[i]
  total += s*(s-1)/2
for i in range(N):
  j = count[A[i]-1]
  ans = total-j*(j-1)/2+(j-1)*(j-2)/2
  print(int(ans))
  


Measured memory_bytes: 83660
#!/usr/bin/env python3

def main():
    N = int(input())
    *T, = map(int, input().split())
    S = sum(T)
    M = int(input())

    for i in range(0, M):
        P, X = map(int, input().split())
        print(S - T[P - 1] + X)


main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll dis1[100006],dis2[100006],dis0[100006];;
const ll MOD = 1e9+7;
vector<int> G[100006];
int n,k;

ll ans;
void dfs(int idx,int p=100005,int pp=100005)
{
	ll x = k - dis1[p] - dis0[pp] - dis0[p];
	ans = ans * x % MOD;
	dis0[idx] ++ ;
	dis1[p]++;
	for(auto &i:G[idx])
	{
		if(i==p)continue;
		dfs(i,idx,p);
	}
	
		

}

int main()
{
	ans = 1;
	cin >> n >> k;
	for(int i = 0;i<n-1;i++)
	{
		int x,y;
		cin >> x >> y;
		x--;y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	dfs(0);
	cout << ans << endl;

	
}


Measured memory_bytes: 14060
import math
from sys import stdin


def get_result(data):
    N, M = data
    ans = N * (N-1) / 2 + M * (M-1) / 2 
    return int(ans)


if __name__ == '__main__':
    data = list(map(int, stdin.readline().split(' ')))
    result = get_result(data)
    print(result)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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()
{
    int N, gcd = 0;
    cin >> N;
    bool flag = true;
    map<int, int> cnt;
    vint A(N);
    rep(i, N)
    {
        cin >> A[i];
        cnt[A[i]]++;
        if (cnt[A[i]] >= 2)
        {
            flag = false;
        }
    }
    if (flag)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }

    return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N, P;
  cin >> N >> P;
  if (N == 1) {
     cout << P << endl;
     return 0;
  }
  ll ans = 1;
  for (ll i = 2; i * i <= P; ++i) {
    ll temp = P;
    if (P % (ll)pow(i, N) == 0) {
      ans = i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long> A(N + 1);
    for (int i = 0; i < N; i++) cin >> A[i];
    A[N] = 0;

    long long ans = 0;
    for (int i = 0; i < N; i++) {
        ans += A[i] / 2;
        A[i] %= 2;
        if (A[i] == 1 && A[i + 1] > 0) {
            A[i]--, A[i + 1]--;
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main() {
  long long N;
  long long K;
  cin>>N>>K;
  long long sum=0;
  for(long long i=K;i<N+2;i++){
    sum +=i*(N+1-i)+1 ;
   
  }
  cout<<sum%1000000007<<endl;
}




Measured memory_bytes: 3632
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    int N;
    cin >> N;
    int ans = 0;
    REP(i, N + 1) {
    	if (i >= 1 && i <= 9) ans++;
    	else if (i >= 100 && i <= 999) ans++;
    	else if (i >= 10000 && i <= 99999) ans++;
    }
    cout << ans << endl;
}


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

int main(void) {
    int n;
    int maxdiff = 0,diff;
    int choose;
    cin >> n;

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

    sort(a.begin(),a.end());
    choose = a[0];
    for(int i=0;i<(n-1);i++) {
        diff = min(a[i],a[n-1]-a[i]);
        if(maxdiff < diff) {
            maxdiff = diff;
            choose = a[i];
        }
    }

    cout << a[n-1] << " " <<  choose << endl;
    return 0;
}


Measured memory_bytes: 640
n = int(input())
data = list(map(int, input().split()))

flag = 0
if data.count(0) > 0:
	print(0)
else:
  a = data[0]
  for i in range(1,n):
    a = a*data[i]
    if a > 10**18:
      flag = 1
      break
      
  if flag == 1:
    print('-1')
  else:
    print(a)

Measured memory_bytes: 21636
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> ans(n);

  for (int i = 0; i < n-1; ++i) {
    int a;
    cin >> a; --a;
    ++ans.at(a);
  }
  for (int x : ans) {
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 4052
#include<stdio.h>
main(){
  int w,n,A,B,a[30],b[30],c[30],i,tmp;

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

  for(i=0;i<w;i++){
    c[i]=i+1;
  }

  for(i=0;i<n;i++){
    A=a[i]-1; B=b[i]-1;
    tmp=c[A]; c[A]=c[B]; c[B]=tmp;
  }

  for(i=0;i<w;i++){
    printf("%d\n",c[i]);
  }

  return 0;
}

Measured memory_bytes: 592
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
from fractions import gcd
#from math import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    h, w = map(int, input().split())
    C = [None] * h
    for i in range(h):
        C[i] = input()
    for i in range(h):
        print(C[i])
        print(C[i])

if __name__ == '__main__':
    main()


Measured memory_bytes: 64108
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long A,B,C;
  cin>>A>>B>>C;
  vector<long long>v{A,B,C};
  sort(v.begin(),v.end());
  if(A%2==1&&B%2==1&&C%2==1){
    cout<<v[0]*v[1]<<endl;
  }
  else{
    cout<<0<<endl;
  }
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+9;
int arr[maxn];
ll sum[maxn];
ll sumt[maxn];
int n,k;
bool cmp(ll a,ll b){
    return a>b;
}
ll tmpl[maxn],tmpr[maxn];
ll sol(int l,int r){
    if(l==r){
        return arr[l]>=0;
    }
    int mid=(l+r)>>1;
    ll ans=sol(l,mid);
    ans+=sol(mid+1,r);
    int nl=0,nr=0;
    for(int i=l;i<=mid;i++){
        tmpl[nl++]=sumt[i]-sumt[mid+1];
        /*if(l==1&&r==4){
            cout<<'?'<<tmpl[nl-1]<<endl;
        }*/
    }
    for(int i=mid+1;i<=r;i++){
        tmpr[nr++]=sum[i]-sum[mid];
    }
    sort(tmpl,tmpl+nl);
    sort(tmpr,tmpr+nr,cmp);
    int no=0;
    for(int i=0;i<nl;i++){
        for(;no<nr;no++){
            if(tmpl[i]+tmpr[no]<0)break;
        }
        ans+=no;
    }
    //cout<<l<<' '<<r<<' '<<ans<<endl;
    return ans;
}
int main(){
    //freopen("in","r",stdin);
    ios::sync_with_stdio(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
        arr[i]-=k;
        sum[i]=sum[i-1]+arr[i];
    }
    for(int i=n;i>0;i--){
        sumt[i]=sumt[i+1]+arr[i];
        //cout<<i<<'*'<<sumt[i]<<endl;
    }
    ll ans=sol(1,n);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define mod 1000000007
#define ft cout<<"for test"<<endl;
#define pi 2*acos(0.0)
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    double r;
    cin>>r;
    cout<<2*pi*r<<endl;

}


Measured memory_bytes: 3804
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int W = scan.nextInt();
		int H = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int r = scan.nextInt();

		scan.close();

		if(x+r <= W && x-r >= 0 && y+r <= H && y-r >= 0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 17320
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    
    // int A, B;
    // cin >> A >> B;
    // cout << A+B;
    // cout << (1 + 100) * 100 / 2 << endl;

    int H,W;
    cin >> H >> W;
    for(int i=0; i<W+2; i++)
        cout << "#";
    cout << endl;
    string str;
    for(int i=0; i<H; i++){
        cin >> str ;
        cout << "#" << str << "#" << endl;
    }
    for(int i=0; i<W+2; i++)
        cout << "#";
    cout << endl;
}

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

#define ll long long int

struct ST
{
	ll x1, x2;
	ll y1, y2;
	ll z1, z2;
};

ll x[100 + 10] = { 0 };
ll y[100 + 10] = { 0 };
ll z[100 + 10] = { 0 };

ll area = 0;

int main()
{
	ST fish[50 + 10];

	int n,k;

	int i, j;
	int xi, yi, zi;

	int cnt = 0;


	
	cin >> n >> k;

	for (i = 0; i < n; i++)
	{
		cin >> fish[i].x1 >> fish[i].y1 >> fish[i].z1 >> fish[i].x2 >> fish[i].y2 >> fish[i].z2;

		x[i * 2] = fish[i].x1;
		x[(i * 2) + 1] = fish[i].x2;
		y[i * 2] = fish[i].y1;
		y[(i * 2) + 1] = fish[i].y2;
		z[i * 2] = fish[i].z1;
		z[(i * 2) + 1] = fish[i].z2;
	}

	sort(x, x + (n * 2));
	sort(y, y + (n * 2));
	sort(z, z + (n * 2));

	for (xi = 0; xi < n * 2 -1; xi++)
	{
		for (yi = 0; yi < n * 2 -1; yi++)
		{
			for (zi = 0; zi < n * 2 -1; zi++)
			{
				cnt = 0;
				for (i = 0; i < n; i++)
				{
					if (fish[i].x1 > x[xi] || x[xi + 1] > fish[i].x2)
					{
						continue;
					}
					if (fish[i].y1 > y[yi] || y[yi + 1] > fish[i].y2)
					{
						continue;
					}
					if (fish[i].z1 > z[zi] || z[zi + 1] > fish[i].z2)
					{
						continue;
					}

					cnt++;
				}

				if (cnt >= k)
				{
					area += (x[xi + 1] - x[xi]) * (y[yi + 1] - y[yi]) * (z[zi + 1] - z[zi]);
				}

			}
		}
	}

	cout << area << endl;

	return 0;
}

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

using namespace std;

const double PI = 3.141592;
const int MAX_N = 1e5+5;
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

const bool dbgEnabled = false;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef pair<string, ll> psi;
typedef pair<ll, string> pis;
typedef vector<pii> vpii;
typedef vector<psi> vpsi;
typedef vector<pis> vpis;
typedef vector<vi> vvi;

// Debug macros
#define dbg(x) do { \
	if (dbgEnabled) { cerr << #x << ": " << x << "\n"; } \
} while (0)

#define dbgv(x) do { \
	if (dbgEnabled) { cerr << #x << ": [ "; for (auto& _ : x) cerr << _ << " "; cerr << "]\n"; } \
} while (0)

#define dbgvv(x) do { \
	if (dbgEnabled) { cerr << #x << ":\n[\n"; for (auto& __ : x) dbgv(__); cerr << "]\n";} \
} while (0)

void solve() {
	string s; cin >> s;
	ll digitSum = 0;
	for (ll i = 0; i < s.size(); i++) {
		digitSum += (ll)(s[i] - '0');
	}
	
	if (digitSum % 9 == 0)
		cout << "Yes" << endl;
	else 
		cout << "No" << endl;
}

int main() {
	if (!dbgEnabled) {
		ios_base::sync_with_stdio(false);
		cin.tie(nullptr); cout.tie(nullptr);
	}
	
	ll t = 1;
	//cin >> t;
	while(t--) {
		solve();
	}    
    return 0;
}



Measured memory_bytes: 3636
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= 1

cnt = [0]*(2*10**5)#何回出たか
cnt2 = [0]*(2*10**5)#何回目に出てきたか
t = []
nxt = 0
loop = 0

for i in range(2*10**5):
    cnt[nxt] += 1
    if cnt[nxt] >= 2:
        # print("i: " + str(i))
        # print("nxt: " + str(nxt))
        loop = i - cnt2[nxt]
        modC = cnt2[nxt]
        break
    cnt2[nxt] = i
    t.append(nxt)
    nxt = a[nxt]

modK = (k-modC)%loop
# print("-------")
# print(t)
# print("modC: " + str(modC))
# print("modK: " + str(modK))
# print("loop: " + str(loop))
# print(modK)
# print(loop)
# print("-------")

if k < modC:
    print(t[k] + 1)
else:
    print(t[modC + modK] + 1)

"""
発想はあってる
テストケース公開されたら試してみる！
"""

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

int main() {
    int N;
    cin >> N;
    for(int i=1;i<10;i++) {
        for(int j=1;j<10;j++) {
            if (i*j==N) {
                cout << "Yes" << endl;
                exit(0);
            }

        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
const int MAXN=262144,MAXM=30000000;
int P;
#define L 1048576
#define real long double
#define eps 1e-9
char _buf[L],*S,*T,_buf1[L],*S1=_buf1;
inline char gc()
{
	if(S==T)
	{
		T=(S=_buf)+fread(_buf,1,L,stdin);
		if(S==T)return 0;
	}
	return *S++;
}
template<class T> void get(T &x)
{
	char c;
	for(c=gc();(c<'0'||c>'9')&&c!='-';c=gc());
	bool b=0;
	if(c=='-')
	{
		b=1;
		c=gc();
	}
	for(x=c^'0',c=gc();c>='0'&&c<='9';c=gc())x=(x<<3)+(x<<1)+(c^'0');
	if(b)x=-x;
}
inline void pc(char c)
{
	if(S1==_buf1+L)
	{
		fwrite(_buf1,1,L,stdout);
		S1=_buf1;
	}
	*S1++=c;
}
void out(ll x)
{
	if(x>9)out(x/10);
	pc(x%10^'0');
}
int Pow(int x,int y)
{
	int s=1;
	for(;y;y>>=1,x=(ll)x*x%P)if(y&1)s=(ll)s*x%P;
	return s;
}
int A(int x)
{
	return x<0?-x:x;
}
int n,m,N,N0,i,j,ans,q,a[MAXN],b[MAXN],u[20],v[20],o[512],d[MAXN];
struct node
{
	int x,y;
	bool operator<(const node& b)const
	{
		if(x==b.x)return y<b.y;
		return x<b.x;
	}
}f[4096][4096],g[4096],t;
int main()
{
	get(n);
	for(i=1;i<=n;i++)
	{
		get(a[i]);
		get(b[i]);
		d[i]=d[i>>1]+1;
	}
	for(i=0;i<9;i++)o[1<<i]=i;
	N0=min(4095,n);
	for(i=1;i<=N0;i++)for(j=0;j<1<<d[i];j++)
	{
		f[i][j]=f[i>>1][j>>1];
		if(j&1)
		{
			f[i][j].x+=b[i];
			f[i][j].y+=a[i];
		}
	}
	for(i=1;i<=N0;i++)
	{
		sort(f[i],f[i]+(1<<d[i]));
		for(j=1;j<1<<d[i];j++)f[i][j].y=max(f[i][j].y,f[i][j-1].y);
	}
	get(q);
	while(q--)
	{
		get(j);
		get(m);
		for(N=0;j>N0;j>>=1)
		{
			u[N]=b[j];
			v[N++]=a[j];
		}
		t.x=m+1;
		t.y=0;
		ans=(lower_bound(f[j],f[j]+(1<<d[j]),t)-1)->y;
		g[0].x=g[0].y=0;
		for(i=1;i<1<<N;i++)
		{
			g[i].x=g[i^(i&-i)].x+u[o[i&-i]];
			g[i].y=g[i^(i&-i)].y+v[o[i&-i]];
			if(g[i].x<=m)
			{
				t.x=m+1-g[i].x;
				t.y=0;
				ans=max(ans,g[i].y+(lower_bound(f[j],f[j]+(1<<d[j]),t)-1)->y);
			}
		}
		out(ans);
		pc('\n');
	}
	fwrite(_buf1,1,S1-_buf1,stdout);
	return 0;
}

Measured memory_bytes: 103644
main = getContents >>= mapM_ (putStrLn . fout . point_in_a_triangle . fin) . lines
fin = map (read::String->Double) . words
fout p = case p of {True->"YES"; False->"NO"} 
 
point_in_a_triangle [x1,y1,x2,y2,x3,y3,xp,yp]
 = (compare ((x3-x1)*d12+y1) y3 == compare ((xp-x1)*d12+y1) yp) &&
   (compare ((x1-x2)*d23+y2) y1 == compare ((xp-x2)*d23+y2) yp) &&
   (compare ((x2-x3)*d31+y3) y2 == compare ((xp-x3)*d31+y3) yp)
  where
   d12 = (y2-y1)/(x2-x1)
   d23 = (y3-y2)/(x3-x2)
   d31 = (y1-y3)/(x1-x3)

Measured memory_bytes: 4456
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm> 
using namespace std;


int main() {
	int a, b;

	cin >> a>>b;
	if (a*b % 2 == 0) {
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;
	}



	return 0;
}


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

using namespace std;

int n,r;


void shuffle(vector<int> &v,int c){
	stack<int> A;
	stack<int> B;
	for(int i = v.size()-1; i >= 0; i--){
		if(i<v.size()/2){
			B.push(v[i]);
		}
		else
			A.push(v[i]);
	}
	v.clear();
	while(1){
		for(int i = 0; i < c&&!A.empty(); i++){
			v.push_back(A.top());
			A.pop();
		}
		for(int i = 0; i < c&&!B.empty(); i++){
			v.push_back(B.top());
			B.pop();
		}
		if(A.size()==0&&B.size()==0)
			break;
	}
}

int main(){

	while(cin>>n>>r){
		vector<int> cs;
		for(int i = 0; i < r; i++){
			int c;
			cin>>c;
			cs.push_back(c);
		}
		vector<int> v;
		for(int i = 0; i < n; i++){
			v.push_back(i);
		}
		for(int i = 0; i < r; i++){
			shuffle(v,cs[i]);
		}
		cout<<v[v.size()-1]<<endl;
	}

	return 0;
}

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

using namespace std;
#define INF 1000007
#define MOD 1000000007
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef std::pair<int, int> P;

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

int a, b;

void f(int x) {
    a = x % 10;
    b = 0;
    while (x) {
        b = x;
        x /= 10;
    }
}

signed main() {
    string N;
    cin >> N;
    rep(i, N.size()) {
        if (N[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3752
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#define MOD 1000000007
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
int cmp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

lli nCr(int n, int r, lli *mem) {
    if(n < r) return 0;
    if(mem[n*2010 + r]!=0) {
        return mem[n*2010 + r];
    } else {
        if(n==r || r==0) {
            mem[n*2010 + r] = 1;
            return 1;
        }
        lli a = nCr(n-1, r-1, mem);
        lli b = nCr(n-1, r, mem);
        mem[n*2010 + r] = (a+b)%MOD;
        return mem[n*2010 + r];
    }
}

int main()
{
    int n, a,b;
    scanf("%d%d%d",&n,&a,&b);
    printf("%d",MIN(n*a, b));

    return 0;
}


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

int a,b,c,d,e,f,i,ii,iii;

int main(){
    cin >> a;
    b = a;
    c = a;
    f = a;
    int wer[100];
    for(a=a-1;a>=0;a--){
        cin >> wer[a];
    }
    a = b - 1;
    for(ii=0;ii < f;ii++){
        iii = ii;
            for(i = a;i > ii;i--){
            d = wer[ii];
            e = wer[i];
            if(d == e){
                c = c - 1;
                wer[ii] = 0;
            }
            if(e == 0){
            }
        }
    }
    cout << c << endl;

}

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

using namespace std;

using ll = long long;

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

    int a, b, c;
    cin >> a >> b >> c;
    if (a == b) cout << c << endl;
    else if (a == c) cout << b << endl;
    else cout << a << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public static class Solution
{
    public static void Main()
    {
        var S = Console.ReadLine();
        var T = Console.ReadLine();

        var min = int.MaxValue;
        for (int i = 0; i < S.Length - T.Length + 1; i++)
        {
            var s = S.Substring(i, T.Length);
            var count = T.Where((c, i) => c != s[i]).Count();
            min = Math.Min(count, min);
        }

        Console.WriteLine(min);
    }
}

Measured memory_bytes: 26572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
  ll a,b,c;
  cin >> a >> b;
  c= max(a+b,a-b);
  c = max(c,a*b);
  cout << c << endl;
	
	return 0;
}


Measured memory_bytes: 256
def f_a():
    h, w, a, b = map(int, input().split())
    for i in range(h):
        if i<b:
            print("".join(["1"]*a + ["0"]*(w-a)))
        else:
            print("".join(["0"]*a + ["1"]*(w-a)))

if __name__ == "__main__":
    f_a()


Measured memory_bytes: 4084
using System;
using static System.Math;

class Program {
    static void Main(string[] args) {
        var a = new int[4];
        for (int i = 0; i < 4; i++) {
            a[i] = int.Parse(Console.ReadLine());
        }
        Console.WriteLine(Min(a[0], a[1]) + Min(a[2], a[3]));
    }
}

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl;
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

bool is_sq(const int x) {
    int low = sqrt(x);
    while(low * low <= x) {
        if((low + 1) * (low + 1) <= x) low++;
        else break;
    }

    return (low * low) == x;
}

int sq_d(const vi &x, const vi &y) {
    int res = 0;
    REP(i, x.size()) {
        res += (x[i] - y[i]) * (x[i] - y[i]);
    }
    return res;
}

int main() {
    int n, d;
    cin >> n >> d;
    vvi x(n, vi(d));
    REP(i, n) {
        REP(j, d) {
            cin >> x[i][j];
        }
    }

    int cnt = 0;
    REP(i, n) {
        FOR(j, i + 1, n) {
            if(is_sq(sq_d(x[i], x[j]))) cnt++;
        }
    }

    cout << cnt << "\n";

    return 0;
}


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

using namespace std;

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll, ll>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
// #define fat 1000000007
#define fat 998244353
#define PI_2 1.57079632679489661923


int main()
{
    ll tt = 1, n, m, k = 0, i, j, p, q;
    ll a, b, c, d, u, v, x, y;
    ll ans = 0;

    ll l = 0, r = 0;
    bool poss = true;

    boost;
    string sa, sb;

    // cin >> tt;  
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> n;

        map<ll, ll> mp;
        while (n % 2 == 0)  
        {  
            mp[2]++;
            // cout << 2 << " ";  
            n = n/2;  
        }  
    
        // n must be odd at this point. So we can skip  
        // one element (Note i = i +2)  
        for (int i = 3; i <= sqrt(n); i = i + 2)  
        {  
            // While i divides n, print i and divide n  
            while (n % i == 0)  
            {
                mp[i]++;
                n = n/i;  
            }  
        }  
    
        // This condition is to handle the case when n  
        // is a prime number greater than 2  
        if (n > 2)  
            mp[n]++;

        ans = 0;
        loop(z, mp){
            ans += (sqrt(1 + 8*z.S) - 1) / 2;
        }
        cout << ans << nl;        
    }   

    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e8;
const ll INF=1e16;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	ll n,t;
	cin>>n>>t;
	ll sum=0;
	ll s=0;
	rep(i,n){
		ll a;cin>>a;
		if(s<a)sum+=t;
		else sum+=a+t-s;
		s=a+t;
	}
	cout<<sum<<endl;
}











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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll x, y, a, b;
  cin >> x >> y >> a >> b;
  ll p = a - x;
  ll q = b - y;
  //if(p > 0 && q > 0)
    cout << a - q spa b + p spa x - q spa y + p << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A = 0;
  string S;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> S;
    if(S == "Y"){
      A = 1;
      break;
  	}
  }
  if(A == 1){
  cout << "Four" << endl;
  }
  else if(A != 1){
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
/*
 * 高橋君はバーベキューをしようとしています。 バーベキューでは 2 本の串にいくつかの具材を刺した串焼きを N 個作る予定です。
 * 
 * 串は 2N 本あり、i 番目の串の長さは Li です。具材は無限に用意されています。
 * 
 * 串を 2 本組にして具材を刺して串焼きにするのですが、2 本の串のうち短い方の長さを x とすると、串焼きには最大 x 個の具材を刺すことができます。
 * 
 * うまく串を組み合わせたとき、N 個の串焼きに刺すことのできる具材の個数の和の最大値はいくらになるでしょうか？
 */

import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int n = Integer.parseInt(sc.next());
            int[] sticks = new int[2*n];
            int ret = 0;
            
            for(int i=0; i<2*n; i++){
            	sticks[i] = Integer.parseInt(sc.next());
            }
            
            Arrays.sort(sticks);
            
            for(int i=0; i<n; i++){
            	ret += sticks[2*i];
            }
            
            //出力
            System.out.println(ret);
            sc.close();
        }
    }
	

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int X, t;
	cin >> X >> t;
	if (X <= t)cout << 0 << endl;
	else cout << X - t << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::{BufRead, Write};
use std::io;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let (a, b): (usize, usize) = {
        let mut split = buf.split_whitespace();
        (split.next().unwrap().parse().unwrap(), split.next().unwrap().parse().unwrap())
    };
    buf.clear();
    input.read_line(&mut buf).unwrap();
    let s = buf.trim_right().as_bytes();
    let valid = (0..a).chain(a + 1..a + b + 1).all(|x| (s[x] as char).is_digit(10)) && s[a] == b'-';
    writeln!(output, "{}", if valid { "Yes" } else { "No" }).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "3 4
269-6650
",
            "Yes\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "1 1
---
",
            "No\n",
        );
    }

    #[test]
    fn case3() {
        test(
            "1 2
7444
",
            "No\n",
        );
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#include <algorithm>
 
int main() {
 
  int long long H,A,t=0,i,j=0,a;
  int long long ans=0;
  
  cin >> H >> A;
 
  ans=H/A;
 
  if (H%A!=0)
  {
    ans+=1;
  }
  if (H<A)
  {
    ans=1;
  }
  printf ("%lld\n",ans);
  return 0;
}


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

int main(){
	int A,B,C,D;

	scanf("%d %d %d %d",&A,&B,&C,&D);
	int time;

	if(C >= B || A >= D){
		time = 0;
	}
	else if(C >= A ){
		if(B >= D){
			time = D - C;
		}
		else{
			time = B - C;
		}
	}
	else if(A > C){
		if(B >= D){
			time = D - A;
		}
		else{
			time = B - A;
		}
	}
	printf("%d\n",time);

	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<fstream>
#define sc(x) scanf("%d",&x)
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define sz(x) x.size()
#define pb push_back

using namespace std;

typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = 1e5+7;
static const int INF = 0x3f3f3f3f;
static const int MOD = 1e9+7;


int main(){  
    
    string s;
    cin >> s;set<char> se(s.begin(),s.end());
    if(sz(se) == 3)
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 256
## coding: UTF-8

S = input()[::-1] #文字列型で受け取る
N = len(S)
#print(S)

remainder = [0] * 2019
tmp = 0
rad = 1 # *10**(i) % 2019
for i in range(N):
    r = int(S[i])
    tmp += r*rad
    tmp %= 2019
    #print(tmp)
    remainder[tmp] += 1
    rad *= 10
    rad %= 2019

    #print(S[i:], int(S[i:])%2019)
    #remainder[int(S[i:])%2019]+= 1
remainder[0] += 1
#print(-1)



answer = 0
for i in range(2019):
    p = remainder[i]
    answer += p*(p-1)/2
print(int(answer))


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const LL INF = 1e18;

const int MAX = 100000+10;
LL dp[MAX];

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

  int N, W;
  cin >> N >> W;

  fill(dp, dp+MAX, INF);

  dp[0] = 0;
  REP(i,N){
    LL w, v;
    cin >> w >> v;
    for(LL k=MAX-1;k>=v;--k){
      mini(dp[k], dp[k-v] + w);
    }
  }

  LL ans = 0;
  REP(v,MAX) if(dp[v] <= W) ans = v;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
a=list(map(int, input().split()))

dx=-(a[0]-a[2])
dy=-(a[1]-a[3])

result=''
x=[]
y=[]
for i in range(dx):
    result=result+'R'

for i in range(dy):
    result=result+'U'

for i in range(dx):
    result=result+'L'

for i in range(dy):
    result=result+'D'

result=result+'D'

for i in range(dx+1):
    result=result+'R'

for i in range(dy+1):
    result=result+'U'

result=result+'L'

result=result+'U'

for i in range(dx+1):
    result=result+'L'

for i in range(dy+1):
    result=result+'D'

result=result+'R'

print(result)

Measured memory_bytes: 3064
def decrement(hs, l, r)
  sub = hs.slice(l..r)
  min = sub.min
  @res += min
  for i in l..r do
    hs[i] -= min
  end
  hs
end

n = gets.chomp.split(' ').map(&:to_i)[0]
hs = gets.chomp.split(' ').map(&:to_i)
@res = 0

loop do
  l, r = nil, nil
  hs.each_with_index do |h, i|
    l = i if !h.zero? && l.nil?
    r = i - 1 if h.zero? && r.nil? && !l.nil?  
  end
  if l.nil?
    break
  elsif r.nil?
    r = n - 1
  end
  hs = decrement(hs, l, r)
end

puts @res

Measured memory_bytes: 1916
while True:
    a, op, b = map(str, input().split())
    a, b = int(a), int(b)
    if op == '?':
        break
    elif op=='+':
        print(f'{a+b}')
    elif op=='-':
        print(f'{a-b}')
    elif op=='*':
        print(f'{a*b}')
    else:
        print(f'{a//b}')



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

int main() {
	int m, n;
	cin >> m >> n;
	int p[99] = {};

	for (int i = 0;i < m;i++) {
		for (int j = 0;j < n;j++) {
			int a;
			cin >> a;
			if (a == 1)p[i]++;
		}
	}
	sort(p, p + m);
	cout << p[m - 1] << endl;
	return 0;
}

Measured memory_bytes: 3132
#include<iostream>
#include<vector>
#include<map>
using namespace std;
int main()
{
    // スペース区切りの整数の入力
    int N, M;
    cin >> N >> M;
	map<int, int> m;
	vector <int> A(N);

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

	vector<int> sum(N+1);
	sum[0] = 0;

	for (int i=0;i <N;i++){
		sum[i+1] = (sum[i] + A[i]) % M;
	}

	long long ans = 0;

	for(int i=0;i<sum.size();i++){
		// cout << sum[i] << endl;
		// cout << m[sum[i]] << endl<<"---"<<endl;
		ans += m[sum[i]];
		m[sum[i]]++;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    string S,T;
    cin>>S>>T;
    string K=S+S;
    bool flg=false;
    for(int i=0;i<S.size();i++){
        string V=K.substr(i,S.size());
        if(V==T){
            flg=true;
            break;
        }
    }
    if(flg){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int64_t lucas(int N){
  if (N == 0){
    return 2;
  }
  if (N == 1){
    return 1;
  }
  if (N == 29){
    return 1149851;
  }
  if (N == 30){
    return 1860498;
  }
  if (N == 59){
    return 2139295485799;
  }
  if (N == 60){
    return 3461452808002;
  }
  return lucas (N - 1) + lucas (N - 2);
}


int main() {
  int N;
  cin >> N;
  cout << lucas(N) << endl;
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const long long INF = 1LL << 60;
const int MOD = 1e9 + 7;

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 counting(string S1,string S2){
	std::vector<bool> v1(26,false);
	std::vector<bool> v2(26,false);


	rep(i,S1.size()){
		v1.at(S1[i]-'a') = true;
	}
	rep(i,S2.size()){
		v2.at(S2[i]-'a') = true;
	}
	int cnt =0;
	rep(i,26){
		if(v1.at(i) && v2.at(i))cnt++;
	}
	return cnt;
}

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

	string S;
	cin >> S;

	int ans = 0;
	rep2(i,0,N-1){
		chmax(ans,counting(S.substr(0,i+1),S.substr(i+1,N)));
	}
	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 256
S = input().strip()
res = S[::-1]
lens = len(S)
loc = []
for i in range(lens):
    loc.append(0)
for i in range(lens):
    if S[i] == "R":
        whele = S.index("L", i)
        if (whele - i) % 2 == 1:
            loc[whele-1] += 1
        else:
            loc[whele] += 1
    if S[i] == "L":
        where = lens - res.index("R", lens-i-1) - 1
        if (where - i) % 2 == 1:
            loc[where+1] += 1
        else:
            loc[where] += 1
print(*loc)


Measured memory_bytes: 6504
n = int(input())
li = [0]*n
for i in range(n):
    li[i] = int(input())

max_ = max(li)
max_i = li.index(max_)
li.pop(max_i)
max2 = max(li)
res = [max_]*n
res[max_i] = max2

for a in res:
    print(a)


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

#define ff first
#define endl "\n"
#define ss second
using namespace std;
#define maxn 2000006
#define pb push_back
#define ll long long
#define lll __int128
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fr(i,x,n) for(ll i=x;i>=n;i--)
inline ll min(ll a, ll b, ll c) { return min(min(a, b), c);}
inline ll max(ll a, ll b, ll c) { return max(max(a, b), c);}
inline void fastio(){ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);}

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

ll func(ll x){
	if(x==1) return 1;
	return 2*func(x/2)+1;
}

int main(){
	fastio();

	ll h; cin>>h;
	cout<<func(h);
	return 0;
}


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


int main() {
  int a, b;
  cin >> a >> b;
  int num = b - a;
  int height = 0;
  for(int i = 1; i < num+1; ++i ){
    height += i;
  }
  int ans = height-b; 
  cout << ans << endl;
  return 0;
}

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

using namespace std;

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

#ifdef ONLINE_JUDGE
#define DEBUG false
#else
#define DEBUG true
#endif

#define pb emplace_back
#define lb lower_bound
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second

#define ALL(c) (c).begin(),(c).end()

#define DBG0(x)    {if(DEBUG){ cout << #x << ": " << x << "\t"; }}
#define DBG(x)     {if(DEBUG){DBG0(x); cout << endl;}}
#define DBG2(x, y) {if(DEBUG){DBG0(x); DBG(y);}}
#define DBG3(x, y, z) {if(DEBUG){DBG0(x); DBG2(y, z);}}
#define DBG4(w, x, y, z) {if(DEBUG){DBG0(w); DBG3(x, y, z);}}

template <class T>
ostream& operator<<(ostream& os, vector<T> xs){ for(T x: xs) os << x << ' '; return os; }
template <class S, class T>
ostream& operator<<(ostream& os, pair<S,T> st){ os << "(" << st.first << "," << st.second <<")"; return os; }

using namespace std;
const double EPS = 1.0e-14;
typedef complex<double> Point;
istream& operator>>(istream& is, Point &pt){
    double a, b;
    is >> a >> b;
    pt.real(a); pt.imag(b);
    return is;
}

ostream& operator<<(ostream& os, const Point &pt){
    os << make_pair(pt.real(), pt.imag());
    return os;
}

inline double cross(const Point &a, const Point &b){
    return (a.real()*b.imag() - a.imag()*b.real());
}

inline double myarg(Point &a){
    double ret = arg(a);
    return (ret >= 0 ? ret : ret + 2*M_PI);
}

inline double signed_area(const Point &a, const Point &b, const Point &c){
    Point ab = b - a;
    Point ac = c - a;
    return cross(ab, ac) / 2.0;
}

inline bool intersect(const Point &a1, const Point &a2, const Point &b1, const Point &b2) {
  return ((cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS) &&
          (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS));
}

void sort_by_arg(vector<Point> &pts){
    sort(pts.begin(), pts.end(), [](Point a, Point b){ return (myarg(a) < myarg(b)); });
}

double area(vector<Point> &vs){
    int n = vs.size();
    vector<Point> pts(n - 1);
    rep(i, n - 1) pts[i] = vs[i + 1] - vs[0];
    sort_by_arg(pts);
    double ans = 0.0;
    rep(i, n - 1) ans += cross(vs[i], vs[i + 1]);
    return ans / 2.0;
}


typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;

bool counter_clock_wise(const Point &a, const Point &b, const Point &c){
    if(cross(a, b) > 0 && cross(b, c) > 0) return true;
    else return false;
}

int main(void){
    Point a, b, c, p;
    while(cin >> a >> b >> c >> p){
        double A, B, C;
        A = cross(b - a, p - a);
        B = cross(c - b, p - b);
        C = cross(a - c, p - c);
        if((A > 0 && B > 0 && C > 0) || 
           (A < 0 && B < 0 && C < 0))
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1228
// -_-
#include <bits/stdc++.h>
#define int long long
#define read(a) int a; cin >> a;
#define readarr(a, n) int a[(n) + 1] = {}; fori(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori(i, 1, n) {fori(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define mod 1000000007
#define  sort1(v) sort(v.begin(), v.end()) 
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;

 
signed main() 
{

	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	read(n);
	readarr(a, n);

	int sum[n+1] = {};
	sum[0] = 0;

	fori(i, 1, n) sum[i] = a[i] + sum[i-1];

	int dp[n+1][n+1];
	fori(i, 0, n) dp[i][i] = 0;
	fori(i, 1, n-1)
	{
		fori(j, 1, n-i)
		{
			int k = i+j;
			if(k-j == 1) {dp[j][k] = a[j] + a[k];}
			else
			{
				dp[j][k] = 1e18;
				int t = sum[k]-sum[j-1];
				fori(x, j, k-1)
				{
					dp[j][k] = min(dp[j][k], t + dp[j][x] + dp[x+1][k]);
				}
			}
		}
	}
	cout << dp[1][n];

	return 0;
}

Measured memory_bytes: 1536
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

//////////////////////////

#define N 200005
ll n;
ll a[N];
vector<ll>v[N];
vector<ll>LIS;
ll ans[N];

void dfs(ll id,ll par){
    ll pos=POSL(LIS,a[id]);
    ll val=LIS[pos];
    LIS[pos]=a[id];
    
    ll sz=POSL(LIS,inf);
    ans[id]=sz;
    for(auto x:v[id]){
        if(x==par)continue;
        dfs(x,id);
    }
    LIS[pos]=val;
}

int main(){fastio
    cin>>n;
    rep(i,1,n)cin>>a[i];
    rep(i,1,n-1){
        ll b,c;cin>>b>>c;
        v[b].pb(c);
        v[c].pb(b);
    }
    rep(i,1,N)LIS.pb(inf);
    dfs(1,0);
    rep(i,1,n)cout<<ans[i]<<endl;
    
    
    return 0;
}



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

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll n, d, a; cin >> n >> d >> a;
    vector<pair<ll, ll>> temp(n);
    rep(i, n) cin >> temp[i].first >> temp[i].second;
    sort(temp.begin(), temp.end());
    vector<ll> x(n), h(n);
    rep(i, n) {
        x[i] = temp[i].first;
        h[i] = temp[i].second;
    }

    rep(i, n) {
        if (h[i] % a == 0) h[i] = h[i] / a;
        else h[i] = h[i] / a + 1LL;
    }

    vector<int> to(n);

    rep(i, n) {
        // x[i] + 2*d　を超える最大のx
        int idx = upper_bound(x.begin(), x.end(), x[i] + 2*d) - x.begin();
        idx--;
        to[i] = idx;
    }

    ll num = 0;
    ll ans = 0;

    vector<ll> memo(n+1);

    rep(i, n) {
        int right = to[i];
        num += memo[i];
        h[i] -= num;
        if (h[i] > 0) {
            ans += h[i];
            num += h[i];
            memo[right+1] -= h[i];
        }
    }

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


    


Measured memory_bytes: 8832