akhauriyash/Code-Regression huggingface dataset:
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    pre_A = -1
    dp = [True for i in range(A[-1]+1)]
    for i in range(N):
        if pre_A != A[i]:
            for j in range(2, A[-1]+1):
                x = j*A[i]
                if x <= A[-1]:
                    dp[x] = False
                else:
                    break
            pre_A = A[i]
        else:
            dp[A[i]] = False

    count = 0
    for i in range(N):
        if dp[A[i]]:
            count += 1
    print(count)

resolve()

Measured memory_bytes: 32376
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var NK = ReadLine().Split().Select(int.Parse).ToArray();
        int N = NK[0];
        int K = NK[1];
        var A = ReadLine().Split().Select(long.Parse).ToArray();
        Array.Sort(A);

        Modular min = 0;
        Modular max = 0;
        for (int i = 0; i < N-K+1; i++)
        {
            min += Modular.Ncr(N - 1 - i, K-1)*A[i];
        }
        for (int i = N - 1; i >= K-1; i--)
        {
            max += Modular.Ncr(i, K-1)*A[i];
        }
        WriteLine((long)(max-min));
    }
}
class Modular
{
    private const int M = 1000000007;
    private long value;
    public Modular(long value) { this.value = value; }
    public static implicit operator Modular(long a)
    {
        var m = a % M;
        return new Modular((m < 0) ? m + M : m);
    }
    public static Modular operator +(Modular a, Modular b)
    {
        return a.value + b.value;
    }
    public static Modular operator -(Modular a, Modular b)
    {
        return a.value - b.value;
    }
    public static Modular operator *(Modular a, Modular b)
    {
        return a.value * b.value;
    }
    private static Modular Pow(Modular a, int n)
    {
        switch (n)
        {
            case 0:
                return 1;
            case 1:
                return a;
            default:
                var p = Pow(a, n / 2);
                return p * p * Pow(a, n % 2);
        }
    }
    public static Modular operator /(Modular a, Modular b)
    {
        return a * Pow(b, M - 2);
    }
    private static readonly List<int> facs = new List<int> { 1 };
    private static Modular Fac(int n)
    {
        for (int i = facs.Count; i <= n; ++i)
        {
            facs.Add((int)(Math.BigMul(facs.Last(), i) % M));
        }
        return facs[n];
    }
    public static Modular Ncr(int n, int r)
    {
        return (n < r) ? 0
             : (n == r) ? 1
                        : Fac(n) / (Fac(r) * Fac(n - r));
    }
    public static explicit operator int(Modular a)
    {
        return (int)a.value;
    }
}


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

int main() {
  int n; string s; cin >> n >> s;
  if(n % 2) { cout << "No\n"; return 0; }
  int nn = n / 2;
  for(int i = 0, j = nn ; j < (int)s.size() ; ++i, ++j) {
    if(s[i] != s[j]) { cout << "No\n"; return 0; }
  }
  cout << "Yes\n";
}


Measured memory_bytes: 256
import sys

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

a = [i*(i+1)//2 for i in range(60)]
n = ni()
l = factorization(n)
res = 0
for i in range(len(l)):
    j =  l[i][1]
    if l[i][0] == 1:
        continue
    for k,k_ in enumerate(a):
        if j < k_:
            res += k-1
            break
print(res)

Measured memory_bytes: 9532
#067-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()

n=I()
nl=[[] for i in range(n)]
distfen=[-1 for i in range(n)]
distsnu=[-1 for i in range(n)]

for i in range(n-1):
    a,b=IL()
    nl[a-1].append(b-1)
    nl[b-1].append(a-1)
    
q=[[0,0]]
vis=[False for i in range(n)]
while len(q)!=0:
    s,d=q.pop(0)
    vis[s]=True
    for v in nl[s]:
        if not vis[v]:
            distfen[v]=d+1
            q.append([v,d+1])

q=[[n-1,0]]
vis=[False for i in range(n)]
while len(q)!=0:
    s,d=q.pop(0)
    vis[s]=True
    for v in nl[s]:
        if not vis[v]:
            distsnu[v]=d+1
            q.append([v,d+1])
        
fen=0
snu=0

for i in range(1,n-1):
    if distfen[i]<=distsnu[i]:
        fen+=1
    else:
        snu+=1

if fen>snu:
    print("Fennec")
else:
    print("Snuke")

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

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define deb(x) cout << x << endl
#define done(x) {cout << x << endl;return;}
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;


const int N = 405;

int d;
vi c(27);
vvi a(N,vi(27));

void f(vi &v){
  int res = 0;
  vi last(27,-1);
  rep(i,0,d){
    last[v[i]]=i;
    fr(j,1,26)
      res-=(i-last[j])*c[j];
    res+=a[i][v[i]];
  }
  cout<<res<<endl;
}


void solve() {

  
  cin>>d;
  fr(i,1,26)
    cin>>c[i];
  rep(i,0,d)
    fr(j,1,26)
      cin>>a[i][j];
  
  vi v(d);
  rep(i,0,d)
    cin>>v[i];
  int q;
  cin>>q;
  while(q--){
    int x,y;
    cin>>x>>y;
    v[x-1]=y;
    f(v);
  }
}


signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(15);
    int t = 1;
   //cin >> t;

    while (t--)
        solve();
#ifdef aa
    cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}







