akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const ll MOD = 1000000007LL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
int vis[200005];
vector<int> g[200005];
int cnt[200005];
int group = 0;
void dfs(int u) {
  vis[u] = 1;
  cnt[group]++;
  for (int v : g[u]) {
    if (!vis[v])
      dfs(v);
  }
}
int main() {
  IOS;
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].pb(v);
    g[v].pb(u);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      group++;
      dfs(i);
    }
  }
  cout << *max_element(cnt, cnt + 200005) << endl;
}


Measured memory_bytes: 21516
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MOD = 1e9 + 7;struct ModularInt{int n;ModularInt(int n_=0):n(n_){}};
ModularInt operator-(ModularInt a){return -a.n+MOD*(a.n!=0);}
ModularInt operator+(ModularInt a,ModularInt b){int x=a.n+b.n;return x-(x>=MOD)*MOD;}
ModularInt operator-(ModularInt a,ModularInt b){int x=a.n-b.n;return x+(x<0)*MOD;}
ModularInt operator*(ModularInt a,ModularInt b){return (long long)a.n*b.n%MOD;}
ModularInt &operator+=(ModularInt &a,ModularInt b){return a=a+b;}
ModularInt &operator-=(ModularInt &a,ModularInt b){return a=a-b;}
ModularInt &operator*=(ModularInt &a,ModularInt b){return a=a*b;}
istream &operator>>(istream &i,ModularInt &a){return i>>a.n;}
ostream &operator<<(ostream &o,ModularInt a){return o<<a.n;}

int N, K;
vector <int> G[1000005];

ModularInt answer = 1;

void dfs(int v, int depth, int p = -1) {
  int kids_count = 0;
  for(auto u: G[v]) if(u != p) {
    answer *= max(0, K - (kids_count++) - min(2, (depth + 1)));
    dfs(u, depth + 1, v);
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin >> N >> K;
  for(int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(1, 0);
  answer *= K;
  cout << answer << endl;
}


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

typedef long long ll;
const int MAXN = 100010;

int n, s; ll x[MAXN], p[MAXN], ans[MAXN];
vector< pair<int, int> > G[MAXN];

inline void add(int u, int v, int w)
{
	G[u].push_back(make_pair(v, w));
}

void dfs(int x)
{
	for(int i = 0; i < (int)G[x].size(); ++i)
	{
		pair<int, int> y = G[x][i];
		ans[y.first] = ans[x] + y.second;
		dfs(y.first);
	}
}

int main()
{
	scanf("%d %d", &n, &s);
	for(int i = 1; i <= n; ++i) scanf("%lld %lld", &x[i], &p[i]);
	int l = 1, r = n;
	while(l < r)
	{
		if(x[l] >= s) add(l, l + 1, x[l + 1] - x[l]), ++l;
		else if(x[r] <= s) add(r, r - 1, x[r] - x[r - 1]), --r;
		else if(p[l] >= p[r]) add(l, r, x[r] - x[l]), p[l] += p[r], --r;
		else add(r, l, x[r] - x[l]), p[r] += p[l], ++l;
	}
	ans[l] = abs(s - x[l]); dfs(l);
	printf("%lld\n", max(ans[1], ans[n]));
	return 0;
}

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

int main(){
    int n, sum;
    cin >> n >> sum;
    int x, y, z;
    for(x = 0; x <= n; ++x){
        for(y = 0; y <= n; ++y){
            int left = sum - 10000*x - 5000*y;
            if(left%1000==0){
                z = left / 1000;
                if(x + z + y == n && z>=0){
                    printf("%d %d %d", x, y, z);
                    return 0;

                }
                
            }
            
        }
    }
    printf("-1 -1 -1");
    return 0;
}

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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    int N;
    cin >> N;
    vector<char> S(N);
    for(int i = 0; i < N; i++) cin >> S[i];
    vector<int> cnt(N);
    for(int i = 1; i < N; i++){
        if(S[i] == 'E') cnt[0]++;
    }
    for(int i = 1; i < N; i++){
        cnt[i] = cnt[i - 1];
        if(S[i] == 'E') cnt[i]--;
        if(S[i - 1] == 'W') cnt[i]++;
    }
    int min_n = I_INF;
    for(int a : cnt){
        min_n = min(min_n, a);
    }
    cout << min_n << endl;
}

Measured memory_bytes: 1792
n = int(input())
b = [int(i) for i in input().split()]
ans = []

for j in range(n):
    for i in range(len(b), 0, -1):
        try:
            if b[i-1] == i:
                b.pop(i-1)
                ans.append(i)
                break
        except: pass 
            
if len(b) == 0:
    [print(ans[-i-1]) for i in range(n)]
else:
    print(-1)

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

template <class T>
void print(T t){
    std::cout<<t<<std::endl;
}
template <class T>
void print(std::vector<T> t){
    for(auto& s : t) std::cout<<s<<",";
    std::cout<<std::endl;
}

using namespace std;
typedef long int ll;

int main(){
    int n;
    vector<ll> a,b,c;
    vector<int> ar,br;

    // input
    cin >> n;
    a.resize(n);
    b.resize(n);
    c.resize(n);
    ar.reserve(n);
    br.reserve(n);
    for(int i=0;i<n;++i) cin >> a[i];
    for(int i=0;i<n;++i) cin >> b[i];
    for(int i=0;i<n;++i) cin >> c[i];

    // calc
    sort(a.begin(),a.end(), std::greater<ll>());
    sort(b.begin(),b.end(), std::greater<ll>());
    sort(c.begin(),c.end(), std::greater<ll>());
    int ai=0,bi=0,ci=0;
    while(bi!=n){
        if(b[bi] >= c[ci]){
            br.emplace_back(ci);
            ++bi;
            continue;
        }
        if(ci == n){
            br.emplace_back(ci);
            ++bi;
            continue;
        }else{
            ++ci;
        }
    }
    ai=0,bi=0,ci=0;
    while(ai!=n){
        if(a[ai] >= b[bi]){
            ar.emplace_back(bi);
            ++ai;
            continue;
        }
        if(bi == n){
            ar.emplace_back(bi);
            ++ai;
            continue;
        }else{
            ++bi;
        }
    }
    ll sum = 0;
    vector<ll> su;
    su.resize(n);
    for(int i=0;i<n;++i){
        sum += br[i];
        su[i] = sum;
    }
    sum = 0;
    for(auto ad : ar){
        if(ad!=0) sum += su[ad-1];
    }

    // output
    /*print(n);
    print(a);
    print(b);
    print(c);
    print(ar);
    print(br);*/
    print(sum);
}

Measured memory_bytes: 4224
import bisect


def LI():
    return list(map(int, input().split()))


N = int(input())
L = LI()
L.sort()
ans = 0
for i in range(N-1, 1, -1):
    for j in range(i-1, 0, -1):
        ind = bisect.bisect_right(L, L[i]-L[j])
        if ind < j:
            ans += j-ind
print(ans)


Measured memory_bytes: 9320
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b) //最大公約数
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

