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

// Template Headers {{{
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long; using vll = vector<long long>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}

int solve() {
	ll x; cin >> x;
	const int M = 4000;
	vll por(M);
	for (int i = 0; i < M; i++) por[i] = 1LL * i * i * i * i * i;
	for (int i = 0; i < M; i++) for (int j = 0; j < M; j++) {
		if (por[i] - por[j] == x) return cout << i << ' ' << j << endl, 0;
		if (por[i] + por[j] == x) return cout << i << ' ' << -j << endl, 0;
	}
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	// precompute();
	// int t; cin >> t; for (int i=1;i<=t;i++)
	solve();
	// cout << "Case #" << i << ": ", solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>

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

using namespace std;

int n, k, p, q;
int b[4001][4001];
int w[4001][4001];

void sum(int x[][4001]){
    rep(i, q){
        rep(j, q + 1){
            x[i + 1][j] += x[i][j];
        }
    }
    rep(i, q + 1){
        rep(j, q){
            x[i][j + 1] += x[i][j];
        }
    }
}

int rect(int x[][4001], int xb, int xe, int yb, int ye){
    return x[xe][ye] - x[xe][yb] - x[xb][ye] + x[xb][yb];
}

int main(){
    cin >> n >> k;
    p = k * 2;
    q = p * 2;
    rep(i, n){
        int x, y;
        string c;
        cin >> x >> y >> c;
        x = x % p + 1;
        y = y % p + 1;
        if(c == "B"){
            ++b[x][y];
            ++b[x + p][y];
            ++b[x][y + p];
            ++b[x + p][y + p];
        } else {
            ++w[x][y];
            ++w[x + p][y];
            ++w[x][y + p];
            ++w[x + p][y + p];
        }
    }
    sum(b);
    sum(w);
    int ans = 0;
    rep(i, p){
        rep(j, p){
            int cb = rect(b, i, i + k, j, j + k) + rect(b, i + k, i + p, j + k, j + p);
            int cw = rect(w, i, i + k, j + k, j + p) + rect(w, i + k, i + p, j, j + k);
            ans = max(cb + cw, ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 125312
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

vector<int> tsort(vector<vector<int>> &g) {
    int n = g.size(), k = 0;
    vector<int> ord(n), in(n);
    for (int u = 0; u < n; u++) for (int v: g[u]) in[v]++;
    queue<int> que;
    for (int u = 0; u < n; u++) if (in[u] == 0) que.push(u);
    while (!que.empty()) {
        int u = que.front(); que.pop();
        ord[k++] = u;
        for (int v: g[u]) if (--in[v] == 0) que.push(v);
    }
    return *max_element(in.begin(), in.end()) == 0 ? ord : vector<int>();
}

int main() {
    int n, m; cin >> n >> m;
    string s; cin >> s;
    vector<vector<int>> g(n * 2);
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b; a--, b--;
        if (s[a] == s[b]) {
            g[a].emplace_back(b + n);
            g[b].emplace_back(a + n);
        } else {
            g[a + n].emplace_back(b);
            g[b + n].emplace_back(a);
        }
    }
    cout << (tsort(g).empty() ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 20484
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            int K = in.nextInt();
            int[] x = in.nextIntArray(N);
            int nega = (int) IntStream.of(x).filter(n -> n <= 0).count();
            int min = 1010101010;
            for (int i = 0; i + K <= N; i++) {
                if (i + K <= nega) {
                    min = Math.min(min, -x[i]);
                } else if (nega < i + 1) {
                    min = Math.min(min, x[i + K - 1]);
                } else {
                    min = Math.min(min, Math.min(-x[i] * 2 + x[i + K - 1], -x[i] + x[i + K - 1] * 2));
                }
            }
            out.println(min);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

    }
}



Measured memory_bytes: 39212
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pi 3.14159265358979323846
#define mod 100000
int main()
{ 
    IOS;
    ll p;
    p=1;
    while(p--)
    {
        ll a,b,c,d,e,n,sum=0,maxx=0;
        string A,B;
        cin>>A>>B;
        for(c=0;c<=A.length()-B.length();c++)
        {
            sum=0;
            for(d=c;d<c+B.length();d++)
            {
                if(A[d]==B[d-c])
                {
                    sum++;
                }
            }
            maxx=max(sum,maxx);
        }
        cout<<B.length()-maxx<<endl;
    }
}

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String N = sc.next();

		if (N.charAt(0) >= N.charAt(1) && N.charAt(0) >= N.charAt(2)) {
			for (int i = 0; i < 3; i++) {
				System.out.print(N.charAt(0));
			}
		} else {
			for (int i = 0; i < 3; i++) {
				System.out.print(Character.getNumericValue(N.charAt(0)) + 1);
			}
		}
	}
}


Measured memory_bytes: 22996
a = int(input())

if a >=1800:
    print('1')
elif a >=1600:
    print('2')
elif a >=1400:
    print('3')
elif a >=1200:
    print('4')
elif a >=1000:
    print('5')
elif a >=800:
    print('6')
elif a >=600:
    print('7')
else:
    print('8')

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

int main()
{
    int H,N;
    int A;
    scanf("%d%d",&H,&N);
    int i,sum=0;
    for(i=0;i<N;i++)
    {
       scanf("%d",&A);
       sum=sum+A;
    }
    if(sum<H)
    {
        printf("No");
    }
    else
    {
        printf("Yes");
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b==c){
        if(a%2){
            cout<<0<<endl;
        }else{
            cout<<-1<<endl;
        }
        return 0;
    }
    int cnt=0;
    while(true){
        if(a%2||b%2||c%2)break;
        int A=a/2,B=b/2,C=c/2;
        a=B+C;b=A+C;c=B+C;
        cnt++;
    }
    cout<<cnt<<endl;


    return 0;
}


Measured memory_bytes: 256
diagram = gets.chomp.chars

search = ->{
  max = min = height = 0
  diagram.each_with_index do |x, i|
    case x
    when "\\"
      height -= 1
      min = height if height < min
    when "/"
      height += 1
      max = height if height > max
    end
  end
  [max - min, max]
}

n, level = search.()
table = Array.new(n) {[]}

diagram.each_with_index do |x, i|
  case x
  when "\\"
    table[level] << i
    level += 1
  when "/"
    level -= 1
    a = table[level].last
    table[level] << i if a
  end
  table
end
table.map! do |one_level|
  ar = []
  one_level.each_slice(2) {|x| ar << x}
  ar.select {|x| x.size == 2}
end

calc_area = ->(pair, level) {
  area = pair[1] - pair[0]
  return area if level == n
  table1 = table[level]
  table[level].each do |downer_pair|
    if pair[0] < downer_pair[0] and downer_pair[1] < pair[1]
      table1 -= [downer_pair]
      area += calc_area.(downer_pair, level + 1)
    end
  end
  table[level] = table1
  area
}

pools = []
solve = ->{
  min = [[Float::INFINITY, 0], 0]
  table.each_with_index do |one_level, i|
    next if one_level.empty?
    pair = one_level[0]
    min = [pair, i] if pair[0] < min[0][0]
  end
  table[min[1]] -= [min[0]]
  pools << calc_area.(min[0], min[1] + 1) if min[0][0] != Float::INFINITY
  solve.() unless table.flatten.empty?
}

solve.() unless table.empty?

if pools.empty?
  puts 0, 0
else
  puts pools.inject(&:+)
  puts pools.size.to_s + " " + pools.join(" ")
end



Measured memory_bytes: 123008
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

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

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let mut b: Vec<usize> = sc.vec(N);
    let mut ans = Vec::new();
    while !b.is_empty() {
        let mut found = false;
        for i in (0..b.len()).rev() {
            if i+1 == b[i] {
                ans.push(b.remove(i));
                found = true;
                break;
            }
        }
        if !found {
            println!("-1");
            return;
        }
    }
    ans.reverse();
    for &a in &ans {
        println!("{}", a);
    }
}


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

using namespace std;

using ll = long long;
using p  = pair<ll, ll>;
constexpr ll INF = 1LL << 62;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a, b, ans = 0;
    cin >> a >> b;
    for (ll i = 1; i <= a; i++) {
        if (i < a) {
            ans++;
        }
        if (i == a && i <= b) {
            ans++;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
//============================================================================
//?????°?????????
//============================================================================

	int H,W;
	int T[101][101];
	char chr;
//============================================================================
//??\???
//============================================================================

	cin>>H>>W;
	for (int i=0;i<H;i++){
		for (int j=0;j<W;j++){
			cin>>chr;
			if (chr=='c')T[i][j]=0;
			if (chr=='.')T[i][j]=-1;
		}
	}
//============================================================================
//????¨??????????  abs
//============================================================================
	int R[101][101]={};
	int S;
	for (int i=0;i<H;i++){
		S=-1;
		for (int j=0;j<W;j++){
			if (T[i][j]==-1){
				if (S>=0)S+=1;
				R[i][j]=S;
			}
			if (T[i][j]==0){
				R[i][j]=0;
				S=0;
			}

		}
	}
//============================================================================
//????????????R
//============================================================================
	for (int i=0;i<H;i++){
		cout<<R[i][0];
		for (int j=1;j<W;j++){
			cout<<" "<< R[i][j];
		}cout<<endl;
	}	return 0;

}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define Rrep(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int c, n, m, s, d;
int a, b, f;
struct edge {int to, cost;};
vector<edge> G[105];
vector<vector<int> > dp(11, vector<int>(105, 0));

void dijkstra(int s, int a) {
	priority_queue<P, vector<P>, greater<P> > que;
	rep(i, 105) dp[a][i] = INF;
	dp[a][s] = 0;
	que.push(P(0, s));

	while(!que.empty()) {
		P p = que.top(); que.pop();
		int tmp = p.second;
		if(dp[a][tmp] < p.first) continue;
		rep(i, G[tmp].size()) {
			int to = G[tmp][i].to;
			int cost = (a == 0) ? G[tmp][i].cost + dp[a][tmp] : min(G[tmp][i].cost + dp[a][tmp], G[tmp][i].cost / 2 + dp[a - 1][tmp]);
			if(dp[a][to] > cost) {
				dp[a][to] = cost;
				que.push(P(-cost, to));
			}
		}
	}

}

int main() {
	while(scanf("%d %d %d %d %d", &c, &n, &m, &s, &d)) {
		s--; d--;
		if(c == 0) return 0;
		rep(i, m) {
			scanf("%d %d %d", &a, &b, &f); 
			a--; b--;
			G[a].push_back((edge){b, f});
			G[b].push_back((edge){a, f});
		}
		int ans = INF;
		rep(i, c + 1) dijkstra(s, i);
		printf("%d\n", dp[c][d]);

		rep(i, 105){
      		G[i].erase(G[i].begin(), G[i].end());
    	}
    	rep(i, 11){
      		dp[i].erase(dp[i].begin(), dp[i].end());
    	}
	}
	return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables ***************/
int n, k;
/**********************************************/

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

    cin >> n >> k;
    int ans = 1;
    REP(i, n){
        if(ans * 2 < ans + k) ans *= 2;
        else ans += k;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int N;
    cin >> N;
    int A[200000] = {};
    int a[200000] = {};
    
    for(int i=0;i<N;i++){
        cin >> A[i];
        a[i] = A[i];
    }
    
    sort(A,A+N,greater<int>());
    
    for(int i=0;i<N;i++){
        if(A[0] != a[i]){
            cout << A[0] << endl;
        }else{
            cout << A[1] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
int N, M;
void func()
{
    cin >> N;
    map<string, int> S;
    int ans(0);
    rep(i, 0, N)
    {
        string tmp;
        cin >> tmp;
        if (!(S.count(tmp)))
        {
            ++ans;
            S[tmp] = 1;
        }
    }
    cout << ans << endl;
}
int main()
{
    func();
}

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


void solve(){
    int a = 0, b = 0;
    for(int i = 0; i < 3; i++){
        int k; cin >> k;
        if(k == 5) a++;
        else if(k == 7) b++;
    }
    if(a == 2 && b == 1){
        cout << "YES\n";
    }
    else cout << "NO\n";
}

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

    bool multitest = false;
//    multitest = true;
    if(multitest){
        int t; cin >> t;
        while(t--)
            solve();
    }
    else
        solve();
}






Measured memory_bytes: 3540
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	String s=sc.next();
	char c[]=s.toCharArray();
	int ans=0;
	for(int i=0;i<=s.length()-1;i++){
		if(c[i]=='+'){
			ans++;
		}else{
			ans--;
		}
	}
System.out.println(ans);
	}}

Measured memory_bytes: 21844
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int, input().split())))[a-x:]
q=sorted(list(map(int, input().split())))[b-y:]
r=sorted(list(map(int, input().split())),reverse=True)
import heapq
eat=p+q
heapq.heapify(eat)
for i in r:
	j=heapq.heappop(eat)
	if j<i:
		heapq.heappush(eat,i)
	else:
		heapq.heappush(eat,j)
#print(list(eat))
print(sum(list(eat)))

Measured memory_bytes: 22504
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int cnt=0;cnt<n;cnt++){
    string s0;
    map <string,bool> li;
    int r=1;
    cin>>s0;
    li[s0]=1;
    for(int i=1;i<s0.size();i++){
      string s=s0;
      reverse(s.begin()+i,s.end());
      if(!li[s]) r++;
      li[s]=1;
      reverse(s.begin(),s.begin()+i);
      if(!li[s]) r++;
      li[s]=1;
      reverse(s.begin()+i,s.end());
      if(!li[s]) r++;
      li[s]=1;
      s=s0.substr(i)+s0.substr(0,i);
      if(!li[s]) r++;
      li[s]=1;
      reverse(s.end()-i,s.end());
      if(!li[s]) r++;
      li[s]=1;
      reverse(s.begin(),s.end()-i);
      if(!li[s]) r++;
      li[s]=1;
      reverse(s.end()-i,s.end());
      if(!li[s]) r++;
      li[s]=1;
    }
    cout<<r<<endl;
  }
  return 0;
}

