akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//------------------------------------------------------------------

int main(void){
  bool x;
  cin >> x;
  prt(!x);
}


Measured memory_bytes: 3632
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define MAX_N 23
#define MAX_M 33

int N,M,x,y;
bool field[21][21];
char dir[MAX_M];
int dis[MAX_M];

bool input(){
  x=10;
  y=10;
  REP(i,21){
    REP(j,21){
      field[i][j]=false;
    }
  }
  cin>>N;
  REP(i,N){
    int a,b;
    cin>>a>>b;
    field[a][b]=true;
  }
  if(N!=0){
   cin>>M;
   REP(i,M) cin>> dir[i]>>dis[i];
   }
  return(N!=0);
}

void solve(){
  REP(i,M){
    if(dir[i]=='N'){
      REP(j,dis[i])field[x][y+j]=false;
      y+=dis[i];
    }
    else if(dir[i]=='E'){
      REP(j,dis[i])field[x+j][y]=false;
      x+=dis[i];
    }
    else if(dir[i]=='S'){
      REP(j,dis[i])field[x][y-j]=false;
      y-=dis[i];
    }
    else{
      REP(j,dis[i])field[x-j][y]=false;
      x-=dis[i];
    }
  }
  field[x][y] = false;

  REP(i,21){
    REP(j,21){
      if(field[i][j]){
        cout<<"No"<<endl;
        return ;
      }
    }
  }
  cout<<"Yes"<<endl;
}

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

Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;
    
struct Node{
    ll index;   // index in node list
    vector<ll > connect;
    ll cnt; //探索済ノードの数
};
    
int reach[100001];
ll N;
ll K;
ll mod = 1000000007;
ll ans = 1;
    
void dfs(vector<Node> &node, int index){

    //距離２以内の探索済みであるノードの数
    ll num = 0;
    for(int i = 0; i < node[index].connect.size(); i++){
        int next_index = node[index].connect[i];
        if(reach[next_index] == 1){
            num += ( node[next_index].cnt );
        }
    }

    if(num >= K) num = K;
    ans *= (K - num);
    ans %= mod;
    if(DEBAG){
        cout << "index : " << index << endl;
        cout << "ans : " << ans << endl; 
    }

    for(int i = 0; i < node[index].connect.size(); i++){
        int next_index = node[index].connect[i];
        if(reach[next_index] == 0){
            reach[next_index] = 1;
            node[index].cnt ++;
            node[next_index].cnt ++;
            dfs(node, next_index);
        }
    }
       
}
    
int main(){
    
    cin >> N >> K;
    
    vector<Node> node(N);
    for(int i = 0; i < N; i++){
        node[i].index = i;
        node[i].cnt = 0;
    }
    for(int i = 0; i < N-1; i++){
        ll a, b;
        cin >> a >> b;
        a --;
        b --;
        node[a].connect.push_back(b);
        node[b].connect.push_back(a);
    }
    
    reach[0] = 1;
    dfs(node, 0);

    cout << ans << endl;
    
}

Measured memory_bytes: 9984
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(13);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI = 3.141592653589793;

const int INF = 1e18;

void solve()
{
	int n;
	cin >> n;
	if(n==0) n=1;
	else n = 0;
	cout << n ;
}

int32_t main()
{
	FastIO;
	Fast_D;
	int T;
	T=1;
	while(T--) solve();
	return 0;
}



Measured memory_bytes: 3636
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            num = 500*i + 100*j + 50*k
            if num == X:
                count = count + 1

print(count)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
  string s;
  cin >> s;
  int counter = 0;
  if (s[0] == s[1] and s[1] == s[2]) ++counter;
  if (s[1] == s[2] and s[2] == s[3]) ++counter;
  if (counter == 0) cout << "No" <<endl;
  else cout << "Yes" <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	ll N; cin >> N; cout << N*(N-1)/2 << endl;
}


Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N, M;
	
	cin >> N >> M;

	int a[N][M];
	memset(a, 0, sizeof(a));
	int k[N];
	rep(i, N)
	{
		cin >> k[i];
		rep(j, k[i])
		{
			int tmp;
			cin >> tmp;
			a[i][tmp-1] = 1;
		}
	}

	int count = 0;

	for(int j = 0; j < M; j++)
	{
		int tmp = 1;
		int i = 0;
		for(i = 0; i < N; i++)
		{
			if ((tmp & a[i][j]) == 0)
			{
				break;
			}
		}
		if (i == N)
		{
			count++;
		}
	}

	cout << count << endl;
	
	return 0;
}


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