int powm(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

int divide(int a, int b) {
    return (a % mod) * powm(b, mod - 2) % mod;
}

int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}


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


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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> rr,gg,bb;
    set<int> r,g,b;
    for(int i=1;i<=n;++i){
        if(s[i-1]=='R') {
            r.insert(i);
            rr.push_back(i);
        }
        if(s[i-1]=='G') {
            g.insert(i);
            gg.push_back(i);
        }
        if(s[i-1]=='B') {
            b.insert(i);
            bb.push_back(i);
        }
    }

    
    /*
    cout << "r";
    rep(i,rr.size()){
        cout  << rr[i] << " ";
    }
    cout << endl;
    cout << "g";
    rep(i,gg.size()){
        cout  << gg[i] << " ";
    }
    cout << endl;
    cout << "b";
    rep(i,bb.size()){
        cout  << bb[i] << " ";
    }
    cout << endl;
    */

    ll res = 0;

    rep(i,rr.size()){
        rep(j,gg.size()){
            int si,sj;
            si = rr[i];
            sj = gg[j];
            int temp = abs(si-sj);
            int p_min,p_max;
            p_min = min(si,sj)-temp;
            p_max = max(si,sj)+temp;
            int dumy=0;
            if(b.count(p_min)==1) dumy++;
            if(b.count(p_max)==1) dumy++;

            if((temp%2)==0){
                if(b.count(min(si,sj)+(temp/2))==1) dumy++;
            }

            //cout << si <<":" <<sj <<":"<<dumy << endl;

            res+=max(0,int(int(b.size())-dumy));
        }
    }

    cout << res << endl;

}


Measured memory_bytes: 3760
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(C: str):
    print(chr(ord(C)+1))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    C = next(tokens)  # type: str
    solve(C)

if __name__ == '__main__':
    main()


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

int n,m,pic[110][111],ed[60][60];
int edb[111][110];
int site;
int num,flag = 0;
int ans,count;

void deb() {
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++)
      cout <<pic[i][j] << " ";
    cout << endl;
  }
  cout << "-------------------"<<endl;
  for(int i=0;i<m;i++) {
    for(int j=0;j<m;j++) {
      printf("%2d ",ed[i][j]);
    }
    cout << endl;
  }
  cout << "---------------"<<endl;
}


void input() {
     
   for(int i=0;i<n;i++) {
    for(int j=0;j<n;j++) {
      cin >> pic[i][j];
    }
  }
    
  for(int i=0;i<m;i++) {
    for(int j=0; j<m;j++) {
      cin >> ed[i][j];
    }
  }
}


void rot() {
  int rotf = 0;
  int rotk;
  for(int i=0;i<m;i++){
    rotk = 0;
    for(int j=m-1;j>=0;j--) {
      edb[i][rotk] = ed[j][i];
      rotk++;
    }
  }

  
  for(int i=0;i<m;i++)
    for(int j=0;j<m;j++) {
      ed[i][j] = edb[i][j];
      if(ed[i][j] != -1 && rotf == 0) {
	site = i*m+j;
	num = ed[i][j];
	rotf = 1;
      }
    }

}


void check(int h,int w) {
  int chfla;
  count = 0;
  chfla = 0;
  for(int i=0;i<m;i++) {
    for(int j=0;j<m;j++) {

      if(h+i-site/m >=0 && n > h+i-site/m && w+j-site%m >=0 && w+j-site%m < n) {
	//	printf("ed[%d][%d](%d) == pic[%d][%d](%d)\n",i,j,ed[i][j],h+i-site/m,w+j-site%m,pic[h+i-site/m][w+j-site%m]);
      if(ed[i][j] == -1)count++;
      else if(ed[i][j] == pic[h+i-site/m][w+j-site%m]) count++;
      else {
	chfla = 1;
	break;
      }
      }else break;
    }
    if(chfla == 1) break;
  }
  
  ans = (h)*n+(w);
  //cout << "count = "<<count<<endl;
}

void search() {
  int sefla = 0;

  //cout << num << endl;
  for(int i=0;i<n;i++) {
    for(int j=0; j<n;j++) {
      //  printf("pic[%d][%d](%d) == %d\n",i,j,pic[i][j],num);
      if(pic[i][j] == num) {
	//	printf("pic[%d][%d](%d) => check(%d,%d);\n--------------\n",i,j,pic[i][j] ,i,j);
	check(i,j);
	if(count == m*m) {
	  sefla = 1;
	  break;
	}
      }
    }
    if(sefla == 1) break;
  }
}

  


