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;

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  rep(i,n) cin >> x[i] >> y[i];
  auto dist = [&](int i, int j) {
    double dx = x[i]-x[j];
    double dy = y[i]-y[j];
    return sqrt(dx*dx+dy*dy);
  };
  double len = 0;
  rep(i,n)rep(j,i) {
    len += dist(i,j);
  }
  int num = 2;
  for (int i = n-1; i >= 1; --i) num *= i;
  int fact = 1;
  for (int i = n; i >= 1; --i) fact *= i;
  double ans = (len*num) / fact;
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define VI vector<int>
const int MOD = 1e9 + 7;

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

    auto add = [] (int &a, int b) {
        a += b;
        if(a >= MOD)
            a -= MOD;
    };
    
    int dp[2][305][305];
    memset(dp, 0, sizeof(dp));
    
    dp[0][0][n] = 1;

    for(int i = 0; i < m; ++i) {
        int par = i % 2;
        memset(dp[1 - par], 0, sizeof(dp[1 - par]));
        for(int j = 0; j <= min(i, n - 1); ++j)
            for(int k = 1; k <= n; ++k) {
                //cerr << i << " " << j << " " << k << " " << dp[par][j][k] << "\n";
                add(dp[1 - par][j + 1][min(j + 1, k)], dp[par][j][k]);
                add(dp[1 - par][j][n], 1LL * dp[par][j][k] * min(k, j + 1) % MOD);
                add(dp[1 - par][j][k], 1LL * dp[par][j][k] * max(0, (j + 1 - k)) % MOD);
            }
    }

    int ans = dp[m % 2][n - 1][n];

    for(int i = 1; i <= n - 1; ++i)
        ans = 1LL * ans * i % MOD;

    cout << ans << "\n";
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>

int main()
{
    // std::cout << std::fixed << std::setprecision(5);
    std::string s;
    std::cin >> s;

    for(int i=2; i<s.length(); i+=2)
    {
        std::string p = s.substr(0, (s.length()-i)/2);
        std::string q = s.substr((s.length()-i)/2, (s.length()-i)/2);
        if(p==q)
        {
            std::cout << p.length() * 2 << std::endl;
            return 0;
        }
    }
}

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


int main() {
  int n,l;
  cin >> n >> l;
  vector<string>s(n);
  for (int i = 0; i < n; i++) {
    cin >> s.at(i);
  }
  sort(s.begin(),s.end());
  for (int i = 0; i< n; i++) {
    cout << s.at(i);
  }
}

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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (2000000000)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  int h,w;
  cin >> h >> w;
  string s;
  string a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  rep(i,h){
    rep(j,w){
      cin >> s;
      if(s == "snuke"){
        cout << a[j] << i+1 << endl;
        return 0;
      }
    }
  }
}

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

long long n,cost;

int main(){

	cin>>n;
	int v[n+3];
	
	for(int i=1;i<=n;i++)cin>>v[i];
	v[0]=v[n+1]=0;
	
	
	for(int i=1;i<=n+1;i++){
	    cost+=abs(v[i]-v[i-1]);
    }

    
    for(int i=1;i<=n;i++){
        cout<<cost-abs(v[i]-v[i-1])-abs(v[i]-v[i+1])+abs(v[i+1]-v[i-1])<<endl;
    }

return 0;
}


Measured memory_bytes: 1664
void main() {
	auto ip = readAs!(ulong[]), N = ip[0], P = ip[1];
	if(N == 1) {
		writeln(P);
		return;
	}
	auto arr = generate_prime_list(pow(P, 1./N).ceil.to!ulong + 1);
	ulong[] m;
	foreach(i; arr) {
		ulong k;
		while(P % i == 0) {
			P /= i;
			k++;
		}
		if(k >= N) m ~= i ^^ (k / N);
	}
	if(m != []) m.reduce!"a*b".writeln;
	else writeln(1);
}

