akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    string s, t;
    cin >> s >> t;
    ll slen = s.length();
    Map<char, vll> cmap;
    rep(i, slen) {
        char c = s[i];
            
        cmap[c].push_back(i);
    }

    ll ans = 1;
    ll nowpos = -1;
    int tlen = t.length();
    rep(i, tlen) {
        char c = t[i];
        if (cmap.find(c) == cmap.end()) {
            cout << -1 << endl;
            return 0;
        }

        int cmapvlen = cmap[c].size();
        // cout << "c" << c << cmap[c][0] << endl;
        if (nowpos >= cmap[c][cmapvlen - 1]) {
            ans++;
            nowpos = cmap[c][0];
        } else if (nowpos < cmap[c][0]) {
            nowpos = cmap[c][0];
        } else {
            int left = -1;
            int right = cmapvlen;
            while ((right - left) > 1) {
                int mid = left + (right - left) / 2;
                if (cmap[c][mid] <= nowpos) {
                    left = mid;
                } else {
                    right = mid;
                }
            }
            nowpos = cmap[c][right];
        }
        // cout << "n" << nowpos << endl;
        // cout << ans << endl;
    }
    cout << (ans-1)*slen + nowpos + 1 << endl;
}

Measured memory_bytes: 1728
#include <stdio.h>

int main(void)
{
  int n;
  int i;
  long  int re = 1;

  while(1){
    scanf("%d", &n);
    if(1 <= n && n <= 20) break;
  }

  for(i = 0; i < n; i++){
    re *= n-i;
  }

  printf("%ld\n", re);

  return 0;
}

Measured memory_bytes: 592
n = int(input())
c = input()

l = 0
r = n - 1

ans = 0
while l < r:
    while c[l] != "W" and l + 1 < n:
        l += 1

    while c[r] != "R" and r - 1 >= 0:
        r -= 1

    if l < r:
        ans += 1
        l += 1
        r -= 1

print(ans)



Measured memory_bytes: 67876
import math

def get_circle_center_and_radius(x1, y1, x2, y2, x3, y3):
    d = 2 * ((y1 - y3) * (x1 - x2) - (y1 - y2) * (x1 - x3))
    if d == 0:
        x = (x1+x3)/2
        y = (y1+y3)/2
        r2 = (x3-x)**2 + (y3-y)**2
        # r = math.sqrt(r2)
        return (x,y), r2

    a = (x3-x2)**2 + (y3-y2)**2
    b = (x1-x2)**2 + (y1-y2)**2
    c = (x3-x1)**2 + (y3-y1)**2
    if a+b<c:
        x = (x3+x1)/2
        y = (y3+y1)/2
        r2 = c/4
    elif b+c<a:
        x = (x3+x2)/2
        y = (y3+y2)/2
        r2 = a/4
    elif c+a<b:
        x = (x1+x2)/2
        y = (y1+y2)/2
        r2 = b/4
    else:
        x = ((y1 - y3) * (y1 ** 2 - y2 ** 2 + x1 ** 2 - x2 ** 2) - (y1 - y2) * (y1 ** 2 - y3 ** 2 + x1 ** 2 - x3 ** 2)) / d
        y = ((x1 - x3) * (x1 ** 2 - x2 ** 2 + y1 ** 2 - y2 ** 2) - (x1 - x2) * (x1 ** 2 - x3 ** 2 + y1 ** 2 - y3 ** 2)) / -d
        # r = math.sqrt((x - x1) ** 2 + (y - y1) ** 2)
        r2 = (x - x1) ** 2 + (y - y1) ** 2
    return (x, y), r2

def main():
    n = int(input())
    xyl = []
    for _ in range(n):
        x,y = map(int, input().split())
        xyl.append((x,y))

    xyl.sort()
    if n == 2:
        x1,y1 = xyl[0]
        x2,y2 = xyl[1]
        r2 = (x1-x2)**2 + (y1-y2)**2
        r = math.sqrt(r2)
        print(r/2)
        exit()

    ans = 10**18
    for i in range(n):
        for j in range(i+1,n):
            for k in range(j+1,n):
                x1,y1 = xyl[i]
                x2,y2 = xyl[j]
                x3,y3 = xyl[k]
                (cx,cy),r2 = get_circle_center_and_radius(x1, y1, x2, y2, x3, y3)
                for x,y in xyl:
                    d2 = (x-cx)**2 + (y-cy)**2
                    if d2 <= r2+10**(-6):
                        pass
                    else:
                        break
                else:
                    ans = min(ans,r2)
                    
    print(math.sqrt(ans))