int main() {
  int ansmax;
  
  while(1) {
    
    cin >> n >> m;
    if(n==0 && m== 0) break;
    input();
    ansmax = n*n+1;
    ans = n*n+1;
	
    for(int i=0;i<4;i++) {
	rot();
	//deb();    

	search();
	
	if(m*m == count &&( (ans/n) < ansmax/n) ||((ans%n) < (ansmax%n) && (ans/n) <= ansmax/n)) ansmax  = ans; 
    }
    
    
    if(ansmax != n*n+1) cout << ansmax%n+1 << " " << ansmax/n+1<< endl;
    else cout << "NA" << endl;	
  }
  
  return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 

const int mod = 1000000007;
const int inf = 1e9;

ll f(ll n){
    return n*(n-1)/2;
}

int main(){
    ll n;
    cin >> n;
    ll a[n];
    rep(i,0,n){cin >> a[i];}
    map<int,int> m;
    rep(i,0,n){m[a[i]]++;}
    ll ans = 0;
    for(auto itr = m.begin();itr!=m.end();itr++){
        ans += (ll)f(itr->second);
    }
    rep(i,0,n){
        cout << (ll)ans - m[a[i]] + 1 << endl;
    }
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
char a[5]={'a','e','i','o','u'};
int main()
{
    char c;
    c=getchar();
    for(int i=0;i<5;i++)
	{
        if(c==a[i])
		{
            cout<<"vowel"<<endl;
            return 0;
        }
    }
    cout<<"consonant"<<endl;
    return 0;
}

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


void solve(long long N, long long M, long long C, std::vector<long long> B, std::vector<std::vector<long long>> A){
	int ans = 0;
	for(int i=0; i<N; i++){
		int tmp = 0;
		for(int j=0; j<M; j++) tmp += A[i][j]*B[j];
		if(tmp+C>0) ans++;
	}
	printf("%d\n", ans);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long C;
    scanf("%lld",&C);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&B[i]);
    }
    std::vector<std::vector<long long>> A(N, std::vector<long long>(M));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < M ; j++){
            scanf("%lld",&A[i][j]);
        }
    }
    solve(N, M, C, std::move(B), std::move(A));
    return 0;
}


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

using namespace std;

int main(){
    int W, H, N;
    int x[100], y[100], a[100];

    cin >> W >> H >> N;
    for (int i = 0; i < N; i++){
        cin >> x[i] >> y[i] >> a[i];
    }
    int num[] = {0, W, 0, H};
    for (int i = 0; i < N; i++){
        switch(a[i]){
        case 1:
            num[0] = max(num[0], x[i]);
            break;
        case 2:
            num[1] = min(num[1], x[i]);
            break;
        case 3:
            num[2] = max(num[2], y[i]);
            break;
        case 4:
            num[3] = min(num[3], y[i]);
            break;
        }
    }
    if (num[0] >= num[1] || num[2] >= num[3]) {
        cout << 0 << endl;
    }
    else {
        cout << (num[1] - num[0]) * (num[3] - num[2]) << endl;
    }
    return 0;

}

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

int main() {
int N,A,B;
A = 0;
B = 0;
cin >> N;
vector<int> v(N);
for (int i = 0; i < N; i++)
{
    cin >> v.at(i);
}

sort(v.begin(),v.end());
reverse(v.begin(),v.end());


for (int i = 0; i < N; i++)
{
    if (i%2 == 0)
    A += v.at(i);
    else
    {
        B += v.at(i);
    }
    
}
cout << A - B << endl;

}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
int main(void){
  std::vector<int>lis = {1, 4, 10, 20, 35, 56, 84, 120, 165, 220, 286, 364, 455, 560, 680, 816, 969, 1140, 1330, 1540, 1771, 2024, 2300, 2600, 2925, 3276, 3654, 4060, 4495, 4960, 5456, 5984, 6545, 7140, 7770, 8436, 9139, 9880, 10660, 11480, 12341, 13244, 14190, 15180, 16215, 17296, 18424, 19600, 20825, 22100, 23426, 24804, 26235, 27720, 29260, 30856, 32509, 34220, 35990, 37820, 39711, 41664, 43680, 45760, 47905, 50116, 52394, 54740, 57155, 59640, 62196, 64824, 67525, 70300, 73150, 76076, 79079, 82160, 85320, 88560, 91881, 95284, 98770, 102340, 105995, 109736, 113564, 117480, 121485, 125580, 129766, 134044, 138415, 142880, 147440, 152096, 156849, 161700, 166650, 171700, 176851, 182104, 187460, 192920, 198485, 204156, 209934, 215820, 221815, 227920, 234136, 240464, 246905, 253460, 260130, 266916, 273819, 280840, 287980, 295240, 302621, 310124, 317750, 325500, 333375, 341376, 349504, 357760, 366145, 374660, 383306, 392084, 400995, 410040, 419220, 428536, 437989, 447580, 457310, 467180, 477191, 487344, 497640, 508080, 518665, 529396, 540274, 551300, 562475, 573800, 585276, 596904, 608685, 620620, 632710, 644956, 657359, 669920, 682640, 695520, 708561, 721764, 735130, 748660, 762355, 776216, 790244, 804440, 818805, 833340, 848046, 862924, 877975, 893200, 908600, 924176, 939929, 955860, 971970};
  std::vector<int>lis_1 = {1, 35, 165, 455, 969, 1771, 2925, 4495, 6545, 9139, 12341, 16215, 20825, 26235, 32509, 39711, 47905, 57155, 67525, 79079, 91881, 105995, 121485, 138415, 156849, 176851, 198485, 221815, 246905, 273819, 302621, 333375, 366145, 400995, 437989, 477191, 518665, 562475, 608685, 657359, 708561, 762355, 818805, 877975, 939929};
  std::vector<int>dp(1000001);
  std::vector<int>dp_1(1000001);
  for (int i = 0; i < 1000001; i++){
    dp[i] = 1000;
    dp_1[i] = 1000;
  }
  dp[0] = 0;
  dp_1[0] = 0;
  for (int i = 0; i < 1000001; i++){
    for (int j = 0; j < lis.size(); j++){
      if (i+lis[j] <= 1000000){
        dp[i+lis[j]] = std::min(dp[i]+1, dp[i+lis[j]]);
      }
    }
  }
  for (int i = 0; i < 1000001; i++){
    for (int j = 0; j < lis_1.size(); j++){
      if (i+lis_1[j] <= 1000000){
        dp_1[i+lis_1[j]] = std::min(dp_1[i]+1, dp_1[i+lis_1[j]]);
      }
    }
  }

  while (1){
    int n;
    std::cin >> n;
    if (n == 0) break;
    std::cout << dp[n] << " " << dp_1[n] << std::endl;
  }
  return 0;
}