ulong[] generate_prime_list(T)(T N) if(isIntegral!T) {
	ulong[] prime_list = [2];
	bool not_prime = false;
	foreach(i; 3..N.to!ulong+1) {
		auto p = i.to!float.sqrt.ceil.to!ulong;
		foreach(j; prime_list) {
			if(j > p) break;
			if(i % j == 0) {
				not_prime = true;
				break;
			}
		}
		if(!not_prime) prime_list ~= i;
		not_prime = false;
	}
	return prime_list;
}

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

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define revrep(i,n) for(long long i=n-1;i>=0;i--)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define pv(x) copy(all(x),output)
#define pa(a) rep(i,0,sizeof(a)/sizeof(a[0]))cout<<a[i]<<" "
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define test int t;cin>>t; while(t--)
#define set0(x) memset(x,0,sizeof(x))
#define set1(x) memset(x,1,sizeof(x))
#define getarr(arr,n) int arr[n];rep(i,0,n)cin>>a[i]
#define getvec(vec,n) vi vec;int x;rep(i,0,n){cin>>x;vec.pb(x);}
#define dg(x) cout<<#x<<':'<<x<<endl;
#define dg2(x,y) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<endl;
#define dg3(x,y,z) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<' '<<#zz<<':'<<zz<<endl;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
vi b_v;void bin(unsigned int n) { if (n > 1) bin(n>>1); b_v.pb(n & 1); }
int isPowerof2(int x) { return (x && !(x & x-1)); }

