akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;

int n, k;
vector<int> e[100000];

ll calc(ll v, ll p) {
    ll ret = 1;
    int cnt = 0;
    rep(i,e[v].size()) {
        if (e[v][i] == p) continue;
        if (v == 0) ret = ret * (k-1-cnt) % MOD;
        else ret = ret * (k-2-cnt) % MOD;
        cnt++;
    }
    //cerr << v << " " << ret << endl;
    rep(i,e[v].size()) {
        if (e[v][i] == p) continue;
        ret = ret * calc(e[v][i], v) % MOD;
    }
    return ret;
}

int main() {
    cin >> n >> k;
    rep(i,n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    cout << k*calc(0, 0)%MOD << endl;
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
char s[100],t[100];
int p(char i,char j)
{
	return i>j;
}
string a,b;
int main()
{
	int i,j;
	string s1,t1;
	cin>>s1>>t1;
	for(i=0;i<s1.size();i++)
	s[i]=s1[i];
	sort(s,s+i);
	for(i=0;i<t1.size();i++)
	t[i]=t1[i];
	sort(t,t+i,p);
	if(s1.size()>t1.size()) j=s1.size();
	else j=t1.size();
	
	for(i=0;i<j;i++)
	if(s[i]>t[i]) 
	{cout<<"No";return 0;}
	else if(s[i]<t[i])
	{cout<<"Yes";return 0;}
	cout<<"No";
	
	return 0;
}

Measured memory_bytes: 256
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix
from itertools import permutations

N, M, R = map(int, input().split())
r = list(map(int, input().split()))
abc = [list(map(int, input().split())) for _ in range(M)]

r = [e - 1 for e in r]

g = [[0] * N for _ in range(N)]
for a, b, c in abc:
	a -= 1
	b -= 1
	g[a][b] = c
	g[b][a] = c

dist = floyd_warshall(csr_matrix(g))

ans = float("inf")
for pat in permutations(r, len(r)):
	sm = 0
	for e1, e2 in zip(pat, pat[1:]):
		sm += dist[e1][e2]

	ans = min(ans, sm)

ans = int(ans)
print(ans)


Measured memory_bytes: 23396
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#define endl '\n'
//#define ll long long
#define mod 1000000007
#define NCONS 100001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
#define int long long
#define double long double
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
typedef long long ll;

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

#define YYYY cout << "YES" << endl
#define NNNN cout << "NO" << endl
#define yyyy cout << "Yes" << endl
#define nnnn cout << "No" << endl

int32_t main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int K, X; cin >> K >> X;
    
    for(int i = -1000000; i <= 1000000; i++)
    {
        if(abs(i - X) < K)
            cout << i << " ";
    }
    
    return 0;
}


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

int main() {
    int i, w, n;
    int a, b;
    int ami[40];

    cin >> w >> n;
    for (i=0; i<w; i++) ami[i] = i+1;
    for (i=0; i<n; i++) {
        scanf("%d,%d\n", &a, &b);
        swap(ami[a-1], ami[b-1]);
    }
    for (i=0; i<w; i++) cout << ami[i] << endl;
    return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
using u128 = __uint128_t;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vi> vvll;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef vector<vector<pair<ll,ll>>> vvii;
typedef long double ld;
typedef vector<long double> vld;
typedef vector<vector<long double>> vvld;
typedef vector<bool> vbl;
typedef vector<vector<bool>> vvbl;
#define pb push_back
#define rep(x,n) for(int x = 0 ; x < n ; x++)
#define rep1(x,n) for(int x = 1 ; x < n ; x++)
#define rrep(x,n) for(int x = n ; x >= 0 ; x--)
#define all(c) (c).begin() , (c).end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>            
const ll MOD = 1e9 + 7;
const ll MAX = 1e6 + 10;
const ll INF = 1e18;

int ans = -1;
vi dp;
vvi g;

int dfs(int node)
{
    if(dp[node] == -1)
    {
        int temp = -1;
        if (g[node].size() == 0)
            return 0;
        for(auto child : g[node])
            temp = max(temp,dfs(child));
        return dp[node] = temp + 1;
    }
    return dp[node];
    
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    ll n, m;
    cin >> n >> m;
    g.resize(n + 1);
    dp.resize(n + 1, -1);
    rep(i,m)
    {
        ll a, b;
        cin >> a >> b;
        --a, --b;
        g[a].pb(b);
    }
    rep(i,n)
        if (dp[i] == -1)
            m = dfs(i);
    rep(i,n+1)
        ans = max(ans,dp[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


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

	int X;
	cin >> X;
	int N = 100;
	int ans = 0;
	while(ans <= 3760){
		++ans;
		N = N * 1.01;
		if(N >= X){
			cout << ans << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3640
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
 
 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;


int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
 
//    auto start = chrono::steady_clock::now();
  
//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readll(n);

        ll ret = 0;
        for(ll d=1; d <=n; ++d) {
            ll how_many = n/d;
            ret += d*(how_many*(how_many+1))/2;
        }

        cout << ret << endl;
    }
 
//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;
 
    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>

int main(void){
  int n;
  scanf("%d",&n);

  char s[n];
  scanf("%s",s);
  int w[300010] = {0} , e[300010] = {0};

  for(int i = 0;s[i] != '\0';i ++){
    if(s[i] == 'W'){
      w[i] ++;
    }
    else{
      e[i] ++;
    }
    w[i+1] = w[i];
    e[i+1] = e[i];
  }

  int count = 0 , min = 10000000;
  for(int i = 0;i < n;i ++){
    if(i > 0)
     count = w[i-1] + (e[n] - e[i]);
    
    else
     count = e[n]; 
	
    //printf("%d\n",count);
    if(count < min){
      min = count;
    }
    count = 0;
  }

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

  return 0;
}

Measured memory_bytes: 4364
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

struct Card {
    char s;
    int v;
};


void merge(vector<Card> &A, int left, int mid, int right){
    int n1 = mid - left, n2 = right - mid;
    vector<Card> L(n1 + 1), R(n2 + 1);
    rep(i, n1) L[i] = A[left + i];
    rep(i, n2) R[i] = A[mid + i];
    L[n1].v = INF;
    R[n2].v = INF;
    int i = 0, j = 0;
    for(int k = left; k < right; k++){
        if(L[i].v <= R[j].v){
            A[k] = L[i];
            i++;
        } else {
            A[k] = R[j];
            j++;
        }
    }
}

void mergeSort(vector<Card> &A, int left, int right){
    if(right - left > 1){
        int mid = (left + right)/2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}


int partition(vector<Card> &A, int p, int r){
    int x = A[r].v;
    int i = p - 1;
    for(int j = p; j < r; j++){
        if(A[j].v <= x){
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}

void quickSort(vector<Card> &A, int p, int r){
    if(p < r){
        int q = partition(A, p, r);
        quickSort(A, p, q-1);
        quickSort(A, q+1, r);
    }
}

int main(){
    int N;
    cin >> N;
    vector<Card> A(N), B(N);
    rep(i, N) {
        cin >> A[i].s >> A[i].v;
    } 
    B = A;
    quickSort(A, 0, N - 1);
    mergeSort(B, 0, N);

    bool flag = true;
    rep(i, N){
        if(A[i].s != B[i].s){
            flag = false;
            break;
        }
    }

    if(flag) cout << "Stable" << endl;
    else cout << "Not stable" << endl;

    rep(i, N){
        cout << A[i].s << ' ' << A[i].v << endl;
    }
}


Measured memory_bytes: 5188
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=305;
int f[MAXN][MAXN][MAXN],n,K;char ch[MAXN];
int main()
{
	scanf("%s",ch+1);n=strlen(ch+1);K=read();
	f[0][n+1][0]=0;int ans=0;
	for(int i=0;i<=n;i++)for(int j=n+1;j>=i;j--)for(int k=0;k<=K;k++)
	{
		int ad=(ch[i]==ch[j]?0:1);
		if(i-1>=0)chkmax(f[i][j][k],f[i-1][j][k]);
		if(j+1<=n+1)chkmax(f[i][j][k],f[i][j+1][k]);
		if(i-1>=0&&j+1<=n+1&&k-ad>=0)chkmax(f[i][j][k],f[i-1][j+1][k-ad]+1);
		if(i<j)chkmax(ans,2*f[i][j][k]);
		else chkmax(ans,2*f[i][j][k]-1);
	}pr2(ans);
	return 0;
}


Measured memory_bytes: 110848
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;
use std::cmp::min;

#[allow(unused_macros)]
macro_rules! swap {
    ($a:expr, $b:expr) => {
        let tmp = $a;
        $a = $b;
        $b = tmp;
    };
}

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<i64>();
    let q = scan.read::<usize>();
    let vw = arr(q, |_| (scan.read::<i64>(), scan.read::<i64>()));
    if n == 1 {
        for (v, w) in vw {
            println!("{}", min(v, w));
        }
    } else {
        for (mut v, mut w) in vw {
            while v != w {
                if v > w {
                    swap!(v, w);
                }
                w = ((w-1) - 1) / n + 1;
            }
            println!("{}", v);
        }
    }
}

// region template
#[allow(dead_code)]
fn iu(i: isize) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> isize { i as isize }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 7292
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    string s;
    cin >> s;
    if(s == "SSR" || s == "SRS" || s == "RSS" || s == "RSR") cout << 1 << endl;
    else if(s == "SRR" || s == "RRS") cout << 2 << endl;
    else if(s == "RRR") cout << 3 << endl;
    else cout << 0 << endl;
    return 0;
}

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

using ll = long long;

#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, m, q, a[20];
vector<tuple<int, int, int, int>> v;
int res;

void rec(int pos, int num) {
	if(num > m) return;
	if(pos == n) {
		int ret = 0;
		REP(i, 0, q) {
			int a1, b1, c1, d1;
    		tie(a1, b1, c1, d1) = v[i];
    		if(a[b1] - a[a1] == c1) ret += d1; 
    	}
    	res = max(res, ret);
		return;
	}
	while(num <= m) {
		a[pos] = num;
		rec(pos+1, num);
		++num;
	}
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m >> q;
    REP(i, 0, q) {
    	int a1, b1, c1, d1;
    	cin >> a1 >> b1 >> c1 >> d1;
    	--a1, --b1;
    	v.pb(make_tuple(a1, b1, c1, d1));
    }
    rec(0, 1);
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 3664
#ifdef Rahul
#include "RAHUL.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define error(...) 42;
#endif
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
const int MOD = (int) 1e9 + 7;
const i64 INF = (i64) 1e18 + 42;

const int N = 3e5 + 42;
vector<int> x[N];
vector<int> y[N];

int main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  int h, w, m;
  cin >> h >> w >> m;
  set<pair<int, int>, greater<>> a, b;
  for (int i = 0; i < m; ++i) {
    int u, v; cin >> u >> v;
    x[u].push_back(v);
    y[v].push_back(u);
  }
  for (int i = 0; i < N; ++i) {
    if (!x[i].empty()) a.emplace(SZ(x[i]), i);
    if (!y[i].empty()) b.emplace(SZ(y[i]), i);
  }
  int ans = 0;
  for (int i = 1; i < N; ++i) {
    for (int j : x[i]) {
      b.erase({SZ(y[j]), j}); 
      b.insert({SZ(y[j])-1, j}); 
    }
    uax(ans, SZ(x[i]) + b.begin()->first);
    for (int j : x[i]) {
      b.insert({SZ(y[j]), j}); 
    }
  }
  kek(ans);
}


Measured memory_bytes: 78652
/*
 Author : Bisma
 @ copy from bisma template 1.0
 */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <iomanip>
#include <fstream>
#include <cstdio>
using namespace std;
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define repn(a,b,c) for(int a=b; a>=c; a--)
#define ll long long
#define mem(a, b) memset(a, (b), sizeof(a))
#define loop(a,b,c) for(int a = b ;a<c;a++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second
#define FOR(a,b,c) for(int a = b ; a<c ; a++ )
ll max(ll a, ll b){
    if(a>b) return a;
    return b;
}

ll min(ll a, ll b){
    if(a>b) return b;
    return a;
}

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

const int lim = 1e5;

ll __gcd(ll a, ll b){

	if(b > a) swap(a,b);

	if(b == 0) return a;

	return __gcd(b, a % b);

}


ll r[lim];
ll l[lim];

ll a[lim];

int main(){

	fast();

	ll n ;

	cin>>n;

	rep(i,1,n){
		cin>>a[i];
	}

	l[1] = 0;
	r[n] = 0;



	if(n > 2){

		rep(i,2,n){
			l[i] = __gcd(l[i-1] , a[i-1]);
		}

		// rep(i,1,n){
		// 	cout<<"l"<<i<<" :" <<l[i]<<endl;
		// }

		repn(i , n - 1, 1){
			r[i] = __gcd(r[i+1] , a[i+1]);
		}

		// rep(i,1,n){
		// 	cout<<"r"<<i<<" :" <<r[i]<<endl;
		// }


		ll ans = -1;

		rep(i,1,n){

			ll p = __gcd(l[i] , r[i]);

			ans = max(ans , p);

		}

		cout<<ans<<endl;

	}else{
		cout<<max(a[1],a[2])<<endl;
	}

	
return 0;
}
 


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
bool isprime[100005];
bool islike[100005];
int primesum[100005];
int main(){
    FOR(i, 2,100001){
        isprime[i] = true;
    }
    FOR(i,2,100001){
        if(isprime[i]){
            int no = i*2;
            while(no<= 100000){
                isprime[no] = false;
                no+=i;
            }
        }
    }
    FOR(i,3,100001){
        if( i%2!=0 && isprime[i]  && isprime[(i+1)/2]){
            islike[i] = true;
        }
    }
    REP(i,100001){
        primesum[i]= primesum[i-1] ;
        if(islike[i])primesum[i]++;

    }
    int q; cin >> q;
    REP(i,q){
        int l,r; cin >> l >> r;
        cout << primesum[r] - primesum[l-1] << endl;;
    }
    


}

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

int main(){
  int x; cin >>x;
  long long a,b=0;
  while(b<=0)
  {
  long long c=pow(b,5)+x; a=pow(c,0.2); long long d=pow(a,5);
  if(c==d && a>b){cout <<a<<" "<<b; return 0;}
  if(c==d && a<=b) break;
  else b--;
  }
  b=0;
  while(b>=0)
  {
  long long c=pow(b,5)+x; a=pow(c,0.2); long long d=pow(a,5);
  if(c==d && a>b){cout <<a<<" "<<b; return 0;}
  else b++;
  }
}

Measured memory_bytes: 4208
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0;i<10000;++i)
        {
            if (1000 * i >= n)
            {
                System.out.println((1000*i) - n);
                break;
            }
        }
        sc.close();
    }
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    vi d(N); REP(i, N) cin >> d[i];
    sort(ALL(d));
    int a = d[N/2-1], b = d[N/2];
    cout << b - a << endl;
} 
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void) {

  int n;
  int np,nm;
  int i,flag;

  while(scanf("%d",&n)!=EOF) {

    np=n+1;
    nm=n-1;
    //printf("%d %d\n",np,nm);
    while(1) {

      flag=1;
      //printf("%d\n",np);
      for(i=2;i<np;i++) {
	if(np%i==0) {
	  flag=0;
	  break;
	}
      }
      //printf("%d\n",flag);
      if(flag==1) break;

      np++;
    }	
    //printf("%d",np);
    while(1) {

      flag=1;
      
      for(i=2;i<nm;i++) {
	if(nm%i==0) {
	  flag=0;
	  break;
	}
      }

      if(flag==1) break;

      nm--;
    }

    printf("%d %d\n",nm,np);

  }
   
  return 0;

}

Measured memory_bytes: 0
n, m, x = gets.split.map(&:to_i)
books = []
n.times do
  books << gets.split.map(&:to_i)
end

choose = []
book_idx = (0..n-1).to_a
(1..n).each do |i|
  choose.concat(book_idx.combination(i).to_a)
end

ans = Float::INFINITY
choose.each do |c|
  cost = 0
  rikai = Array.new(m, 0)
  c.each do |ci|
    book = books[ci]
    cost += book[0]
    clear = true
    m.times do |i|
      rikai[i] += book[i+1]
      clear = false if rikai[i] < x
    end
    ans = cost if clear && cost < ans
  end
end

if ans.finite?
  puts ans
else
  puts '-1'
end


Measured memory_bytes: 14976
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
char march[5] = {'M', 'A', 'R', 'C', 'H'};

int main() {
    int n; cin >> n;
    vector<ll> cnt(5);
    for (int i = 0; i < n; i++) {
        string str; cin >> str;
        for (int j = 0; j < 5; j++) {
            if (str[0] == march[j]) cnt[j]++;
        }
    }

    ll ans = 0;
    for (int i = 0; i < 3; i++) {
        for (int j = i + 1; j < 4; j++) {
            for (int k = j + 1; k < 5; k++) {
                ans += cnt[i] * cnt[j] * cnt[k];
            }
        }
    }
    cout << ans << endl;
}

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

int main(){
  int n,k;
  int cnt[100003];
  int i,j;
  double sum = 0;

  scanf("%d %d", &n, &k);

  for(i = 1;i <= n;i++){
    cnt[i] = 0;
    j = i;
    while(j < k){
      cnt[i]++;
      j = j*2;
    }

    sum += 1/(n*pow(2,cnt[i]));
  }

  printf("%.14f\n", sum);

  return 0;
}


Measured memory_bytes: 128
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		long N = long.Parse(input[0]);
		long A = long.Parse(input[1]);
		long B = long.Parse(input[2]);
      if(A>B){
      long mem = A;
        A = B;
        B = mem;
      }
  if(A%2==B%2){
    Console.WriteLine((B-A)/2);
  }else{
      long r = A+(B-A-1)/2;
	  A = N-A+1;
 	  B = N-B+1;
 	  long l = A+(B-A-1)/2;
 	  Console.WriteLine(Math.Min(r,l));
  }
      
	}
}

Measured memory_bytes: 11092
N, L = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
(N-1).times do |i|
    if as[i] + as[i+1] >= L
        puts 'Possible'
        (1..i).each {|i| puts i}
        (N-1).downto(i+2){|i| puts i}
        puts i+1
        exit
    end
end

puts 'Impossible'

Measured memory_bytes: 13572
#include <stdio.h>

int fib(int);
int F[100];

int main()
{

  int n,total,i;

  for(i=0 ; i<100 ; i++){
    F[i]=0;
  }


  scanf("%d",&n);

  total=fib(n);

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

 
  return 0;
}    


int fib(int n){

  static int total=0;

  if(F[n]!=0) return F[n];
  else if(n==0) return F[n]=1;
  else if (n==1) return F[n]=1;
  else return F[n]=fib(n-1)+fib(n-2);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  int n;
  cin >> n;
  cout << "ABC" << n <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int a[105],b[105],c[105];
int main()
{
    int n,t=-1;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
        if(c[i]!=0) t=i;
    }
    for(int c1=0;c1<=100;c1++)
        for(int c2=0;c2<=100;c2++)
    {
        bool flag=true;
        int h=c[t]+abs(c1-a[t])+abs(c2-b[t]);
        for(int i=0;i<n;i++)
        {
            int haha=h-abs(c1-a[i])-abs(c2-b[i]);
            int s=max(haha,0);
            if(s!=c[i]) {flag=false;break;}
        }
        if(flag)
        {
            printf("%d %d %d\n",c1,c2,h);
            return 0;
        }
    }
}


Measured memory_bytes: 760
# -*- coding: utf-8 -*-
# 整数の入力

# s = input()
# t = input()
# # s = "ratcode"
# # t = "atlas"

# # a = int(input())
# # スペース区切りの整数の入力
n,k = map(int, input().split())
l = map(int, input().split())
l = list(l)
l.sort()
l.reverse()
# # 文字列の入力
# s = input()
# s = list(s)
# t = list(t)
# s.sort()
# t.sort()
# t.reverse()

# t2 = ''.join(t)
# s2 = ''.join(s)
c=0
ans=0
for i in l:
  c+=1
  ans+=i
  if c >= k:
    break

print( ans)

# f =False
# for sc,tc in zip(s,t):
#   # print(sc+" "+tc)
#   if tc > sc:
#     f=True
#     break;
#   if tc < sc:
#     f=False
#     break;

# if f:
#   print("Yes")
# else:
#   print("No")

# 出力
# print("{} {}".format(a+b+c, s))

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

int main() {
  int k, x;
  
  cin >> k >> x;
  
  for (int i=x-k+1;i<x+k-1;i++) {
    cout << i << ' ';
  }
  cout << x+k-1 << endl;
  
  return 0;
}

Measured memory_bytes: 256
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <math.h>
# include <time.h>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define MAXN 250
# define eps 1e-3
# define MAXM 500005
# define MOD 1000000007
# define INF 1000000000
# define MIN(a,b) (a)>(b)?(b):(a)
# define MAX(a,b) (a)<(b)?(b):(a)
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
typedef long long LL;
typedef unsigned long long ULL;

int b[50][26],c[26],flag=0;

int main()
{
    char a[50][55];
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        scanf("%s",a[i]);
    for(int i=0;i<n;i++)
        for(int j=0;j<strlen(a[i]);j++)
            b[i][a[i][j]-97]++;
 /*   for(int i=0;i<n;i++)
    {
        printf("\ni=%d,strlen=%d",i,strlen(a[i]));
        for(int j=0;j<26;j++)
            printf("%c=%d",j+97,b[i][j]);
    }*/
    mem(c,100);
    for(int j=0,i=0;j<26;j++)
    {
        for(int i=0;i<n;i++)
            if(b[i][j]<c[j])c[j]=b[i][j];
    }
/*    for(int j=0;j<26;j++)
        printf("%c=%d\n",j+97,c[j]);*/
    for(int j=0;j<26;j++)
        for(int i=0;i<c[j];i++)
        {
            printf("%c",97+j);
        }
    cout<<endl;
    return 0;
}























Measured memory_bytes: 256
N = int(input())
S = input()

leader = S[0]
right = 0
left = 0

for i in range(1,N):
    right += 1 if (S[i]=="W") else 0

result = right

for i in range(1,N):
    if (S[i-1]=="E"):
        left += 1
    if (S[i]=="W"):
        right -= 1
    result = max(result, right+left)

print(N-result-1)


    

Measured memory_bytes: 3668
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  vector<P> vec;
  REP(i, n) {
    int x, y;
    cin >> x >> y;
    vec.push_back(P(x, y));
  }
  sort(ALL(vec));
  double ans = 0;
  int cnt = 0;
  do {
    cnt++;
    double sum = 0;
    REP(i, n - 1) {
      double tmp =
          (vec[i].first - vec[i + 1].first) * (vec[i].first - vec[i + 1].first);
      tmp += (vec[i].second - vec[i + 1].second) *
             (vec[i].second - vec[i + 1].second);
      sum += sqrt(tmp);
    }
    ans += sum;
  } while (next_permutation(ALL(vec)));
  ans /= cnt;
  printf("%.10f\n", ans);
  return 0;
}

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