if __name__ == "__main__":
    main()

Measured memory_bytes: 76064
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vvl d = VV(n, 3, 0, ll);
  for(int i=0;i<n;i++) std::cin >> d[i][0] >> d[i][1] >> d[i][2];
  vvl x = VV((1<<n), n, 0, ll);
  vvl y = VV((1<<n), n, 0, ll);

  for(int i=0;i<(1<<n);i++){
    for(int j=0;j<n;j++) {
      x[i][j] = abs(d[j][0]);
      y[i][j] = abs(d[j][1]);
    }
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
        if((i>>k)&1){
          x[i][j] = min(x[i][j], abs(d[j][0] - d[k][0]));
          y[i][j] = min(y[i][j], abs(d[j][1] - d[k][1]));
        }
      }
    }
  }
  vll ret(n+1, 1000000000000000000);

  for(int i=0;i<(1<<n);i++){
    int S = i, sub = S;
    ll ans = 1000000000000000000;


    do{
      ll p = sub, q = S - p;
      ll tmp = 0;
      for(int j=0;j<n;j++){
        if((i>>j)&1) continue;
        tmp += min(x[p][j], y[q][j]) * d[j][2];
      }
      ans = min(ans, tmp);
      sub = (sub - 1) & S;
    }while(sub != S);

    ll bt = __builtin_popcount(i);
    ret[bt] = min(ret[bt], ans);
  }

  //std::cout << x[2][2] << '\n';

  for(int i=0;i<=n;i++) std::cout << ret[i] << '\n';
  return 0;
}