int32_t main(){
	boost;osit;
	int n;
	cin>>n;
	vii a(n);
	rep(i,0,n){
		int x,y;
		cin>>x>>y;
		a[i]={y,x};
	}
	sort(all(a));
	int t=0;
	rep(i,0,n){
		t+=a[i].s;
		if(t>a[i].f){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    string S;
    cin >> S;
    vector<long long> a(S.size() + 1);
    vector<long long> b(S.size() + 1);
    vector<long long> c(S.size() + 1);

    for (int i = 0; i <= S.size() - 1; i++)
    {
        if (S[i] == '<') a[i + 1] = a[i] + 1;
    }

    for (int i = S.size() - 1; i >= 0; i--)
    {
        if (S[i] == '>') b[i] = b[i + 1] + 1;
    }
    
    long long ans = 0;
    for (int i = 0; i < c.size(); i++)
    {
        c[i] = max(a[i], b[i]);
        ans += c[i];
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 12664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=1e9+7;
int main()
{
    ll n,m;
    cin>>n>>m;
    if(abs(n-m)>1)
    {
        printf("0\n");
        return 0;
    }
    if(n==m)
    {
        ll ans=n+m;
        n--;
        bool flag=true;
        while(n>1||m>1)
        {
            if(flag)
            {
                ans=(ans*m)%maxn;
                m--;
            }
            else
            {
                ans=(ans*n)%maxn;
                n--;
            }
            flag=!flag;
        }
        printf("%lld\n",ans%maxn);
    }
    else if(n>m)
    {
        ll ans=n;
        n--;
        bool flag=true;
        while(n>1||m>1)
        {
            if(flag)
            {
                ans=(ans*m)%maxn;
                m--;
            }
            else
            {
                ans=(ans*n)%maxn;
                n--;
            }
            flag=!flag;
        }
        printf("%lld\n",ans%maxn);
    }
    else
    {
        ll ans=m;
        m--;
        bool flag=true;
        while(n>1||m>1)
        {
            if(!flag)
            {
                ans=(ans*m)%maxn;
                m--;
            }
            else
            {
                ans=(ans*n)%maxn;
                n--;
            }
            flag=!flag;
        }
        printf("%lld\n",ans%maxn);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=100010;
map <pair<int,int>,int> ma;
vector <int> wall[5];
struct node {
    int p[4],top;
}line[maxn*2];
int vis[maxn*2];
struct node2 {
    int id,val;
}s[maxn*2];
int C,R,ss[maxn*2];
int cmp(node a,node b)
{
    return a.p[0]<b.p[0];
}
int cmp3(node2 a,node2 b) {
    return a.val<b.val;
}
int onwall(int x,int y)
{
    if (y==C) return 1;
    if (x==R) return 2;
    if (y==0) return 3;
    if (x==0) return 4;
    return -1;
}
int cmp2(int x,int y)
{
    return x>y;
}
int main()
{
   // freopen("text.in","r",stdin);
    node2 e;
    int top,x1,x2,y1,y2,n,pos1,pos2,i,j,cnt,id,win,tops;
    scanf("%d%d%d",&R,&C,&n);
    top=0;
    for (i=1;i<=n;i++) {
        scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
        pos1=onwall(x1,y1); pos2=onwall(x2,y2);
        if (pos1==-1||pos2==-1) continue ;
        //printf("id=%d qwe  %d %d\n",i,pos1,pos2);
        ++top;
        if (pos1==1||pos1==3) {
            wall[pos1].push_back(x1);
            ma[make_pair(pos1,x1)]=top;
        }else {
            wall[pos1].push_back(y1);
            ma[make_pair(pos1,y1)]=top;
        }
        if (pos2==1||pos2==3) {
            wall[pos2].push_back(x2);
            ma[make_pair(pos2,x2)]=top;
        }else {
            wall[pos2].push_back(y2);
            ma[make_pair(pos2,y2)]=top;
        }
    }
    for (i=1;i<=4;i++) {
        if (i==1||i==4) sort(wall[i].begin(),wall[i].end());
        else sort(wall[i].begin(),wall[i].end(),cmp2);
        /*for (j=0;j<wall[i].size();j++) {
            printf("%d ",wall[i][j]);
        }
        printf("\n");*/
    }
    cnt=0;
    for (i=1;i<=4;i++) {
        for (j=0;j<wall[i].size();j++) {
            ++cnt;
            //id=ma[i][wall[i][j]];
            id=ma[make_pair(i,wall[i][j])];
            line[id].p[line[id].top++]=cnt;
        }
    }
    for (i=1;i<=top;i++) {
        if (line[i].p[0]>line[i].p[1]) swap(line[i].p[0],line[i].p[1]);
    }
    sort(line+1,line+top+1,cmp);
    win=1;
    /*printf("top=%d\n",top);
    for (i=1;i<=top;i++) {
        printf("%d %d\n",line[i].p[0],line[i].p[1]);
    }*/
    /*for (i=2;i<=top;i++) {
        if (line[i].p[0]<line[i-1].p[1]) {win=0; break ;}
    }
    if (win) {
        printf("YES\n");
    }else {
        printf("NO\n");
    }*/
    tops=0;
    for (i=1;i<=top;i++) {
        e.val=line[i].p[0];
        e.id=i;
        s[++tops]=e;
        e.val=line[i].p[1];
        e.id=i;
        s[++tops]=e;
    }
    memset(ss,0,sizeof(ss));
    memset(vis,0,sizeof(vis));
    sort(s+1,s+tops+1,cmp3);
    /*printf("\n\n\n\n");
    for (i=1;i<=tops;i++) {
        printf("%d %d\n",s[i].id,s[i].val);
    }*/
    for (i=1;i<=tops;i++) {
        if (!vis[s[i].id]) {
            ss[++ss[0]]=s[i].id;
            vis[s[i].id]=1;
        }else {
            if (ss[ss[0]]!=s[i].id) {win=0; break ;}
            else {
                ss[0]--;
            }
        }
    }
    if (win) {
        printf("YES\n");
    }else {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 19696
#include<map>
#include<iostream>
#include<iomanip>
//#include<conio.h>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<stdio.h>
#include<fstream>
#include<assert.h>
#include<time.h>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<sstream>
#include<string.h>
#define mp make_pair
#define ll long long
#define all(v) v.begin(),v.end()
#define memset(a,b) memset(a,b,sizeof(a))
using namespace std;
const int INF=1e9;
inline void write(ll x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void rd(long long &val){
    long long x=0;
    int f=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-'){
		f=-1;
		ch=getchar();
	}
    while(ch>='0'&&ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    val=x*f;
}
inline void rd(int &val){
    int x=0;
    int f=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-'){
		f=-1;
		ch=getchar();
	}
    while(ch>='0'&&ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    val=x*f;
}
inline void print(int x){
	write(x);
	putchar('\n');
}
vector<pair<int,int> >g[1000005];
vector<int> newg[1000005],all[1000005];
int use[1000005];
int dist[1000005];
int x[1000005],n,m,b,e;
int ptr[1000005];
int main(){
	ios_base::sync_with_stdio(false);
	int i,j;
	int p,q,z,mx=0,u,v,c,col,it;
	rd(n);
	rd(m);
	for(i=0;i<m;++i){
		rd(p),rd(q),rd(z);
		--p,--q;
		g[p].push_back(mp(z,q));
		g[q].push_back(mp(z,p));
		all[z].push_back(p);
		all[z].push_back(q);
		mx=max(mx,z);
	}
	for(i=0;i<n;++i) sort(g[i].begin(),g[i].end());
	int newn=n;
	for(col=0;col<=mx;++col){
		if(!all[col].size()) continue;
		for(it=0;it<all[col].size();it++){
			v=all[col][it];
			if(use[v]==col) continue;
			queue<int> q;
			q.push(v);
			use[v]=col;
			vector<int> vec;
			vec.push_back(v);
			while(!q.empty()){
				int t=q.front();
				q.pop();
				while(ptr[t]<g[t].size()){
					c=g[t][ptr[t]].first;
					if(c!=col) break;
					u=g[t][ptr[t]].second;
					if(use[u]!=col){
						use[u]=col;
						q.push(u);
						vec.push_back(u);
					}
					++ptr[t];
				}
			}
			for(i=0;i<vec.size();++i){
				newg[vec[i]].push_back(newn);
				newg[newn].push_back(vec[i]);
			}
			++newn;
		}
	}
	for(i=0;i<newn;++i) dist[i]=-2;
	queue<int> qu;
	dist[0]=0;
	qu.push(0);
	while(!qu.empty()){
		int t=qu.front();
		qu.pop();
		for(i=0;i<newg[t].size();++i){
			u=newg[t][i];
			if(dist[u]==-2){
				dist[u]=dist[t]+1;
				qu.push(u);
			}
		}
	}
	cout<<dist[n-1]/2<<endl;
	return 0;
}

Measured memory_bytes: 102016
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORS(i, m, n) for (int i = m; i <= n; i++)
#define BIT(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H - h) * (W - w) << "\n";
}

Measured memory_bytes: 256
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll              long long
#define pi              pair<int,int>
#define pll             pair<ll,ll>
#define pb              push_back
#define F               first
#define S               second
#define vi              vector<int>
#define vll             vector<ll>
#define endl            '\n'
#define all(v)          (v).begin(),(v).end()
#define FOR(i,a,b)      for(int i=a;i<b;i++)
#define MP(a,b)         make_pair(a,b)
#define debug(x)        cerr<< #x << " : " << x << endl;
#define debugp(p)       cerr<< #p << " : " << "(" << (p).first << "," << (p).second << ")\n";
#define debugv(v)       cerr<< #v << " : " << "["; for(int i = 0; i < (v).size(); i++) cerr << v[i] << " "; cerr<<"]\n";
#define debugs(m)       cerr<< #m << " : [ "; for(auto itr = m.begin(); itr != m.end(); itr++) cerr <<*itr << " "; cerr << "]\n";
#define debugm(m)       cerr<< #m << " : [ "; for(auto itr = m.begin(); itr != m.end(); itr++) cerr <<"(" << itr->first << "," << itr->second << ") "; cerr << "]\n";

/* ordered set: 
tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
member functions :
1. order_of_key(k) : number of elements strictly lesser than k
2. find_by_order(k) : k-th element in the set
*/

inline ll modexp(ll x, ll ex , ll md) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}

const int inf = 1e9 + 7;

void solve(){
    int n , k;
    cin >> n >> k;
    vector<int> h (n + k + 4 , 0);
    for (int i = 1; i <= n; i++) cin >> h[i];
    vector<int> dp (n + k + 4 , inf);
    dp[1] = 0;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= k; j++){
            dp[i + j] = min (dp[i + j] , dp[i] + abs (h[i + j] - h[i]));
        }
    }
    cout << dp[n] << endl;
}
int main(){
    ios :: sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr);
    
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    #ifdef LOCAL
    cerr << "Time elapsed\t: " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";       
    #endif
}



Measured memory_bytes: 3932
n, k = list(map(int, input().split()))
costs = list(map(int, input().split()))

if k > n:
    k == n

if n == 2:
    print(abs(costs[-1] - costs[-2]))
else:
    dp = [float("inf") for i in range(n)]
    dp[-1] = 0

    for i in range(1, k + 1):
        curr_min = float("inf")
        for j in range(i):
            curr_min = min(abs(costs[n - i - 1] - costs[n - j - 1]) + dp[n - j - 1], curr_min)
        dp[n - i - 1] = curr_min    

    for i in range(n - k - 2, -1, -1):
        curr_min = float("inf")
        for j in range(1, k + 1):
            curr_min = min(curr_min, abs(costs[i] - costs[i + j]) + dp[i + j]) 
        dp[i] = curr_min

    print(dp[0])


Measured memory_bytes: 88664
N = int(input())
A = list(map(int,input().split()))

cnt = 0
flag = False
while True:
    for i in range(N):
        if A[i] % 2 == 1:
            flag = True
            break
    else:
        cnt += 1
    if flag:
        break
    A = list(map(lambda x:x//2,A))
print(cnt)

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

int main(){
	int n;
	cin >> n;
	int r,l,a,b;
	for(int i = 0; i < n; i++){
		cin >> r >> l >> a >> b;
		int c = r * a + l * b;
		cout << (a > 4 && b > 1 ? c / 10 * 8 : a > 4 ? min(c,(r * a + l * 2)/ 10 * 8) : b > 1 ?  min(c,(r * 5 + l * b)/ 10 * 8) : min(c,(r * 5 + l * 2)/ 10 * 8)) << endl;
	}
	return 0;
}


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

int main() {
  long long n;
  cin>>n;
  map<string,int>mp;
  int max=0;
  for(long long i=0;i<n;i++){
    string s;
    cin>>s;
    mp[s]++;
    if(max<mp[s]){
      max=mp[s];
    }
  }
  vector<string>ans;
  for(auto x:mp){
    if(x.second==max){
      ans.push_back(x.first);
    }
  }
  sort(ans.begin(),ans.end());
  for(long long i=0;i<ans.size();i++){
    cout<<ans.at(i)<< endl;
  }
}


Measured memory_bytes: 26868
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

int main(){
  int n, c1 = 0, c2 = 0, c4 = 0;
  scanf("%d", &n);
  for(int i = 0, x;i < n;++i){
    scanf("%d", &x);
    if(x % 4 == 0) ++c4;
    else if(x % 2 == 0) ++c2;
    else ++c1;
  }

  if(c2 > 0) ++c1;

  printf(c1 <= c4 + 1 ? "Yes\n" : "No\n");

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        String S = sc.next();
                        if ((S.length()-(S.charAt(0)==S.charAt(S.length() - 1)?1:0)) % 2 == 0) {
                                System.out.println("Second");
                        } else {
                                System.out.println("First");
                        }
                }
        }
}

Measured memory_bytes: 13708
def main():
    n, m, x, y = map(int, input().split())

    x_max = max(list(map(int, input().split())) + [x])
    y_min = min(list(map(int, input().split())) + [y])

    print('No War' if x_max < y_min else 'War')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	int n;
	float m;
	cin >> n >> m;
	vector<float> a(n);
	for (int i=0; i<n; i++)
		cin >> a[i];

	int sum=0;
	for (int i=0; i<n; i++) sum += a[i];

	int cnt=0;
	for (int i=0; i<n; i++) {
		if (a[i] >= sum /(4*m)){
			cnt++;
		}
	}

	if (cnt >= m)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  string c;
  cin >> c;
  vector<int> r(0), w(0);
  for (int i = 0; i < N; i++) {
    if (c[i] == 'R') r.push_back(i);
    else w.push_back(i);
  }
  reverse(r.begin(),r.end());
  
  int rsize = r.size();
  int wsize = w.size();
  int i = 0;
  while(true) {
    if (i == rsize) break;
    if (i == wsize) break;
    if (r[i] < w[i]) break;
    i++;
  }
  cout << i << endl;
}

Measured memory_bytes: 4684
#include <bits/stdc++.h>
using  namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
#define INF 1e18+1


int main(){
	int k,t;
	int ma=0;
	cin>>k>>t;
	REP(i,t){
		int a;
		cin>>a;
		ma=max(ma,a);
	}
	int ans=0;
	if((k+1)/2<ma){
		ans=ma-(k-ma)-1;
	}
	cout<<ans<<endl;
}
	
	

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

int main (void){
  int h,w;
  string s[110];

  cin >> h >> w;
  for(int i = 0;i < h;i++){
    cin >> s[i];
  }

  for(int i = 0;i <= w+1;i++){
    cout << '#';
  }
  cout << '\n';

  for(int i = 0;i < h;i++){
    cout << '#' << s[i] << "#\n";
  }

  for(int i = 0;i <= w+1;i++){
    cout << '#';
  }
  cout << '\n';

  return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll v[300001],n,ans;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
        if(v[i]<v[i-1])
        {
            ans+=(v[i-1]-v[i]);
            v[i]=v[i-1];
        }
    }
    cout<<ans;
    return 0;
}


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

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

// code starts
int main()
{
  int n;
  ll x;cin>>n>>x;
  vector<ll> meat(n+1,0);
  vector<ll> pan(n+1,0);
  meat[0]=1;
  int i;
  for(i=1;i<=n;i++)
  {
    meat[i]=meat[i-1]*2+1;
    pan[i]=pan[i-1]*2+2;
  }
  ll right=meat[n]+pan[n];
  ll left=1;
  ll mid;
  ll ans=0;
  int nlev=n;
  while(nlev>0)
  {
    mid=(left+right)/2;
    if(x==left)break;
    else if(x==right)
    {
      ans+=meat[nlev];
      break;
    }
    else if(x<mid)
    {
      left++;
      right=mid-1;
    }
    else if(x>mid)
    {
      left=mid+1;
      right--;
      ans+=meat[nlev-1]+1;
    }
    else
    {
      ans+=meat[nlev-1]+1;
      break;
    }
    nlev--;
  }
  if(nlev==0)ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; for(auto v : V) os << v << " "; return os << "]"; }
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; for(auto s:S) os<<s<<" ";return os<<"}"; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) { return os << "(" << P.first << "," << P.second << ")";}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) { os << "{ "; for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") "; return os<<"}"; }
#ifdef LMAO
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | "; __f(comma+1, args...); }
#else
    #define trace(...) 42