Measured memory_bytes: 10476
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            while(true){
                int a,b,c,d,e;
                int x,y;
                a=0;
                b=0;
                c=0;
                d=0;
                e=0;
               String line = reader.readLine();
                for(int i=0;i<5;i++){
                    switch(i){
                        case 0:
                        e = line.indexOf('?');
                        break;
                        case 1:
                        a = line.indexOf('+');
                        break;
                        case 2:
                        b = line.indexOf('-');
                        break;
                        case 3:
                        c = line.indexOf('*');
                        break;
                        case 4:
                        d = line.indexOf('/');
                        break;
                    }
                }
                if(e!=-1)
                break;
                else if(a!=-1){
                    StringTokenizer token1 = new StringTokenizer(line," + ");
                    x = Integer.parseInt(token1.nextToken());
                    y = Integer.parseInt(token1.nextToken());
                    System.out.println(x+y);
                }else if(b!=-1){
                    StringTokenizer token2 = new StringTokenizer(line," - ");
                    x = Integer.parseInt(token2.nextToken());
                    y = Integer.parseInt(token2.nextToken());  
                    System.out.println(x-y);
                }else if(c!=-1){
                    StringTokenizer token3 = new StringTokenizer(line," * ");
                    x = Integer.parseInt(token3.nextToken());
                    y = Integer.parseInt(token3.nextToken());
                    System.out.println(x*y);
                }else if(d!=-1){
                    StringTokenizer token4 = new StringTokenizer(line," / ");
                    x = Integer.parseInt(token4.nextToken());
                    y = Integer.parseInt(token4.nextToken());
                    System.out.println(x/y);
                }else 
                break;
            } 
        }catch(IOException e){
            System.out.println(e);
        }catch(NumberFormatException e){
System.out.println("The input number was not correct.");
        }
    }
}