int main()
{
    int n;
    bool flag=false;
    cin>>n;
    while(n!=0)
    {
        int p=n%10;
        if(p==7)
        {
            flag=true;
            break;
        }
        n/=10;
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    R=ii()
    G=ii()

    print(2*G-R)




if __name__ == "__main__":
    main()

Measured memory_bytes: 61836
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int S,W; cin >> S >> W;
    if(S <= W) cout << "unsafe" << endl;
    else cout << "safe" <<endl;
}

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

int main(){
  int a,d=1;
  cin >>a;
  vector<int>s(a);
  vector<int>dp(a);
  for(int i=0;i<a;i++){
    cin>>s[i];
  }
  dp[0]=s[0];
  for(int i=1;i<a;i++){
    dp[i]=min(s[i],dp[i-1]);
    if(s[i]<=dp[i])d++;
  }
  cout <<d;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}

#define N 100000
void solve(){
    vl isPrime(N+5,1);
    isPrime[0]=isPrime[1]=0;
    fore(i,2,N){
        if(isPrime[i]){
            for(ll j=i+i;j<=N;j+=i)isPrime[j]=0;
        }
    }

    vl cnt(N+5);
    fore(i,1,N){
        cnt[i]+=cnt[i-1];
        if(i%2==0)continue;
        if(isPrime[i]&&isPrime[(i+1)/2])cnt[i]+=1;
    }

    ll q;cin>>q;
    rep(i,q){
        ll l,r;cin>>l>>r;
        cout<<cnt[r]-cnt[l-1]<<endl;
    }
}

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


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<string> track(n);
  for (int i = 0; i < n; ++i) {
    cin >> track[i];
  }

  for (int i = 0; i < n - 1; ++i) {
    for (int j = 0; j < m - 1; ++j) {
      if (track[i][j] == '#' && track[i + 1][j] == '#' && track[i][j + 1] == '#') {
        cout << "Impossible" << endl;
        return 0;
      }
    }
  }
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j < m; ++j) {
      if (track[i][j] == '#' && track[i - 1][j] == '#' && track[i][j - 1] == '#') {
        cout << "Impossible" << endl;
        return 0;
      }
    }
  }
  cout << "Possible" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec; }
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