Measured memory_bytes: 3220
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<string>
#include<queue>

using namespace std;
const long long INF=9223372036854775800;
const long long mod=1e9+7;
const int MOD=1e9+7;
long long fac[100001];
long long ifac[100001];
long long mod_pow(int x,int n){//xのn乗
    if(n%2==0){
        if(n==0){
            return 1;
        }else{
            long long c=mod_pow(x,n/2);
            return c*c%mod;
        }
    }else{
        if(n==1){
            return (long long)x;
        }else{
            long long c=mod_pow(x,(n-1)/2);
            return (c*c%mod)*(long long)x%mod;
        }
    }
}
long long comb(int a,int b){//aCbを返す関数
    if(b==a || b==0) return 1;
    if(a<=0 || a<b) return 0;
    long long ret=(((fac[a]*ifac[a-b])%mod)*ifac[b])%mod;
    return ret;
}

int main(){
    int N;
    int A[100002];
    int left,right;
    int Where[100001]={};
    cin>>N;
    for(int i=1;i<=N+1;i++){
        cin>>A[i];
        if(Where[A[i]]==0){
            Where[A[i]]=i;
        }else{
            left=Where[A[i]];
            right=i;
        }
    }
    left--;
    right=N+1-right;
    fac[0]=1;
    ifac[0]=1;
    fac[1]=1;
    ifac[1]=1;
    for(int i=2;i<=N+1;i++){
        fac[i]=(fac[i-1]*i)%mod;
        ifac[i]=(ifac[i-1]*mod_pow(i,MOD-2) )%mod;
    }
    for(int k=1;k<=N+1;k++){
        long long ans=comb(N+1,k);
        long long sub=comb(left+right,k-1);
        /*
        for(int j=0;j<k;j++){
            sub = (sub+comb(left,j)*comb(right,k-j-1)%mod)%mod;
        }*/
        ans=(ans-sub+mod)%mod;
        //(j文字,(2回現れる文字),(k-j)文字)というパターンの引き算が残っていた
        if(k==1) ans=N;
        if(k==N+1) ans=1;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3584
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

    static class Pos {
        public int x;
        public int prev;

        public Pos(int x, int prev) {
            this.x = x;
            this.prev = prev;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[m];
        int[] b = new int[m];
        int[] ans = new int[n + 1];
        Map<Integer, List<Integer>> map = new HashMap<>();
        for (int i = 1; i <= n; i++) {
            map.put(i, new ArrayList<>());
        }
        for (int i = 0; i < m; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            List<Integer> alist = map.get(a[i]);
            alist.add(b[i]);
            map.put(a[i], alist);
            List<Integer> blist = map.get(b[i]);
            blist.add(a[i]);
            map.put(b[i], blist);
        }

        List<Integer> oneList = map.get(1);
        Deque<Pos> queue = new ArrayDeque<>();
        for (int i = 0; i < oneList.size(); i++) {
            queue.add(new Pos(oneList.get(i), 1));
        }
        while (!queue.isEmpty()) {
            int size = queue.size();
            for (int i = 0; i < size; i++) {
                Pos pos = queue.poll();
                int num = pos.x;
                int prev = pos.prev;

                if (ans[num] != 0) {
                    continue;
                }
                ans[num] = prev;
                List<Integer> l = map.get(num);
                for (int j = 0; j < l.size(); j++) {
                    queue.add(new Pos(l.get(j), num));
                }
            }
        }

        for (int i = 2; i <= n; i++) {
            if (ans[i] == 0) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
        for (int i = 2; i <= n; i++) {
            System.out.println(ans[i]);
        }
    }

}


Measured memory_bytes: 90200
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	char a,b;
	cin>>a>>b;
	if(a=='H'){
		ce(b)
	}else{
		if(b=='H'){
			ce(a)
		}else{
			ce('H')
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo 1e18
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vs vector<string>



using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=1e2+10,mod=1e9+7;
int main ()
{
    FASTIO
    ll n ;
    cin >> n;
    string s;
    cin >> s;
    if(n>=s.si)return cout << s << endl,0;
    for(int i=0;i<n;i++)cout << s[i];
    if(s.si>n)cout << "...";
    return 0;
}
/**

*/


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
typedef long long ll;
const int mod = 1e9 + 7;

template <class T>
T gcd(T a, T b) {

    if(b == 0){
        return a;
    }
    else{
        gcd(b, a%b);
    }
}
template <class T>
T lcm(T a, T b){

    T g = gcd(a, b);

    return a / g * b;
}
int main() {

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

    ll x = b - a + 1;
    ll l = lcm(c, d);

    ll ans = x - (b/c - (a-1)/c) - (b/d - (a-1)/d) + (b/l - (a-1)/l);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		if (k == 1) {
			System.out.println(0);
		} else {
			System.out.println(n - k);
		}
	}
}


Measured memory_bytes: 21716
#include <stdio.h>
#include <set>
using namespace std;
int main(){
int n,m,k;
  set<int> s,b,temp;
  scanf("%d%d",&n,&m);
  n--;
  scanf("%d",&k);
  while(k--){
  scanf("%d",&m);
    s.insert(m);
  }
  while(n--){
  scanf("%d",&k);
    b.clear();
    while(k--){
    scanf("%d",&m);
      b.insert(m);
    }
    temp.clear();
    for(int i:s)if(b.find(i)==b.end())temp.insert(i);
    for(int i:temp)s.erase(i);
  } 
  printf("%d\n",(int)s.size());
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	string s,t;
	int i,cnt=0;
	cin>>s>>t;
	for(i=0;i<s.size();i++){
		if(s[i] == t[i]){
			//do nothing
		}
		else{
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3444
def sol(x,m):
	if x<=0:
		return 0
	else:
		return x//m

a,b,n = map(int,input().split())
if a==0:
	print(sol(b,n)+1)
# elif a==1:
# 	print(sol(b,n))
else:
	print(sol(b,n)-sol(a-1,n))

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
int A,B,a,b,num;
cin>>A>>B;
num=(A+B)/2;
a=A-num;
b=B-num;
if(abs(a)==abs(b))
cout<<num<<endl;
else
cout<<"IMPOSSIBLE"<<endl;
return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

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

int n;
ll a[100010],b[100010];
const int MOD=1e9+7;
ll ans=1;

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

	cin>>n;
	FOR(i,1,n+1) cin>>a[i];
	FOR(i,1,n+1) cin>>b[i];

	if(a[n]!=b[1]) {
		cout<<0<<endl;
		return 0;
	}

	FOR(i,1,n+1) {
		if(a[i]==a[i-1]) {
			if(b[i]==b[i+1]) {
				ans*=min(a[i],b[i]);
				ans%=MOD;
			}
			else {
				if(b[i]>a[i]) {
					cout<<0<<endl;
					return 0;
				}
				ans*=1;
			}
		}
		else {
			if(a[i]>b[i]) {
				cout<<0<<endl;
				return 0;
			}
			if(b[i]==b[i+1]) {
				ans*=1;
			}
			else {
				if(a[i]!=b[i]) {
					cout<<0<<endl;
					return 0;
				}
				ans*=1;
			}
		}
	}
	cout<<ans%MOD<<endl;

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;
int fa[maxn];
struct Node {
    ll x, y, id;
} st[maxn];

struct Edge {
    ll cost, p1, p2;
} edge[maxn * 2];

int cmp1(Node a, Node b)
{
    return a.x < b.x;
}
int cmp2(Node a, Node b)
{
    return a.y < b.y;
}
int cmp3(Edge a, Edge b)
{
    return a.cost < b.cost;
}
int find(int u)
{
    if (fa[u] == u)
        return fa[u];
    return fa[u] = find(fa[u]);
}
int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%lld%lld", &st[i].x, &st[i].y);
        st[i].id = i;
        fa[i] = i;
    }
    sort(st + 1, st + 1 + n, cmp1);
    int cnt = 0;
    for (int i = 2; i <= n; i++) {
        edge[++cnt].p1 = st[i - 1].id;
        edge[cnt].p2 = st[i].id;
        edge[cnt].cost = st[i].x - st[i - 1].x;
    }
    sort(st + 1, st + 1 + n, cmp2);
    for (int i = 2; i <= n; i++) {
        edge[++cnt].p1 = st[i - 1].id;
        edge[cnt].p2 = st[i].id;
        edge[cnt].cost = st[i].y - st[i - 1].y;
    }
    sort(edge + 1, edge + 1 + cnt, cmp3);
    ll ans = 0;
    int num = 0;
    for (int i = 1; i <= cnt; i++) {
        int fa_p1 = find(edge[i].p1);
        int fa_p2 = find(edge[i].p2);
        if (fa_p1 == fa_p2)
            continue;
        else {
            fa[fa_p1] = fa_p2;
            num++;
            ans += (edge[i].cost);
        }
        if (num == n - 1)
            break;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 7680
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}
		
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] * 4 * m >= sum) {
				cnt++;
			}
		}
		
		String ans = cnt >= m ? "Yes" : "No";
		System.out.println(ans);
	}
}


Measured memory_bytes: 23252
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
const ll MOD = 998244353;

int main() {
    ll n;
    cin >> n;
    vector<ll> as(n);
    vector<ll> bs(n);
    for (ll i = 0; i <n; ++i) {
        cin >> as[i];
        bs[i] = as[i];
    }
    sort(bs.begin(), bs.end());
    for (auto &a: as) {
        if (a == bs[n-1]) {
            cout << bs[n-2] << endl;
        } else {
            cout << bs[n-1] << endl;
        }
    }
}


Measured memory_bytes: 4736
list = {}
for a in range(1, int(input()) + 1) : list[a] = a
for a in range(int(input())) :
    x, y = [int(temp) for temp in input().split(',')]
    temp = list[x]
    list[x] = list[y]
    list[y] = temp
for a in range(1, len(list) + 1) : print(list[a])

Measured memory_bytes: 7552
arr = gets.chop.split.map(&:to_i)
if (arr[0] == arr[2] && arr[0] != arr[1]) || (arr[0] == arr[1] && arr[0] != arr[2]) || (arr[0] != arr[1] && arr[1] == arr[2])
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 1788
fn read1<T: std::str::FromStr>() -> T {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        s.trim().parse().ok().unwrap()
    }
     
    fn main() {
        let v = vec![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];
        let k = read1::<usize>();
        println!("{}", v[k-1]);
    }

Measured memory_bytes: 4352
#include "bits/stdc++.h"

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

//constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;


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

	cin>>N>>M;
	vector<vector<int>>edge(N+1);
	vector<vector<int>>rev(N+1);
	vector<vector<int>>box(N+1,vector<int>(N+1));
	for(int i=0;i<M;i++){
		cin>>L>>R;
		edge[L].push_back(R);
		box[L][R]=1;
		rev[R].push_back(L);
	}
	int ans=MOD;
	for(int i=1;i<=N;i++){
		vector<int>dis(N+1,MOD);
		dis[i]=0;
		queue<int>Q;
		Q.push(i);
		while(!Q.empty()){
			int cn=Q.front();
			Q.pop();
			for(auto j:edge[cn]){
				if(dis[j]>dis[cn]+1){
					dis[j]=dis[cn]+1;
					Q.push(j);
				}
			}
		}
		for(int j=1;j<=N;j++){
			if(dis[j]!=MOD&&box[j][i]){
				ans=min(ans,dis[j]);
			}
		}
	}
	for(int i=1;i<=N;i++){
		vector<int>dis(N+1,MOD);
		dis[i]=0;
		queue<int>Q;
		Q.push(i);
		while(!Q.empty()){
			int cn=Q.front();
			Q.pop();
			for(auto j:edge[cn]){
				if(dis[j]>dis[cn]+1){
					dis[j]=dis[cn]+1;
					Q.push(j);
				}
			}
		}
		for(int j=1;j<=N;j++){
			if(dis[j]!=MOD&&box[j][i]&&dis[j]==ans){
				vector<int>ret;
				int cn=j;
				ret.push_back(i);
				while(cn!=i){
					for(auto k:rev[cn]){
						if(dis[k]+1==dis[cn]){
							ret.push_back(cn);
							cn=k;
							break;
						}
					}
				}
				reverse(ret.begin(),ret.end());
				cout<<ret.size()<<endl;
				for(auto k:ret){
					cout<<k<<endl;
				}
				return 0;
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 4352
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    string s;
    cin >> s;
    if (s[0] == s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    //cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main()
{
  long int x, y, d1=1000, d2=1, m=1000;
  
  scanf("%ld", &x);
  while(x/d2 > 100){
    y = x % d1 / d2; 
    if(abs(753-y) < m){
      m = abs(753-y);
    }
    d1 *= 10;
    d2 *= 10;
  }
  printf("%d\n", m);
  
  return 0;
}

Measured memory_bytes: 128
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: String = input();
    println!(
        "{}",
        if n == n.chars().rev().collect::<String>() {
            "Yes"
        } else {
            "No"
        }
    );
}


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

int32_t main()
{
  int n,k;
  cin>>k>>n;
  int sum=0;
  int a[n];
  int d[n];
  for(int i=0;i<n;i++){
      cin>>a[i];
  }
  for(int i=1;i<n;i++){
      d[i-1]=a[i]-a[i-1];
  }
  d[n-1]=(k-a[n-1])+(a[0]);
  sort(d,d+n);
  for(int i=0;i<n;i++){
      sum+=d[i];
  }
  cout<<sum-d[n-1]<<endl;

}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define P(x) cout << (x) << "\n"
#define D(x) cerr << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

using i64=long long int; // 10^18
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int n,m;
int x[100001], y[100001], z[100001];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>m;
    UnionFind tree(n+1);
    for(int i=0;i<m;i++){
        cin>>x[i]>>y[i]>>z[i];
        tree.unite(x[i], y[i]);
    }
    set<int> sss;
    for(int i=1;i<=n;i++){
        sss.insert(tree.root(i));
    }
    P((int)sss.size());
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;

const int N = 1e6+5;

unordered_map <int, int> prcnt;
int lp[N], n, vvod, pair_copr, set_copr;
vector <int> pr, lispr, mas;

void fact( int chis ) {
    if( chis <= 1 ) {
        return;
    }

    lispr.push_back( lp[chis] );

    fact( chis / lp[chis] );
}

int main()
{
    ios_base::sync_with_stdio(0);
    //freopen( "input.txt", "r", stdin );

    for( int i = 2; i <= N; i++ ) {
        if( lp[i] == 0 ) {
            lp[i] = i;
            pr.push_back( i );
        }

        for( int j = 0; j < int(pr.size()) && pr[j] <= lp[i] && i * pr[j] <= N; j++ ) {
            lp[i * pr[j]] = pr[j];
        }
    }

    cin >> n;

    for( int i = 0; i < n; i++ ) {
        cin >> vvod;

        mas.push_back( vvod );
    }

    for( auto i : mas ) {
        lispr = {};
        fact( i );
        if( lispr.size() ) {
            prcnt[lispr[0]]++;
            for( int j = 0; j < int(lispr.size())-1; j++ ) {
                if( lispr[j+1] != lispr[j] ) {
                    prcnt[lispr[j+1]]++;
                }
            }
        }
    }

    for( auto i : prcnt ) {
        if( i.s > 1 ) {
            pair_copr = 1;
        }

        if( i.s == n ) {
            set_copr = 1;
        }
    }

    if( !pair_copr ) {
        cout << "pairwise coprime";
    } else {
        if( !set_copr ) {
            cout << "setwise coprime";
        } else {
            cout << "not coprime";
        }
    }

    return 0;
}


Measured memory_bytes: 14716
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
long long int a[200001],sa[200002];
int main(void)
{
	int n,q,s,t,i,j,l,r,x;
	long long psum,msum,tem;
	scanf("%d %d %d %d",&n,&q,&s,&t);
	for(i=0;i<=n;i++)	scanf("%lld",&a[i]);
	sa[0]=0;
	for(i=1;i<=n;i++)	sa[i]=a[i]-a[i-1];
	psum=0;	msum=0;
	for(i=1;i<=n;i++)	{
		if(sa[i]<0)	msum+=sa[i];
		else psum+=sa[i];
	}
//	printf("%lld %lld\n",psum,msum);
	for(i=0;i<q;i++)	{
		scanf("%d %d %d",&l,&r,&x);
		if(sa[l]>=0)	{
			if(x+sa[l]>=0)	{
				psum+=x;	sa[l]+=x;
			}
			else {
				psum-=sa[l];	msum+=sa[l]+x;	sa[l]+=x;
			}
		}
		else {
			if(x+sa[l]>=0)	{
				msum-=sa[l];	psum+=sa[l]+x;	sa[l]+=x;
			}
			else {
				msum+=x;	sa[l]+=x;
			}
		}
		x=-x;
		if(r+1<=n)	{
			if(sa[r+1]>=0)	{
				if(x+sa[r+1]>=0)	{
					psum+=x;	sa[r+1]+=x;
				}
				else {
					psum-=sa[r+1];	msum+=sa[r+1]+x;	sa[r+1]+=x;
				}
			}
			else {
				if(x+sa[r+1]>=0)	{
					msum-=sa[r+1];	psum+=sa[r+1]+x;	sa[r+1]+=x;
				}
				else {
					msum+=x;	sa[r+1]+=x;
				}
			}
		}
		
		tem=-psum*s-msum*t;
		printf("%lld\n",tem);
//		printf("%lld %lld\n",psum,msum);
	}
	return 0;
}


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

#define ll long long int
#define hell 1000000007
#define vi vector <ll>
#define pb push_back
#define pii pair<ll,ll>
#define vii vector <pii>
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define sep(i,a,b)  for(ll i=a-1;i>=b;i--)
#define inf (ll)(1e16)

using namespace std;

long double helper(vector <long double> &a,ll st,ll c,vector < vector <long double> > &dp)
{
    ll n=a.size();
    if(st>=n||c>n-st)
        return 0.0;
    if(st==n-1&&c==1)
        return a[st];
    else if(st==n-1&&c<=0)
        return 1.0-a[st];
    if(dp[st][c]!=-1)
        return dp[st][c];
    long double ans=0;
    ans+=((long double)1.0-a[st])*helper(a,st+1,c,dp);
    ans+=a[st]*helper(a,st+1,c-1,dp);
    return dp[st][c]=ans;
}

void solve()
{
    ll n;
    cin>>n;
    cout<<fixed<<setprecision(10);
    vector <long double> a(n);
    rep(i,0,n)
        cin>>a[i];
    vector < vector <long double> > dp(n+2,vector <long double> (n+2,0.0));
    long double ans=0;
    rep(i,0,n+1)
    {
        rep(j,0,n+1)
        {
            if(i==0&&j==0)
                dp[i][j]=1.0;
            else if(i==0)
                dp[i][j]=0;
            else if(j==0)
                dp[i][j]=dp[i-1][j]*(1.0-a[i-1]);
            else
                dp[i][j]=dp[i-1][j]*(1.0-a[i-1])+a[i-1]*dp[i-1][j-1];
            if(j>n/2)
            ans+=dp[n][j];
        }
    }
    cout<<ans;
}

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


Measured memory_bytes: 141184
open Printf
open Scanf

let solve a b c k =
  let rec f x y z = if x < y then (y, z) else f x (y * 2) (z + 1) in
  let (b2, k2) = f a b 0 in
  let (_, k3) = f b2 c k2 in
  if k >= k3 then "Yes" else "No"

let () =
  scanf "%d %d %d %d " solve |> printf "%s\n"


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

int main() {
	int n; cin >> n;
	int arr[n];
	for (int i = 0; i < n; i++) cin >> arr[i];
	int able = 1;
	arr[0]--;
	for (int i = 1; i < n; i++) {
		if (arr[i] > arr[i - 1]) arr[i]--;
	}
	for (int i = 0; i < n - 1; i++) {
		if (arr[i] - arr[i + 1] > 0) {
			able = 0;
			break;
		}
	}
	if (able) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
string a[100001];int n,l;
bool cmp(string b,string y)
{
	return b<y;
}
int main()
{
    cin>>n>>l; 
    for(int i=1;i<=n;i++)
    cin>>a[i];
    sort(a+1,a+1+n,cmp); 
    for(int i=1;i<=n;i++)
    cout<<a[i];
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <sstream>

using namespace std;


int main()
{
	// Input
	string str;
	int N;
	getline(cin,str);
	N = stoi(str);
	vector<int> subordinates = vector<int>(N + 1, 0);
	getline(cin, str);

	// Parse
	int len = str.length();
	int idx = 0;
	int start = 0;
	while (start < len)
	{
		int size = 1;
		while (idx < len && !isspace(str.at(idx++))) ++size;
		int boss = stoi(str.substr(start, size));
		subordinates[boss] += 1;
		start = idx;
	}

	// Print
	stringstream ss;
	for (int i = 1; i < N; ++i)
	{
		ss << subordinates[i] << endl;
	}
	ss << subordinates[N];
	cout << ss.str();
}

Measured memory_bytes: 6352
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top, s[200];
void push(int x)
{
    top++;
    s[top]=x;
}
int pop(void)
{
    top--;
    return s[top+1];
}
int main()
{
    int a, b, i;
    char str[100];
    top=0;

	for(i=0;;i++)
	{
		scanf("%c", &str[i]);
		if((str[i]-32)==0) break;
	}
    while((str[i]-10)!=0)
    {
        if(str[0]=='+')
        {
            a=pop();
            b=pop();
            push(a+b);
        }
        else if(str[0]=='-')
        {
            a=pop();
            b=pop();
            push(b-a);
        }
        else if(str[0]=='*')
        {
            a=pop();
            b=pop();
            push(a*b);
        }
        else if(str[0]=='/')
        {
            a=pop();
            b=pop();
            push(b/a);
        }
        else
            push(atoi(str));

		for(i=0;;i++)
		{
			scanf("%c", &str[i]);
			if((str[i]-32)==0 || (str[i]-10)==0) break;
		}
    }
    if(str[0]=='+')
    {
        a=pop();
        b=pop();
        push(a+b);
    }
    else if(str[0]=='-')
    {
        a=pop();
        b=pop();
        push(b-a);
    }
    else if(str[0]=='*')
    {
        a=pop();
        b=pop();
        push(a*b);
    }
    else if(str[0]=='/')
    {
        a=pop();
        b=pop();
        push(b/a);
    }
    else
        push(atoi(str));

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

    return 0;
}

Measured memory_bytes: 548