akhauriyash/Code-Regression huggingface dataset:
int1 = lambda x: int(x) - 1

N, M = map(int, input().split())
G = [list() for _ in range(N)]
edges = [tuple(map(int1, input().split())) for _ in range(M)]
for u,v in edges:
    G[u].append(v)
    G[v].append(u)

pre = [-1]*N
low = [-1]*N

def detect_bridge(v, p=None, c=0):
    ret = list()
    pre[v] = low[v] = c
    c += 1
    for x in G[v]:
        if x == p: continue
        if pre[x] < 0:
            br, c = detect_bridge(x, v, c)
            ret.extend(br)
             
        if low[v] > low[x]: low[v] = low[x]
    if pre[v] == low[v] > 0:
        ret.append((p, v))
    return ret, c

bridges, _ = detect_bridge(0)
print(len(bridges))

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=e-1; i>=s; i--)

int main(){

    ll n, x; cin >> n >> x;

    ll nlayer[n];
    ll npatty[n];
    nlayer[0] = 1;
    npatty[0] = 1;
    reps(i, 1, n+1){
        nlayer[i] = 3 + 2*nlayer[i-1];
        npatty[i] = 1 + 2*npatty[i-1];
        // cout << nlayer[i] << " " << npatty[i] << endl;
    }

    ll ans = 0;
    repr(i, n+1){
        if(x > nlayer[i]) x = nlayer[i];
        // cout << i << " " << nlayer[i] << " " << x << " " << ans << endl;

        if(i == 1){
            if(x == 2){
                ans += 1;
            }
            else if(x == 3){
                ans += 2;
            }
            else if(x == 4 || x == 5){
                ans += 3;
            }
            break;
        }

        ll center = (nlayer[i] + 1)/2;
        // cout << " " << center << endl;
        if(x == center){
            ans += npatty[i-1] + 1;
            break;
        }
        else if(x > center){
            x -= center;
            ans += npatty[i-1] + 1;
        }
        else if(x < center){
            x -= 1;
        }

        // cout << " " << x << endl;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <vector>

#include <bits/stdc++.h>
using namespace std;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define TRUE (0)
#define FALSE (1)

// This value shold be close to used maximum value.  
#define NUM_MAX 20000000005

// void sort(uint32_t *num, uint32_t size);

int main()
{
    vector<vector<uint64_t>> arr(0);
    vector<uint64_t> temp_vec(2);
    vector<uint64_t> num_vec(0);
    string result;
    // vector<long long> res_vec(0);
    // uint64_t res_arr[NUM_MAX];
    // uint32_t sum = 0;
    uint64_t num1, num2;
    uint64_t num;
    // uint64_t result;
    uint64_t sum;

    // uint32_t res_i = 0;
    // string str_temp, str_temp2;
    uint64_t temp, temp2;
    uint64_t i, j, k, l, count, n, o, size;
    // uint32_t count = 0;
    // string str;
    // uint8_t k_flag;
 
    cin >> result;

    num = result.length();
    num1 = num/2;

    for (i=0; i<num; i++) {
        if (result.at(i) != result.at(num - 1 - i)) {
            cout << "No" << endl;
            return 0;
        }
    }

    for (i=0; i<num1; i++) {
        if (result.at(i) != result.at(num1 - i - 1)) {
            cout << "No" << endl;
            return 0;
        }
    
        if (result.at(num1 + 1 + i) != result.at(num - i - 1)) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    // for (i=0; i<num; i++) {
    //     cin >> temp_vec.at(0) >> temp_vec.at(1);
    //     arr.push_back(temp_vec);
    // }

    // for (i=0; i<num; i++) {
    //     temp = arr.at(i).at(0);
    //     result[temp] = arr.at(i).at(1);
    // }

    return 0;
}

uint64_t silver_fox(vector<vector<int64_t>>& monster_arr, uint64_t range, uint64_t attack, uint64_t count)
{
    int64_t life, pos, num;
    int64_t i, short_i;

    while (monster_arr.size() != 0) {
        pos = monster_arr[0][0];
        life = monster_arr[0][1];
        count++;
        short_i = 0;

        for (i = 0; i < monster_arr.size(); i++) {
            short_i++;
            if (monster_arr[i][0] < pos + range) {
                monster_arr[i][1] -= attack;
            } else {
                break;
            }
        }

        for (i = short_i - 1; i >= 0; i--) {
            if (monster_arr[i][1] <= 0) {
                monster_arr.erase(monster_arr.begin() + i);
            }
        }
    }

    return count;
}

// void sort(uint32_t *num, uint32_t size) {
//     uint32_t i, j, k;
//     uint32_t sorted_num;
//     uint32_t array[NUM_MAX] = {0};

//     for (i = 1; i < size + 1; i++) {
//         array[num[i - 1]]++;
//     }

//     sorted_num = 0;

//     for (i = 0; i < NUM_MAX; i++) {
//         for (j = 0; j < array[i]; j++) {
//             num[j + sorted_num] = i;
//         }
//         sorted_num += j;
//         j = 0;
//     }

//     return;
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  ll T[N];
  REP(i, N) { cin >> T[i]; }
  ll ans = T[0];
  REP(i, N) { ans = ans / __gcd(ans, T[i]) * T[i]; }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
MOD = 1_000_000_007
N, M = gets.split.map(&:to_i)
A = M.times.map{gets.to_i}.group_by(&:itself)
dp = [0,1]
(1 .. N).each do |h|
  a,b = dp
  if A[h]
    dp[0] = b
    dp[1] = 0
  else
    dp[0] = b
    dp[1] = (a + b) % MOD
  end
end
puts dp[1]


Measured memory_bytes: 13236
#include <iostream>

int main(){
    int W, H, x, y, r;

    std::cin>> W >> H >> x >> y >> r;


    if(x+r>W || y+r>H) std::cout << "No\n";
    else if(x-r<0 || y-r<0) std::cout << "No\n";
    else std::cout << "Yes\n";

}

Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <list>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>

using namespace std;


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

	int left = S / 100;
	int right = S % 100;

	int YYMM_f = 1;
	int MMYY_f = 1;

	if ((left > 12 || left==0) && (right < 13 && right >0)) {
		YYMM_f = 1;
		MMYY_f = 0;
		std::cout << "YYMM";
	}
	else if ((left < 13 && left > 0)&& (right > 12 || right ==0)) {
		YYMM_f = 0;
		MMYY_f = 1;
		std::cout << "MMYY";
	}
	else if ((left > 12 || left == 0) && (right > 12 || right == 0)) {
		YYMM_f = 0;
		MMYY_f = 0;
		std::cout << "NA";
	}
	else {
		std::cout << "AMBIGUOUS";
	}
}

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

int N;
double PW;
double vw[100001],pf[100001],vf[100001],th[100001];

const double EPS = 1e-9;

double getcost( double h ){
  double ret = h * PW;
  for(int i=0;i<N;i++){
    double np = h * vw[i];
    if( np-EPS > th[i] ) continue;
    double F = (th[i] - np) / vf[i];
    ret += (F+EPS)*pf[i];
  }
  return ret;
}

int main(){
  while( ~scanf("%d",&N) && N ){
    scanf("%lf",&PW);
    for(int i=0;i<N;i++){
      scanf("%lf%lf%lf%lf",&vw[i],&pf[i],&vf[i],&th[i]);
    }
    double st = 0.0, ed = 10000.0;
    double res = 1e10;
    while( abs( ed - st ) >EPS ){
      double d = (ed-st)/3.0;
      double h1 = st + d;
      double h2 = st + 2.0 * d;
      //cout << "h1: "<< h1 << " = " << getcost(h1) << endl;
      //cout << "h2: "<< h2 << " = " << getcost(h2) << endl;      
      double c1 = getcost(h1), c2 = getcost(h2);
      if( c1 > c2 ){
        st = h1;
        res = min ( res, c2 );
      } else {
        ed = h2;
        res = min ( res, c1 );
      }
    }


    printf("%.10lf\n",res);
  }
}

Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll l, r;
    cin >> l >> r;
    if ((r / 2019) != (l / 2019)) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 2018;
    reps(i, l, r) {
        reps(j, i + 1, r + 1) {
            ans = min(ans, i * j % 2019);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int N,M;
    cin>>N>>M;

    multiset<int> A;
    for(int i = 0;i < N;i++) {
        int a;
        cin>>a;
        A.insert(-a);
    }

    for(int i = 0;i < M;i++) {
        auto it = A.begin();
        int x = *it;
        A.erase(it);
        x = -x;
        x = x/2;
        A.insert(-x);
    }

    Int ans = 0;
    for(auto it = A.begin();it != A.end();it++) {
        ans += -(*it);
    }

    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 4992
// ALDS1_4_B Binary Search

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

namespace alds1_4_b
{
	bool binarySearch(vector<int> &sorted, int x, int begin, int end)
	{
		if (end - begin == 1)
			return x == sorted[begin];

		int n = end - begin;
		int mid = begin + n / 2;

		if (x == sorted[mid])
			return true;
		else if (x < sorted[mid])
			return binarySearch(sorted, x, begin, mid);
		else
			return binarySearch(sorted, x, mid, end);
	}

	bool isMember(vector<int> &sorted, int x)
	{
		return binarySearch(sorted, x, 0, sorted.size());
	}

	int countMembersInSortedCollection(vector<int> &sorted, vector<int> &T)
	{
		size_t n = T.size();
		int C(0);
		for (int i = 0; i < n; ++i)
		{
			if (isMember(sorted, T[i]))
				++C;
		}
		return C;
	}

	int countMembers(vector<int> &S, vector<int> &T)
	{
		sort(S.begin(), S.end());
		return countMembersInSortedCollection(S, T);
	}

	void solve(istream &is, ostream &os)
	{
		int n, q, buf;
		vector<int> S, T;

		is >> n;
		for (int i = 0; i < n; ++i) {
			is >> buf;
			S.push_back(buf);
		}

		is >> q;
		for (int i = 0; i < q; ++i)
		{
			is >> buf;
			T.push_back(buf);
		}

		int C = countMembers(S, T);

		os << C << endl;
	}
}

int main()
{
	alds1_4_b::solve(cin, cout);
	return 0;
}


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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int a, b, c, d; cin >> a >> b >> c >> d;

    int t[110] = {0};

    for (int i = a; i <= b; ++i) {
        t[i]++;
    }

    for (int i = c; i <= d; ++i) {
        t[i]++;
    }

    int ans = 0;

    for (int ti : t) {
        if (ti == 2) {
            ++ans;
        }
    }

    cout << max(ans-1, 0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <stdio.h>
using namespace std;
int n;
struct node {
	int v;
	int id;
} a[100005],b[100005];
int book[100005];
int to[100005];
bool cmp(node x,node y) {
	return x.v<y.v;
}
void solve() {
	sort(a+1,a+n+1,cmp);
	sort(b+1,b+n+1,cmp);
	for(int i=1; i<=n; i++) {
		if(a[i].v>b[i].v) {
			cout<<"No"<<endl;
			return;
		}
	}
	for(int i=1; i<n; i++) {
		if(a[i + 1].v<=b[i].v) {
			cout<<"Yes"<<endl;
			return;
		}
	}
	for(int i = 1; i <= n; i ++) {
		to[a[i].id] = b[i].id;
	}
	int qnum=0;
	int ans = 0;
	for(int i=1; i<=n; i++) {
		int top=i,flag=0;
		while(book[top]==0) {
			flag=1;
			book[top]=1;
			top=to[top];
		}
		if(flag) qnum++;
	}
	if(qnum!=1)
		cout<<"Yes"<<endl;
	else {
		cout<<"No"<<endl;
	}
}
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++) {
		scanf("%d",&a[i].v);
		a[i].id=i;
	}
	for(int i=1; i<=n; i++) {
		scanf("%d",&b[i].v);
		b[i].id=i;
	}
	solve();
	return 0;
}


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

int main()
{
    int x;
    int y = 0;
    cin >> x;
    if (x >= 1800) y = 1;
    else if (x >= 1600) y = 2;
    else if (x >= 1400) y = 3;
    else if (x >= 1200) y = 4;
    else if (x >= 1000) y = 5;
    else if (x >= 800) y = 6;
    else if (x >= 600) y = 7;
    else y = 8;
    cout << y << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;

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

		while(sc.hasNextInt()){
			Date d = new Date(sc.nextInt(),sc.nextInt(),sc.nextInt());

			if(d.contains(new Date(1868,9,8),new Date(1912,7,29)))
				System.out.print("meiji " + (d.y - 1868 + 1));
			else if(d.contains(new Date(1912,7,30),new Date(1926,12,24)))
				System.out.print("taisho " + (d.y - 1912 + 1));
			else if(d.contains(new Date(1926,12,25),new Date(1989,1,7))){
				System.out.print("showa " + (d.y - 1926 + 1));
			}
			else if(d.contains(new Date(1989,1,8),new Date(Integer.MAX_VALUE,Integer.MAX_VALUE,Integer.MAX_VALUE))){
				System.out.print("heisei " + (d.y - 1989 + 1));
			}
			else{
				System.out.println("pre-meiji");
				continue;
			}

			System.out.println(" " + d.m + " " + d.d);
		}
	}
}

class Date{
	int y;
	int m;
	int d;

	Date(int y,int m,int d){
		this.y = y;
		this.m = m;
		this.d = d;
	}

	public int compareTo(Date date){
		if(this.y != date.y) return this.y - date.y;
		if(this.m != date.m) return this.m - date.m;
		if(this.d != date.d) return this.d - date.d;
		return 0;
	}

	public boolean contains(Date d1,Date d2){
		if(this.compareTo(d1) >= 0 && this.compareTo(d2) <= 0)
			return true;
		else
			return false;
	}
}

Measured memory_bytes: 12000
n=gets.to_i

sam1=Array.new(n)
sam2=Array.new(n)
sam1=gets.split.map!(&:to_i)
sam2=gets.split.map!(&:to_i)
#数列をint型に変更

kot1=1#sam1
kot2=1#sam2
wai1=0
wai2=0
kazu1=n
kazu2=n
for i in 0..n-2
  ans1=1
  for j in 1..kazu1
    ans1=ans1*j
  end#ans1=nの階上
  kot1+=ans1/kazu1*(sam1[i]-1)#ans1にnの階上を入力　２の階上で終了にする
  kazu1=kazu1-1
  for k in 0..n-1
    if sam1[k]>sam1[i]
      sam1[k]=sam1[k]-1#大きい数を1小さくする
    end
  end
end
for i in 0..n-2
  ans2=1
  for j in 1..kazu2
    ans2=ans2*j
  end#ans1=nの階上
  kot2+=ans2/kazu2*(sam2[i]-1)#ans1にnの階上を入力　２の階上で終了にする
  kazu2=kazu2-1
  for k in 0..n-1
    if sam2[k]>sam2[i]
      sam2[k]=sam2[k]-1#大きい数を1小さくする
    end
  end
end
puts (kot1-kot2).abs


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

int main() {
	int n,k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];

	for (int i=k;i<=n-1;i++) {
		if (a[i]>a[i-k]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 4776
import math



    
X = int(input())

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


if X == 1 or X == 2:
    print(2)
    exit()


while True:
    if not is_prime(X):
        X += 1
    else:
        print(X)
        exit()
    


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

using namespace std;

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

  char S[101][101];
  for(int i = 0; i < M; i++) {
    for(int j = 0; j < N; j++) cin >> S[i][j];
  }

  int cnt = 0;
  for(int i = 1; i < M; i++) {
    for(int j = 0; j < N; j++) {
      if(S[i][j] == 'o') continue;
      bool flag = true;
      for(int k = -1; k <= 1 && flag; k++) {
	if(j + k < 0 || N <= j + k) continue;
	if(S[i][j+k] == 'o') flag = false;
      }
      for(int k = -1; k <= 1 && flag; k++) {
	for(int l = -1; l <= 1 && flag; l++) {
	  if(i + k < 0 || M <= i + k || j + l < 0 || N <= j + l) continue;
	  if(S[i+k][j+l] == 'x') flag = false;
	}
      }
      if(flag) cnt++;
    }
  }

  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N;
    cin >> N;
    vector<ll> x(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }
    ll L;
    cin >> L;
    int K = 1;
    while((1<<K) < N) K++;
    vector<vector<int>> dbl(K, vector<int> (N));

    for (int i = 0; i < N; i++) {
        dbl[0][i] = (upper_bound(ALL(x), x[i] + L) - x.begin()) - 1;
    }

    for (int k = 1; k < K; k++) {
        for (int i = 0; i < N; i++) {
            dbl[k][i] = dbl[k-1][dbl[k-1][i]];
        }
    }

    int Q;
    cin >> Q;
    int a, b;
    for (int i = 0; i < Q; i++) {
        cin >> a >> b; a--; b--;
        if(a > b) swap(a, b);
        ll ans = 0;
        for (int k = K-1; k >= 0; k--) {
            if(dbl[k][a] < b){
                a = dbl[k][a];
                ans += (1<<k);
            }
        }
        printf("%lld\n", ans + 1);
    }

}

Measured memory_bytes: 11180
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
using namespace std;

using VI = vector <int> ;
using VVI = vector <VI> ;

class FenwickTree {
    VI sum;
public:
    FenwickTree (int treeSize) {
        sum = move(VI(treeSize+1));
    }

    void addVal(int idx, int val) {
        while (idx < sum.size()) {
            sum[idx] += val;
            idx += (idx & (-idx));
        }
    }

    int getVal(int idx) {
        if (idx <= 0) {
            return 0;
        }

        int ret = 0;

        while (idx) {
            ret += sum[idx];
            idx -= (idx & (-idx));
        }

        return ret;
    }

    int queryRange(int a, int b) {
        return getVal(b) - getVal(a-1);
    }
};


const int MAXS = 500010;
char str[MAXS];

int main() {

    vector <FenwickTree*> ft;
    int N;
    int Q;

    scanf("%d", &N);
    scanf("%s", str);

    for (int i = 0; i < 26; ++i) {
        ft.push_back(new FenwickTree(N));
    }

    for (int i = 0; i < N; ++i) {
        int c = str[i] - 'a';
        ft[c]->addVal(i+1, 1);
    }

    scanf("%d", &Q);
    while (Q--) {
        int t;
        scanf("%d", &t);

        if (t == 1) {
            int idx;
            char ch;
            scanf("%d %c", &idx, &ch);

            ft[str[idx-1]-'a']->addVal(idx, -1);
            ft[ch-'a']->addVal(idx, 1);
            str[idx-1] = ch;
        } else {
            int distinct = 0;
            int l;
            int r;
            scanf("%d%d", &l, &r);

            for (int i = 0; i < 26; ++i) {
                int v = ft[i]->queryRange(l, r);
                if (v) {
                    ++distinct;
                }
            }

            printf("%d\n", distinct);
        }
    }


    return 0;
}

Measured memory_bytes: 51712
#include <bits/stdc++.h>
using namespace std; 
typedef long long lli;
#define mod 1000000007
#define fori(n) for(int i=0;i<n;i++)
#define forj(n) for(int j=0;j<n;j++)
#define forli(n) for(lli i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(),a.end())
 
//FUNCTONS
lli llipower(lli x, lli y){lli res = 1; while (y > 0){if (y & 1) res = (res*x); y = y>>1;x = (x*x);}return res;}
lli llipowerp(lli x, lli y,lli p){lli res = 1;x = x % p; while (y > 0){if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p;}return res;}
lli gcd(lli a, lli b){ if (!a) return b; return gcd(b%a,a);}
lli binarySearch(vector<int> arr, int l, int r, int x){ 
	if (r >= l) { 
		lli mid = l + (r - l) / 2; 
		if (arr[mid] == x) return mid; 
		if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x); 
		return binarySearch(arr, mid + 1, r, x); 
	}return -1;
}
template <typename T> void printvec(vector<T> inp){for(int i=0;i<inp.size();i++){cout<<inp[i]<<" ";}cout<<endl;}
template <typename T> T ceildiv(T x, T y){return 1 + ((x - 1) / y);}
lli modInverse(lli a, lli m){lli g = gcd(a, m);if (g != 1) return -1;else return llipowerp(a, m-2, m);} 

int main(){

    string s,srev;
    cin>>s;
    srev=s;
    reverse(srev.begin(),srev.end());
    int n=s.size();
    string left=s.substr(0,n/2);
    string right=s.substr(n/2+1,n/2);
    string lrev=left;
    reverse(lrev.begin(),lrev.end());

    string rrev = right;
    reverse(rrev.begin(), rrev.end());
    if(srev==s && lrev==left && rrev==right) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
 


Measured memory_bytes: 256
moji_list =sorted(list('abcdefghijklmnopqrstuvwxyz'))

n = int(input())
S = [0]*n
for  i in range(n):
    S[i] = input()
    
moji_con = [0] * len(moji_list)

for i in range(len(moji_list)):
    MM = []
    moji = moji_list[i]
    
    for word in S:
        MM.append(word.count(moji))
    
    moji_con[i] = min(MM)
    
ans = ''
for i in range(len(moji_con)):
    if moji_con[i] != 0:
        ans += moji_con[i]*moji_list[i]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N=105;
int n,m,i,j;
char c[N][N];
bool han[N],lie[N];
int main()
{
	cin>>n>>m;
	for(i=0;i<n;i++)cin>>c[i];
	for(i=0;i<n;i++)
	{
		bool f=true;
		for(j=0;j<m;j++)
			if(c[i][j]=='#')f=false;
		han[i]=f;
	}
	for(j=0;j<m;j++)
	{
		bool f=true;
		for(i=0;i<n;i++)
			if(c[i][j]=='#')f=false;
		lie[j]=f;
	}
	for(int i=0;i<n;i++)
	{
		if(han[i])continue;
		for(int j=0;j<m;j++)
		{
			if(lie[j])continue;
			cout<<c[i][j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n + 1];
		int b[] = new int[n + 1];
		int c[] = new int[n];
		for (int i = 1; i <= n; ++i)
			a[i] = sc.nextInt();
		for (int i = 1; i <= n; ++i)
			b[i] = sc.nextInt();
		for (int i = 1; i < n; ++i)
			c[i] = sc.nextInt();
		sc.close();
		long ans = 0;
		int pre = -2, crt = 0;
		for(int i = 1; i <= n; ++i){
			crt = a[i];
			ans += b[crt];
			if(crt == pre + 1)ans += c[pre];
			pre = crt;
		}
		System.out.println(ans);
	}
}


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

using ull = unsigned long long;
using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
const int inf = INT_MAX;

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

    int n, x, t;
    cin >> n >> x >> t;

    cout << (n + x - 1) / x * t;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MS(a) memset(a,0,sizeof(a))
#define MP make_pair
#define PB push_back
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//////////////////////////////////////////////////////////////////////////
const int maxn = 1e5+10;

int n,k,a[maxn];

int gcd(int x,int y){
	return x%y==0 ? y : gcd(y,x%y);
}

int main(){
	cin >> n >> k;
	int mx = -1;
	for(int i=1; i<=n; i++){
		cin >> a[i];
		mx = max(mx,a[i]);
	}
	if(n==1){
		if(a[1]==k) puts("POSSIBLE");
		else puts("IMPOSSIBLE");
		return 0;
	}
	int g = 0;
	for(int i=1; i<=n; i++){
		g = gcd(g,a[i]);
	}
	bool f;
	if(g!=1){
		if(k%g==0 && mx>=k) f = 1;
		else f = 0;
	}else{
		if(mx>=k) f = 1;
		else f = 0;
	}
	if(f) puts("POSSIBLE");
	else puts("IMPOSSIBLE");

    return 0;
}

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

class Solution {
    public:
        int sol(){
            int n,x,y,z;
            cin>>n;
            vector<int> a;
            vector<int> b;
            vector<int> c;
            vector<vector<int>> dp(4,vector<int>(n,0));
            for(int i=0;i<n;i++){
                cin>>x>>y>>z;
                a.push_back(x);
                b.push_back(y);
                c.push_back(z);
            }
            dp[0][0] = a[0];
            dp[1][0] = b[0];
            dp[2][0] = c[0]; 
            for(int i=1;i<n;i++){
                dp[0][i] = a[i] + max(dp[1][i-1], dp[2][i-1]);
                dp[1][i] = b[i] + max(dp[0][i-1], dp[2][i-1]);
                dp[2][i] = c[i] + max(dp[0][i-1], dp[1][i-1]);
            }
            return max(max(dp[0][n-1],dp[1][n-1]),dp[2][n-1]);
        }
};

int main(){
    Solution test;
    cout<<test.sol();
    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define ci(x) cin >>x
#define co(x) cout<<x<<endl
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a) {
 long long ans=1;
 while(a>1){
 ans*=a;
 ans%=1000000007;
     a--;
    }
    return ans;
     }
int main() {
ll A;
  ll B;
    ll M;
    cin >>A>>B>>M;
  vl a(A);
  vl b(B);
  rep(i,A) {
    cin >>a.at(i);
  }
rep(i,B) {
cin >>b.at(i);
}

  vl x(M);
  vl y(M);
  vl c(M);
  rep(i,M) {
cin >>x.at(i)>>y.at(i)>>c.at(i);
  }

  vl aa(A);
  vl bb(B);
  rep(i,A) {
    aa.at(i)=a.at(i);
  }
rep(i,B) {
bb.at(i)=b.at(i);
}
sort(all(aa));
  sort(all(bb));
  
  
  ll ps=aa.at(0)+bb.at(0);
  
  
  vl vec(M);
  rep(i,M) {
    
    vec.at(i)=-c.at(i)+a.at(x.at(i)-1)+b.at(y.at(i)-1);
  }
  sort(all(vec));
  
  ll PS=vec.at(0);
  
  cout<<min(ps,PS)<<endl;
}
    
    
  
 

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pll pair<ll,ll>
#define vi vector < int >
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define s(x) scanf("%d",&x)
#define sll(x) scanf("%lld",&x)
#define pf(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define flash ios_base::sync_with_stdio(false);cin.tie(0)
#define goog(x) cout << "Case #" << x << ": "
#define MAX5 200005
#define MAX6 2000005
#define MLOG 18
#define limit 1e18
#define mod 1000000007   
void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int power(int x, int y, int p){
    int res = 1;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

void solve(){
    int a, b;
    cin >> a >> b;
    cout << 6 - (a+b) << endl;
} 
signed main(){  
//  freopen("ii.txt", "w", stdin);
    flash;
    int t = 1;
    //  cin >> t;  
    for(int tc = 1; tc <= t; tc++){
    //goog(tc);
        solve();
    }
}

Measured memory_bytes: 256
use std::io;

pub fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let line: Vec<i32> = buf.split_whitespace().into_iter().map(|s| s.parse().unwrap()).collect();
    let A = line[0];
    let B = line[1];
    if A >= 10 || B >= 10 {
        println!("-1")
    } else {
        println!("{}", A * B)
    }
}

Measured memory_bytes: 4352
#include <iostream>
#define ll long long
 
using namespace std;
 
int main() {
    ll t, x, ans = 1;
    cin >> t;
    while (t--) {
        cin >> x;
        if (!x) {
            ans = 0;
            break;
        }
        if (1000000000000000000ll / ans < x)
            ans = -1;
        else
            ans *= x;
    }
    cout << ans;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define int long long
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> P;
typedef vector<P> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int max(int a,int b){if(a>b)return a; return b;}
int min(int a,int b){if(a>b)return b; return a;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  V a(5);
  cin>>n;
  rep(i,5)cin>>a[i];
  SORT(a);
  int res=n/a[0]+(n%a[0]==0?0:1);
  res+=4;
  out(res);
  
  return 0;
}



Measured memory_bytes: 256
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

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

#define DEBUG
#undef DEBUG

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

template<typename T>
void print_array(T* p, int n)
{
    REP(i, n) {
        cout << p[i] << " ";
    }
    cout << "\n";
}

int N;
bool S[100000];
bool A1[100000]; // true:正直者, false:嘘つき
bool A2[100000];

bool partner(bool s, bool a_center, bool a_lr)
{
    return s ^ a_center ^ a_lr;
}

bool possible(bool a_ini, bool a_next, bool a_prev)
{
    A1[0] = a_ini;
    A1[1] = a_next;

    FOR(i, 1, N-1) {
        A1[i+1] = partner(S[i], A1[i], A1[i-1]);
    }
    if(A1[N-1] != a_prev) return false;
    if(partner(S[N-1], A1[N-1], A1[N-2]) != A1[0])
        return false;

    return true;

#if 0
    A1[0] = A2[0] = a_ini;

    A1[1]   = a_next;
    A2[N-1] = a_prev;

    FOR(i, 1, N-1) {
        A1[i+1] = partner(S[i], A1[i], A1[i-1]);
    }
    cout << "A1: ";
    print_array(A1, N);
    if(partner(S[N-1], A1[N-1], A1[N-2]) != A1[0])
        return false;

    for(int i = N-1; i >= 2; --i) {
        A2[i-1] = partner(S[i], A2[i], A2[i+1]);
    }
    cout << "A2: ";
    print_array(A2, N);
    if(partner(S[1], A2[1], A2[2]) != A2[0])
        return false;

    return equal(A1, A1+N, A2);
#endif
}

void solve()
{
    bool ok = false;
    if(S[0]) {
        if(possible(true, true, true)) {
            ok = true;
            goto finish;
        }
        if(possible(true, false, false)) {
            ok = true;
            goto finish;
        }
        if(possible(false, true, false)) {
            ok = true;
            goto finish;
        }
        if(possible(false, false, true)) {
            ok = true;
            goto finish;
        }
    }
    else {
        if(possible(true, true, false)) {
            ok = true;
            goto finish;
        }
        if(possible(true, false, true)) {
            ok = true;
            goto finish;
        }
        if(possible(false, true, true)) {
            ok = true;
            goto finish;
        }
        if(possible(false, false, false)) {
            ok = true;
            goto finish;
        }
    }

finish:
    if(!ok) {
        cout << -1 << "\n";
    }
    else {
        REP(i, N) {
            cout << (A1[i] ? 'S' : 'W');
        }
        cout << "\n";
    }
}

int main()
{
    cin >> N;
    string s;
    cin >> s;
    REP(i, N) {
        S[i] = s[i] == 'o';
    }

    solve();

    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort(v.rbegin(), v.rend())
typedef pair<int, int> pii;

ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
} 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
} 
ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	int ar[n+1] = {};
	for(int i = 0; i < n-1; i++){
		int sayi; cin>>sayi; 
		ar[sayi]++;
	}
	for(int i = 1; i <= n; i++) cout<<ar[i]<<"\n";
}


Measured memory_bytes: 4392
#include <iostream>
#include <algorithm>
#include <numeric>


int64_t a[51];
int64_t p[51];

int64_t calc(int lv, int64_t x) {
    if(x == 0) return 0;
    if(lv == 0) return 1;
    if(x > a[lv] / 2) return p[lv-1] + calc(lv-1, x - a[lv] / 2 - 1) + 1;
    return calc(lv-1, x - 1);
}


int main(void) {
    int lv;
    int64_t x;
    std::cin >> lv >> x;

    a[0] = 1;
    p[0] = 1;
    for(int i=1; i<=lv; i++){
        a[i] = a[i-1] * 2 + 3;
        p[i] = p[i-1] * 2 + 1;
    }

    std::cout << calc(lv, x) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

#define forn(i, s, f) for (int i = s; i < f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector <int> a(n + 2);
    forn (i, 1, n + 1) 
        cin >> a[i];
    int ans = 0;
    forn (l, 0, n + 1) {
        forn (r, l + 1, n + 2) {
            if (l + (n + 1 - r) > k)
                continue;
            vector <int> b;
            int sum = 0;
            forn (i, 1, l + 1)
                b.pb(a[i]), sum += a[i];
            forn (i, r, n + 1)
                b.pb(a[i]), sum += a[i];
            sort(all(b));
            forn (i, 0, min(sz(b), k - l - (n + 1 - r)))
                if (b[i] < 0) 
                    sum -= b[i];
            ans = max(ans, sum);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import Data.List
g n
  | n > 0 = n
  | otherwise = 0
f (n:a:b:[])
  | a > b = putStrLn ((show b) ++ " " ++ (show (g (a + b - n))))
  | otherwise = putStrLn ((show a) ++ " " ++ (show (g (a + b - n))))
main = do
  xs <- map read . words <$> getLine
  f xs


Measured memory_bytes: 508
#[allow(dead_code)]
pub struct Scanner<'a> {
    _buf: &'a str,
    iter: ::std::str::SplitWhitespace<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    pub fn new(buf: &'a str) -> Self {
        Scanner {
            _buf: buf,
            iter: buf.split_whitespace(),
        }
    }

    pub fn array<T>(&mut self, n: usize) -> Vec<T>
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        let mut res = Vec::with_capacity(n);
        for _ in 0..n {
            res.push(self.value());
        }
        res
    }

    pub fn value<T>(&mut self) -> T
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        self.next().parse().unwrap()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.next().chars().collect()
    }

    fn next(&mut self) -> &str {
        self.iter.next().unwrap()
    }
}

fn main() {
    let mut _input = String::new();
    {
        use ::std::io::Read;
        ::std::io::stdin().read_to_string(&mut _input).unwrap();
    }
    let mut sc = Scanner::new(&_input);

    let s = sc.chars();

    let mut ans = 0_i64;
    let mut nb  = 0;
    for c in s {
        match c {
            'B' => nb  += 1,
            'W' => ans += nb,
            _   => panic!(),
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define fr(i,c,b) for(int i=c;i<b;i++)
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define MAX 1000001

typedef long long int ll;

using namespace std;

int main()
{
    si(n);
    cout<<n*n*n;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define INF 1020304050

int main()
{
  int n;cin>>n;
  vector<int> a(n);
  int i;
  rep(i,n)cin>>a[i];
  vector<int> lans(n,INF);
  rep(i,n)
  {
    int ind=lower_bound(all(lans),a[i])-lans.begin();
    lans[ind]=a[i];
  }
  int ans=0;
  rep(i,n)
  {
    if(lans[i]!=INF)ans++;
    else break;
  }
  cout<<ans<<endl;
}



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

int main(){

  int n, x=0, ans=0;
  string s;
  cin >> n >> s;

  for(int i=0; i<n; i++){
    if(s[i]=='I'){
      x++;
    } else {
      x--;
    }
    if(x>ans){
      ans = x;
    }
  }

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        long nextLong() {

            return Long.parseLong(next());
        }

        BigInteger nextBigIntger() {
            BigInteger bb = new BigInteger(next());
            return bb;
        }
    }

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        String ss = sc.nextLine();
        int cnt =0;
        for(int i=0;i<ss.length();i++){
            if(ss.charAt(i)=='1')
                cnt++;
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21204
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    s=STR()
    ct=0
    for i in range(n):
        seta=set(s[0:i])
        setb=set(s[i:])
        ct=max(ct,len(seta&setb))
    print(ct)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
{-# LANGUAGE BangPatterns #-}

import           Control.Applicative
import           Control.Monad
import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap.Strict    as M
import qualified Data.Sequence         as S

readi :: B.ByteString -> Int
readi bs | Just (n, _) <- B.readInt bs = n

data Tree a
    = Empty
    | Node a (Tree a) (Tree a)
    deriving Show

insert :: Ord a => a -> Tree a -> Tree a
insert x Empty = Node x Empty Empty
insert x (Node y l r)
    | x < y     = Node y (insert x l) r
    | otherwise = Node y l (insert x r)

print' :: Show a => Tree a -> IO ()
print' t = do
    putStrLn . (' ' :) . unwords $ fmap show (inOrder t)
    putStrLn . (' ' :) . unwords $ fmap show (preOrder t)

preOrder :: Tree a -> [a]
preOrder Empty        = []
preOrder (Node x l r) = x : preOrder l ++ preOrder r

inOrder :: Tree a -> [a]
inOrder Empty        = []
inOrder (Node x l r) = inOrder l ++ [x] ++ inOrder r

find :: Int -> Tree Int -> Bool
find _ Empty = False
find x (Node y l r)
    | x == y    = True
    | x < y     = find x l
    | otherwise = find x r

delete :: Int -> Tree Int -> Tree Int
delete _ Empty = error "delete from empty tree"
delete x (Node y l r)
    | x < y     = Node y (delete x l) r
    | x > y     = Node y l (delete x r)
    | isEmpty l && isEmpty r = Empty
    | isEmpty l = r
    | isEmpty r = l
    | otherwise =
          let m = getMin r
           in Node m l (delete m r)

isEmpty :: Tree Int -> Bool
isEmpty Empty = True
isEmpty _     = False

getMin :: Tree Int -> Int
getMin Empty = error "getMin from empty tree"
getMin (Node x Empty _) = x
getMin (Node _ l     _) = getMin l

solve :: Tree Int -> [[B.ByteString]] -> IO ()
solve _ [] = return ()
solve !t (bs:bss)
    | c == 'p' = do
        print' t
        solve t bss
    | c == 'f' = do
        let n = readi $ bs !! 1
        if find n t
            then putStrLn "yes"
            else putStrLn "no"
        solve t bss
    | c == 'd' = do
        let n = readi $ bs !! 1
        solve (delete n t) bss
    | otherwise = do
        let n = readi $ bs !! 1
        solve (insert n t) bss
  where
    c = B.head (head bs)

main :: IO ()
main = do
    B.getLine
    xss <- fmap B.words . B.lines <$> B.getContents
    solve Empty xss



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

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

  if(a!=b&&a!=c){
    cout<<a<<endl;
  }
  else if(b!=a&&b!=c){
    cout<<b<<endl;
  }
  else{
    cout<<c<<endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <stack>
#include <vector>
using namespace std;
#define MOD 1000000007;



int main()
{
    int H, W;
    long long dp[1005][1005]; 
    char matrix[1005][1005];
    cin >> H >> W; 
    for (int i = 0; i <= H; i++) dp[i][0] = 0;
    for (int j = 0; j <= W; j++) dp[0][j] = 0;
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cin >> matrix[i][j];
            if (matrix[i][j] == '#')
                dp[i + 1][j + 1] = 0;
            else {
                if (i == 0 && j == 0) dp[i + 1][j + 1] = 1;
                else dp[i + 1][j + 1] = (dp[i][j + 1] + dp[i + 1][j]) % MOD;
            }
        }
    }
    cout << dp[H][W];
}


Measured memory_bytes: 9088
h, n  = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]

dp = [10**10] * (h+1)
dp[0] = 0

for i in range(1,h+1):
    for j in range(n):
        if(i >= ab[j][0]):
            dp[i] = min(dp[i], dp[ i - ab[j][0]]+ ab[j][1])
        else:
            dp[i] = min(dp[i], dp[0] + ab[j][1])

print(dp[h])

Measured memory_bytes: 43120
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#include <numeric>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};

int N;
int a[55];
 
signed main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> N;
  for (int i=1; i<=N; i++) cin >> a[i];

  int absma = 0;
  int maidx = 1;
  for (int i=1; i<=N; i++) if (abs(absma) < abs(a[i])) {
    absma = a[i];
    maidx = i;
  }

  cout << 2 * N - 2 << endl;
  for (int i=1; i<=N; i++) {
    if (i != maidx) {
      cout << maidx << " " << i << endl;
    }
  }

  if (absma < 0) {
    for (int i=N; i>=2; i--) {
      cout << i << " " << i - 1 << endl;
    }
  } else {
    for (int i=1; i<=N-1; i++) {
      cout << i << " " << i + 1 << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC90(void);
void ABC91(void);
void ABC92(void);
void ABC93(void);
void ABC94(void);
void ABC95(void);
void ABC96(void);
void ABC97(void);
void ABC98(void);
void ABC99(void);

int main(void){
    ABC91();
}

void ABC91(){
    int n,m,i,j,max,a;
    string s;
    cin>>n;
    vector<string> str(n);
    for(i=0;i<n;i++){
        cin>>str[i];
    }
    cin>>m;
    vector<string> stm(m);
    for(i=0;i<m;i++){
        cin>>stm[i];
    }
    max=count(str.begin(),str.end(),str[0])-count(stm.begin(),stm.end(),str[0]);
    for(i=1;i<n;i++){
        a=count(str.begin(),str.end(),str[i])-count(stm.begin(),stm.end(),str[i]);
        if(a>max)max=a;
    }
    for(i=0;i<m;i++){
        a=count(str.begin(),str.end(),stm[i])-count(stm.begin(),stm.end(),stm[i]);
        if(a>max)max=a;
    }
    if(max>0)cout<<max<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 256