Measured memory_bytes: 24460
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

 
int main() {

    ll n;
    cin >> n;
    string s;
    cin >> s;
    
    ll r_count[4001] = {0};
    ll g_count[4001] = {0};
    ll b_count[4001] = {0};
    rep(i,n) {
        r_count[i+1]= r_count[i];
        g_count[i+1]= g_count[i];
        b_count[i+1]= b_count[i];
        if(s[i] == 'R')   r_count[i+1]++;
        if(s[i] == 'G')   g_count[i+1]++;
        if(s[i] == 'B')   b_count[i+1]++;
    }

    ll ans = 0;
    rep(i,n-2) {
        for(int j=i+1;j<n-1;j++) {
            if(s[i]== 'R' && s[j] == 'G') {
                ans += b_count[n]-b_count[j+1];
                if(2*(j+1)-(i+1)<=n) {
                    if(s[2*(j+1)-(i+1)-1] == 'B' && b_count[n]-b_count[j+1]>0) ans--;
                }
            }
            if(s[i]== 'R' && s[j] == 'B') {
                ans += g_count[n]-g_count[j+1];
                if(2*(j+1)-(i+1)<=n) {
                    if(s[2*(j+1)-(i+1)-1] == 'G' && g_count[n]-g_count[j+1]>0) ans--;
                }
            }
            if(s[i]== 'G' && s[j] == 'R') {
                ans += b_count[n]-b_count[j+1];
                if(2*(j+1)-(i+1)<=n) {
                    if(s[2*(j+1)-(i+1)-1] == 'B' && b_count[n]-b_count[j+1]>0) ans--;
                }
            }
            if(s[i]== 'G' && s[j] == 'B') {
                ans += r_count[n]-r_count[j+1];
                if(2*(j+1)-(i+1)<=n) {
                    if(s[2*(j+1)-(i+1)-1] == 'R' && r_count[n]-r_count[j+1]>0) ans--;
                }
            }
            if(s[i]== 'B' && s[j] == 'R') {
                ans += g_count[n]-g_count[j+1];
                if(2*(j+1)-(i+1)<=n) {
                    if(s[2*(j+1)-(i+1)-1] == 'G' && g_count[n]-g_count[j+1]>0) ans--;
                }
            }
            if(s[i]== 'B' && s[j] == 'G') {
                ans += r_count[n]-r_count[j+1];
                if(2*(j+1)-(i+1)<=n) {
                    if(s[2*(j+1)-(i+1)-1] == 'R' && r_count[n]-r_count[j+1]>0) ans--;
                }
            }
        }
    }

    cout << ans << endl;

 return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

/*
    if you have any question about any part of my code,
    please don't shy to ask anytime :)
*/


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

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

    // ll t;
    // cin >> t;
    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

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

bool primes[1000000];

void Sieve(){
    for(int i= 2; i < 1000000; i++){
        primes[i] = true;
    }
    primes[1] = false;    
    for(int i = 2; i < 1000; i++){
        if(primes[i] == true)
            for(int j=i; j*i < 1000000;j++){
                primes[j*i] = false;
            }
    }     
}
bool IsPrime(int x){
    return primes[x];
}

int main(void){
    Sieve();
    int n, c;
    while(cin >> n){
        c = 0;
        for(int i = 2; i <= n; i++){
        if(IsPrime(i)==true)
            c++;
        }
        cout << c << endl;
    }
    return 0;
}


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

int main() {
    string S, T;
    cin >> S;
    cin >> T;
    T.pop_back();
    string messages = "No";
    if(S == T) {
        messages = "Yes";
    }
    cout << messages << endl;
    return 0;
}

Measured memory_bytes: 3632
N = int(input())
s_list = [input() for _ in range(N)]
M = int(input())
t_list = [input() for _ in range(M)]
tmp = s_list.copy()
tmp.append("fdsfsdfsfs")
s_set = list(set(tmp))
result = []
for s in s_set:
    r = 0
    for i in s_list:
        if i == s:
            r += 1
    for j in t_list:
        if j == s:
            r -= 1
    result.append(r)
print(max(result))


Measured memory_bytes: 3064
//34
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int s,dd;cin>>s>>dd,s|dd;){
    int d[100][100];
    fill(d[0],d[100],1<<30);
    for(int i=0;i<s;i++){
      for(int j=0;j<s;j++){
	d[i+dd][j+dd]=0;
      }
    }
    for(int j=0;j<s;j++){
      for(int i=0;i<dd;i++){
	int cd;
	cin>>cd;
	if(cd){
	  d[i][dd+j]=d[dd+j][i]=cd;
	}
      }
    }
    for(int j=0;j<dd-1;j++){
      for(int i=0;i<dd-j-1;i++){
	int cd;
	cin>>cd;
	if(cd){
	  d[j][i+j+1]=d[i+j+1][j]=cd;
	}
      }
    }
    bool u[100]={};
    int l=0;
    int n[100];
    fill(n,n+100,1<<30);
    n[dd]=0;
    for(int i=0;i<s+dd;i++){
      int nm=1<<30;
      int x;
      for(int j=0;j<s+dd;j++){
	if(!u[j]&&nm>n[j]){
	  x=j;
	  nm=n[j];
	}
      }
      u[x]=true;
      l+=n[x];
      for(int j=0;j<s+dd;j++){
	n[j]=min(n[j],d[x][j]);
      }
    }
    cout<<l<<endl;
  }
  return 0;
}

Measured memory_bytes: 1196
num = int(input())
num_list = [int(item) for item in input().split()]

sum_heal = 0

for i, item_d1 in enumerate(num_list):
    for k, item_d2 in enumerate(num_list):
        if i > k:
            sum_heal += item_d1 * item_d2

print(sum_heal)

Measured memory_bytes: 2940
#define DEBUG 0

/**
 * File    : D.cpp
 * Author  : Kazune Takahashi
 * Created : 6/9/2019, 9:09:02 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

/*
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}

void No()
{
  cout << "No" << endl;
  exit(0);
}
*/

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

// const ll MOD = 1000000007;

int H, W;
string S[2010];
bool X[2010][2010];
ll A[2010][2010];
ll B[2010][2010];

ll solve()
{
  for (auto i = 0; i < H; i++)
  {
    ll t = 0;
    for (auto j = 0; j < W; j++)
    {
      if (X[i][j])
      {
        t++;
      }
      else
      {
        for (auto k = j - 1; k >= j - t; k--)
        {
          A[i][k] = t;
        }
        t = 0;
      }
    }
    for (auto k = W - 1; k >= W - t; k--)
    {
      A[i][k] = t;
    }
  }
  for (auto j = 0; j < W; j++)
  {
    ll t = 0;
    for (auto i = 0; i < H; i++)
    {
      if (X[i][j])
      {
        t++;
      }
      else
      {
        for (auto k = i - 1; k >= i - t; k--)
        {
          B[k][j] = t;
        }
        t = 0;
      }
    }
    for (auto k = H - 1; k >= H - t; k--)
    {
      B[k][j] = t;
    }
  }
  ll ans = 0;
  for (auto i = 0; i < H; i++)
  {
    for (auto j = 0; j < W; j++)
    {
      ans = max(ans, A[i][j] + B[i][j]);
    }
  }
  return ans;
}