int main(){
	int n,input;
	vector<int> v;
	cin >> n;
	while(cin>>input)
	{
		v.push_back(input);
	}
	sort(v.begin(),v.end(),std::greater<int>());
	int a,b;
	a=b=0;
	for(int i=0;i<v.size();i++)
	{
		if(i%2==0) a+=v[i];
		else b+=v[i];
	}
	cout << a-b;
	return 0;
}


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

int calc_tap(int a, int b) {
  int n = 1;
  int tap = a;

  while (tap < b) {
    tap += (a - 1);
    n++;
  }
  return n;
}

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

  int res;
  if (b == 1) {
    res = 0;
  } else {
    res = calc_tap(a, b);
  }
  cout << res << endl;
}


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

struct Node{
    int key;
    Node *prev, *next;
};

Node *nil;

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void insert(int key){
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

Node* listsearch(int key){
    Node *cur = nil->next;
    while(cur!=nil && cur->key != key){
        cur = cur->next;
    }
    return cur;
}

void deleteNode(Node *t){
    if(t==nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deletefirst(){
    deleteNode(nil->next);
}

void deletelast(){
    deleteNode(nil->prev);
}

void deletekey(int key){
    deleteNode(listsearch(key));
}

void printlist(){
    Node *cur = nil->next;
    int flag=0;
    while(1){
        if(cur==nil)break;
        if(flag++>0) printf(" ");
        printf("%d", cur->key);
        cur=cur->next;
    }
    printf("\n");
}

int main(){
    int n,a;
    char c[20];
    cin>>n;
    init();
    for(int i=0;i<n;i++){
        scanf("%s", c);
        scanf("%d", &a);
        if(c[0]=='i') insert(a);
        else if(c[0]=='d' && strlen(c)==6) deletekey(a);
        else if(c[0]=='d' && c[6]=='F') deletefirst();
        else deletelast();
    }
    printlist();

}

/*int main(){
    char op[20];
    int key, n, i;

    scanf("%d", &n);
    init();
    for(i = 0; i < n; i++){
        scanf("%s%d" , op , &key);
        if(op[0] == 'i'){
            insert(key);
        }else if(op[0] == 'd'){
            if(strlen(op) > 6){
                if(op[6] == 'F'){
                    deletefirst();
                }else if(op[6] == 'L'){
                    deletelast();
                }
            }else{
                deletekey(key);
            }
        }
    }

    printlist();

    return 0;
}*/






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

typedef long long ll;
const int inf = 1e9;

ll d, t, s;

int main(){
	cin>>d>>t>>s;

	ll x = s * t;
	if(x >= d)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	
	return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    int k; cin >> k;
    bool mul = true;
    int ans = 1;
    REP(i, n){
        if(mul){
            ans *= 2;
            if(ans > k) mul = false;
        }
        else ans += k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
#define MOD (LL)(1e9+7)

//RSQ
struct SegmentTree{
private:
	int N;
	vector<long long> node, lazy;
	vector<bool> lazyFlg;
	const long long DEFAULT = 0LL;
public:
	void init(int n){ //初期化 O(N)
		node.clear();
		lazy.clear();
		lazyFlg.clear();
		N = 1;
		while(N < n) N = (N<<1);
		for(int i=0; i<2*N-1; i++){
			node.push_back(DEFAULT);
			lazy.push_back(0LL);
			lazyFlg.push_back(false);
		}
	}
	void eval(int k, int l, int r){ //遅延評価 O(1)
		if(lazyFlg[k]){ //RUQ：下に更新クエリが溜まっていても加算クエリが溜まっていても上書き
			node[k] = lazy[k];
			if(r-l > 1){
				lazy[2*k+1] = lazy[k] / 2;
				lazyFlg[2*k+1] = true;
				lazy[2*k+2] = lazy[k] / 2;
				lazyFlg[2*k+2] = true;
			}
			lazy[k] = 0LL;
			lazyFlg[k] = false;
		}
		else{ //RAQ：下に更新クエリが溜まっていても加算クエリが溜まっていても加算
			node[k] += lazy[k];
			if(r-l > 1){
				lazy[2*k+1] += lazy[k] / 2;
				lazy[2*k+2] += lazy[k] / 2;
			}
			lazy[k] = 0LL;
		}
	}
	void update(int a, long long x){ //[a,a+1)の値を変更 O(log N)
		update(a, a+1, x);
	}
	void update(int a, int b, long long x, int k=0, int l=0, int r=-1){ //[a,b)の値を変更 O(log N)
		if(r == -1) r = N;
		eval(k, l, r);
		if(b <= l || r <= a) return; //交差する場合
		if(a <= l && r <= b){ //完全に含む場合
			lazy[k] = x * (r-l);
			lazyFlg[k] = true;
			eval(k, l, r);
		}
		else{
			update(a, b, x, 2*k+1, l, (l+r)/2);
			update(a, b, x, 2*k+2, (l+r)/2, r);
			node[k] = node[2*k+1] + node[2*k+2];
		}
	}
	void add(int a, long long x){ //[a,a+1)の値に加算 O(log N)
		add(a, a+1, x);
	}
	void add(int a, int b, long long x, int k=0, int l=0, int r=-1){ //[a,b)の値に加算 O(log N)
		if(r == -1) r = N;
		eval(k, l, r);
		if(b <= l || r <= a) return; //交差する場合
		if(a <= l && r <= b){ //完全に含む場合
			lazy[k] += x * (r-l);
			eval(k, l, r);
		}
		else{
			add(a, b, x, 2*k+1, l, (l+r)/2);
			add(a, b, x, 2*k+2, (l+r)/2, r);
			node[k] = node[2*k+1] + node[2*k+2];
		}
	}
	long long sum(int a, int b, int k=0, int l=0, int r=-1){ //[a,b)の和 O(log N)
		if(r == -1) r = N;
		if(b <= l || r <= a) return DEFAULT; //交差する場合
		eval(k, l, r);
		if(a <= l && r <= b) return node[k]; //完全に含む場合
		return sum(a, b, k*2+1, l, (l+r)/2) + sum(a, b, k*2+2, (l+r)/2, r);
	}
};

int N, Q;
vector<int> edge[200000];

int c = 0;
int dfsOrder[200000];
int pos[200000];
void dfs(int now, int par){
	dfsOrder[now] = c;
	c++;
	for(int i=0; i<edge[now].size(); i++){
		if(edge[now][i] == par) continue;
		dfs(edge[now][i], now);
	}
	pos[now] = c;
}

SegmentTree rsq;
int main(){
	cin >> N >> Q;
	for(int i=0; i<N-1; i++){
		int a, b;
		cin >> a >> b;
		edge[a-1].PB(b-1);
		edge[b-1].PB(a-1);
	}
	dfs(0, -1);
	rsq.init(N);
	for(int i=0; i<Q; i++){
		int p, x;
		cin >> p >> x;
		rsq.add(dfsOrder[p-1], pos[p-1], x);
	}
	for(int i=0; i<N; i++){
		if(i != 0) cout << " ";
		cout << rsq.sum(dfsOrder[i], dfsOrder[i]+1);
	}
	cout << endl;
}

Measured memory_bytes: 35804
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

// ────────────────────────────────────────────────────

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

	vi t(n);
	rep(i, n) cin >> t[i];

	sort(ASC(t));
	int max_ = t.back();

	vi yak;
	for (int i = max_; i >= 1; --i) {
		if (max_ % i == 0) yak.push_back(i);
	}
	sort(ASC(yak));

	int ans = 0;

	rep(i, n) {
		if (t[i] == max_) continue;

		for (int j = 0; j < yak.size(); ++j) {
			if (t[i] <= yak[j]) {
				ans += yak[j] - t[i];
				break;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3248
from sys import stdin
import itertools
N = int(stdin.readline().rstrip())
input = []
for i in range(N):
    input.append([int(x) for x in stdin.readline().rstrip().split()])

dist = 0
for ir in list(itertools.permutations(range(N))):
    now_dist = 0
    for i in range(len(ir) - 1):
        x = ir[i]
        y = ir[i + 1]
        now_dist += ((input[x][0] - input[y][0]) ** 2 + (input[x][1] - input[y][1]) ** 2) ** (1 / 2)
    dist += now_dist
output = dist / len(list(itertools.permutations(range(N))))
print(output)

Measured memory_bytes: 8052
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<math.h>
#define maxn 1<<17
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
char ch[10000005];
int main()
{
    while(~scanf("%s",ch)){
        printf("%c%d%c\n",ch[0],strlen(ch)-2,ch[strlen(ch)-1]);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace __gnu_pbds;
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define f first
#define s second

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

typedef
tree<
  pair<ll,int>,
  null_type,
  less<pair<ll,int>>,
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	ordered_set seenPrefs;
	int N, K; cin >> N >> K;
	vi arr (N);
	F0R(i, N) {
		cin >> arr[i]; arr[i] -= K;
	}

	ll ans = 0; 
	ll curPref = 0;
	F0R(i, N) {
		seenPrefs.insert({curPref, i});
		curPref += arr[i];
		auto above = seenPrefs.upper_bound({curPref, N});
		if (above == seenPrefs.begin()) continue;
		--above;
		ans += seenPrefs.order_of_key(*above) + 1;
	}
	print(ans);
}

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

int main() {
	
	int a, b, k;
	cin >> a >> b >> k;
	for(int i = a; i <= b; i++){
		if(i < a + k || i > b - k) cout << i << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

# 遅延評価で加えてあげるだけ

N,Q = map(int,readline().split())
AB = (tuple(int(x) for x in readline().split()) for _ in range(N-1))
PX = (tuple(int(x) for x in readline().split()) for _ in range(Q))

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in PX:
    value[p] += x

par = [None] * (N+1)
q = [1]
while q:
    x = q.pop()
    for y in graph[x]:
        if y == par[x]:
            continue
        value[y] += value[x]
        q.append(y)
        par[y] = x

answer = ' '.join(map(str,value[1:]))
print(answer)


Measured memory_bytes: 67076
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		sc.close();

		int a = N / 100;
		int b = (N % 100) / 10;
		int c = (N % 100) % 10;
		int check = 100 * c + 10 * b + a;
		if(N == check) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}

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

using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FOR(i, a) for (int i = 0; i < (a); i++)

const int N = int(1e8) + 7;

void init(){

}

void solve(){
    int n;
    int A[103];
    int MEM[103];
    MEM[0] = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &A[i]);
        MEM[i+1] = A[i]+MEM[i];
    }
    int ans = abs(MEM[n] - 2*MEM[1]);
    for(int i = 1; i < n; i++)
        ans = min(ans, abs(MEM[n] - 2*MEM[i]));
    printf("%d", ans);
}

const bool mtc = false;

int main(){
    int t;
    if(mtc){
        scanf("%d", &t);
        while(t--) solve();
    }
    else solve();
}


Measured memory_bytes: 256
import math
x = int(input())
ans = 0
if math.floor(x/500) >=1 :
    ans += math.floor(x/500)*1000
    x -= math.floor(x/500)*500
if x > 0 and math.floor(x/5) >=1 :
    ans +=  math.floor(x/5)*5
print(ans)

Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,k;
    cin>>a>>b>>k;
    cout<<max(a-k,(ll)0)<<" "<<max((ll)0,b-max((ll)0,(k-a)))<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		if ((N % 4 == 0) || (N % 7 == 0) || (N % 11 == 0)) {
			System.out.println("Yes");
		} else if (N > 7 && (N - 7) % 4 == 0) {
			System.out.println("Yes");
		} else if (N > 14 && (N - 14) % 4 == 0) {
			System.out.println("Yes");
		} else if (N > 21 && (N - 21) % 4 == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(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];
	sort(a.begin(),a.end());
	sort(c.begin(),c.end());
	long long ans=0;
	for(int i=0;i<n;i++){
		long long j=lower_bound(a.begin(),a.end(),b[i])-a.begin();
		long long k=upper_bound(c.begin(),c.end(),b[i])-c.begin();
		ans+=j*(c.size()-k);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1408
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function (chunk) {
    const n = chunk.toString();
    const arr = n.split(' ');
    const r2 = Number(arr[1].replace("\n", ""));
    const l2 = Number(arr[0]);
    if(l2<r2){
        console.log("a < b");        
    }else if(l2>r2){
        console.log("a > b");
    }else{
        console.log("a == b");
    }
});


Measured memory_bytes: 15504
#include<iostream>
using namespace std;
int main()
{
    int a[10];
    int n,m,s,c;
    cin>>n>>m;
    for(int i=0;i<10;i++)
        a[i]=-1;
    for(int i=1;i<=m;i++){
        cin>>s>>c;
        if(a[s]!=-1&&a[s]!=c){
            cout<<"-1";
            return 0;
        }
        a[s]=c;
    }
    if(n>1&&a[1]==0){
        cout<<"-1";
        return 0;
    }
    if(n==1){
        if(a[1]==-1)
            cout<<"0";
        else cout<<a[1];
        return 0;
    }
    for(int i=1;i<=n;i++){
        if(i==1&&a[i]==-1)
            cout<<"1";
        else if(a[i]==-1)
            cout<<"0";
        else cout<<a[i];
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i <n ; i++) {
            arr[i] = s.nextInt();
        }
        Arrays.sort(arr);
        int count = 0;
        for (int i = 0; i < k; i++) {
            count+=arr[i];
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 38940
n = int(input())

d = 2
ans = 0

while d * d <= n:
    if n % d != 0:
        d += 1
        continue

    z = d
    
    while n % z == 0:
        n //= z
        z *= d
        ans += 1

    while n % d == 0:
        n /= d

if n != 1:
    ans += 1

print(ans)

Measured memory_bytes: 9256
import java.util.HashMap;
import java.util.Objects;
import java.util.Scanner;

class C {

    static class Pair {
        final int bits;
        final String s;

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Pair pair = (Pair) o;
            return bits == pair.bits &&
                    Objects.equals(s, pair.s);
        }

        @Override
        public int hashCode() {

            return Objects.hash(bits, s);
        }

        public Pair(int bits, String s) {

            this.bits = bits;
            this.s = s;
        }
    }

    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final char[] S = sc.next().toCharArray();
        final HashMap<Pair, Integer> map = new HashMap<>();
        for (int i = 0; i < 1 << N; i++) {
            final StringBuilder sb = new StringBuilder();
            for (int j = 0; j < N; j++)
                if ((i & 1 << j) > 0)
                    sb.append(S[j]);
            for (int j = N - 1; j >= 0; j--)
                if ((i & 1 << j) == 0)
                    sb.append(S[j]);
            final Pair p = new Pair(Integer.bitCount(i), sb.toString());
            map.put(p, map.getOrDefault(p, 0) + 1);
        }
        long ans = 0;
        for (int i = 0; i < 1 << N; i++) {
            final StringBuilder sb = new StringBuilder();
            for (int j = N - 1; j >= 0; j--)
                if ((i & 1 << j) == 0)
                    sb.append(S[j + N]);
            for (int j = 0; j < N; j++)
                if ((i & 1 << j) > 0)
                    sb.append(S[j + N]);
            final Pair p = new Pair(N - Integer.bitCount(i), sb.toString());
            ans += map.getOrDefault(p, 0);
        }
        System.out.println(ans);
    }
}
public class Main {
    public static void main(String...args) {
        C.main();
    }
}


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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int r;
    cin >> r;
    cout << fixed << setprecision (0) << pow (r, 2) << endl;
    return 0;
}


Measured memory_bytes: 3728
#include <iostream>
using namespace std;
int main(void){
    int N, i, cnt=0, a[105];
    cin >> N;
    for(i=0; i<N; i++){
        cin >> a[i];
    }
    for(i=0; i<N; i++){
        if(a[i] == a[i+1]){
            a[i+1] = 100000;
            cnt ++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;

int n;
std::vector<P> links[100010];

void dijkstra(int st, std::vector<ll> &dist){
	std::priority_queue<P, std::vector<P>, std::greater<P>> que;
	dist[st] = 0;
	que.emplace(0, st);
	while(!que.empty()){
		ll dis, from;
		std::tie(dis, from) = que.top();
		que.pop();
		if(dist[from]<dis) continue;
		for(P p: links[from]){
			ll to, cost;
			std::tie(to, cost) = p;
			if(dist[to]<dis+cost) continue;
			dist[to] = dis+cost;
			que.emplace(dist[to], to);
		}
	}
}
			
	

int main(){
	scanf("%d", &n);
	for(int i=0; i<n-1; i++){
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		links[a-1].emplace_back(b-1, c);
		links[b-1].emplace_back(a-1, c);
	}

	int q, k;
	scanf("%d %d", &q, &k);
	std::vector<ll> dist(n, 1e18);
	dijkstra(k-1, dist);
	
	for(int i=0; i<q; i++){
		int x, y;
		scanf("%d %d", &x, &y);
		printf("%ld\n", dist[x-1]+dist[y-1]);
	}
	return 0;
}


Measured memory_bytes: 11120
#include <bits/stdc++.h>
 
using namespace std;
 
#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
 
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; }
 
typedef long long LL;
 
const int oo = 0x3f3f3f3f;
 
const int maxn = 110;
 
int ex, ey;
 
int n, m;
int g[maxn + 5][maxn + 5];
 
int sum[maxn + 5][maxn + 5];
 
int dp[2][maxn + 5][maxn + 5][maxn + 5];
 
inline int query(int u, int v, int x, int y)
{
	if (u >= x || v >= y) return 0;
	return sum[x][y] - sum[u][y] - sum[x][v] + sum[u][v];
}
 
int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	static char s[maxn + 5];
	scanf("%d%d", &n, &m);
	REP(i, 0, n) 
	{
		scanf("%s", s);
		REP(j, 0, m)
		{
			if (s[j] == 'o') g[i][j] = 1;
			else 
			{
				g[i][j] = 0;
				if (s[j] == 'E') ex = i, ey = j;
			}
		}
	}
	REP(i, 0, n) REP(j, 0, m) sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + g[i][j];
	memset(dp, -oo, sizeof dp);
	dp[0][0][0][0] = 0;
	int ans = 0;
	REP(i, 0, n + 1) 
	{
		int cur = i & 1;
		REP(j, 0, n - i + 1) REP(k, 0, m + 1) REP(l, 0, m - k + 1) if (dp[cur][j][k][l] >= 0)
		{
			chkmax(ans, dp[cur][j][k][l]);
			if (i + j == n || k + l == m) continue;
			REP(u, 0, 4)
			{
				int up, down, left, right;
				int ii = i, jj = j, kk = k, ll = l;
				int val = dp[cur][j][k][l];
				if (u == 0) 
				{
					up = ii, down = ii + 1, left = kk, right = m - ll;
					++ii;
				}
				if (u == 1) 
				{
					++jj;
					up = n - jj, down = n - jj + 1, left = kk, right = m - ll;
				}
				if (u == 2) 
				{
					up = ii, down = n - jj, left = kk, right = kk + 1;
					++kk;
				}
				if (u == 3) 
				{
					++ll;
					up = ii, down = n - jj, left = m - ll, right = m - ll + 1;
				}
				chkmax(up, ex - jj);
				chkmin(down, ex + ii + 1);
				chkmax(left, ey - ll);
				chkmin(right, ey + kk + 1);
				val += query(up, left, down, right);
				chkmax(dp[ii & 1][jj][kk][ll], val);
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(void){
    int i,j,n,x,y,z;

    scanf("%d",&n);

    z = 0;
    for(i=0; i<n; i++){
        scanf("%d",&x);

		y=0;

        if(x==2){
            y=0;
        }

        else if(x<2 || x%2==0){
            y=1;
        }

		else{
        	j=3;
        	while(j <= sqrt(x)){
            	if(x%j==0){
                	y=1;
                  break;
            	}
            	j+=2;
        	}
        }

        if(y==0){
            z++;
        }

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

    return 0;
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
// atoi : atoi(変数名.c_str())
// find(): int i = 変数名.find(“文字列”) 何番目にあるかを得る
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int ans = 0;

void search(vvi &G,vb seen,int v,int unreach){
  if(unreach == 0){
    ans++;
    return;
  }
  seen.at(v) = true;
  rep(i,G.at(v).size()){
    int nv = G.at(v).at(i);
    if(seen.at(nv)) continue;
    search(G,seen,nv,unreach-1);
  }
  return;
}

int main(){
  int n,m;
  cin >> n >> m;
  vvi G(n);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  vector<bool> seen(n,false);
  search(G,seen,0,n-1);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int gcd(int a, int b) {
    while (b) { int t = a%b; a = b; b = t; }
    return a;
}

const int MAXN = 100005;
int a[MAXN];

int n;

bool solve() {
    int even = 0;
    FOR1(i, n) even += (a[i] % 2 == 0);

    if (even % 2 == 1) {
        return true;
    }
    else if (even < n - 1) {
        return false;
    }
    else {
        FOR1(i, n) {
            if (a[i] % 2) {
                if (a[i] == 1) {
                    return false;
                }
                else {
                    a[i]--;
                }
            }
        }

        int g = a[1];
        for (int i = 2; i <= n; i++) g = gcd(g, a[i]);
        FOR1(i, n) a[i] /= g;

        return !solve();
    }
}

int main() {
    GI(n);
    FOR1(i, n) GI(a[i]);

    if (solve()) {
        cout << "First" << endl;
    }
    else {
        cout << "Second" << endl;
    }

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  int a1 = 0;
  int k;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    if (a1 < A[i]) {
      a1 = A[i];
      k = i;
    }
  }
  sort(A.begin(), A.end());
  int a2 = A[n - 2];
  for (int i = 0; i < n; i++) {
    if (i == k) {
      cout << a2 << endl;
      continue;
    }
    cout << a1 << endl;
  }
  return 0;
}


Measured memory_bytes: 2432
#include<cstdio>
using namespace std;
typedef long long LL;
const int maxn=1e5+2;
const int mod=998244353;
int n;
LL ans=1;
int now[3],cnt[3];
char str[maxn<<2];
int change(char ch){
	switch (ch){
		case 'R':{return 0;break;}
		case 'G':{return 1;break;}
		case 'B':{return 2;break;}
	}
}
int main(){
	scanf("%d%s",&n,str+1);
	for (int i=1;i<=n;i++) ans=ans*i%mod;
	for (int i=1;i<=n*3;i++){
		int type=change(str[i]);
		if (cnt[type]){
			ans=ans*cnt[type]%mod;
			cnt[type]--;
		}
		else{
			bool flag=false;
			for (int op=0;op<3;op++)
				if (type!=op&&now[op]){
					ans=ans*now[op]%mod;
					now[op]--;
					cnt[3-op-type]++;
					flag=true;
				}
			if (!flag) now[type]++;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 512
if __name__ == "__main__":
    s = input()

    op = ['+1', '-1']

    for i in op:
        for j in op:
            for k in op:
                if int(s[0]) + int(s[1])*int(i) + int(s[2])*int(j) + int(s[3])*int(k) == 7:
                    print(s[0] + i[0] + s[1] + j[0] +
                          s[2] + k[0] + s[3] + '=7')
                    exit()


Measured memory_bytes: 3060
#include <stdio.h>

int stack[10], stack_pt = -1;

void push(int x){
  stack[++stack_pt] = x;
}
int pop(void){
  if(stack_pt != -1){
    return stack[stack_pt--];
  }else{
    return -1;
  }
}
int main(void){
  for( ; ; ){
    int x;
    scanf("%d", &x);
    if(x){
      push(x);
    }else{
      int flag = pop();
      if(flag != -1){
        printf("%d\n", flag);
      }else{
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long LL;

LL a[1000];

int main()
{
	int n;
	scanf("%d",&n);
	a[0] = 2 , a[1] = 1;
	for(int i = 2 ; i <= 86 ; i++){
		a[i] = a[i - 1] + a[i - 2];
	}
	printf("%lld\n",a[n]);
	return 0;
}

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

bool solve() {
    ll N, a, n2 = 0, n4 = 0;
    cin >> N;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        if ( a % 4 == 0 ) n4++;
        else if ( a % 2 == 0 ) n2++;
    }
    ll m = (n4 > 0 ? 2 * n4 : 0) + ( n2 >= 2 ? n2 - 1 : 0);
    return m >= N - 1;

}

int main() {
    string ans = solve() ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> P;
typedef pair<int, P> P2;
const int inf = 0xfffffff;
const lli llinf = 0xfffffffffffffff;
int fib[] = {1, 2, 3, 5, 8, 13, 21, 34 };
int h, w, k;
lli inapow(P p) {
	return fib[p.first] * fib[p.second];
}
P nei(int a, int b) {
	if (a > b) swap(a, b);
	if (a - b > 1) {
		cout << "err" << endl;
		return P(0,0);
	}
	int l = max(a - 2, 0), r = max(w - b - 1, 0);
	return P(l, r);
}
int main()
{
	cin >> h >> w >> k;
	lli dp[105][10] = { 0 };
	dp[0][1] = 1;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (j > 1) dp[i][j] += dp[i - 1][j - 1] * inapow(nei(j, j - 1));
			dp[i][j] += dp[i - 1][j] * inapow(nei(j, j));
			if (j < w) dp[i][j] += dp[i - 1][j + 1] * inapow(nei(j, j + 1));
			dp[i][j] %= 1000000007;
			//cout << dp[i][j] << " ";
		}
		//cout << endl;
	}
	cout << dp[h][k] << endl;
	return 0;
}


Measured memory_bytes: 256
n,m,x,y=map(int,input().split())
x1=max(map(int,input().split()))
x2=min(map(int,input().split()))
z=list(range(x+1,y+1))
for i in z:
	if x1<i<=x2:
		print("No War")
		break
else:
	print("War")

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int n = Integer.parseInt(str[0]);
        int k = Integer.parseInt(str[1]);

        long ans = (long)k;
        for(int i=1; i<n; i++) ans *= k-1;
        System.out.println(ans);
    }
}


Measured memory_bytes: 21332
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n = ii()
    L = lmi()
    minus = len(list(filter(lambda x: x<0, L)))
    pos = list(map(abs, L))
    if minus % 2 == 0:
        print(sum(pos))
    else:
        print(sum(pos) - min(pos) * 2)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14512
let print_array l =
  Array.fold_left (fun x y -> (if x = "" then "" else x^" ")^(string_of_int y)) "" l |> print_endline;;
let to_list s = Str.split (Str.regexp_string " ") s |> List.map (fun x -> int_of_string x) |> Array.of_list;;

let rec sort l = function
    i when i = Array.length l -> print_array l;l
  | i -> print_array l;
         let key = l.(i) in
         let rec insert l2 = function
             j when j < 0 || l2.(j) <= key -> l2.(j+1)<-key;l2
           | j -> l2.(j+1)<-l2.(j); insert l2 (j-1)
         in sort (insert l (i-1)) (i+1);;

let _ = read_int () and
    a = read_line () |> to_list;;
let _ = sort a 1;;

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

ll A, B, C, K;

signed main(){
    cin >> A >> B >> C >> K;
    if(A>=K) cout << K << endl;
    else if(A+B>=K) cout << A << endl;
    else cout << A-(K-A-B) << endl;
    return 0;
}

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

int main(){
  int n,i,sum,max1;
  cin >> n;
  vector<int> h(n);
  for(i=0;i<n;++i){
    cin >> h[i];
  }
  sum=1;
  max1=h[0];
  for(i=1;i<n;i++){
    if(h[i]>=max1){
      sum=sum+1;
      max1=max(h[i],max1);
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
def solve():
    s = int(input())
    n = s
    a = {s}
    for i in range(2, 10 ** 6 + 1):
        if n % 2 == 0:
            n = n // 2
        else:
            n = 3 * n + 1
        if n in a:
            print(i)
            exit()
        else:
            a.add(n)







if __name__ == '__main__':
    solve()


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

typedef long long ll;

int digit(ll a){
    int digitA;
    digitA = to_string(a).length();
    return digitA;
}
vector<ll> findFactors(ll num){  //素因数分解による全探索->TLEになるため不採用
    vector<ll> vec;
    while(num%2==0){
        num /= 2;
        vec.push_back(2);
    }
    for(int i=3;i<num;i++){
        while(num%i==0){
            num /= i;
            vec.push_back(i);
        }
    }
    return vec;
}

int main(){
    ll n; cin>>n;
    int ans = 10;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            int save = max(digit(i),digit(n/i));
            if(ans>save) ans = save;
        }
    }
    printf("%d",ans);

    return 0;
}

Measured memory_bytes: 256
n = int(input())
As = list(map(int, input().split()))
As.sort()
a1 = As[-1]
a2 = 0
a3 = As[-1]
m = a1//2
for a in As:
    if a > a2 and a <=m:
        a2 = a
    elif a < a3 and m < a:
        a3 = a
if m % 2 == 0:
    if abs(a2-m) <= abs(a3-m):
        print(a1, a2)
    else:
        print(a1, a3)
else:
    if abs(a2-m) <= abs(a3-m-1):
        print(a1, a2)
    else:
        print(a1, a3)

Measured memory_bytes: 14056
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define vi vector < ll  int >
#define CLR(a) memset((a),0,sizeof(a))
#define mp make_pair
#define hell 1000000007
using namespace std;

#define MAXN 100001
int spf[MAXN];
void sieve()
{
	spf[1] = 1;
	for (int i=2; i<MAXN; i++)
		spf[i] = i;
	for (int i=4; i<MAXN; i+=2)
		spf[i] = 2;

	for (int i=3; i*i<MAXN; i++)
	{
		if (spf[i] == i)
		{
			for (int j=i*i; j<MAXN; j+=i)

				if (spf[j]==j)
					spf[j] = i;
		}
	}
}

vector<int> gf(int x)
{
	vector<int> ret;
	while (x != 1)
	{
		ret.push_back(spf[x]);
		x = x / spf[x];
	}
	return ret;
}
int BIT[100050];
void upd(int x) { ++x;  while(x<=MAXN)  {  BIT[x]++;  x+=(x&-x);  } }
int cal(int x) {  ++x;  int res=0;  while(x>0)  {  res+=BIT[x];  x-=(x&-x);  } return res; }

void solve()
{
ll i,j=0,r=200,p,q,k=0,d,y=0,n,h=100000000000000,flag=0,m=0,a=hell,b=hell,id,h1,h2,a1,b1,a2,w,x,u,f,l,c=0,e,ans=0;
 char ch;
 cin>>ch;
 cout<<char(ch+1);

}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
     //cin>>t;
    while(t--)
    solve();

}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  int mid = K/2;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> x[i];
    if (x[i] > mid) ans += 2*(K-x[i]);
    else ans += 2*x[i];
  }
  cout << ans << endl;
}


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

int main( int argc, char *argv[] )
{
	int N,K;
	int *a;
	long long int ans=0;
	scanf("%d%d",&N,&K);
	a=(int *)malloc(N*sizeof(int));
	for(int i=0; i<N; i++){
		scanf("%d",&a[i]);
		if(a[i]>0)ans+=a[i];
	}
	long long int min,tmp=0,tmp1=0;
	for(int i=0; i<K; i++){
		if(a[i]<0)tmp-=a[i];
		else tmp1+=a[i];
	}
	if(tmp<tmp1)min=tmp;
	else min=tmp1;
	
	for(int i=K; i<N; i++){
		long long int tmp2=a[i-K];
		if(tmp2<0)tmp+=tmp2;
		else tmp1-=tmp2;
		if(a[i]<0)tmp-=a[i];
		else tmp1+=a[i];
		if(tmp<min)min=tmp;
		if(tmp1<min)min=tmp1;
	}
	printf("%lld\n",ans-min);
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void){
int a, b, c, i, n;
scanf("%d %d %d", &a, &b, &c);
for(i = a; i <= b; i++){
  if((c % i) == 0){
    n++;
    }
  }
printf("%d\n", n);
return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  string hi = "hi";
  string ans = "Yes";
  for (int i = 0; i < s.size(); i++)
  {
    if(s[i] != hi[i%2]){
      ans = "No";
    }
  }

  if(s.size() % 2) {
    ans = "No";
  }

  cout << ans << endl;
  

  return 0;
}

Measured memory_bytes: 256