#endif
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
#define all(x) x.begin(), x.end()
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000010;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;    
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)   
/*****************start************/

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed<<setprecision(25);cerr<<fixed<<setprecision(10);
    string s,t;
    cin>>s>>t;
    int n=s.size();
    int m=t.size();
    vector<vector<int>> dp(n+1,vector<int> (m+1,0));
    vector<vector<pair<int,int>>> par(n+1,vector<pair<int,int>> (m+1,{-1,-1}));
    //dp[i][j]=dp[i-1][j-1]+a[i]==b[j], dp[i][j-1],dp[i-1][j]
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
                par[i][j]={i-1,j-1};
            }
            else if(dp[i-1][j]>dp[i][j-1])
            {
                dp[i][j]=dp[i-1][j];
                par[i][j]={i-1,j};
            }
            else
            {
                dp[i][j]=dp[i][j-1];
                par[i][j]={i,j-1};
            }
        }
    }
    string ans;
    int x=n,y=m;
    while(par[x][y]!= make_pair(-1,-1))
    {
        pair<int,int> lo;
        if(par[x][y]==make_pair(x-1,y-1))
        {
            ans+=s[x-1];
        }
        lo=par[x][y];
        x=lo.first;
        y=lo.second;
    }
    reverse(all(ans));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 109000