Measured memory_bytes: 12588
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int N,K;
int a[100000],v[100000];
ll ans;
void solve(int K){
	ll res = 0;
	rep(i,N) if((a[i]|K) == K) res += v[i];
	chmax(ans,res);
}
int main(){
	cin>>N>>K;
	rep(i,N) cin>>a[i]>>v[i];
	solve(K);
	rep(i,30){
		if((K>>i)&1){
			ll x = K;
			x ^= 1<<i;
			x |= (1<<i)-1;
			solve(x);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp std::make_pair
#define pb push_back
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::set<int> si;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
str s;
int main(){
  cin>>s;
  int ss=s.size();
  ll a=0,res=0;
  int i=0;
  while(i<=ss-2){
    if(s[i]=='A'){
      a++;
      i++;
    }
    else if(s[i]=='B'&&s[i+1]=='C'){
      res+=a;
      i+=2;
    }
    else{
      a=0;
      i++;
    }
  }
  prin(res);
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

constexpr int MAX_N = 10;
int N;
double x[MAX_N];
string u[MAX_N];

void _main() {
  cin >> N;
  rep(i, 0, N) cin >> x[i] >> u[i];

  double ans = 0.0;
  rep(i, 0, N) {
    if (u[i][0] == 'J') {
      ans += x[i];
    } else {
      ans += x[i] * 380000.0;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <fstream>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
typedef long long ll;

#define INF 1000000000

#define U 1
#define D 2
#define R 4
#define L 8

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

int mat[30][30];
bool visited[30][30];

int main(){
  int w,h;
  while(cin>>w>>h, w|h){
    rep(i,h)rep(j,w){ mat[i][j]=0; visited[i][j]=false; }

    // input
    rep(i,h){
      rep(j,w-1){
        int d;
        scanf("%d", &d);
        if(d==0){
          mat[i][j] |= R;
          mat[i][j+1] |= L;
        }
      }

      if(i==h-1) break;

      rep(j,w){
        int d;
        scanf("%d", &d);
        if(d==0){
          mat[i][j] |= D;
          mat[i+1][j] |= U;
        }
      }
    }

    // wfs
    queue<P> q;
    q.push(mp(mp(0,0),1));
    visited[0][0]=true;
    int res=0;
    while(!q.empty()){
      P p = q.front(); q.pop();
      int x=p.first.first, y=p.first.second;
      if(x==h-1 && y==w-1){
        res = p.second;
        break;
      }
      const int d[] = {U, D, R, L};
      const int dy[]= {0,0,1,-1};
      const int dx[]= {-1,1,0,0};
      rep(i,4){
        int nx=x+dx[i];
        int ny=y+dy[i];
        if(nx<0 || nx>=h || ny<0 || ny>=w || visited[nx][ny]) continue;
        if((mat[x][y]&d[i])==0) continue;

        visited[nx][ny]=true;
        q.push(mp(mp(nx,ny), p.second+1));
      }
    }

    cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 1268
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    int wa=a+b;
    int sa=a-b;
    int sec=a*b;
    if(wa>=sa && wa>=sec)printf("%d\n",wa);
    else if(sa>=wa && sa>=sec)printf("%d\n",sa);
    else if(sec>=sa && sec>=wa)printf("%d\n",sec);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		int m,f,r;
		m = sc.nextInt();
		f = sc.nextInt();
		r = sc.nextInt();
		while(!(m == -1 && f == -1 && r == -1)){
			if(m == -1 || f == -1){
				System.out.println("F");
				m = sc.nextInt();
				f = sc.nextInt();
				r = sc.nextInt();
				continue;
			}
			if(m == -1){
				m = 0;
			}
			
			if(f == -1){
				f = 0;
			}
			if(m + f >= 80){
				System.out.println("A");
			}else if(m + f >= 65 && m + f < 80){
				System.out.println("B");
			}else if(m + f >= 50 && m + f < 65){
				System.out.println("C");
			}else if(m + f >= 30 && m + f < 50){
				if(r >= 50){
					System.out.println("C");
				}else{
					System.out.println("D");
				}
			}else{
				System.out.println("F");
			}
			m = sc.nextInt();
			f = sc.nextInt();
			r = sc.nextInt();
		}
	}
}

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

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	ld ans=0;
	for(int i=0;i<n;i++)
	{
		ll x; cin>>x;
		ans+=ld(1)/ld(x);
	}
	ans=ld(1)/ld(ans);
	cout<<fixed<<setprecision(20)<<ans<<'\n';
}


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

using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr i64 INF = std::numeric_limits<i64>::max()/2;

int main()
{
	std::ios_base::sync_with_stdio(0);
	
	i64 n;

	std::cin >> n;

	std::vector<std::vector<i64>> h(n, std::vector<i64>(3, 0));

	for(i64 i=0; i<n; ++i)
	{
		for(i64 j=0; j<3; ++j)
		{
			std::cin >> h[i][j];
		}
	}

	std::vector<std::vector<i64>> dp(n, std::vector<i64>(3, 0));
	
	dp[0][0]=h[0][0];
	dp[0][1]=h[0][1];
	dp[0][2]=h[0][2];
	
	for(i64 i=1; i<n; ++i)
	{
		for(i64 j=0; j<3; ++j)
		{
			for(i64 k=0; k<3; ++k)
			{
				if(j==k) continue;
				dp[i][j] = std::max(dp[i][j], dp[i-1][k]+h[i][j]);
			}
		}
	}

	std::cout << std::max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << "\n";
	
	return 0;
}

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

static const int N = 8;

bool result[N][N];
int row_table[N];
bool col_table[N];
bool dpos_table[2*N-1];
bool dneg_table[2*N-1];

bool run(int i) {
  if (i == N) {
    return true;
  }
  if (row_table[i] >= 0) {
    if (run(i+1)) {
      return true;
    }
  }
  for (int j = 0; j < N; j++) {
    if (col_table[j] || dpos_table[i+j] || dneg_table[i-j+N-1]) continue;
    result[i][j] = col_table[j] = dpos_table[i+j] = dneg_table[i-j+N-1] = true;
    if (run(i+1)) {
      return true;
    } else {
      result[i][j] = col_table[j] = dpos_table[i+j] = dneg_table[i-j+N-1] = false;
    }
  }
  return false;
}

int main() {
  int k;
  for (int i = 0; i < 2*N-1; i++) {
    dpos_table[i] = false;
    dneg_table[i] = false;
  }
  for (int i = 0; i < N; i++) {
    row_table[i] = -1;
    col_table[i] = false;
    for (int j = 0; j < N; j++) {
      result[i][j] = false;
    }
  }
  cin >> k;
  for (int i = 0; i < k; i++) {
    int row,col;
    cin >> row >> col;
    result[row][col] = true;
    row_table[row] = col;
    col_table[col] = true;
    dpos_table[row+col] = true;
    dneg_table[row-col+N-1] = true;
  }
  run(0);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (result[i][j]) cout << "Q";
      else cout << ".";
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3124
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
import math
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    a,b,c=map(int,input().split())
    mototaiseki=a**2*b
    amaritakasa=((mototaiseki-c)*2)/a**2
    if amaritakasa>b:
        hidarisita=c*2/(a*b)
        konotokinotan=math.degrees(math.atan(b/hidarisita))
        print(konotokinotan)
    else:
        t=amaritakasa/a
        #print(amaritakasa)
        print(math.degrees(math.atan(t)))
if __name__ == '__main__':
    main()

Measured memory_bytes: 5312
import numpy as np

n, W = map(int, input().split())
w = []
v = []
for i in range(n):
  w_, v_ = map(int, input().split())
  w.append(w_)
  v.append(v_)
  
dp = np.full(10**3 *n +1, 10**18)
dp[0] = 0

for i in range(n):
  dp[v[i]:] = np.minimum(dp[v[i]:], dp[:-v[i]]+w[i])
  
ans = 0
for i in range(10**3 *n, -1, -1):
  if dp[i] <= W:
    ans = i
    break
    
print(ans)

Measured memory_bytes: 29244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003;
const ll INF=1LL<<60;
vector<int> G[MAX];

int DFS(int u,int p){
    int gru=0;
    
    for(int to:G[u]){
        if(to==p) continue;
        gru^=(DFS(to,u)+1);
    }
    
    return gru;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    for(int i=0;i<N-1;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    int a=DFS(0,-1);
    
    if(a) cout<<"Alice"<<endl;
    else cout<<"Bob"<<endl;
}



Measured memory_bytes: 12800
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;
const int mod = 1e9+7;
const int maxn = 2e5+10;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int ksm(int x,int y){
	int sum=1;
	while(x){
		if(x&1)sum=1ll*sum*y%mod;
		x>>=1;
		y=1ll*y*y%mod;
	}
	return sum;
}

int to[maxn<<1],net[maxn<<1],h[maxn],e=1;
inline void add(int x,int y){
	to[++e]=y;net[e]=h[x];h[x]=e;
}


int k,m,n;
int siz[maxn],fa[maxn],sum[maxn],p[maxn][3],p2=(mod+1)/2;
int inv[maxn],ans=0;
void dfs(int x){
	siz[x]=1;
	p[x][0]=1;
	for(register int i=h[x];i;i=net[i]){
		int y=to[i];
		if(y==fa[x])continue;
		fa[y]=x;
		dfs(y);	
		siz[x]+=siz[y];
		(p[x][2]+=1ll*p[x][1]*(1+mod-inv[siz[y]])%mod)%=mod;
		(p[x][1]=1ll*p[x][1]*inv[siz[y]]%mod+1ll*p[x][0]*(1+mod-inv[siz[y]])%mod)%=mod;
		p[x][0]=1ll*p[x][0]*inv[siz[y]]%mod;
		//cout<<x<<" "<<p[x][0]<<" "<<p[x][1]<<" "<<p[x][2]<<endl;
	}
	(ans+=1ll*p[x][2]*p2%mod)%=mod;
	if(x!=1)
		(ans+=1ll*p[x][1]*p2%mod*(1+mod-inv[n-siz[x]])%mod)%=mod;
	return;
}

int main(){
	n=read();
	inv[0]=1;
	for(register int i=1;i<=n;i++)inv[i]=1ll*inv[i-1]*p2%mod;
	for(register int i=1;i<n;i++){
		int x=read(),y=read();
		add(x,y);add(y,x);
	}
	dfs(1);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 16384
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2])
}

fn main() {
    let (a1, a2, a3) = input_tuple();
    if a1 + a2 + a3 >= 22 {
        println!("bust");
    } else {
        println!("win");
    }
}


Measured memory_bytes: 4352
int N,C,D[30][30],c[500][500];
long long q[3][30],x,y=1e18;
main(){
	scanf("%d%d",&N,&C);
	for(int i=0;i<C;++i)for(int j=0;j<C;++j)scanf("%d",&D[i][j]);
	for(int i=0;i<N;++i)for(int j=0;j<N;++j)scanf("%d",&c[i][j]);
	for(int t=0;t<C;++t){
		for(int i=0;i<N;++i)for(int j=0;j<N;++j){
			q[(i+j)%3][t]+=D[c[i][j]-1][t];
		}
	}
	for(int i=0;i<C;++i){
		for(int j=0;j<C;++j)if(i!=j){
			for(int k=0;k<C;++k)if(i!=k&&j!=k){
				x=q[0][i]+q[1][j]+q[2][k];
				if(x<y)y=x;
			}
		}
	}
	printf("%lld",y);
}


Measured memory_bytes: 1152
#include <cstdio>
typedef long long ll;
const int Mod=998244353;
const int Maxn=1000000;
int w[Maxn+5];
int cnt[Maxn+5];
int n,m;
int main(){
	int x,ans=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		if(x>m){
			m=x;
		}
		cnt[x]++;
	}
	w[1]=1;
	for(int i=2;i<=m;i++){
		w[i]=1ll*(Mod-Mod/i)*w[Mod%i]%Mod;
	}
	for(int i=1;i<=(m>>1);i++){
		for(int j=(i<<1);j<=m;j+=i){
			w[j]=(w[j]-w[i]+Mod)%Mod;
		}
	}
	for(int i=1;i<=m;i++){
		for(int j=i,sum=0;j<=m;j+=i){
			ans=(ans+(1ll*sum*j%Mod*cnt[j]+(1ll*cnt[j]*(cnt[j]-1)>>1)%Mod*j%Mod*j)%Mod*w[i])%Mod;
			sum=(sum+1ll*j*cnt[j])%Mod;
		}
	}
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  string s;
  cin >> N >> s;

  int cnt_r = 0;
  int cnt_b = 0;
  rep(i, N){
    if(s[i] == 'R'){
      cnt_r++;
    }else{
      cnt_b++;
    }
  }

  if(cnt_r > cnt_b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    if A <= 8 and B <= 8:
        print("Yay!")
    else:
        print(":(")
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
n, m = map(int, input().split())
mod = 1000000007
ans = 1
if(abs(n-m) >= 2):
    print(0)
elif(n == m):
    for i in range(1, n+1):
        ans *= i
        ans %= mod
    for i in range(1, n+1):
        ans *= i
        ans %= mod
    ans *= 2
    ans %= mod
    print(ans)
else:
    for i in range(1, n+1):
        ans *= i
        ans %= mod
    for i in range(1, m+1):
        ans *= i
        ans %= mod
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  int N; cin >> N;
  long long ans = 0;
  for(int i = 1; i <= N; i++){
    if (!(i % 3 == 0) && !(i % 5 == 0)){
      ans += i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

s = ns()
t = ns()
lenS = len(s)
lenT = len(t)

dp = [[0] * (lenT + 1) for _ in range(lenS + 1)]
for i in range(lenS):
    for j in range(lenT):
        if s[i] == t[j]:
            dp[i + 1][j + 1] = dp[i][j] + 1
        else:
            dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])

rest = []
m = 0
i, j = lenS, lenT
while i > 0 and j > 0:
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j - 1]:
        j -= 1
    else:
        rest.append(s[i - 1])
        i -= 1
        j -= 1

print(*rest[::-1], sep="")

Measured memory_bytes: 114012
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func scanInt() int {
	scanner.Scan()
	a, err := strconv.Atoi(scanner.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func main() {
	scanner.Split(bufio.ScanWords)

	a := scanInt()
	b := scanInt()

	for x := 0; x < 1015; x++ {
		t1 := int(math.Floor(float64(x) * 0.08))
		t2 := int(math.Floor(float64(x) * 0.1))
		if t1 == a && t2 == b {
			fmt.Println(x)
			return
		}
	}
	fmt.Println(-1)
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(n);
// string p=s.substr(0,len);
// string q=s.insert(0,str);
// sort(arr, arr+n, greater<int>());
// cout<<fixed<<setprecision(9)<<pi<<endl
// const  double pi = acos(-1.0);
// sort(v.rbegin(),v.rend());
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	int n;
	cin>>n;
	int a[n];

	set<int> s;
	
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		s.insert(a[i]);
	}	

	if(s.size==n)
	{
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
}

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

int main(){
	int a, b;
	cin >> a >> b;

	int sum = 0;
	rep(i, 2){
		if(a < b){
			sum += b;
			b--;
		}else{
			sum += a;
			a--;
		}
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
//Reference https://qiita.com/hatoo@github/items/fa14ad36a1b568d14f3e
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main(){
    let (A, B) = get!(usize, usize);
    let mut ans;
    if A <= 5{
        ans = 0;
    }else if A <= 12{
        ans = B/2;
    }else{
        ans = B ;
    }
    println!("{}", ans );
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
struct Edge {ll s,t,d;};
struct vector<vector<Edge>> Graph;
 
int main(){
  string s; cin>>s;
  if(s.length()>=4&&s.substr(0,4)=="YAKI") cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
n,d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n-1):
  for j in range(i+1, n):
    t = 0
    for k in range(d):
      t += (x[i][k]-x[j][k])**2
    t = t**0.5
    if t.is_integer():
      ans += 1
print(ans)

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

// Shortcut

#define int long long
#define endl '\n'
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) for (int iiii = 0; iiii < a.size(); iiii++) cout << a[iiii] << ' ';
#define PrintVl(a) for (int iiii = 0; iiii < a.size(); iiii++) cout << a[iiii] << endl;
#define PrintA(a, n) for (int iiii = 0; iiii < n; iiii++) cout << a[iiii] << ' ';
#define PrintAl(a, n) for (int iiii = 0; iiii < n; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a));
#define mmset(a) memset(a, 0x3f, sizeof(a));
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 1e5 + 5, mod = 1e9 + 7, inf = 1e9 + 7;

int n, m;
int b[N];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> m;
    ForE(i, 1, m){
        int x, y;
        cin >> x >> y;
        b[x]++;
        b[y + 1]--;
    }
    ForE(i, 1, n){
        b[i] += b[i - 1];
    }
    int ans = 0;
    ForE(i, 1, n){
        if (b[i] == m){
            ans++;
        }
    }
    cout << ans;
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 1024
# N = int(input())
N, M = [int(i) for i in input().split()]
key = []
for i in range(M):
    a, b = [int(_) for _ in input().split()]
    cs = [int(_) for _ in input().split()]
    s = 0
    for c in cs:
        c -= 1
        s |= 1 << c
    key.append([s, a])

INF = 10**9
dp = [INF for i in range(2**N)]
dp[0] = 0
for i in range(2**N):
    for j in range(M):
        t = i | key[j][0]
        cost = key[j][1]
        dp[t] = min(dp[t], dp[i] + cost)
ans = dp[-1]
if ans == INF:
    print(-1)
else:
    print(ans)



Measured memory_bytes: 46040
import java.util.Scanner;

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

			for(;;) {

				int H = sc.nextInt();
				int W = sc.nextInt();

				if(H == 0 && W == 0) {
					break;
				}

				for(int j = 0; j < H; j++) {

					if(j % 2 == 0) {

						for(int k = 0; k < W; k++) {
							if(k % 2 == 0) {
								System.out.print("#");
							} else {
								System.out.print(".");
							}

						}

					} else {

						for(int k = 0; k < W; k++) {
							if(k % 2 == 0) {
								System.out.print(".");
							} else {
								System.out.print("#");
							}

						}
					}
					System.out.print('\n');
				}
				System.out.println();
			}
	}
}

Measured memory_bytes: 35088
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    int N;
    double a, ans = 0;
    cin >> N;
    rep(i,N){
        cin >> a;
        ans += 1/a;
    }
    pr(1/ans);
}

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

l=[0 for i in range(9)]
for i in a:
  if i>=3200:
    l[-1]+=1
  else:
    l[i//400]+=1

cnt=0
for i in l[:-1]:
  if i!=0:
    cnt+=1

if cnt==0:
  print(1,l[-1])
else:
  print(cnt,cnt+l[-1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, x, y;
  cin >> a >> b >> c >> d;
  x = a * b, y = c * d;
  if(x >= y){
    cout << x << endl;
  }
  else if(x < y){
    cout << y << endl;
  }
}
  

Measured memory_bytes: 3620
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; i ++) {
    cin >> a.at(i) >> b.at(i);
  }

  LL count = 0;
  for (int i = n - 1; i >= 0; i --) {
    LL tmp = (b.at(i) - (count + a.at(i)) % b.at(i)) % b.at(i);
    count += tmp;
  }

  cout << count << endl;
}


Measured memory_bytes: 1024
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.stream.IntStream;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int[] a = new int[N];
        for(int i=0;i<N;++i){
            a[i] = scan.nextInt();
        }
        int[] leftl = new int[N];
        int[] rightl = new int[N];

        ArrayDeque<Integer> que = new ArrayDeque<>();
        int index = 0;
        while(index<N){
            while(!que.isEmpty() && a[que.peek()] > a[index]){
                int ind = que.poll();
                rightl[ind] = index-ind -1;
            }
            que.push(index++);
        }
        while(!que.isEmpty()){
            int ind = que.poll();
            rightl[ind] = N - ind -1;
        }

        index = N-1;
        while(index>=0){
            while(!que.isEmpty() && a[que.peek()] > a[index]){
                int ind = que.poll();
                leftl[ind] = ind - index -1;
            }
            que.push(index--);
        }
        while(!que.isEmpty()){
            int ind = que.poll();
            leftl[ind] = ind - index -1;
        }

        long ans = 0;
        for(int i=0;i<N;++i){
            ans += (long)a[i]*(leftl[i]+1)*(rightl[i]+1);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 86704
import java.util.Scanner;

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

		long n = sc.nextLong();

		if (n % 2 == 0) {
			System.out.println(n / 2 - 1);
		} else {
			System.out.println(n / 2);
		}

	}
}


Measured memory_bytes: 23252
#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 <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h> // sqrt
using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    int num;
    if (b < 10){
        num = a * 10 + b;
    }
    else if (b < 100){
        num = a * 100 + b;
    }
    else {
        num = a * 1000 + b;
    }
    int i = 1;
    bool check = false;
    while (true) {
        if (num == i * i) {
            check = true;
            break;
        }
        if (num < i * i) {
            break;
        }
        i++;
    }
    if (check) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split("");
			int ans =700;
			for(String t:chr) {
				if(t.equals("o")) {
					ans+=100;
				}
			}
			System.out.println(ans);

		}
	}
}

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

int main() {
    int N;
    string S;
    cin >> N >> S;
    ll 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 << "\n";
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	x := scanRunes()
	if x[0] >= 'a' && x[0] <= 'z' {
		fmt.Fprintln(wr, "a")
	} else {
		fmt.Fprintln(wr, "A")
	}
}


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

public class Prog
{
    public void run()
    {
        int N = int.Parse(Console.ReadLine());
        string S = Console.ReadLine();
        List<char> bef = new List<char>();
        List<char> aft = new List<char>();
        int count = 0;
        int ans = 0;
        for(int i = 1; i < S.Length - 1; i++)
        {
            for(int j=0;j<i;j++)
            {
                if( !bef.Contains(S[j]))
                {
                    bef.Add(S[j]);
                }
            }
            for(int j=i;j<S.Length;j++)
            {
                if( !aft.Contains(S[j]))
                {
                    aft.Add(S[j]);
                }
            }
            for(int j=0;j<bef.Count;j++)
            {
                if(aft.Contains(bef[j]))
                {
                    count++;
                }
            }
            ans = Math.Max(ans, count);
            bef.Clear();
            aft.Clear();
            count = 0;
        }
        Console.WriteLine(ans);
    }
    public static void Main()
    {
        var prog = new Prog();
        prog.run();
    }

    /*
    最小公倍数
    public static long Lcm(long a, long b)
    {
        return a * b / Gcd(a, b);
    }

    // ユークリッドの互除法 
    public static long Gcd(long a, long b)
    {
        if (a < b)
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }
    */
    //a<=c, b<=d;
}

//Split().Select(int.Parse).ToArray()
//Array.ConvertAll(int.Parse)
//str.IndexOf("Stage",System.StringComparison.CurrentCulture)


Measured memory_bytes: 13152
/* 

A[0]  A[1]  A[2]   .... A[N-3]  A[N-2]  A[N-1]
<--------->             <-------------------->
    left(2)                  right(N-3)

left has index  0 .. N  (0 .. empty,  N .. full)
right has index 0 .. N  (0 .. full,   N .. empty)

*/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cout << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)            \
    cerr << #v << ": ";         \
    REP(__i, (v).size())        \
    cerr << ((v)[__i]) << ", "; \
    cerr << endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

ll gcd(ll x, ll y)
{
    if (x < y)
        std::swap(x, y);

    if (y == 0)
        return x;

    return gcd(y, x % y);
}


int main()
{
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vi A(N); REP(i, N) cin >> A[i];

    vl lhs(N + 1);
    vl rhs(N + 1);

    lhs[1] = A[0];
    for (int i = 1; i < N; ++i) {
        lhs[i + 1] = gcd(lhs[i], A[i]);
    }

    rhs[N - 1] = A[N - 1];
    for (int i = N - 2; i >= 0; --i) {
        rhs[i] = gcd(rhs[i+1], A[i]);
    }

    ll res = 0LL;
    for (int i = 0; i < N; ++i) {
        res = max(res, gcd(lhs[i], rhs[i+1]));
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//for(int i = ; i < ; i++){}

int main(){
  int n;
  cin>>n;
  int a[2][n];
  ll sum1[n];
  ll sum2[n];
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < n; j++){
    cin>>a[i][j];
    if(i == 0){
      if(j !=0) sum1[j]=sum1[j-1]+a[i][j];
      else sum1[j]=a[i][j];
    }
    else {
      if(j!=0) sum2[j]=sum2[j-1]+a[i][j];
      else sum2[j]=a[i][j];
    }
  }
  }
  ll ans = 0;
  for(int i = 0; i < n; i++){
    if(i!=0) ans = max(sum1[i]+sum2[n-1]-sum2[i-1],ans);
    else ans = max(sum1[0]+sum2[n-1],ans);
  }
  /*for(int i = 0; i < n; i++){
    cout<<sum1[i]<<endl;
  }
  for(int i = 0; i < n; i++){
    cout<<sum2[i]<<endl;
  }*/
  cout<<ans<<endl;
  return 0;
}




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

using namespace std;

int main()
{
	int A, B;
	string S;
	cin >> A >> B;
	cin >> S;


	// 文字列の長さがA+B+1か判定
	if (S.size() != A + B + 1) {
		// cout << "文字列の長さが" << S.size() << "です。\n";
		cout << "No\n";
		return 0;
	}

	// -がA番目にあるか判定(文字列は0からスタート)
	if (S.find('-') != A) {
		// cout << "-(ハイフン)は" << S.find('-') << "番目にあります。\n";
		cout << "No\n";
		return 0;
	}

	// A+1番目の文字以外が0から9であるか判定
	for (int i = 0; i < S.size(); i++) {
		// cout << "S[" << i << "]は" << S[i] << "です。\n";
		if (i == A) {
			continue;
		}
		if (S[i] > '9' || S[i] < '0') {
			// cout << "0-9以外の文字が含まれています。\n";
			cout << "No\n";
			return 0;
		} 
	}

	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 3600
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back


main(){
  rep(i,9)rep(j,9){
    cout<<i+1<<"x"<<j+1<<"="<<(i+1)*(j+1)<<endl;
  }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>

int max(int a, int b){
	return a >= b ? a : b;
}

int main(){
	int N, a, b, i, now = 0;
	int M = 86400, K = 10800;
	scanf("%d", &N);
	int *D = (int *)malloc(sizeof(int) * 2 * M);
	for(i = 0; i < 2 * M; i++){
		D[i] = 0;
	}
	for(i = 0; i < N; i++){
		scanf("%d%d", &a, &b);
		D[(now + a) % M]++;
		D[(now + a) % M + M]++;
		now = (now + a + b) % M;
	}
	for(i = 0, now = 0; i <= K; i++){
		now += D[i];
	}
	int ans = now;
	for(i = 0; i < M; i++){
		now -= D[i];
		now += D[i + K + 1];
		ans = max(ans, now);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	const llong inf=1e18;
	
	int n;
	cin>>n;
	
	vector<llong> aa(n);
	REP(i,n) cin>>aa[i];
	sort(ALL(aa));
	
	llong ans=1;
	REP(i,n){
		llong a=aa[i];
		debug(a);
		
		double tmp=log10(ans)+log10(a);
		debug(tmp);
		if(tmp>18){
			cout<<-1<<endl;
			return 0;
		}
		
		ans*=a;
		debug(ans);
		if(ans>inf){
			cout<<-1<<endl;
			return 0;
		}
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 4944
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U>
inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U>
inline void cmin(T& a, U b) { if (a > b) a = b; }

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cerr << fixed << setprecision(15);
  }
} io_setup;

constexpr char el = '\n';
#line 2 "f2.cpp"

constexpr ll mod = 998244353;

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

  ll ans = 0;
  vl dp(s+1);
  vl next(s+1);

  rep(i, n) {
    dp[0]++;
    dp[0] %= mod;
    next.assign(s+1, 0);

    rep(j, s+1) {
      next[j] += dp[j];
      next[j] %= mod;
      if (j+a[i] <= s) {
        next[j+a[i]] += dp[j];
        next[j+a[i]] %= mod;
      }
    }

    copy(all(next), dp.begin());
    ans += dp[s];
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int mp[1000200];
int s[1000200];
int main()
{
    int a,i;
    cin>>a;
    for(i=2; i<=a; i++)
    {
        cin>>s[i];
        mp[s[i]]++;
    }
    for(i=1; i<=a; i++)
    {
        cout<<mp[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 5200