int main()
{
  ll N;
  std::cin >> N;
  std::vector< ll > vb(N-1, 0LL);
  for (ll i = 0; i < N-1; i++) {
    std::cin >> vb[i];
  }

  std::vector< ll > va(N, 0LL);
  va[0]   = vb[0];
  va[N-1] = vb[N-2];
  for (ll i = 1; i < N-1; i++) {
    va[i] = std::min(vb[i], vb[i-1]);
  }

  ll sum = std::accumulate(va.begin(), va.end(), 0LL);
  print(sum);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;

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



	int r, g, b; cin >> r >> g >> b;
	int sum = ((r % 10)*10 + g % 10 )*10+ b % 10;
	if (sum % 4 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;


		return 0;
	
}


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

using namespace std;
using LL = long long;
using P = pair<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()

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a, Ts... ts) {return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, l;
    cin >> n >> l;

    int m = 0;
    int sum = 0;
    REP(i, n)
    {
        sum += l+i;
    }
    int ans = INF;
    REP(i, n)
    {
        if(abs(ans - sum) > abs((sum - (l+i)) - sum)) ans = sum - (l+i);
    }
    cout << ans << endl;

}

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

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

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

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

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

int main() {
    int n;
    cin >> n;
    int tempt = 0;
    int tempx = 0;
    int tempy = 0;
    int t, x, y;
    int dift, md;

    bool can = false;
    for (int i = 0; i < n; i++) {
        cin >> t >> x >> y;
        dift = t - tempt;
        md = abs(x - tempx) + abs(y - tempy);
        if (md <= dift && (md % 2 == dift % 2)) {
            can = true;
            tempt = t;
            tempx = x;
            tempy = y;
        } else {
            can = false;
            break;
        }
    }

    if (can) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import itertools
S = raw_input()
ans = 0
for p in itertools.product([True, False], repeat=len(S)-1):
  t = ''
  for i in xrange(len(S)):
    t += S[i]
    if i != len(S)-1 and p[i]:
      t += '+'
  ans += eval(t)

print ans


Measured memory_bytes: 2692
n = int(input())
a, b = [], []
tmp_a, tmp_b = 0, 0
time_count = 0
result = 0

for i in range(n):
    tmp_a, tmp_b = map(int, input().split())
    a.append(tmp_a)
    b.append(tmp_b)

sort_data = zip(a, b)
sort_data = sorted(sort_data, key=lambda x:x[1])
a, b = zip(*sort_data)

for i in range(n):
    time_count += int(a[i])
    if time_count <= b[i]:
        result = 1
    else:
        result = 0
        break

if result == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 49100
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();

		int w = sc.nextInt();

		String answer = "";
		for (int i = 0; i < s.length(); i = i + w) {
			answer = answer + String.valueOf(s.charAt(i));
		}

		System.out.println(answer);
	}
}