int main()
{
  cin >> H >> W;
  for (auto i = 0; i < H; i++)
  {
    cin >> S[i];
  }
  for (auto i = 0; i < H; i++)
  {
    for (auto j = 0; j < W; j++)
    {
      X[i][j] = (S[i][j] == '.');
    }
  }
  solve();
#if DEBUG == 1
  cerr << "A" << endl;
  for (auto i = 0; i < H; i++)
  {
    for (auto j = 0; j < W; j++)
    {
      cerr << A[i][j];
    }
    cerr << endl;
  }
  cerr << "B" << endl;
  for (auto i = 0; i < H; i++)
  {
    for (auto j = 0; j < W; j++)
    {
      cerr << B[i][j];
    }
    cerr << endl;
  }
#endif
  cout << solve() - 1 << endl;
}

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

#define TCLOOP() int tc; cin>>tc; while(tc--)

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) int(s.length())
#define sz(v) int(v.size())
#define MOD 1000000007

// Code Here

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n; cin>>n;
    ll a[n]; f(i,0,n-1) cin>>a[i];
    ll cc = 1;
    ll ans = 0;
    f(i,0,n-1) {
    	if(a[i] == cc) {
    		cc++;
    	}
    	else ans++;
    }
    if(ans < n) cout<<ans;
    else cout<<-1;
    return 0;
}

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

int n, q;
int S[100000], T[50000];

bool hoge(int up, int down, int co){

    //cout << S[down] << " " << T[co] << " " << S[up] << endl;
    if (T[co]<S[down] || T[co]>S[up]) return false;
    else if (T[co] == S[(up + down) / 2]||T[co]==S[up]||T[co]==S[down]) return true;
    else if (T[co] > S[(up + down) / 2])
    {
        if (down != (up + down) / 2) down = (up + down) / 2;
        else down++;
    }
    else if (T[co] < S[(up + down) / 2])
    {
        if (up != (up + down) / 2) up = (up + down) / 2;
        else up--;
    }
    else return false;
    return hoge(up, down, co);
}

int main() {
    
    cin >> n;
    for (int i = 0; i < n; i++) cin >> S[i];
    cin >> q;
    for (int i = 0; i < q; i++) cin >> T[i];

    int ans = 0;
    for (int i = 0; i < q; i++)
    {
        //cout << hoge(n-1, 0, i) << endl;
        if (hoge(n-1, 0, i) == true) ans++;
    }
    cout << ans << endl; 
    return 0;
}


Measured memory_bytes: 3672
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if(A < 10 && B < 10){
      System.out.println(A * B);
    }else{
      System.out.println(-1);
    }
  }
}


Measured memory_bytes: 25172
N, K = map(int, input().split())
d, A = [], []	

for i in range(K):
  d.append(int(input()))
  manko = list(map(int, input().split()))
  A.extend(manko)
  #print(d)
  #print(A)

A = list(set(A))
#print(A)

L = len(A)
print(N-L)

Measured memory_bytes: 9160
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

		int N = Integer.parseInt(sc.nextLine());
		Map<String, Integer> map = new HashMap<>();
		long cnt = 0;

		for (int i = 0; i < N; i++) {
			String[] strArr = sc.nextLine().split("");
			Arrays.sort(strArr);
			String str = String.join(",", strArr);
			if (map.containsKey(str)) {
				int freq = map.get(str) + 1;
				map.put(str, freq);
				cnt += freq;
			}
			else {
				map.put(str, 0);
			}
		}

		System.out.println(cnt);
	}
}

Measured memory_bytes: 163020
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-8;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll h,w;cin>>h>>w;
    if(h==1||w==1){
        cout<<1<<endl;
        return 0;
    }
    cout<<(h*w+1)/2<<endl;
}





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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s; cin>>s;
	vector<int>v(s.size(),0);
	for(int i=0;;){
		while(i<s.size()&&s.at(i)!='R')++i;
		if(i>=s.size())break;
		int st=i;
		while(s.at(i)=='R')++i;
		v.at(i)+=(i-st)/2;
		v.at(i-1)+=(i-st+1)/2;
	}
	for(int i=s.size()-1;;){
		while(i>=0&&s.at(i)!='L')--i;
		if(i<0)break;
		int st=i;
		while(s.at(i)=='L')--i;
		v.at(i)+=(st-i)/2;
		v.at(i+1)+=(st-i+1)/2;
	}
	for(auto&&i:v)cout<<" "s<<i;
}

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

int h,w;
char s[400][400];

int cost[400][400];
int dp[400][400];