ll lcm(ll a, ll b) //最小公倍数
{
	return a * b / gcd(a, b);
}

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);
	return s + n;
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}

// ===============================================================

int main() {
	ll a; cin >> a;
	ll b = a / 100;
	ll c = a % 100 / 10;
	ll d = a % 10;
	if (b == 7 || c == 7 || d == 7) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

Measured memory_bytes: 3496
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  ll X, K, D;
  cin >> X >> K >> D;
  if (X < 0) X = -X;
  ll q = X / D;
  ll r = X % D;
  if (K >= q) K -= q;
  else {
    cout << X - D * K << endl;
    return 0;
  }
  if (K % 2) {
    cout << D - r << endl;
  } else {
    cout << r << endl;
  }
}


Measured memory_bytes: 3616
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
	
	Scanner stdIn = new Scanner(System.in);
	
	int n = stdIn.nextInt();
	int[] h = new int[n];
	int max;
	int count = 1;
	for (int i = 0; i < n; i++) {
		h[i] = stdIn.nextInt();
	}
	
	max = h[0];
	
	for (int i = 1; i < n; i++) {
		if (h[i] >= max) {
			max = h[i];
			count++;
		}
	}
	
	System.out.println(count);
	
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	int mi = 1005, ma = -1;
	FOR(i, n) {
		int a;
		cin >> a;
		mi = min(mi, a);
		ma = max(ma, a);
	}
	cout << ma - mi << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    ll y[x];
    for (int i=0;i<x;i++)
        cin>>y[i];
    ll ans=1000;
    for (int i=1;i<x;i++){
        if (y[i]>y[i-1]){
            ans=(ans/y[i-1])*y[i]+(ans%y[i-1]);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string a,b;
    cin >> a >>b;
    string w=a+b;
    for(int i=1;i*i<=100100;i++){
        string ans = to_string(i*i);
        if(ans.size()==w.size()){
            rep(j,ans.size()){
                if(w[j]!=ans[j]){
                    break;
                }
                else{
                    if(j==ans.size()-1){
                        cout << "Yes";
                        return 0;
                    }
                }
            }
            
        }
    }

    cout << "No";

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
def I(): return(list(map(int,input().split())))
def sieve(n):
	a=[1]*n
	for i in range(2,n):
	    if a[i]:
	        for j in range(i*i,n,i):
	            a[j]=0
	return a

a,b,c,k=I()
print(min(a-(k-(a+b)),k))
	





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

using namespace std;

int main(){
	int n; cin >> n;
	vector<int> ru(n,-1);
	for(int i = 0; i < n; ++i){
		int temp; cin >> temp;
		ru[i] = --temp;
	}
	int ans = 0;
	for(int i = 0; i < n; ++i){
		if(ru[i] == -1)continue;
		int l = ru[i];
		if(ru[l] == i){
			ans++;
			ru[i] =-1;
			ru[l] = -1;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
def red_to_row(cs, i)
  cs[i] = "x" * cs[i].size
end

def red_to_col(cs, i)
  cs.size.times do |j|
    cs[j] = cs[j][0...i] + "x" + cs[j][i+1...cs[j].size]
  end
end

def main
  h,w,k = gets.chomp.split(" ").map(&:to_i)
  cs = []
  h.times do
    line = gets.chomp
    cs.push line
  end
  ans = 0

  [0,1].repeated_permutation(h+w) do |combination|
    cs_copy = Marshal.load(Marshal.dump(cs))
    (0...h).each do |i|
      red_to_row(cs_copy, i) if combination[i] == 1
    end
    (h...h+w).each do |i|
      red_to_col(cs_copy, i-h) if combination[i] == 1
    end

    cnt = 0
    cs_copy.size.times do |i|
      cnt += cs_copy[i].count('#')
    end
    ans += 1 if cnt == k
  end
  puts ans
end

main



Measured memory_bytes: 14348
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <cassert>
#include <algorithm>
using namespace std;

#define DEBUG (0)

#if DEBUG
#define DPRINTF(...)  printf("D(L%d) %s: ", __LINE__, __func__); printf(__VA_ARGS__)
#else
#define DPRINTF(...)
#endif // DEBUG

bool binarySearch(const int array[], const int start, const int end, const int val)
{
  DPRINTF("START %d  END %d\n", start, end);

  if (start > end)
    return false;

  int mid = (start + end) / 2;

  if (val == array[mid])
    return true;
  else if (val > array[mid])
    return binarySearch(array, mid + 1, end, val);
  else // (val < array[mid]
    return binarySearch(array, start, mid - 1, val);
}


int main() {
  int numOfS, numOfT;

  cin >> numOfS; cin.ignore();
  int s[numOfS];
  for (int i = 0; i < numOfS; i++) {
    cin >> s[i];
  }


  cin >> numOfT; cin.ignore();
  int t[numOfT];
  for (int i = 0; i < numOfT; i++) {
    cin >> t[i];
  }

#if DEBUG
  DPRINTF("ARRAY S :");
  for (int i = 0; i < numOfS; i++)
    cout << " " << s[i];
  cout << endl;

  DPRINTF("ARRAY T :");
  for (int i = 0; i < numOfT; i++)
    cout << " " << t[i];
  cout << endl;
#endif

  // We can assume that all elements in S is sorted in asceding order
  int count = 0;
  for (int i = 0; i < numOfT; i++) {
    if (binarySearch(s, 0, numOfS - 1, t[i]))
      count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }


main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    map <int, int> nice;
    for (int i = 0, a, b; i < m; i++) {
        cin >> a >> b;
        --a;
        if (nice.count(a)) {
            if (nice[a] != b) {
                cout << "-1\n";
                rr;
            }
        }
        nice[a] = b;
    }
    if (nice.count(0) && nice[0] == 0) {
        if (sz(nice) > 1 || n > 1) {
            cout << "-1\n";
            rr;
        }
        cout << "0\n";
        rr;
    }
    if (n == 1 && m == 0) {
        cout << "0\n";
        rr;
    }
    if (!nice.count(0)) nice[0] = 1;
    cout << nice[0];
    int mx = 0;
    for (auto &i : nice) umax(mx, i.x);
    for (int i = 1; i < n; i++) {
        if (!nice.count(i)) nice[i] = 0;
        cout << nice[i];
    }
    cout << '\n';
}


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

int N;
int L[210];



int main()
{
	cin >> N;
	for(int i=0;i<N*2;++i) cin >> L[i];
	sort(L,L+N*2);
	int ans = 0;
	for(int i=0;i<N;++i){
		ans += L[i*2];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
Taro, Hanako = 0, 0

for i in range(N):
    temp_data = list(map(str, input().split()))
    TEMP_data = temp_data.copy()
    TEMP_data.sort(reverse=True)
    if temp_data[0] == temp_data[1]:
        Taro += 1
        Hanako += 1
    else:
        if temp_data[0] == TEMP_data[0]:
            Taro += 3
        elif temp_data[1] == TEMP_data[0]:
            Hanako += 3

print(Taro, Hanako, sep=' ')


Measured memory_bytes: 5604
from typing import List, Tuple


def main():
    n, m = map(int, input().split())
    g = []
    for _ in range(m):
        a, b = map(int, input().split())
        g.append((a, b))
    print(osp(n, g))


def osp(n: int, g: List[Tuple[int, int]]) -> int:
    graph = [[False] * n for _ in range(n)]
    for a, b in g:
        graph[a - 1][b - 1] = True
        graph[b - 1][a - 1] = True
    v = [False] * n

    return dfs(0, v, n, graph)


def dfs(i, v, n, graph):
    v[i] = True
    if all(v):
        v[i] = False
        return 1

    cnt = 0
    for j in range(n):
        if v[j]:
            continue
        if not graph[i][j]:
            continue
        cnt += dfs(j, v, n, graph)

    v[i] = False
    return cnt


if __name__ == '__main__':
    main()


Measured memory_bytes: 10080
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;

using Graph = vector<vector<int>>;
ll modPow(ll x, ll n) {
    if(n==0) return 1;
    ll res = modPow(x*x%MOD, n/2);
    if(n&1) res=res*x%MOD;
    return res;
}
ll mul(ll l, ll r) {
    ll ret =1;
    for(int i=0; i<l-r+1; ++i) {
        ret*=i+r;
        ret%=MOD;
    }
    return ret;
}
ll com(ll n, ll k) {
    ll ret1 = mul(n,n-k+1);
    ll ret2 = mul(k,1);
    ll ret3 = modPow(ret2, MOD-2);
    return ret1*ret3%MOD;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; cin >> s;
    int n = s.size();
    string ss = s;
    reverse(all(ss));
    if (ss != s) {
        cout << "No" << "\n";
        return 0;
    }
    string sss;
    string ssss;
    rep(i,n) {
        if (i<=(n-1)/2-1) {
            sss += s[i];
        } else {
            ssss = s.substr((n+3)/2-1);
        }
    }
    if (sss==ssss) {
        cout << "Yes" << "\n";
        return 0;
    }
    cout << "No" << "\n";
}



Measured memory_bytes: 256
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        a: [usize;n],
        q: usize,
        operation: [(usize,usize);q]
    }

    let mut map = HashMap::new();

    let mut ans = 0;

    for &i in &a {
        let v = map.entry(i).or_insert(0);
        *v += 1;
        ans += i;
    }

    for &(target, after) in &operation {
        let target_count = map.get(&target);
        let mut count = 0;
        if target_count != None {
            let tmp_count = target_count.unwrap();
            ans -= tmp_count * target;

            let a = tmp_count.clone();
            count = a;

            map.insert(target, 0);
        }

        if count != 0 {
            ans += after * count;
            let after_num = map.entry(after).or_insert(0);
            *after_num += count;
        }

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

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 6780
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=1e5+10;
struct node{
	int x,id;
};
node w[MAXN];
ll a[MAXN],b[MAXN],c[MAXN],ans[MAXN];
int n,q,t;
bool cmp(node x,node y)
{
	return x.x<y.x;
}
int s1(int l,int r,int x)
{
	if (l>r) return n+1;
	int mid=(l+r)/2;
	if (a[mid]>=x) return min(mid,s1(l,mid-1,x));
	else return s1(mid+1,r,x);
}
bool pan(int now,int x,int y)
{
    if (y>1) {
    	int t1=s1(1,y-1,x-a[n-now]+x);
    	if (t1==n+1) t1=0; else t1=y-t1;
    	if (now>=(t1+n-now-y+1)) return 1; else return 0;
	}
	else return now*2>=n;
}
void s(int x,int y,int l,int r)
{
	if (l>r) return;
	int mid=(l+r)/2;
	if (pan(mid,x,y)) {
		t=min(t,mid); s(x,y,l,mid-1);
	}
	else s(x,y,mid+1,r);
}
int main()
{
	scanf("%d",&n);
	scanf("%d",&q);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for (int i=1;i<=q;i++) scanf("%d",&w[i].x),w[i].id=i;
	for (int i=1;i<=n;i++) b[i]=b[i-2]+a[i];
	c[n]=a[n];
	for (int i=n-1;i>=1;i--) c[i]=c[i+1]+a[i];
	sort(w+1,w+q+1,cmp);
	int l=1;
	t=n+1;
	for (int i=1;i<=q;i++) {
		while (l<=n&&w[i].x>a[l]) l++; 
		if (l<=n) {
			t=n+1;
			s(w[i].x,l,1,n-l+1);
			ans[w[i].id]=c[n-t+1]+(n>2*t?b[n-2*t]:0);
		}
		else ans[w[i].id]=b[n];
	}
	for (int i=1;i<=q;i++) printf("%lld\n",ans[i]);
}

Measured memory_bytes: 5632
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
import std.math;
void main()
{
    int A, B, C;
	auto input = readln.split.to!(int[]);
	A = input[0];
	B = input[1];
    C = input[2];
    if(A > B){
        writeln(0);
    }else if(B/A >C){
        writeln(C);
    }else{
        writeln(B/A);
    }
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int a, b; cin >> a >> b;
  cout << ((a*b%2==1) ? "Odd" : "Even") << endl;
}

Measured memory_bytes: 256
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	money = int(input())
	num_gohyaku = money // 500
	nokori = money%500
	num_five  = nokori // 5
	shiawase = num_gohyaku * 1000 + num_five * 5
	print(shiawase)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 38256
import bisect
n,k=map(int,input().split())
mod=10**9+7
a=list(map(int,input().split()))
c=sorted(a)
d=[0]*n
e=[0]*n
for i in range(n):
  d[i]=bisect.bisect_left(c,a[i])
for i in range(n):
  cnt=0
  for j in range(i,n):
    if a[i]>a[j]:
      cnt+=1
  e[i]=cnt
st=sum(e)*k%mod
ad=sum(d)%mod
print((st+(ad*(k-1)*k//2)%mod)%mod)

Measured memory_bytes: 43244
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

/* include file*/
#include <functional>
#include <vector>
using namespace std;

template <class Monoid>
struct Segment {
  using Func = function<Monoid(Monoid, Monoid)>;

  vector<Monoid> node;
  Monoid ide;
  int n = 1;

  Func bin_f;
  Func update_f;

  Segment(const vector<Monoid>& init, Monoid ide_, Func f_, Func u_f)
    : bin_f(f_), ide(ide_), update_f(u_f) {
      int sz = init.size();
      while (n < sz) n *= 2;
      node.assign(n * 2 - 1, ide);
      for (int i = 0; i < sz; i++) node[i + n - 1] = init[i];
      for (int i = n - 2; i >= 0; i--)
        node[i] = bin_f(node[i * 2 + 1], node[i * 2 + 2]);
    }

  void update(int i, Monoid x) {
    i += n - 1;
    node[i] = update_f(node[i], x);
    while (i) {
      i = (i - 1) / 2;
      node[i] = bin_f(node[i * 2 + 1], node[i * 2 + 2]);
    }
  }

  Monoid get_inter(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (a <= l && r <= b) return node[k];
    if (r <= a || b <= l) return ide;

    Monoid lm = get_inter(a, b, k * 2 + 1, l, (l + r) / 2);
    Monoid rm = get_inter(a, b, k * 2 + 2, (l + r) / 2, r);
    return bin_f(lm, rm);
  }
};

// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2730414#1
// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2730425#1

int N;
i64 K;
vector<i64> a;

int main(){
  cin >> N >> K;
  a.resize(N);
  rep(i,0,N - 1) cin >> a[i];
  rep(i,0,N - 1) a[i] -= K;
  rep(i,1,N - 1) a[i] += a[i - 1];
  vector<i64> vec;
  rep(i,0,N - 1) vec.push_back(a[i]);
  sort(vec.begin(),vec.end());

  Segment<i64> seg(vector<i64>(N,1),0,[](i64 a,i64 b){return a + b;},[](i64 node,i64 x){return node + x;});

  i64 now = 0;
  i64 res = 0;

  rep(i,0,N - 1){
    int index = lower_bound(vec.begin(),vec.end(),now) - vec.begin();
    res += seg.get_inter(index,N);
    now = a[i];
    seg.update(lower_bound(vec.begin(),vec.end(),now) - vec.begin(),-1);
  }

  cout << res << endl;
}


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

int main() {
  int i,City,Road;
  cin >> City >> Road;
  vector<int> Road_cnt(City);
  
  for(i=0; i<Road ; i++){
    int a,b;
    cin >> a >> b;
    Road_cnt.at(a-1)++;
    Road_cnt.at(b-1)++;
  } 
  for(i=0; i<City ; i++){
    cout << Road_cnt.at(i) << endl;
  }
}

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

int main(){
	char S[10];
  	char tmp[4];
  	int i,j,val;
  	int ans = 753;
  	gets(S);
  	for(i=0; i<strlen(S)-2; i++){
        tmp[0]= S[i];
      	tmp[1] = S[i+1];
      	tmp[2] = S[i+2];
      	
      	val = atoi(tmp);
      	if(fabs(val - 753) < ans){
          ans = fabs(val - 753);
        }
    }
  	printf("%d", ans);
}
      

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

using namespace std;

void solve()
{
	string str;
	while(cin >> str)
	{
		string Ans;
		int n = str.size();
		for(int i = 0; i < n; ++i)
		{
			if(str[i] == '@')
			{
				int length = str[i + 1] - '0';
				for(int j = 0; j < length; ++j)
				{
					Ans += str[i + 2];
				}
				i += 2;
			}
			else
			{
				Ans += str[i];
			}
		}
		cout << Ans << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI acos(-1.0)
#define sq(n) ((n)*(n))

using namespace std;
using ll = long long;

int main() {
    FAST;

    int a, b;
    cin >> a >> b;

    a *= b;
    cout << a;

    return 0;
}


Measured memory_bytes: 3652
from math import ceil

def enum_divisor(n):
    res = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i != 0:
            continue
        res.append(i)
        if i * i != n:
            res.append(n // i)
    return res

ans = 0
n = int(input())
for x in enum_divisor(n):
    if x == 1:
        continue
    tmp = n
    while tmp % x == 0:
        tmp //= x
    if tmp % x == 1:
        ans += 1

ans += len(enum_divisor(n - 1)) - 1
print(ans)

Measured memory_bytes: 3316
#include <stdio.h>
 
int main(void){
	double v,t,y,n1;
	int n;
	while(scanf("%lf",&v)!=EOF){
    	t=v/9.8;
    	y=4.9*t*t;
    	n=0;
    	n1=(5+y)/5;
    	while(n<n1){
    		n=n+1;
    	}
		printf("%d\n",n);
    }
	return 0;
}


//debug for alfa

Measured memory_bytes: 628
import math
n,a,b=map(int,input().split())

count=0
mod=1000000007

def C(n,a):
    x=1
    y=1
    for i in range(a):
        x*=n-i
        y*=i+1
        x%=mod
        y%=mod
    return x*pow(y,mod-2,mod)%mod

count+=pow(2,n,mod)
#print(count)
count-=1
count-=C(n,a)
#print(count)
count-=C(n,b)

print(max(0,(count)%mod))

Measured memory_bytes: 3064
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  string s;
  cin >> s;
  deque<char> a(s.begin(), s.end());
  int m;
  cin >> m;
  bool rev = false;
  while (m--) {
    int t, x;
    char c;
    cin >> t;
    if (t == 1) {
      rev ^= 1;
    } else {
      cin >> x >> c;
      x -= 1;
      x ^= rev;
      if (x == 0) {
        a.push_front(c);
      } else {
        a.push_back(c);
      }
    }
  }
  if (rev) reverse(a.begin(), a.end());
  for (auto& c : a) cout << c;
  cout << endl;
  return 0;
}


Measured memory_bytes: 976
import java.util.Scanner;

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

        String[] ans = new String[h + 2];

        for (int i = 0; i < h + 2; ++i) {
            ans[i] = "";
        }

        for (int i = 0; i < w + 2; ++i) {
            ans[0] += "#";
            ans[h+1] += "#";
        }

        for (int i = 1; i < h + 1; ++i) {
            ans[i] += "#";
            ans[i] += sc.next();
            ans[i] += "#";
        }

        for (int i = 0; i < h + 2; ++i) {
            System.out.println(ans[i]);
        }
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>
#include<map>

using namespace std;

int main()
{
	int n;
	cin >> n;
	set<int> st;
	vector<int> a;
	map<int,int> mp;
	for(int i=0;i<n;i++)
	{
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
		st.insert(tmp);
	}
	

	if(st.size()>3)cout << "No" << endl;
	else if(st.size()==3)
	{
		bool flag=true;


		int x[3];
		int j=0;
		for(auto itr=st.begin();itr !=st.end();itr++)
		{
			x[j]=*itr;
			mp[*itr]=0;
			j++;
		}
		for(int i=0;i<n;i++)
			mp[a[i]]++;
		
		if(mp[x[0]]!=mp[x[1]] or mp[x[1]]!=mp[x[2]] or mp[x[0]]!=mp[x[2]])
		{
			cout << "No" << endl;
			return 0;
		}

		int keta=0;
		while(true)
		{
			int cnt1=0;
			int cnt0=0;
			for(int i=0;i<3;i++)
			{
				if(x[i] & (1<<keta))cnt1++;
				else cnt0++;
			}
			if(cnt0==3 or (cnt1==2 and cnt0==1))
				;
			else
			{
				flag=false;
				break;
			}

			keta++;
			if((1<<keta)>x[0] and (1<<keta)>x[1] and (1<<keta)>x[2])break;
		}
		cout << (flag ? "Yes":"No") << endl;
	}
	else if(st.size()==2)
	{
		bool flag=true;


		int big;
		int small;
		big=a[0];
		for(int i=0;i<n;i++)
		{
			if(a[i]!=big)
			{
				small=a[i];
				break;
			}

		}
		
		mp[small]=0;
		mp[big]=0;
		
		for(int i=0;i<n;i++)
			mp[a[i]]++;
		if(mp[small]>mp[big])
		{
			int tmp=small;
			small=big;
			big=tmp;
		}
		if(mp[big]!=mp[small]*2)
		{
			cout << "No" << endl;
			return 0;
		}

		int keta=0;
		while(true)
		{
			int cnt1=0;
			int cnt0=0;
			for(int i=0;i<3;i++)
			{
				if(a[i] & (1<<keta))cnt1++;
				else cnt0++;
			}
			if(!(small & (1<<keta)) and (big & (1<<keta)))
				;
			else if(!(small & (1<<keta)) and !(big & (1<<keta)))
				;
			else
			{
				flag=false;
				break;
			}

			keta++;
			if((1<<keta)>small and (1<<keta)>big)break;
		}
		cout << (flag ? "Yes":"No") << endl;

	}
	else if(st.size()==1)
	{
		auto itr=st.begin();
		cout << (*itr==0 ? "Yes" : "No") << endl; 

	}

}

Measured memory_bytes: 4216
#include <stdio.h>

int main(void) {
	int n, money[101] = {0};
	scanf("%d", &n);
	
	money[4] = 1;
	money[7] = 1;
	for (int i = 8; i <= n; i++)
		if (money[i-4] == 1 || money[i-7] == 1)
			money[i] = 1;
	
	printf(money[n] ? "Yes" : "No");
	
	return 0;
}

Measured memory_bytes: 128
def TwoFactor(n):
    cnt = 0
    while n % 2 == 0:
        cnt += 1
        n /= 2
    return cnt


def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)


N, M = map(int, input().split())
a = list(map(int, input().split()))
cnt = TwoFactor(a[0])
for i in range(N):
    if cnt != TwoFactor(a[i]):
        print(0)
        exit()
lcm = a[0]
for i in range(1, N):
    g = gcd(lcm, a[i])
    lcm = lcm * a[i] // g
    if lcm / 2 > M:
        print(0)
        exit()
print(M // (lcm // 2) - M // lcm)


Measured memory_bytes: 15060
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <iostream>
#include <climits>
#include <cstring>
#include <functional>
using namespace std;

#define rep(i,N) for(int i = 0;i < N;++i)
using LL = long long;

typedef pair<LL, LL> P;

int N;
int C;
int tt[200002];
int s[100000];
int t[100000];
int c[100000];
int sm[200002];
int mx;

int main() {
	cin >> N >> C;
	rep(i, N) {
		cin >> s[i] >> t[i] >> c[i];
	}

	rep(i, C + 1) {
		rep(j, 200002) tt[j] = 0;
		rep(j, N) if (i == c[j]) { tt[2 * s[j] - 1]++; tt[t[j] * 2]--; }
		rep(j, 200001) tt[j + 1] += tt[j];
		rep(j, 200002) if (tt[j] > 0) sm[j]++;
	}
	rep(i, 200002) {
		if (mx < sm[i]) mx = sm[i];
	}
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 2944
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

const int sz = 1e6+5;
int f[sz];
int A[sz];
int cnt[sz];

void PreCompute() {
	f[0] = 1;
	f[1] = 1;
	for (int i = 2; i < sz; ++i) {
		if (f[i] == 0) {
			for (int j = i; j < sz; j += i) {
				f[j] = i;
			}
		}
	}
}

int main() {
	PreCompute();
	int N;
	sci(N);
	RESET(cnt);
	RESET(A);
	int GCD = 0;
	for (int i = 0; i < N; ++i) {
		sci(A[i]);
		GCD = __gcd(GCD, A[i]);
		int tmp = A[i];
		set<int> hit;
		while (tmp > 1) {
			hit.insert(f[tmp]);
			tmp /= f[tmp];
		}
		for (auto &it : hit) {
			++cnt[it];
		}
	}
	int MAX = *max_element(ALLN(cnt, sz));
	if (MAX <= 1) {
		puts("pairwise coprime");
	} else if (GCD == 1) {
		puts("setwise coprime");
	} else {
		puts("not coprime");
	}
	return 0;
}

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

int main() {
  int n,m; cin >>n >>m;
  vector<int> x(n, 0);
  rep(i,m){
    int a,b; cin >>a >>b;
    if(a==1) x[b]++;
    if(b==n) x[a]++;
  }
  for(int i = 2; i<n; i++){
    if(x[i]==2){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 4024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   ll t=1;
   //cin>>t;
   while(t--)
   {
       ll n,k;
       cin>>n>>k;
       ll a[n+1],i;
       for(i=0;i<n;i++)
        cin>>a[i];
       for(i=k;i<n;i++)
       {
           if(a[i]>a[i-k])
            cout<<"Yes"<<endl;
           else
            cout<<"No"<<endl;
       }
   }

}


Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define N 3005
#define endl "\n"
#define mod 1000000007
ll n; ld p[N],dp[N][N];
ld maxval(ll i,ll noof_head){
	if(i==n){
		if(noof_head>i-noof_head)
			return (ld)1.0;
		else 
			return (ld)0.0;
	}
	if(dp[i][noof_head]!=-1){
		return dp[i][noof_head];
	}
	
	ld h,t;
	h=maxval(i+1,noof_head)*((ld)1.0-p[i]);
	t=maxval(i+1,noof_head+1)*p[i];
	return dp[i][noof_head]=(h+t);
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	for(i=0;i<N;i++){
		for(j=0;j<N;j++){
			dp[i][j]=-1.0;
		}
	}
	cin>>n;
	for(i=0;i<n;i++){
		cin>>p[i];
	}
	
	ld v=maxval(0,0);
	cout<<setprecision(10)<<v;
	return 0;
}


Measured memory_bytes: 142208
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,k;
long long a[100000+10],pre[100000+10];
long long ans,sum,minn,maxx,want;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		sum+=a[i];
		pre[i]=pre[i-1]+a[i];
		if(a[i]>=0)want+=a[i];
	}
	//最后白：
//	for(int i=1;i+k-1<=n;i++){
//		long long judge=want;
//		for(int j=i;j<=i+k-1;j++){
//			if(a[j]>=0)judge-=a[j];
//		}
//		ans=max(ans,judge);
//	} 
	long long judge=want;
	for(int i=1;i<=k;i++)if(a[i]>=0)judge-=a[i];
	ans=max(ans,judge);
	for(int i=k+1;i<=n;i++){
		if(a[i-k]>=0)judge+=a[i-k];
		if(a[i]>=0)judge-=a[i];
		ans=max(ans,judge);
	}
	//最后黑：
//	 for(int i=1;i+k-1<=n;i++){
//		long long judge=want;
//		for(int j=i;j<=i+k-1;j++){
//			if(a[j]<0)judge+=a[j];
//		}
//		ans=max(ans,judge);
//	} 
	judge=want;
	for(int i=1;i<=k;i++)if(a[i]<=0)judge+=a[i];
	ans=max(ans,judge);
	for(int i=k+1;i<=n;i++){
		if(a[i-k]<=0)judge-=a[i-k];
		if(a[i]<=0)judge+=a[i];
		ans=max(ans,judge);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<map>

using namespace std;
#define mod 1000000007
#define ll long long 




int arr[100009];
int dp[100009];
int n, k;

int solve(int idx) {
	
	if(idx == n - 1)
		return 0;

	if(dp[idx] != -1)
		return dp[idx];

	int ans = INT_MAX;

	for(int i = 1; i <= k; i++) {
		if(idx + i >= n) break;
		ans = min(ans, solve(idx + i) + abs(arr[idx + i] - arr[idx]));
	}

	return dp[idx] = ans;
}


int main() {

	memset(dp, -1, sizeof(dp));
	cin>>n>>k;

	for(int i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
	}

	cout<<solve(0)<<endl;

	return 0;
}

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


void solve(long long A, long long B, long long H, long long M){
    static const double pi = 3.141592653589793;

    double t1 = 2 * pi * ((H * 60.0 + M) / 720.0);
    //cout << t1 << endl;
    double x1 = A * cos(t1);
    double y1 = A * sin(t1);

    double t2 = 2 * pi * (M / 60.0);
    double x2 = B * cos(t2);
    double y2 = B * sin(t2);

    double res = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 -y2));
    printf("%.10lf\n", res);
    
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long H;
    scanf("%lld",&H);
    long long M;
    scanf("%lld",&M);
    solve(A, B, H, M);
    return 0;
}


Measured memory_bytes: 4168
import sys
import math 
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()
N,K = na()
S = [na() for i in range(N)]
S.sort(key=lambda x:x[1],reverse=True)
res = []
tmp=0
d=set([])
ds = []
for t,dd in S[:K]:
    tmp+=dd
    if t in d:
        ds.append(dd)
    else:
        d.add(t)
ans = tmp + len(d)**2
ax = ans

for t,dd in S[K:]:
    if len(ds)==0:
        break
    if t not in d:
        ax +=2*len(d)+1
        ax += dd-ds.pop()
        d.add(t)
        ans = max(ax,ans)
print(ans)

Measured memory_bytes: 30796