Measured memory_bytes: 24916
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    sort(A.begin(),A.end());
    map<ll,vector<int>> mp;
    rep(i,N) mp[A[i]].push_back(i);

    vector<ll> power(31);
    rep(i,31) power[i] = (1 << i);

    int ans = 0;
    vector<int> used(N,0);
    irep(i,N) {
        if (used[i]) continue;
        mp[A[i]].pop_back();
        irep(j,31) {
            if (power[j] - A[i] < 0) continue;
            ll k = power[j] - A[i];
            if (mp.count(k) && mp[k].size() > 0 && mp[k].back() != i) {
                ++ans;
                used[mp[k].back()] = 1;
                mp[k].pop_back();
                break;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 27484
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define N 0
#define INF 0x3f3f3f3f
#define LL long long
#define mz(x) ms(x,0)
#define ms(x,y) memset(x,y,sizeof(x))
#define mc(x,y) memcopy(x,y,sizeof(y))
#define MOD 1000000007

using namespace std ;

int main()
{
	int n ;
	scanf ("%d", &n) ;
	int con = 0 ;
	bool flag = false ;
	for (int i=0; i<n; i++)
	{
		int a, b ;
		scanf ("%d%d", &a, &b) ;
		
		if (a == b)
			con++ ;
		else
			con = 0 ;
		
		if (!flag && con >= 3)
			flag = true ;
	}
	
	if (flag)
		cout << "Yes" << endl ;
	else
		cout << "No" << endl ;

	return 0 ;
}

Measured memory_bytes: 3184
n=int(input())
a=list(map(int, input().split()))
cnt_4=0
cnt_2=0
for i in range(n):
    if a[i]%4==0:
        cnt_4+=1
    elif a[i]%2==0:
        cnt_2+=1

print('Yes' if cnt_4*2+1>=n or (cnt_4*2+cnt_2>=n) else 'No')


Measured memory_bytes: 15020
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <stdlib.h>
#include <deque>
using namespace std;
 
int main () {
  int n;
  cin >> n;
  int m[n] = {0};
  for (int i = 1; i < n; i++){
    int a;
    cin >> a;
    m[a-1]++;
  }
  for (int i = 0; i < n; i++){
    cout << m[i] << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 4348
{-# LANGUAGE BangPatterns #-}
import Data.Int
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM

solve :: Int -> Int -> V.Vector (Int,Int) -> V.Vector Int64
solve n m edges = V.create $ do
  -- m 番目の島から順番に島同士が「繋がっていく」と考える

  -- j = assocs ! i : i 番目の島の親が j
  -- assocs <- VM.new n
  -- forM_ [0..n-1] $ \i -> VM.write assocs i i
  assocs <- V.thaw $ V.enumFromN 0 n

  -- numberOfElements ! i : i番目の島と同じ連結成分に属する島の個数
  numberOfElements <- VM.replicate n 1

  let -- i 番目の島と同じ連結成分に属する島の中で一番番号が若いものを返す
      getRoot i xs = do
        j <- VM.read assocs i
        if i == j
          then return (i, xs)
          else getRoot j (i:xs)

      -- i 番目の島と j 番目の島を繋いで、新たに繋がった組み合わせの個数を返す
      unify i j = do
        (i',xs) <- getRoot i []
        (j',ys) <- getRoot j []
        let !k = min i' j'
        VM.write assocs i' k
        VM.write assocs j' k
        forM_ xs (\l -> VM.write assocs l k)
        forM_ ys (\l -> VM.write assocs l k)
        if i' == j'
          then return 0
          else do
          n1 <- VM.read numberOfElements i'
          n2 <- VM.read numberOfElements j'
          VM.write numberOfElements k (n1 + n2)
          return $! n1 * n2
  result <- VM.new m
  VM.write result (m-1) $ fromIntegral n * (fromIntegral n - 1) `quot` 2
  forM_ [m-1,m-2..1] $ \i -> do
    let (a,b) = edges V.! i
    convenience <- unify a b
    prevInconveniences <- VM.read result i
    VM.write result (i-1) (prevInconveniences - convenience)
  return result

main = do
  [n,m] <- map read . words <$> getLine -- 2 <= n <= 10^5, 1 <= m <= 10^5
  edges <- V.replicateM m $ do
    [a,b] <- map read . words <$> getLine
    return (a-1, b-1)
  -- maxIncovenience < n * (n - 1) / 2 < 10^10 (2^32 < 10^10)
  let result = solve n m edges
  V.forM_ result print


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

string a, b;

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

  int n = atoi((a+b).c_str());

  for (int i = 0; ; i++) {
    int m = i * i;
    if (m == n) {
      cout << "Yes";
      break;
    }
    if (m > n) {
      cout << "No";
      break;
    }
  }


  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#include<string.h>


int main(void)


{


 int sum;


 char str[1100];


 int i;


 for(i=0;i<1100;i++){


    str[i]=0;


  }


  while(1){


     scanf("%s",str);


     if(strcmp(str,"0")==0){


        break;


     }


     sum=0;


     for(i=0;str[i]!='\0';i++){


        sum+=str[i]-'0';


      }


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


   }


   return 0;


}

Measured memory_bytes: 536
import java.util.*;

public class Main{
	public static void main(String[] args){
      	Scanner sc = new Scanner(System.in);
    	int l = Integer.parseInt(sc.next());
      	int r = Integer.parseInt(sc.next());
      	int x = Integer.parseInt(sc.next());
      	int count = 0;
      	for(int cnt = l;cnt < r + 1;cnt++){
			if(cnt % x == 0){
            	count++;
      		}
        }
      	System.out.println(count);
    }
}


Measured memory_bytes: 35512
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n, m, k, ans = 4e18l;
ll a[15][1005];
ll s[15];

int main()
{
    scanf("%lld%lld%lld", &n, &m, &k);
    for(ll i = 0; i < n; i++)
    {
        for(ll j = 0; j < m; j++)
        {
            scanf("%1lld", &a[i][j]);
        }
    }
    for(ll i = 0; i < (1 << (n - 1)); i++)
    {
        bool vv = false;
        ll cnt = 0;
        for(ll j = 0; j < n; j++) s[j] = 0;
        for(ll j = 0; j < m; j++)
        {
            ll ii = 0;
            bool v = false;
            for(ll l = 0; l < n; l++)
            {
                s[ii] += a[l][j];
                if(s[ii] > k)
                {
                    cnt++;
                    v = true;
                    break;
                }
                if(i & (1 << l)) ii = l + 1;
            }
            ii = 0;
            if(v)
            {
                for(ll l = 0; l < n; l++) s[l] = 0;
                for(ll l = 0; l < n; l++)
                {
                    s[ii] += a[l][j];
                    if(s[ii] > k) {vv = true; break;}
                    if(i & (1 << l)) ii = l + 1;
                }
            }
            if(vv) break;
        }
        ll cnt2 = 0;
        for(ll j = 0; j < n - 1; j++) if(i & (1 << j)) cnt2++;
        if(!vv) ans = min(ans, cnt + cnt2);
    }
    cout<<ans<<endl;
    return 0;
}


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

c = 0
flag = 1
while flag:
    flag=0
    for j in reversed(range(1, n)):
        if a[j] < a[j-1]:
            b = a[j]
            a[j] = a[j-1]
            a[j-1] = b
            flag = 1
            c += 1
print(*a)
print(c)


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

int main() {
  string s;
  cin >> s;
  int size = s.size();
  int locA, locZ;
  for (int i=0; i<size; i++) {
    if (s.at(i)=='A') {
      locA = i;
      break;
    }
  }
  for (int i=size-1; i>=0; i--) {
    if (s.at(i)=='Z') {
      locZ = i;
      break;
    }
  }
  int ans = locZ-locA+1;
  cout << ans << endl;
}

Measured memory_bytes: 640