#include<cstdio>
#include<iostream>
using namespace std;
int n,l,b,a[100005];
int main(){
	scanf("%d%d",&n,&l);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		if(a[i]+a[i-1]>=l) b=i-1;
	}
	if(!b){printf("Impossible");return 0;}
	printf("Possible\n");
	for(int i=1;i<b;++i) printf("%d\n",i);
	for(int i=n-1;i>=b;--i) printf("%d\n",i);
}

Measured memory_bytes: 1152
K = int(input())
A = list(map(int, input().split()))

if A[-1] != 2:
    print(-1)
    exit()
else:
    m, M = 2, 3
    for i in range(K-2, -1, -1):
        if A[i] > M:
            print(-1)
            exit()
        else:
            if m % A[i] != 0:
                m = (m // A[i] + 1) * A[i]
            M = (M // A[i] + 1) * A[i] - 1
if m > M:
    print(-1)
    exit()
else:
    print(m, M)

Measured memory_bytes: 14252
A, B, K = map(int, input().split())

list2 = [ A + K - 1 , B - K + 1]
if A + K - 1 >= B - K +1 or A > B - K:
    i = A
    while i <= B:
        print(i)
        i += 1
else:
    i = A
    while i <= A + K - 1:
        print(i)
        i += 1
    i = B - K + 1
    while i <= B:
        print(i)
        i += 1


Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int n = stdIn.nextInt();
			if(n == 0) break;
			int counter = 0;
			for(int i = 1; i < n; i++) {
				if(sorv(i,n)) {
					counter++;
				}
			}
			System.out.println(counter);
		}
	}
	
	public static boolean sorv(int i,int n) {
		int p = i++;
		while(true) {
			p += i++;
			if(p == n) return true;
			if(p > n) return false;
		}
	}

}

