akhauriyash/Code-Regression huggingface dataset:
use std::io::stdin;
use std::cmp::max;

fn main(){
    let (n, W) = getpair();
    let mut vss:Vec<Vec<usize>> = Vec::new();
    for _ in 0..4 { vss.push(Vec::new()) }
    let (w1, v1) = getpair();
    vss[0].push(v1);
    for _ in 1..n {
        let (w, v) = getpair();
        vss[(w as i64 - w1 as i64) as usize].push(v)
    }
    for i in 0..4 { vss[i].sort(); vss[i].reverse() }
    println!("{}", solve(&vss, w1, W));
}

fn solve(vss: &Vec<Vec<usize>>, w: usize, W: usize) -> usize{
    if vss.len()==0 {
        0
    } else {
        let mut sum_w = 0;
        let mut sum_v = 0;
        let mut ans = solve(&vss[1..].to_vec(), w+1, (W as i64 - sum_w as i64) as usize);
        for v in &vss[0]{
            sum_w += w;
            if sum_w > W {
                break;
            } else {
                sum_v += *v;
                ans = max(ans, sum_v + solve(&vss[1..].to_vec(), w+1, (W as i64 - sum_w as i64) as usize));
            }
        }
        ans
    }
}

#[allow(dead_code)]
fn getline() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn getvec() -> Vec<usize>{
    let line = getline();
    line.split_whitespace().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn geti64s() -> Vec<i64>{
    let line = getline();
    line.split_whitespace().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn getpair() -> (usize, usize){
    let nm = getvec();
    (nm[0], nm[1])
}

Measured memory_bytes: 4352
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int a,b,d,r;
        double f;
        String ans;
        a=scan.nextInt();
        b=scan.nextInt();

        d=a/b;
        r=a%b;
        f=(double)a/b;
        BigDecimal answer=java.math.BigDecimal.valueOf(f);
        ans=answer.toPlainString();
        System.out.println(d +" "+ r +" "+ ans);
    }
}


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