int calc(int t){
	memset(cost,0,sizeof(cost));
	memset(dp,0x3f,sizeof(dp));
	for(int i=0;i<=h;i++){
		for(int j=0;j<=h;j++){
			if(i==0||j==0)cost[i][j]=0;
			else cost[i][j]=cost[i-1][j-1]+(s[i-1][t]==s[j-1][t+1]);
		}
	}
	dp[h][h]=0;
	for(int i=h;i>=0;i--){
		for(int j=h;j>=0;j--){
			if(i)dp[i-1][j]=min(dp[i-1][j],dp[i][j]+cost[i][j]);
			if(j)dp[i][j-1]=min(dp[i][j-1],dp[i][j]+cost[i][j]);
		}
	}
	return dp[0][0];
}
int main(){
	scanf("%d%d",&h,&w);
	rep(i,h)scanf("%s",s[i]);
	int ans=0;
	rep(i,w-1){
		ans+=calc(i);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
 
using namespace std;
string S;
 
int main() {
  cin >> S;
  string words[4] = {"maerd", "remaerd", "esare", "resare"};
  int cur = S.size();
  while (cur > 0) {
    bool isValid = false;
    for (int i = 0; i < 4; ++i) {
      if (cur < (int)words[i].size()) continue;
      string tmp = S.substr(cur - words[i].size(), words[i].size());
      reverse(tmp.begin(), tmp.end());
      if (tmp == words[i]) {
	isValid = true;
	cur -= words[i].size();
	break;
      }
    }
    if (!isValid) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			long[] a = IntStream.range(0, n).mapToLong(i -> scanner.nextLong()).toArray();
			// sum1=[1,-1,...], sum2=[-1,1,...]
			int[] sum1 = new int[n], sum2 = new int[n];
			Arrays.fill(sum1, 1);
			Arrays.fill(sum2, -1);
			IntStream.range(0, n / 2).forEach(i -> {
				sum1[2 * i + 1] = -1;
				sum2[2 * i + 1] = 1;
			});
			System.out.println(Math.min(getResult(a, sum1), getResult(a, sum2)));
		}
	}

	/**
	 * @param a   数値配列
	 * @param sum 変更したい合計値の配列
	 * @return 変更が必要なステップ数
	 */
	private static long getResult(final long[] a, final int[] sum) {
		int n = a.length;
		long now = 0, result = 0;
		for (int i = 0; i < n; i++) {
			now += a[i];
			if (sum[i] * now <= 0) {
				result += Math.abs(sum[i] - now);
				now = sum[i];
			}
		}
		return result;
	}
}


Measured memory_bytes: 61040
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    it.next();
    let mut a = vec![];
    for c in it.next().unwrap().chars() {
        match a.last() {
            Some(&x) if c == x => (),
            _ => a.push(c),
        }
    }
    println!("{}", a.len());
}

fn main() {
    run();
}

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

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

    deque<int> screen;
    for(int i=0; i<s.length(); i++){
        if(s[i] == '0') screen.push_back(0);
        if(s[i] == '1') screen.push_back(1);
        if(s[i] == 'B' && !screen.empty()) screen.pop_back();
    }
    while(!screen.empty()){
        cout << screen.front();
        screen.pop_front();
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int a, b, c;
		for ( int n = stdIn.nextInt(); n-- > 0; System.out.println( a * a + b * b == c * c || b * b + c * c == a * a || c * c + a * a == b * b ? "YES" : "NO" ) ) {
			a = stdIn.nextInt();
			b = stdIn.nextInt();
			c = stdIn.nextInt();
		}
	}
}

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N, K;
    cin >> N >> K;
    double ans = 0;
    for (int i = 1; i <= N; i++) {
        int k = i, cnt = 0;
        while(k < K) {k *= 2; cnt++;}
        ans += pow(0.5, cnt);
    }
    cout << ans / N << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

int main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 0; i < n - 2; i++) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
	}
	cout << ans << endl;
	return 0;
}

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

pair<long long,long long> g(long long n){
  pair<long long,long long> ret(0,0);
  long long n_ = n;
  while(n_ > 0) ret.first += n_/5, n_ /= 5;
  n_ = n;
  while(n_ > 0) ret.second += n_/2, n_/= 2;
  return ret;
}