Measured memory_bytes: 19844
#include <stdio.h>

int main()
{
    float k;
    int a,b,c;
    
    scanf("%d%d",&a,&b);
    k=(float)(a+b)/2;
    c=k;
    if(c+0.5==k)
    {c++;
        printf("%d",c);
    }else{
        if(c+0.5<k)
        {c++;
            printf("%d",c+1);
        }else{
            printf("%d",c);
        }
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int X, N;
  cin>>X>>N;

  vector<Int> A(N);
  cin>>A;
  sort(A.begin(), A.end());

  set<Int> S;
  for(Int a:A) S.insert(a);

  Int ans = -INF;
  for(Int i=-1000;i<=1000;i++){
    if(S.count(i)) continue;
    if(abs(X - ans) > abs(X - i)) ans = i;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3660
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::cmp::Ordering;

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}
impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

fn main() {
    input! {
        r: i32,
        g: i32
    }
    let ans = 2 * g - r;
    println!("{}", ans);
} 


Measured memory_bytes: 4352
A, B = map(int, input().split())

Amin = -(-A*100//8)

Amax = -(-(A+1)*100//8) -1

Bmin = -(-B*100//10)

Bmax = -(-(B+1)*100//10) -1

if Amin > Bmax or Bmin > Amax:
  print(-1)
else:
  print(max(Amin, Bmin))

Measured memory_bytes: 3060
#include <iostream>
#include <string.h>
#include <queue>

#define W_MAX 32
#define H_MAX 32
#define mp make_pair


int maze[H_MAX][W_MAX];

int hline[H_MAX][W_MAX];
int wline[H_MAX][W_MAX];


using namespace std;

int main(void)
{
	int w,h;
	int i1,i2,i3;
	int x,y;
	int gool;
	int num;

	while(1){
		cin >> w >> h;
		if(w+h==0) break;

		memset(maze,-1,sizeof(maze));
		memset(hline,-1,sizeof(hline));
		memset(wline,-1,sizeof(wline));

		for(i1=1;i1<=h;i1++){
			for(i2=1;i2<=w;i2++){
				maze[i1][i2]=0;
			}
			
		}

		for(i1=1;i1<h;i1++){
			for(i2=1;i2<w;i2++) cin >> hline[i1][i2];
			for(i2=1;i2<=w;i2++) cin >> wline[i1][i2];
		}
		for(i2=1;i2<w;i2++) cin >> hline[i1][i2];

		queue<pair<int,int> > q;
		q.push(mp(1,1));
		maze[1][1]=1;
		gool=0;

		while(!q.empty()){
			x = q.front().first;
			y = q.front().second;
			q.pop();
			//cout << x << " " << y<< endl;
			if(x==w && y==h) {

				gool=1;
				break;
			}

			num=maze[y][x];

			/* 右　下　左　上*/
			if(maze[y][x+1]==0 && hline[y][x]==0) {
				maze[y][x+1]=num+1;
				q.push(mp(x+1,y));
			}
			if(maze[y+1][x]==0 && wline[y][x]==0) {
				maze[y+1][x]=num+1;
				q.push(mp(x,y+1));
			}
			if(maze[y][x-1]==0 && hline[y][x-1]==0) {
				maze[y][x-1]=num+1;
				q.push(mp(x-1,y));
			}
			if(maze[y-1][x]==0 && wline[y-1][x]==0) {
				maze[y-1][x]=num+1;
				q.push(mp(x,y-1));
			}	
		}

		/*for(i1=1;i1<=h;i1++){
			for(i2=1;i2<=w;i2++){
				cout << maze[i1][i2] << " ";
			}
			cout << endl;
		}*/

		if(gool==1) cout << maze[h][w] << endl;
		else cout << 0 << endl; 

	}

	return 0;
}

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

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

//繰り返し自乗法によるmod累乗計算
//a = 底、　n = 指数
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}

ll comb(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}


int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = modpow(2, n);
  ans--;
  ll nca = comb(n,a);
  ll ncb = comb(n,b);
  ans -= (nca + ncb);
  cout << (ans + mod * 10) % mod << endl;

}






Measured memory_bytes: 256
x, y=input().split()

x, y=int(x), int(y)

out=[]

if x==1:
    if y in [2, 4]:
        print("Yes")
    else:
        print("No")
else:
    for i in range(x+1):
        j=x-i
        if 2*i+4*j==y:
            out.append("succeeded")
            break
        else:
            continue

    if "succeeded" in out:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 9184
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        int P = ni();
        int[] a = new int[N];
        int numOdd = 0;
        int numEven = 0;
        for (int i = 0; i < N; i++) {
            int A = ni();
            a[i] = A;
            if(A%2==0) numEven ++;
            else numOdd++;
        }
        if(numOdd==0){
            if(P%2==1){
                out.println(0);
                return;
            }
        }
        long selectEven = 1;
        for (int i = 0; i < numEven; i++) {
            selectEven *= 2;
        }
        long[] com = new long[numOdd+1];
        com[0] = 1;
        for (int i = 1; i < com.length; i++) {
            com[i] = com[i-1] * (numOdd - i +1) / i;
        }
        // System.out.println(Arrays.toString(com));
        long ans = 0;
        if(P%2 == 1){
            for (int i = 1; i <= numOdd; i+=2) {
                ans += com[i];
            }
        }else{
            for (int i = 0; i <= numOdd; i+=2) {
                ans += com[i];
            }
        }
 
        out.println(ans * selectEven);
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);

    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0;i < n;i++)
#define all(n) n.begin(),n.end()

const int INF = 1e9;

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

	vector<int> imos(100003, 0);
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		imos[a]++;
		imos[b+1]--;
	}
	int ans = 0;
	int count = 0;
	rep(i, imos.size()) {
		count += imos[i];
		if (count >= i) {
			ans = max(i, ans);
		}
	}
	cout << ans << endl;

	return 0;
}

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