int main() {
  int N, Q;
  cin >> N >> Q;
  dsu uf(N);
  rep(query, Q) {
    int t, u, v;
    cin >> t >> u >> v;
    if (t == 0) uf.merge(u, v);
    else {
      if (uf.same(u, v)) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }
}

Measured memory_bytes: 3848
#include <stdio.h>
#include <math.h>

static int true = 1;
static int false = 0;

int isprime(int x);

int
main(void)
{
        int n;
        int num;
        int prime = 0;
        int i;

        scanf("%d", &n);

        for (i = 0; i < n; i++) {
                scanf("%d", &num);
                if (isprime(num) == true)
                        prime++;
        }

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

        return 0;
}

int
isprime(int x)
{
        int i =3;

        if (x == 2)
                return true;

        if (x < 2 || x % 2 == 0)
                return false;

        while (i <= sqrt(x)) {
                if (x % i == 0)
                        return false;
                i = i + 2;
        }

        return true;
}



Measured memory_bytes: 2040
using System;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int a = sc.NextInt();
        int b = sc.NextInt();
        int c = sc.NextInt();
        int d = sc.NextInt();

        int s = Math.Max(a, c);
        int e = Math.Min(b, d);

        Console.WriteLine(Math.Max(0, e - s));
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

vector<int> divisor(int n){
  vector<int> ret;
  for(int i = 1 ; i*i <= n ; i++){
    if(n % i == 0){
      ret.push_back(i);
      if(i != n/i) ret.push_back(n/i);
    }
  }
  return ret;
}

int main(){
  int n;
  int a, b, c;
  vector<int> A, B, C;
  
  cin >> n;
  if(n == 2){
    cin >> a >> b;
    A = divisor(a), B = divisor(b);
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    for(int i = 0 ; i < A.size() ; i++){
      if(binary_search(B.begin(), B.end(), A[i])) cout << A[i] << endl;
    }
  }
  if(n == 3){
    cin >> a >> b >> c;
    A = divisor(a), B = divisor(b), C = divisor(c);
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    for(int i = 0 ; i < A.size() ; i++){
      if(binary_search(B.begin(), B.end(), A[i]) &&
	 binary_search(C.begin(), C.end(), A[i])) cout << A[i] << endl;
    }
  }
  return 0;
} 

Measured memory_bytes: 1220
#include <iostream>
#include <string>

using namespace std;

int N;
int length[44];

int len[]={5,7,5,7,7};

int search_len(int s,int l){
    int total=0;
    while(s<=N&&total<l) {
        total+=length[s];
        s++;
    }

    if (total==l) return s;
    else return -1;
}

bool judge(int s){
    int next=s;
    for(int i=0;i<5;i++){
        auto temp=search_len(next,len[i]);
        if (temp==-1) return false;
        next=temp;
    }
    return true;
}

int main(){
    string buf;

    while(true){
        cin>>N;
        if (N==0) break;
        for(int i=1;i<=N;i++){
            cin>>buf;
            length[i]=buf.size();
        }

        int i=1;
        while(i<=N){
            if (judge(i)) {
                printf("%d\n",i);
                break;
            }
            i++;
        }
    }

    return 0;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)

int main() {
  int n;cin >> n;
  int cnt = 0;
  int target = 1;
  for(int i=0;i<n;++i){
    int t;cin>>t;
    if(t==target){
      ++cnt;
      ++target;
    }
  }
  if(cnt>0){
    cout << n-cnt << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

  //reading in data
  //FILE* fp = fopen("input.txt","r");
  int c;

  //fscanf(fp,"%i",&c);
  scanf(" %i",&c);
  //printf("\n%i\n\n",c);

  int nums[c];
  for(int i=0; i<c; i++){
    //fscanf(fp,"%i",&nums[i]);
    scanf(" %i",&nums[i]);
    if(i>c-2){
      printf("%i\n",nums[i]);
    }else{
      printf("%i ",nums[i]);
    }
  }


  //insertion sort algorithm
  for(int i=1; i<c; i++){
    int key = nums[i];

    //sorting
    int j = i-1;
    while(j>=0 && nums[j]>key){
      nums[j+1] = nums[j];
      j--;
    }
    nums[j+1] = key;

    for(int k=0; k<c; k++){
      if(k>c-2){
	printf("%i\n",nums[k]);
      }else{
	printf("%i ",nums[k]);
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    ll x, k, d; cin >> x >> k >> d;
    x = abs(x);
    ll dr = x % d;
    ll cr = x / d;
    ll dl = dr - d;
    ll cl = cr + 1;
    if (dr == -dl) {
        if (cr <= k) cout << dr << endl;
        else cout << x - k * d << endl;
    }
    else if (dr < -dl){
        if (cr > k) cout << x - k * d << endl;
        else if ((k - cr) % 2 == 0) cout << dr << endl;
        else cout << -dl << endl;
    }
    else if (dr > -dl){
        if (cl > k) cout << x - k * d << endl;
        else if ((k - cl) % 2 == 0) cout << -dl << endl;
        else cout << dr << endl;
    }
}

Measured memory_bytes: 3644
#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() {
  double l;
  cin >> l;
  double a,b;
  a=l/3.0;
  b=l/3.0+(l-a*3);
  double ans=a*a*a;
  cout << fixed << setprecision(12) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define LL long long
#define NUM 1000000007

using namespace std;

int main()
{
    int x, t;
    cin >> x >> t;

    if (x-t>0)
    {
        cout << x - t << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define ld long double
#define ub upper_bound
#define lb lower_bound
#define pii pair<int,int>
using namespace std;
signed main(){
    fast;
    int a[3][3];
    for(int i=0;i<3;i++){
        for(int j = 0;j<3;j++)
            cin>>a[i][j];
    }
    int n;
    cin>>n;
    for(int k=1;k<=n;k++){
        int x;
        cin>>x;
        for(int i = 0;i<3;i++){
            int flag = 0;
            for(int j = 0;j<3;j++){
                if(a[i][j] == x){
                    a[i][j] = -1;
                    flag = 1;
                    break;
                }
            }
            if(flag)break;
        }
    }
    for(int i=0;i<3;i++){
        int flag = 1;
        for(int j = 0;j<3;j++){
            if(a[i][j]!=-1){
                flag = 0;
                break;
            }
        }
        if(flag){
            cout<<"Yes";
            return 0;
        }
    }
    for(int j=0;j<3;j++){
        int flag = 1;
        for(int i = 0;i<3;i++){
            if(a[i][j]!=-1){
                flag = 0;
                break;
            }
        }
        if(flag){
            cout<<"Yes";
            return 0;
        }
    }
    if(a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1)
        cout<<"Yes";
    else if(a[2][0] == -1 && a[1][1] == -1 && a[0][2] == -1)
        cout<<"Yes";
    else cout<<"No";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int n,m;
char array1[55][55],array2[55][55];
bool solve(int i,int j){
    for(int k=0;k<m;++k){
        for(int l=0;l<m;++l){
            if(i+k<n&&j+l<n){
                if(array1[i+k][j+l]!=array2[k][l]){
                    return 0;
                }
            }
            else{
                return 0;
            }
        }
    }
    return 1;
}
int main()
{
int i,j,flag=0;
scanf("%d %d",&n,&m);
for(i=0;i<n;++i){
    for(j=0;j<n;++j){
        scanf(" %c",&array1[i][j]);
    }
}
for(i=0;i<m;++i){
    for(j=0;j<m;++j){
        scanf(" %c",&array2[i][j]);
    }
}
for(i=0;i<n;++i){
    for(j=0;j<n;++j){
       if(solve(i,j)){
         flag=1;
         break;
       }
    }
}
(flag)?printf("Yes"):printf("No");



    return 0;
}


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

//関数
long ab(long x){
    return max(x,0-x);
}
//main関数
int main() {
    
    
    //入力
    long N;
    cin>>N;
    vector<long> h(N);
    for(int i=0;i<N;i++){
        cin>>h.at(i);
    }
    
    //計算
    vector<long> dp(N,0);
    dp.at(1)=ab(h.at(1)-h.at(0));
    for(int i=2;i<N;i++){
        dp.at(i)=min(dp.at(i-2)+ab(h.at(i-2)-h.at(i)),dp.at(i-1)+ab(h.at(i-1)-h.at(i)));
    }
    for(int i=0;i<N;i++){
     //   cout<<dp.at(i)<<" ";
    }
   // cout<<endl;
    
    //出力
    cout<<dp.at(N-1)<<endl;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k,ans=0;
    cin>>a>>b>>c>>k;
    if(a<=k)
    {
        ans=a;
        k-=a;
    }
    else
    {
        ans=k;
        k=0;
    }
    if(b<=k)
        k-=b;
    else
        k=0;
    cout<<ans-k<<endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    rep(i, 0, x) cin >> a[i];
    rep(i, 0, y) cin >> b[i];
    rep(i, 0, z) cin >> c[i];

    sort(all(a), greater<ll>());
    sort(all(b), greater<ll>());
    sort(all(c), greater<ll>());

    priority_queue<tuple<ll, int, int, int>> pq;
    set<tuple<int, int, int>> used;
    pq.push(make_tuple(a[0] + b[0] + c[0], 0, 0, 0));
    used.insert(make_tuple(0, 0, 0));
    int cnt = 0;
    while (cnt < k) {
        cout << get<0>(pq.top()) << endl;
        cnt++;
        int i = get<1>(pq.top());
        int j = get<2>(pq.top());
        int k = get<3>(pq.top());
        pq.pop();

        if (i < x - 1) {
            if (!used.count(make_tuple(i + 1, j, k))) {
                pq.push(make_tuple(a[i + 1] + b[j] + c[k], i + 1, j, k));
                used.insert(make_tuple(i + 1, j, k));
            }
        }

        if (j < y - 1) {
            if (!used.count(make_tuple(i, j + 1, k))) {
                pq.push(make_tuple(a[i] + b[j + 1] + c[k], i, j + 1, k));
                used.insert(make_tuple(i, j + 1, k));
            }
        }

        if (k < z - 1) {
            if (!used.count(make_tuple(i, j, k + 1))) {
                pq.push(make_tuple(a[i] + b[j] + c[k + 1], i, j, k + 1));
                used.insert(make_tuple(i, j, k + 1));
            }
        }
    }

    return 0;
}


Measured memory_bytes: 896
while True:
    a,op,b = raw_input().split()
    aa = int(a)
    bb = int(b)
    if op == '?':
        break
    elif op == '+':
        print aa + bb
    elif op == '-':
        print aa - bb
    elif op == '*':
        print aa * bb
    elif op == '/':
        print aa / bb

Measured memory_bytes: 4200
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define ll long long
#define mod 1000000007LL
#define INF 123456789012345
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =2e5 + 10;
int p[maxn];
int check[maxn];

int main() {
	int n;cin >> n;
	rep(i,n)
	{
		cin >> p[i];
		p[i]--;
		check[i] = -1;
	}

	rep(i,n)
	{
		if(p[i] == 0)
		{
			check[0] = 0;
			continue;
		}

		if(check[p[i]-1] == -1) check[p[i]] = 0;
		else check[p[i]] = 1;
	}

	int ans = 0;
	int sum = 0;
	rep(i,n)
	{
		if(check[i] == 1) sum++;
		else sum = 0;
		ans = max(ans,sum);
	}
	cout << n-ans-1<<endl;
	
	return 0;
}

Measured memory_bytes: 1792
N = int(input())
h = list(map(int,input().split()))
dp = [0 for i in range(N+1)]
dp[2] = abs(h[1]-h[0])
for i in range(3,N+1):
    dp[i] = min(dp[i-1]+abs(h[i-1]-h[i-2]),dp[i-2]+abs(h[i-1]-h[i-3]))
print(dp[N])

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

int main() {
	vector<vector<char>>c(2, vector<char>(3));
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 3; j++)cin >> c.at(i).at(j);
	}
	if (c.at(0).at(0) == c.at(1).at(2) && c.at(0).at(1) == c.at(1).at(1) && c.at(0).at(2) == c.at(1).at(0))cout << "YES" << endl;
	else cout << "NO" << endl;


}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int S, h, m, s;
	scanf("%d", &S);

	h = S / 3600;
	m = (S - 3600*h) / 60;
	s = (S - 3600 * h) - 60 * m;
	printf("%d:%d:%d\n", h, m, s);

	return 0;

}

Measured memory_bytes: 592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var HW = ReadInts();
            var loadlist = new List<List<int>>();
            for (int i = 0; i < HW[0]; i++)
            {
                var a = ReadInts();
                loadlist.Add(a.ToList());
            }

            var list = new List<int>();
            for (int i = 0; i < HW[0]; i++)
            {
                for (int j = 0; j < HW[1]; j++)
                {
                    var ans = 0;

                    for (int l = 0; l < HW[0]; l++)
                    {
                        for (int k = 0; k < HW[1]; k++)
                        {
                            var t = loadlist[l][k];
                            var kyori = Min(Abs(i - l), Abs(j - k));
                            ans += t * kyori;
                        }
                    }
                    list.Add(ans);
                }
            }
            WriteLine(list.Min());
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



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

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

  int count = 0;
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) == 'x') {
      count++;
    }
  }
if(count > 7)
  cout<<"NO"<<endl;
  else
    cout<<"YES"<<endl;
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int main(){

    int N,A[2][100]={},max;

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

    for(int i=0;i<N;i++){
        int  tmp=0;
        for(int j=0;j<=i;j++){
            tmp += A[0][j] ;
        }
        for(int j=i;j<N;j++){
            tmp += A[1][j] ;
        }

        if(tmp>max)max = tmp;
    }
    
    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())

a = list(map(int,input().split()))

if N == 1:
    print(0)
    sys.exit()

a.sort()

line = []

for i in range(a[0],a[N-1]+1):
    line.append(i)

def calculation(hairetu,P): #Pにはline，すなわち数直線の値を入れる
    len_hairetu = len(hairetu)
    cal_result = 0
    for i in range(0,len_hairetu):
        cal_result += (hairetu[i] - P)**2
    return cal_result


def search_area(hairetu,line):
    length = len(line)
    if length < 5:
        return line
    
    half = length//2
    f_N = half//2

    f1 = half-f_N
    f3 = half+f_N
    if calculation(hairetu,f1) < calculation(hairetu,f3):
        line = line[0:half]
        search_area(hairetu,line)
    elif calculation(hairetu,f1) > calculation(hairetu,f3):
        line = line[half:length]
        search_area(hairetu,line)
    
search_area(a,line)

min = 1000000
for i in range(0,len(line)):
    if calculation(a, line[i]) < min:
        min = calculation(a,line[i])

print(min)

Measured memory_bytes: 3064
package main

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

func main() {
	n := getInt()
	ps := getIntSlice(n)

	cnt := 0
	for i, p := range ps {
		if p != i+1 {
			cnt++
		}
	}

	ans := "YES"
	if cnt > 2 {
		ans = "NO"
	}
	fmt.Println(ans)
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
#include <stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(void) {
	int N, a, b;
	cin >> N >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i % N == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}


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

int main(void){
  int N;
  cin >> N;
  int ss[N] = {};
  vector<int>v,u;
  long int ans = 0;
  int a;
  long int max = 0;
  int x,y;
  for(int i = 0; i < N;++i){
    cin >> a;
    v.push_back(a-1);
    ss[a-1]++;
    if(ss[a-1] == 2){
      u.push_back(a-1);
    }
  }

  for(int i:u){
    max += 0.5*ss[i]*(ss[i]-1);
  }
  for(int i = 0; i < N;i++){
    if(ss[v[i]] <= 1){
      ans = max;
    }
    else{
      ans = max - 0.5*ss[v[i]]*(ss[v[i]]-1) + 0.5*(ss[v[i]]-1)*(ss[v[i]]-2);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4340
using System;
using System.IO;
using System.Linq;

class Solve {
    static void Main(string[] args) {
        var arr = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int N = arr[0], M = arr[1];
        var brk = new int[M];
        for (int i = 0; i < M; i++) {
            brk[i] = int.Parse(Console.ReadLine());
        }
        var dp = new long[N + 1];
        dp[0] = 1;
        dp[1] = 1;
        var index = 0;
        if (brk.Any() && brk[index] == 1) {
            dp[1] = 0;
            index++;
        }
        for (int i = 2; i <= N; i++) {
            if (index < M && i == brk[index]) {
                index++;
                continue;
            }
            dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007;
        }
        var answer = dp[^1];
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}

Measured memory_bytes: 31308
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;

class Main {

	boolean[] isPrime = new boolean[200000];
	{
		Arrays.fill(isPrime, true);
		isPrime[0] = isPrime[1] = false;
		for (int i = 2; i < isPrime.length; ++i) {
			if (!isPrime[i])
				continue;
			for (int j = 2 * i; j < isPrime.length; j += i) {
				isPrime[j] = false;
			}
		}
	}

	boolean[] a = new boolean[200000];

	public void run() {
		Scanner sc = new Scanner(System.in);
		int[] sum = new int[200000];
		for (int i = 2; i < a.length; ++i) {
			if (isPrime[i] && isPrime[(i + 1) / 2]) {
				a[i] = true;
				sum[i]++;
			}
		}
		for (int i = 2; i < sum.length; ++i)
			sum[i] += sum[i - 1];
		int Q = sc.nextInt();
		for (int i = 0; i < Q; ++i) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			System.out.println(sum[r] - sum[l - 1]);
		}

	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}
}


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

const int N=105;
const int M=1e5+10;
const int Inf=1e9;

int last[N<<2],nx[M],to[M],val[M],tot=1;
int n,m,S,T;

void Add(int x,int y,int r)
{
	tot++;
	to[tot]=y;
	nx[tot]=last[x];
	val[tot]=r;
	last[x]=tot;
}

void Ins(int x,int y,int r)
{
	Add(x,y,r);
	Add(y,x,0);
}

char ch[N];
int d[N<<2],q[M];

int bfs()
{
	int l,r;
	for(int i=1;i<=T;i++) d[i]=-1;
	d[S]=0;
	q[l=r=1]=S;
	while(l<=r)
	{
		int x=q[l++];
		for(int j=last[x];j;j=nx[j])
		{
			int v=to[j];
			if(val[j]>0&&d[v]==-1)
			{
				d[v]=d[x]+1;
				q[++r]=v;
			}
		}
	}
	return d[T]==-1?0:1;
}

int find(int x,int low)
{
	int f=0;
	if(x==T) return low;
	for(int j=last[x];j;j=nx[j])
	{
		int v=to[j];
		if(d[v]!=d[x]+1) continue;
		int r=find(v,min(low-f,val[j]));
		val[j]-=r;
		f+=r;
		val[j^1]+=r;
		if(f==low) return f;
	}
	if(!f) d[x]=-1;
	return f;
}
	


int main()
{
	scanf("%d%d",&n,&m);
	S=n+m+1,T=S+1;
	for(int i=1;i<=n;i++)
	{
		scanf("%s",ch+1);
		for(int j=1;j<=m;j++)
		{
			if(ch[j]=='S')
			{
				Ins(S,i,Inf);
				Ins(S,j+n,Inf);
			}
			if(ch[j]=='T')
			{
				Ins(j+n,T,Inf);
				Ins(i,T,Inf);
			}
			if(ch[j]=='o')
				Ins(i,j+n,1),Ins(j+n,i,1);
		}
	}
	int Ans=0;
	while(bfs()) Ans+=find(S,Inf);
	//cout<<Ans<<endl;
	if(Ans>=Inf) puts("-1");
	else cout<<Ans<<endl;
}
	

Measured memory_bytes: 768
//Author:- Yatin Patel
//Mail:- yatinpatel.gt@gmail.com

#include <bits/stdc++.h>
#define FILEIN ifstream fin;fin.open("input.txt");
#define FILEOUT ofstream fout;fout.open("output.txt");

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

#define FAST ios::sync_with_stdio(false);ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second

#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<ll,vector<ll>,greater<ll> >
#define maxQueue priority_queue<ll,vector<ll>,less<ll> > 

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>b;i--)
#define FILL(a,b) memset((a),(b),sizeof((a)))

#define MOD 1000000007
#define INF LONG_MAX
#define MINF LONG_MIN

ll power(ll x, unsigned ll y){
    if (y == 0)
        return 1;
    else if (y%2 == 0)
        return power(x, y/2)*power(x, y/2);
    else
        return x*power(x, y/2)*power(x, y/2);
}

//#define fin cin
//#define fout cout

int main(){

    FAST;
    string str;
    cin>>str;
    if(str=="keyence"){
        cout<<"YES";
        return 0;
    }
    for(ll i=0;i<str.length();i++){
        for(ll j=i;j<str.length();j++){
            string temp = str;
            temp.erase(i,j-i+1);
            //cout<<temp<<endl;
            if(temp=="keyence"){
                cout<<"YES";
                return 0;
            }
        }
    }
    cout<<"NO";
    return 0;
}






Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<utility>
#define mod 998244853
using namespace std;
int in[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
struct b{
  int x, y;
};
struct compare{
  bool operator()(pair<int, int> const& a, pair<int, int> const& b)
  {
      return a.second > b.second;
  }
};
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, k, x, nb=0;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        cin >> x;
        if( x >= k)
            nb++;
    }
    cout << nb << '\n';
}

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

using namespace std;

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

int main(void){
    int K, N;
    
    cin >> K >> N;
    
    vector<int> house;
    
    for (int i = 0; i < N; i++) {
        int in_;
        cin >> in_;
        
        house.push_back(in_);
    }
    
    long long dis = -1;
    
    for (int i = 0; i < N - 1; i++) {
        dis = max(dis, house[i + 1] - house[i] - 1);
    }
    
    dis = max(dis, K - (house[N - 1] - house[0] + 1));
    
    cout << (K - dis - 1) << endl;
    
    return 0;
}

Measured memory_bytes: 1400
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long A, B, C, X, Y;
    scan(A, B, C, X, Y);
    long ans = long.max;
    ans = ans.min(A * X + B * Y);
    ans = ans.min(C * (max(X, Y) * 2));
    ans = ans.min(C * (min(X, Y) * 2) + (X < Y ? B : A) * (max(X, Y) - min(X, Y)));
    writeln(ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<utility>
using namespace std;

long long gcd(long long x, long long y) {
    if (y == 0)
        return x;

    return gcd(y, x%y);
}

vector<pair<long long, int>> primeFactorization(long long n) {
    vector<pair<long long, int>> ret;
    for (long long i = 2; i*i <= n; i++) {
        if (n%i != 0)
            continue;

        int cnt = 0;
        while (n%i == 0) {
            cnt++;
            n /= i;
        }

        ret.push_back(make_pair(i, cnt));
    }

    if (n != 1)
        ret.push_back(make_pair(n, 1));

    return ret;
}

int main(void)
{
    long long A, B;
    cin >> A >> B;

    long long n = gcd(A, B);
    auto prime = primeFactorization(n);

    cout << prime.size() + 1 << endl;

    return 0;
}


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

#ifdef LOCAL
#include "../debug.h"
#else
#define debug(x...) 141
#endif
#define forn(i,x,n) for(int i = x; i < n; ++i)
#define forit(it, m) for(auto it = m.begin(); it!=m.end(); ++it)
typedef long long ll;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x,y;

    {
        cin>>x>>y;
        if(y>=2*x && y%2==0 && x-(y-2*x)/2>=0)
        	cout<<"Yes";
        else cout<<"No";
    }
    return 0;
}

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

using namespace std;

using ll = long long;

template<class T>
struct Graph {
    struct Edge {
        int dst; T w;
        Edge(int _d, T _w) : dst(_d), w(_w) {}
    };

    const T INF, n;
    int src;
    bool is_neg_cycle;
    std::vector<std::vector<Edge>> adj;
    std::vector<T> d;
 
    Graph(int _n, int _s)
        : INF(std::numeric_limits<T>::max()), n(_n), src(_s),
          is_neg_cycle(false), adj(n), d(n, INF) { }
 
    void add_edge(int u, int v, T w) { adj[u].emplace_back(Edge(v, w)); }
    T ShortestDistance(const int t) const { return d[t]; }
    bool IsNegativeCycleFromS() const { return is_neg_cycle; }
 
    bool CheckNegativeCycle() {
        std::fill(d.begin(), d.end(), 0);
        BellmanFord();
        return is_neg_cycle;
    }
 
    void BellmanFord() {
        d[src] = 0;
        for (int i = 0; ; ++i) {
            bool update = false;
            for (int v = 0; v < n; ++v)
                for (const auto &e : adj[v])
                    if (d[v] < INF && d[v] + e.w < d[e.dst]) {
                        d[e.dst] = d[v] + e.w;
                        update = true;
                        if (e.dst == n - 1 && n <= i) is_neg_cycle = true;
                    }
            if (!update) break;
            if (i == 2 * n) { break; }
        }
    }
};

// template<class T>
// struct Graph {
//     const int n, src;
//     const T INF;
//     bool is_neg_cycle;
//     std::vector<std::vector<std::pair<int, T>>> adj;
//     std::vector<T> d;

//     Graph(int _n, int _s)
//         : n(_n), src(_s), INF(std::numeric_limits<T>::max()),
//           is_neg_cycle(false), adj(n), d(n, INF) { }

//     void add_edge(int u, int v, T w) { adj[u].push_back(std::make_pair(v, w)); }
//     T ShortestDistance(const int t) const { return d[t]; }
//     bool IsNegativeCycleFromS() const { return is_neg_cycle; }
//     void ChangeSource(int _s) { src = _s; fill(d.begin(), d.end(), INF); }

//     void BellmanFord() {
//         d[src] = 0;
//         for (int i = 0; ; ++i) {
//             bool update = false;
//             for (int v = 0; v < n; ++v)
//                 for (const auto &e : adj[v])
//                     if (d[v] < INF && d[v] + e.second < d[e.first]) {
//                         d[e.first] = d[v] + e.second;
//                         update = true;
//                     }
//             if (!update) break;
//             if (i == n - 1) { is_neg_cycle = true; break; }
//         }
//     }
// };

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

    int n, m;
    cin >> n >> m;

    Graph<ll> g(n, 0);
    for (int i = 0; i < m; ++i) {
        ll a, b, c;
        cin >> a >> b >> c;
        g.add_edge(a - 1, b - 1, -c);
    }

    g.BellmanFord();
    if (g.is_neg_cycle) cout << "inf\n";
    else cout << -g.ShortestDistance(n - 1) << endl;

    return 0;
}


Measured memory_bytes: 384
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    int N; cin >> N;

    int ans = N / 3;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
S = list(input())
ans = [0] * len(S)
R_cnt = 0
L_cnt = 0
border = 0
before = "R"
for i in range(len(S)):
    if S[i] == before:
        if before == "R":
            R_cnt += 1
        else:
            L_cnt += 1
    else:
        if before == "R":
            border = i - 1
            L_cnt = 1
            before = "L"
        else:
            ans[border] = (R_cnt + 1) // 2 + L_cnt // 2
            ans[border+1] = R_cnt // 2 + (L_cnt + 1) // 2
            R_cnt = 1
            before = "R"
ans[border] = (R_cnt + 1) // 2 + L_cnt // 2
ans[border+1] = R_cnt // 2 + (L_cnt + 1) // 2
print(" ".join(map(str, ans)))


Measured memory_bytes: 11176
n = int(input()) #頂点数

matrix = [[0]*n for i in range(n)]

for i in range(n):
    adj_list = list(map(int,input().split()))
    for j in adj_list[2:]: #3番目からの隣接ノードを取得する
        matrix[i][j-1] = 1 #隣接ノードを成分を1に変更する

for i in range(n):
    for j in range(n):
        if j != n-1: 
            print(matrix[i][j], end = " ")
        else:
            print(matrix[i][j])


Measured memory_bytes: 6384
def resolve():
    K = int(input())
    array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1,
             14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

    print(array[K - 1])

resolve()

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(void){
    double x1,y1,x2,y2;
    cin >> x1;
    cin >> y1;
    cin >> x2;
    cin >> y2;
    double d=pow(x1-x2,2)+pow(y1-y2,2);
    cout << fixed << setprecision(8) << sqrt(d);
    cout << endl;
}


Measured memory_bytes: 3276
#include<stdio.h>
int main(void){
int i,A,B;
char number[A+B+1];
scanf("%d",&A);
scanf("%d",&B);
scanf("%s",number);
for(i=0;i<=A-1;i++){
if(number[i]=='-') {
printf("No");
return 0;
}
}
if(number[A]!='-') {
printf("No");
return 0;
}
for(i=A+1;i<=A+B;i++){
if(number[i]=='-'){
printf("No");
return 0;
}
}
printf("Yes");
return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(){
	char a[8],b[101],c[8];
	scanf("%s %s %s",a,b,c);
	printf("%c%c%c\n",a[0],b[0],c[0]);
	
	return 0;
}

Measured memory_bytes: 128
import javax.print.DocFlavor;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        PrintWriter pw = new PrintWriter(System.out);

        st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int m = Integer.parseInt(st.nextToken());
        if(n==m) {
            pw.println("Yes");
        }
        else {
            pw.println("No");
        }


        pw.flush();
        pw.close();
    }
}


Measured memory_bytes: 22612
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int N, C, K; cin >> N >> C >> K;
    if (C == 1) { cout << N << endl; return 0; }
    int t[N]; for (int i = 0; i < N; i++) cin >> t[i];
    sort(t, t+N);
    int ans = 0, dep_time = -1, cap = C;
    for (int i = 0; i < N; i++) {
        if (dep_time == -1 || dep_time < t[i]) {
            dep_time = t[i] + K; ans++; cap = C-1;
        } else {
            cap--;
            if (cap == 0) { dep_time = -1; cap = C; }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
/* ex9_1
   Graku */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct node {
    struct node *next;
    char binary;
}node;

int get_last(node *l);
node* pop(node *l);
node* push(node *l, char n);

int main() {
    node *list = NULL;
    int count = 0;
    char s[100000];
    scanf("%s", s);

    for (int i = 0; i < strlen(s); i++) {
        if (list == NULL) { //list is empty
            list = push(list, s[i]);
        }
        else if (list->binary != s[i]) { //end of list is "01" or "10"
            list = pop(list);
            count += 2;
        }
        else { //end of list is "00" or "11"
            list = push(list, s[i]);
        }
    }

    printf("%d\n", count);
    return 0;
}

node* pop(node *list) {
    if (list == NULL) { //list is empty
        printf("Error: list is NULL\n");
        exit(1);
    }
    if (list->next == NULL) { //list has one element
        return NULL; //list is empty
    }
    node *head = list->next;
    free(list);
    return head;
}

node* push(node *list, char c) {
    node *new = malloc(sizeof(node)); //new element
    new->next = list; //new is end of list
    new->binary = c;
    return new;
}

Measured memory_bytes: 4948
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353

class BinaryIndexedTree:
    # http://hos.ac/slides/20140319_bit.pdf
    def __init__(self, size):
        """
        :param int size:
        """
        self._bit = [0] * size
        self._size = size

    def add(self, i, w):
        """
        i 番目に w を加える
        :param int i:
        :param int w:
        """
        x = i + 1
        while x <= self._size:
            self._bit[x - 1] += w
            x += x & -x

    def sum(self, i):
        """
        [0, i) の合計
        :param int i:
        """
        ret = 0
        while i > 0:
            ret += self._bit[i - 1]
            i -= i & -i
        return ret

    def __len__(self):
        return self._size


N = int(sys.stdin.buffer.readline())
S = list(sys.stdin.buffer.readline().decode().rstrip())
Q = int(sys.stdin.buffer.readline())
queries = [sys.stdin.buffer.readline().decode().rstrip().split() for _ in range(Q)]

bits = [BinaryIndexedTree(size=N) for _ in range(26)]
for i, c in enumerate(S):
    bits[ord(c) - ord('a')].add(i, 1)

ans = []
for q, a, b in queries:
    if q == '1':
        i = int(a) - 1
        c = str(b)
        bits[ord(S[i]) - ord('a')].add(i, -1)
        S[i] = c
        bits[ord(S[i]) - ord('a')].add(i, 1)
    if q == '2':
        l = int(a) - 1
        r = int(b) - 1
        cnt = 0
        for bit in bits:
            if bit.sum(r + 1) - bit.sum(l) > 0:
                cnt += 1
        ans.append(cnt)

print(*ans, sep='\n')


Measured memory_bytes: 168852
#include<stdio.h>

int main(){
	int i, j, k, l, min, n, p[101], m[100][100];

	scanf("%d", &n);
	for (i = 1; i <= n; i++){
		scanf("%d %d", &p[i - 1], &p[i]);
	}
	
	for(i = 0; i < n; i++){
	    m[i][i] = 0;
	}
	for(i = 1; i < n; i++){
	    for(j = 0; j < n - i; j++){
	        min = 1000000;
	        for(k = j; k < j + i; k++){
	        	m[j][j + i] = m[j][k] + m[k + 1][j + i] + p[j]*p[k + 1]*p[j + i + 1];
	            if(min > m[j][j + i]){
	                min = m[j][j + i];
	            }
	        }
	        m[j][j + i] = min;
	    }
	}

	printf("%d\n", m[0][n - 1]);

	return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long D;
vector<long> c(26);
vector<vector<long>> s(365,vector<long>(26));
vector<long> t(365);
vector<long> kari(365);
long karians = -1e15;
map<long, vector<long>> mp;

void INPUT(){
  cin >> D;
  rep(i,26) cin >> c.at(i);
  rep(i,D){
    rep(j,26) cin >> s.at(i).at(j);
  }
}

long greedy(){
  vector<long> lastday(26,-1);

  long ans = 0;
  rep(i,D){
    vector<long> tmpscore(26,ans);
    rep(j,26){
      tmpscore.at(j) += s.at(i).at(j);
      rep(k,26){
        if(j != k){
          tmpscore.at(j) -= (i - lastday.at(k))*c.at(k);
        }
      }
    }
    long day = 0;
    long maxi = tmpscore.at(0);
    rep(j,26){
      if(tmpscore.at(j) > maxi){
        maxi = tmpscore.at(j);
        day = j;
      }
    }
    ans = maxi;
    //cout << day+1 << endl;
    t.at(i) = day;
    lastday.at(day) = i;
  }
  return ans;
}

long calc(){
  vector<long> lastday(26,-1);
  long ans = 0;
  rep(i,D){
    long tt = t.at(i);
    ans += s.at(i).at(tt);
    lastday.at(tt) = i;
    rep(j,26){
      ans -= (i - lastday.at(j)) * c.at(j);
    }
    //cout << ans << endl;
  }
  return ans;
}

void OUTPUT(){
  rep(i,D){
    cout << kari.at(i)+1 << endl;
  }
}

int main(){
  long start = clock();
  INPUT();
  long now = greedy();
  karians = now;
  kari = t;
  srand(time(NULL));
  long cnt = 0;
  while((clock() - start)/(CLOCKS_PER_SEC/1000) < 1930){
    cnt++;
    long d = rand() % D;
    long q = rand() % 26;
    long prev_q = t.at(d);
    t.at(d) = q;
    long res = calc();
    if(res > now){
      now = res;
    }else if(cnt >= 5000){
      cnt = 0;
      if(now > karians){
        karians = now;
        t.at(d) = prev_q;
        kari = t;
        t.at(d) = q;
      }
      now = res;
    }else{
      t.at(d) = prev_q;
    }
  }
  if(now > karians){
    kari = t;
  }
  OUTPUT();
}

Measured memory_bytes: 3724
def main():
    A, B = map(int, input().split())
    postcode = input()
    answer = False
    if postcode.count("-") == 1:
        if postcode[A] == "-" and postcode[:A].isdecimal() and postcode[A + 1:].isdecimal():
            answer = True
    print("Yes" if answer else "No")


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    set<string> s;
    int n;  cin >> n;

    for (int i = 0; i < n; i++) {
        string t;
        cin >> t;
        s.insert(t);
    }

    cout << s.size() << endl;
    return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    set<string> ans;
    for (int i=0; i<n; i++) {
        string s;
        cin >> s;
        ans.insert(s);
    }
    cout << ans.size() << "\n";

    return 0;
}


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

int main(){
 int c=0;
 string s;
 cin>>s;
 
 for(int i=0;i<s.size();i++)if(s[i]=='A')c++;
 
 if(c>0&&c<s.size())cout<<"Yes";
 
 else cout<<"No";
 
}
    
  
  

Measured memory_bytes: 3612
n, k = map(int, input().split())
l = list(map(int, input().split()))
res = float('inf')
for i in range(n - k + 1):
    a = max(0, - l[i])
    b = max(0, l[i + k - 1])
    res = min(res, a + b + min(a, b))
print(res)

Measured memory_bytes: 14228