int main(){
  long long N;
  cin >> N;
  if(N%2){
    auto p = g(N), q = g(N/2);
    q.second += N/2;
    p.first -= q.first;
    p.second -= q.second;
    cout << min(p.first,p.second) << endl;
  }else{
    auto p = g(N/2);
    p.second += N/2;
    cout << min(p.first,p.second) << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define print(n) std::cout << n << std::endl
#define FOR(i,n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int r,g,b;
    cin >> r >> g >> b;
    int n = 100 * r + 10 * g + b;
    if(n % 4 == 0)print("YES");
    else print("NO");
 }

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    int N;cin >> N;
    string S;cin >> S;
    int kari = 0,ans = 0;
    for(int i = 0;i<N;i++){
        string T = S.substr(0,i);
        string R = S.substr(i,N-i);
        for(int j = 0;j<26;j++){
            char C = 97+j;
            int Rcount = count(R.begin(),R.end(),C);
            int Tcount = count(T.begin(),T.end(),C);
            if(Rcount >= 1 && Tcount >= 1) kari++;
        }
        ans = max(ans,kari);
        kari = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc079/tasks/abc079_c

A_B_C_D = input()
plus = '+'
minus = '-'
right_side = '=7'
ans = ''

def dfs(i, formula, sum):
    # ベースケース
    if i == 7:
        if sum == 7:
            # global変数を使うなんてイケてないのでは？
            global ans 
            ans = formula + right_side        
        return
    
    # +を入れる場合
    dfs(i+2, formula[:i] + plus + formula[i:], sum + int(formula[i]))

    # -を入れる場合
    dfs(i+2, formula[:i] + minus + formula[i:], sum - int(formula[i]))

dfs(1, A_B_C_D, int(A_B_C_D[0]))

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
    int n;//数列の長さ
    
    int suuji;//数列の値
    
    
    scanf("%d",&n);
    
    int a[n];//数列を格納する配列
    
    for(int i=0;i<n;i++){//入力する数列の数分ループ
        scanf("%d",&suuji);
        a[i]=suuji;
    }
    for(n=n-1;n>=0;n--){
        printf("%d",a[n]);
        if(n!=0){//最後に空白は入れない
            printf(" ");
        }
        
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2028
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
    int n,q;
    cin >> n >> q;
    for(int i=0; i<q; i++){
        lli x,y;
        cin >> x >> y;
        if(n==1){
            cout << min(x, y) << endl;
            continue;
        }
        x--;
        y--;
        while(x != y){
            if(x < y) swap(x, y);
            x = (x-1)/n;
        }
        cout << x+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
const int MAX=105;

typedef struct c
{
    char s[20];
    int num;
}card;
int cmp(char s1[],char s2[])
{
    int len1,len2;
    len1=strlen(s1);len2=strlen(s2);
    if(len1!=len2) return 1;
    for(int i=0;i<len1;i++)
    {
        if(s1[i]!=s2[i]) return 1;
    }
    return 0;
}
int main()
{
    int a,b;
    card a1[MAX],a2[MAX];
    char s1[MAX][20],s2[MAX][20];
    for(int i=0;i<MAX;i++)
    {
        a1[i].num=0;a2[i].num=0;
    }
    cin>>a;
    for(int i=0;i<a;i++)  cin>>s1[i];
    cin>>b;
    for(int i=0;i<b;i++)   cin>>s2[i];

    int k1=1,j,k2=1;
    strcpy(a1[0].s,s1[0]);
    a1[0].num=1;
    for(int i=1;i<a;i++)
    {
        for( j=0;j<k1;j++)
            if(cmp(s1[i],a1[j].s)==0)//相等
            {a1[j].num++;break;}
        if(j==k1)
        {
            strcpy(a1[k1].s,s1[i]);
            a1[k1].num++;
            k1++;
        }
    }
    strcpy(a2[0].s,s2[0]);
    a2[0].num=1;
    for(int i=1;i<b;i++)
    {

        for( j=0;j<k2;j++)
            if(cmp(s2[i],a2[j].s)==0)//相等
            {a2[j].num++;break;}
        if(j==k2)
        {
            strcpy(a2[k2].s,s2[i]);
            a2[k2].num++;
            k2++;
        }
    }
    //printf("k1=%d,k2=%d\n",k1,k2);
    int cnt,ans,f;
    ans=0;
    for(int i=0;i<k1;i++)
    {
        cnt=0;f=1;
        for(int j=0;j<k2;j++)
        {
            if(cmp(a1[i].s,a2[j].s)==0)
            {
                cnt=a1[j].num-a2[i].num;
                //printf("%d,%d\n",a1[j].num,a2[i].num);
                if(cnt<0) cnt=0;
                f=0;
            }

        }
              if(f)
                cnt=a1[i].num;
        if(cnt>ans) ans=cnt;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>

int main() {
	std::string s1, s2, s3;
	std::cin >> s1 >> s2 >> s3;
	std::transform(s1.begin(), s1.end(), s1.begin(), toupper);
	std::transform(s2.begin(), s2.end(), s2.begin(), toupper);
	std::transform(s3.begin(), s3.end(), s3.begin(), toupper);

	printf("%c%c%c\n", s1[0], s2[0], s3[0]);	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    deque<int> d;
    long long n; cin >> n;
    while (n) {
        d.emplace_front(n%10);
        n /= 10;
    }
    int dn = d.size();
    int ans = 0;
    int cur = 0;
    for (int i = 0; i < dn; i++) {
        cur += d[i];
        ans = max(ans, cur-1 + (dn-i-1) * 9);
    }
    ans = max(ans, cur);
    cout << ans << endl;
    return 0;
}

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

int main() {
	int ans = 0, s, nv;
	cin >> s;
	nv = s;
	set<int> st;
	st.insert(nv);
	while(1){
		if(nv%2 == 0) nv/=2;
		else nv = 3*nv + 1;
		ans++;
		if(st.find(nv) != st.end()) break;
		st.insert(nv);
	}
	cout << ans + 1;
	return 0;
}

Measured memory_bytes: 256