#define REP(i, a, b) for (int i = (int)a; i <= (int)b; i++)
#define fi first
#define sc second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int>> vpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<int, int> pii;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

const i64 MOD = 1000000007;
const int INF = 2000000000;

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

	int a;
	string s;

	cin >> a >> s;

	if (a >= 3200) cout << s << endl;
	else cout << "red" << endl;

	return 0;
}

Measured memory_bytes: 384
import heapq


def solve(order_list):
    priority_queue = []
    # time O(N log(N))
    for key, order in enumerate(order_list):
        priority = (order - 1) % 10
        heapq.heappush(priority_queue, [-priority, order, key])

    sum_time = 0
    # time O(N log(N))
    while priority_queue:
        priority, order, key = heapq.heappop(priority_queue)
        if len(priority_queue) and order % 10:
            sum_time += (order // 10 + 1) * 10
        else:
            sum_time += order
    return sum_time


def main():
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())

    ans = solve([a, b, c, d, e])
    print(ans)


main()


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

const int MAXN = 1e5 + 10;
vector<int> vt[MAXN];
int path[MAXN], vis[MAXN], indx = 0;
bool flag = false;
int root, ans = 0;

void dfs(int x, int pre){
    if(flag) return;
    path[pre] = x;
    if(x == root) flag = true;
    for(int i = 0; i < vt[x].size(); i++){
        if(vt[x][i] != pre) dfs(vt[x][i], x);
    }
}

void sol(int x, int pre){
    ans++;
    for(int i = 0; i < vt[x].size(); i++){
        if(vt[x][i] != pre) sol(vt[x][i], x);
    }
}

int main(void){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, x, y;
    cin >> n;
    for(int i = 0; i < n - 1; i++){
        cin >> x >> y;
        vt[x].push_back(y);
        vt[y].push_back(x);
    }
    root = n;
    dfs(1, 0);
    int cnt = 0, pos = 0;
    while(path[cnt] != 0){
        cnt = path[cnt];
        vis[pos++] = cnt;
    }
    int cc = (pos + 1) >> 1;
    sol(vis[cc - 1], vis[cc]);
    if(ans > n - ans) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int MAX = 2e5+10;

vi s;

ll count() {
    ll res = 0;
    ll count = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 0) count++;
        else res += count;
    }
    return res;
}

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

    ll ans;
    REP(i, S.length()-1) {
        if (S[i] == 'A') s.push_back(0);
        else if (S[i] == 'B' && S[i+1] == 'C') { s.push_back(1); i++; }
        else {
            ans += count();
            s = vi(0);
        }
    }
    ans += count();
    cout << ans << endl;
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
 
#define A_MAX 1000000
#define A_MAX_HALF 500000
 
using namespace std;
 
int min_factor[A_MAX + 1];
int q[A_MAX + 1];
int a[A_MAX + 1];
vector<int> primes{ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997 };
int N;
 
// 入力読み込みは uzzy 氏のコードを真似した
const int cm = 1 << 19;
char cn[cm], * ci = cn, ct;
inline int getint() {
    int A = 0;
    while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
    return A;
}
 
int main() {
  	//fread(cn, 1, cm, stdin);
  
    for (int i = 2; i <= A_MAX_HALF; ++i) {
        if (!min_factor[i]) {
            min_factor[i] = i;
        }
        int min_factor_i = min_factor[i];
        for (int p : primes) {
            int n = i * p;
            if (n > A_MAX) {
                break;
            }
            min_factor[n] = p;
            if (p == min_factor_i) {
                q[n] = q[i];
                break;
            } else {
                q[n] = i;
            }
        }
    }
 
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        ++a[A];
    }
 
    int is_pairwise_coprime = 1;
    for (int n = A_MAX; n > 1; --n) {
        int an = a[n];
        if (an) {
            if (an > 1) {
                if (an == N) {
                    printf("not coprime\n");
                    return 0;
                }
                is_pairwise_coprime = 0;
            }
            a[min_factor[n]] += an;
            a[q[n]] += an;
        }
    }
    if (is_pairwise_coprime) {
        printf("pairwise coprime\n");
    } else {
        printf("setwise coprime\n");
    }
 
    return 0;
}

Measured memory_bytes: 15320