akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define maxn 100100
struct P1
{
	string name;
	int v,tim;
	bool operator <(const P1& pp) const 
	{
		if(v!=pp.v) return v<pp.v;
		else return tim<pp.tim;
	}
};
struct P2
{
	string name;
	int v,tim;
	bool operator <(const P2& pp) const 
	{
		if(v!=pp.v) return v>pp.v;
		else return tim>pp.tim;
	}
}a[maxn];
set<P1>s1;
set<P2>s2;
int n,m;
string man;
int v;
#define P pair<int,int>
map<string,P>mp;
P1 p2top1(P2 tmp)
{
	P1 ans;
	ans.name=tmp.name;
	ans.v=tmp.v;
	ans.tim=tmp.tim;
	return ans;
}
P2 p1top2(P1 tmp)
{
	P2 ans;
	ans.name=tmp.name;
	ans.v=tmp.v;
	ans.tim=tmp.tim;
	return ans;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		a[i].tim=i;
		cin>>a[i].name;
		scanf("%d",&a[i].v);
		mp[a[i].name]=P(a[i].v,i);
	}
	sort(a+1,a+n+1);
	int lx=n/5;
	for(int i=1;i<=lx;++i) s1.insert(p2top1(a[i]));
	for(int i=lx+1;i<=n;++i) s2.insert(a[i]);
	scanf("%d",&m);
	int tot=n;
	for(int i=1;i<=m;++i)
	{
		int now=n+i;
		char op[5];
		scanf("%s",op);
		if(*op=='+')
		{
			cin>>man;
			scanf("%d",&v);
			mp[man]=P(v,now);
			tot++;
			set<P1>::iterator it;
			it=s1.begin();
			P1 tmp,this_man;
			if(it!=s1.end())
			{	
				tmp=(*it);
				this_man.name=man;this_man.v=v; this_man.tim=now;
			}
			if(it!=s1.end()&&tmp<this_man)
			{
				s1.insert(this_man);
				cout<<man;
				puts(" is working hard now.");
				if(tot%5!=0)
				{
					P1 tmp=(*it);
					P2 ttmp=p1top2(tmp);
					s1.erase(it);
					s2.insert(ttmp);
					cout<<tmp.name;
					puts(" is not working now.");
					
				}
			}
			else 
			{
				if(tot%5==0)
				{
					set<P2>::iterator it;
					it=s2.begin();
					P2 this_,tmp;
					if(it!=s2.end())
					{
						tmp=(*it);
						this_.name=man; this_.v=v; this_.tim=now;
					}
					else tmp.v=-100000;
					if(this_<tmp)
					{
						P1 cpy=p2top1(this_);
						s1.insert(cpy);
						cout<<man;
						puts(" is working hard now.");
					}
					else
					{
						s2.erase(*it);
						P1 cpy=p2top1(tmp);
						s1.insert(cpy);
						s2.insert(this_);
						cout<<man;
						puts(" is not working now.");
						cout<<tmp.name;
						puts(" is working hard now.");
					}
				}
				else 
				{
					P2 this_;
					this_.name=man; this_.v=v; this_.tim=now;
					s2.insert(this_);
					cout<<man;
					puts(" is not working now.");
				}
			}
		}
		else 
		{
			tot--;
			cin>>man;
			P sx=mp[man];
			set<P1>::iterator it;
			P1 tmp1;
			tmp1.name=man; tmp1.v=sx.first; tmp1.tim=sx.second;
			it=s1.find(tmp1);
			if(it==s1.end())
			{
				//puts("cc2");
				P2 tmp2;
				tmp2=p1top2(tmp1);
				s2.erase(tmp2);
				if(tot%5==4)
				{
					it=s1.begin();
					tmp1=(*it);
					s1.erase(it);
					tmp2=p1top2(tmp1);
					s2.insert(tmp2);
					cout<<tmp1.name;
					puts(" is not working now.");
				}
			}
			else 
			{
				//puts("cc3");
				s1.erase(it);
				if(tot%5!=4)
				{
					set<P2>::iterator it2;
					it2=s2.begin();
					//s2.erase(it2);
					P2 ss=(*it2);
					s2.erase(it2);
					P1 tt=p2top1(ss);
					s1.insert(tt);
					cout<<ss.name;
					puts(" is working hard now.");
				}
			}
		}		
	}
	return 0;
}

Measured memory_bytes: 14364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long int li;
typedef vector<int> vi;
#define pb push_back
vi a;
vi b;
int n,m,x,y;
int main() {
cin>>n>>m>>x>>y;
for(int i=0;i<n;i++)
{
    int g;cin>>g;
    a.pb(g);
}
for(int i=0;i<m;i++)
{
    int g;cin>>g;
    b.pb(g);
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
int z=a[n-1]+1;
if((z)<=b[0] && z>x && z<=y)
{
    cout<<"No War"<<endl;
}else
{
    cout<<"War"<<endl;
}

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static int[][] board = new int[10][10];

	private static final int SMALL  = 1,
			                 MEDIUM = 2,
			                 LARGE  = 3;


    public static void main(String[] args) {

		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				board[i][j] = 0;
			}
		}

        Scanner sc = new Scanner(System.in).useDelimiter(System.getProperty("line.separator"));

        String[] s;
        while(sc.hasNext()){
        	s = sc.next().split(",");
        	update_board(Integer.parseInt(s[0]),Integer.parseInt(s[1]),Integer.parseInt(s[2]));
        }
        System.out.println(cnt_0_cell());
        System.out.println(max_cell());
    }

    private static void update_board(int x,int y,int size){

		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				if((((i == x && (j <= y + 1 &&  j >= y - 1)) || ((i <= x + 1 &&  i >= x - 1) && j == y)) && size == SMALL)  ||
				  (              j <= y + 1 &&  j >= y - 1   &&   i <= x + 1 &&  i >= x - 1              && size == MEDIUM) ||
				  ((             j <= y + 1 &&  j >= y - 1   &&   i <= x + 1 &&  i >= x - 1            ) ||
					            (i == x     &&  j == y - 2)  || ( i == x     &&  j == y + 2)             ||
					            (i == x - 2 &&  j == y    )  || ( i == x + 2 &&  j == y    )   		   ) && size == LARGE)
					{board[i][j]++;}
			}
		}
    }

    private static int cnt_0_cell(){
    	int sum = 0;
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				if(board[i][j] == 0){sum++;}
			}
		}
		return sum;
    }

    private static int max_cell(){
    	int max = 0;
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				if(max < board[i][j]){max = board[i][j];}
			}
		}
		return max;
    }

}

Measured memory_bytes: 17160
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    //一番狭い所を探してあげればいい
    int N,M; cin >> N >> M;
    int cnt=0;
    int l,r;
    cin >> l >> r;
    int mi=l,ma=r;
    cerr << "\n";
    cerr << "\t" << mi << " " << ma << endl;
    for(int i=0;i<M-1;i++){
        cin >> l >> r;
        if(l>=mi){
            mi=l;
        }
        if(r<=mi){
            //mi=r;
        }
        if(l<=ma){
            //ma=l;
        }
        if(r<=ma){
            ma=r;
        }
        cerr << "\t" << mi << " " << ma << endl;
    }
    if(mi>ma){
        cout << 0 << endl;
    }else{
        cout << ma-mi+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 1005, MAX = 5005;
int n, p[N], a[N], dp[N], f[N][MAX];
vector<int> g[N];
void solve(int u) {
	fa (v, g[u]) solve(v);
	fw (i, 0, g[u].size() + 1) fw (j, 0, a[u] + 1) f[i][j] = inf;
	f[0][0] = 0;
	int id = 0;
	fa (v, g[u]) {
		fw (j, 0, a[u] + 1) if (f[id][j] != inf) {
//			cout << "f[" << id << "][" << j << "] = " << f[id][j] << "\n";
			if (j + a[v] <= a[u]) f[id + 1][j + a[v]] = min(f[id + 1][j + a[v]], f[id][j] + dp[v]);
			if (j + dp[v] <= a[u]) f[id + 1][j + dp[v]] = min(f[id + 1][j + dp[v]], f[id][j] + a[v]);
		}
		id++;
	}
	dp[u] = inf;
//	cout << "u = " << u + 1 << "\n";
	fw (j, 0, a[u] + 1) dp[u] = min(dp[u], f[g[u].size()][j]);
//	cout << "dp = " << dp[u] << "\n";
}
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	p[0] = -1;
	fw (i, 1, n) cin >> p[i], p[i]--, g[p[i]].pb(i);
	fw (i, 0, n) cin >> a[i];
	memset(dp, 63, sizeof dp);
	solve(0);
	if (dp[0] == inf) cout << "IMPOSSIBLE";
	else cout << "POSSIBLE";
	return 0;
}

Measured memory_bytes: 17408
#include <stdio.h>
char s[10];
int main()
{
  while((scanf("%s",s))!=EOF){
    if(s[0] != 's' &&
       (s[0] == s[1] && s[0] == s[2] ||
	s[0] == s[3] && s[0] == s[6] ||
	s[0] == s[4] && s[0] == s[8])) {
      printf("%c\n",s[0]);
    }else if(s[5] != 's' &&
	     (s[5] == s[3] && s[5] == s[4] ||
	      s[5] == s[2] && s[5] == s[8])){
      printf("%c\n",s[5]);
    }else if(s[7] != 's' &&
	     (s[7] == s[6] && s[7] == s[8] ||
	      s[7] == s[1] && s[7] == s[4])){
      printf("%c\n",s[7]);
    }else if(s[2] != 's' && s[2] == s[4] && s[2] == s[6]){
      printf("%c\n",s[2]);
    }else{
      printf("d\n");
    }
  }
  return 0;
}

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

int main()
{
string s ;
cin >> s ;
if(s[0]!=s[1]||s[1]!=s[2])cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		String n;
		try (Scanner sc = new Scanner(System.in)) {
			n = sc.next();
			System.out.println(String.format("%32s", Long.toBinaryString(Long.parseLong(n))).replace(' ', '0'));
			System.out.println(String.format("%32s", Long.toBinaryString(~Long.parseLong(n))).substring(32));
			System.out.println(String.format("%33s", Long.toBinaryString(Long.parseLong(n)<<1)).replace(' ', '0').substring(1));
			System.out.println(String.format("%32s", Long.toBinaryString(Long.parseLong(n)>>>1)).replace(' ', '0'));
		}
	}
}


Measured memory_bytes: 26388
#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define lll pair<ll,ll>
#define ii pair<int, int>
#define vii vector<ii>
#define vi vector<int>
#define ff first
#define ss second
#define pb(a) push_back(a)
#define ppb() pop_back()
#define mkp(a,b) make_pair(a,b)
#define vs vector<string>
#define vc vector<char>
#define deb1(a) cout<<#a<<" "<<a<<"\n"
#define deb2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<"\n";
#define deb3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<"\n"
#define all(a) a.begin(),a.end()
#define mms0(a) memset(a,0,sizeof(a))
#define mms1(a) memset(a,-1,sizeof(a))
#define FOR(a,b,c) for(int i=(a);i<(b);i+=(c))
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define _ 0
using namespace std;

int N,M;
vi *g;
vi dp(100001,-1);

int dfs(int u){
   if(g[u].size() == 0) return 0;
   if(dp[u] != -1) return dp[u];

   int len = 0;
   for(auto it:g[u]){
      len = max(len,1 + dfs(it));
   }
   return dp[u] = len;
}

int long_path(){
   for(int i=1;i<=N;i++){
      dfs(i);
   }
  // for(int i=0;i<=N;i++) cout<<dp[i]<<" ";
   return *max_element(all(dp));
}

void solve(){
   cin>>N>>M;
   g = new vi[N+1];

   FOR(_,M,1){
      int u,v;
      cin>>u>>v;
      g[u].pb(v);
   }
   cout<<long_path();
}




int main(){
   int t = 1;
  // cin>>t;
   while(t--){
      solve();
   }
   return 0;
}

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

using namespace std;
using std::vector;

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x, y) x = max(x,y)
#define chmin(x, y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i, n) for(int i = 0 ; i < n; ++i)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a / gcd(a , b)) * b;
}

int main(){

  int h, w; cin >> h >> w;
  vector<string> vs(h);

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

  vvi wa_tate(h, vi(w, 0));
  vvi wa_yoko(h, vi(w, 0));
  
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(j == 0 and vs[i][j] == '.')
        wa_yoko[i][j] = 1;
      else if(vs[i][j] == '.')
        wa_yoko[i][j] = wa_yoko[i][j-1] + 1;
    }
  }

  for(int i = 0; i < h; i++){
    int max_v = 0;
    for(int j = w - 1; j>=0; j--){
      if(wa_yoko[i][j] != 0){
        if(wa_yoko[i][j] > max_v)
          max_v = wa_yoko[i][j];
        wa_yoko[i][j] = max_v;
      }
      else
        max_v = 0;
    }
  }

  for(int j = 0; j < w; j++){
    for(int i = 0; i < h; i++){
      if(i == 0 and vs[i][j] == '.')
        wa_tate[i][j] = 1;
      else if(vs[i][j] == '.')
        wa_tate[i][j] = wa_tate[i-1][j] + 1;
    }
  }

  for(int j = 0; j < w; j++){
    int max_v = 0;
    for(int i = h - 1; i >= 0; i--){
      if(wa_tate[i][j] != 0){
        if(wa_tate[i][j] > max_v)
          max_v = wa_tate[i][j];
        wa_tate[i][j] = max_v;
      }
      else
      max_v = 0;
    }
  }

  int ans = 0;

  rep(i, h){
    rep(j, w){
      chmax(ans, wa_tate[i][j] + wa_yoko[i][j]);
    }
  }

  pr(ans - 1);

  return 0;
}


Measured memory_bytes: 35712
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int m1 = scan.nextInt();
        int d1 = scan.nextInt();
        int m2 = scan.nextInt();
        int d2 = scan.nextInt();
        if (m1 != m2) {
            System.out.println(1);
        } else {
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
long A[500];
long M[500];
bool OK(long x,int N,int K){
	for(int i=0;i<N;i++){
		M[i] = A[i] % x;
	}
	sort(M,M+N);
	int p = 0;
	int q = N-1;
	long ans = 0;
	while(p < q){
		if(M[q]+M[p] <= x){
			ans += M[p];
			M[q] += M[p];
			p++;
		}
		else{
			ans += x - M[q];
			M[p] -= x - M[q];
			q--;
		}
	}
	return ans <= K;
}
void Calc(){
	int N = rei();
	long K = rei();
	long sum = 0;
	for(int i=0;i<N;i++){
		A[i] = rei();
		sum += A[i];
	}
	long ans = 0;
	for(long i=1;i*i<=sum;i++){
		if(sum % i == 0){
			if(OK(i,N,K)){
				ans = max(ans,i);
			}
			if(OK(sum/i,N,K)){
				ans = max(ans,sum/i);
			}
		}
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <deque>

using namespace std;

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

	int t, x;
	cin >> t >> x;

	cout << t / (double)x << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int n;
	int a[102];
	int cnt = 0;

	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		if(i % 2 == 1 && a[i] % 2 == 1){
			cnt++;
		}
	}

	printf("%d", cnt);
}


Measured memory_bytes: 1704
#include<iostream>
#include<algorithm>
using namespace std;
int l[100100], r[100100];
int main(){
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m;i++){
		cin >> l[i] >> r[i];
	}
	sort(l, l + m);
	sort(r, r + m);
	int k = r[0] - l[m-1];
	if(k<0)
		cout << 0;
	else
		cout << k+1;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <stack>

using namespace std;
using Relations = vector<vector<int>>;

const int no_group = -1;
const int no_user_id = -1;

void depth_first_search(Relations& list_graph, int started_user_id, vector<int>& connected_group, int group_id) {
  stack<int> visited_path;
  visited_path.push(started_user_id);
  connected_group[started_user_id] = group_id;

  while(!visited_path.empty()) {
    int current_user_id = visited_path.top();

    int unvisited_adjacency_user_id = no_user_id;
    for(int i = 0; i < list_graph[current_user_id].size(); i++) {
      int adjacency_user_id = list_graph[current_user_id][i];
      if(connected_group[adjacency_user_id] == no_group) {
        unvisited_adjacency_user_id = adjacency_user_id;
        break;
      }
    }

    if(unvisited_adjacency_user_id != no_user_id) {
      connected_group[unvisited_adjacency_user_id] = group_id;
      visited_path.push(unvisited_adjacency_user_id);
    } else {
      visited_path.pop();
    }
  }
}


int main() {
  int user_num;
  int relation_num;
  Relations list_graph;

  // Init
  cin >> user_num >> relation_num;
  list_graph.resize(user_num);

  // Construct list graph
  for(int i = 0; i < relation_num; i++) {
    int user1_id, user2_id;
    cin >> user1_id >> user2_id;
    list_graph[user1_id].push_back(user2_id);
    list_graph[user2_id].push_back(user1_id);
  }

  // Group connected component
  vector<int> connected_group(user_num, no_group);

  int group_id = 0;
  for(int i =  0; i < user_num; i++) {
    if(connected_group[i] == no_group) {
      depth_first_search(list_graph, i, connected_group, group_id++);
    }
  }


  // Answer queries
  int query_num;
  cin >> query_num;
  for(int i = 0; i < query_num; i++) {
    int user1_id, user2_id;
    cin >> user1_id >> user2_id;

    if(connected_group[user1_id] == connected_group[user2_id]) {
      cout << "yes";
    } else {
      cout << "no";
    }
    cout << endl;
  }
}



Measured memory_bytes: 9260
# -*- coding: utf-8 -*-

def bsearch(l,n,k):
    ok = -1
    ng = n

    while ng-ok>1:
        mid = (ng+ok)//2
        if l[mid]<k:
            ok = mid
        else:
            ng = mid
    return ok

def f(l):
    n = len(l)
    l.sort()

    res = 0
    for i in range(n-1):
        for j in range(i+1,n):
            k = bsearch(l,n,l[i]+l[j])
            res += k-j

    return res

if __name__ == '__main__':
    n = int(input())
    l = list(map(int, input().split()))
    print(f(l))



Measured memory_bytes: 42588
#include <stdio.h>
#include <math.h>
#define MAX 1000000

void init(void);
int count(int);

char chk[MAX] = {0, 0, 1};

int main(void) {
    int n;
    for(init(); ~scanf("%d", &n); printf("%d\n", count(n)));
    return 0;
}

void init(void) {
    int i, j, lim = sqrt(MAX) + 1;
    for(i = 3; i < MAX; i += 2) {
        chk[i] = 1;
    }
    for(i = 3; i < lim; i += 2) {
        if(chk[i]) {
            for(j = i * 2; j < MAX; j += i) {
                chk[j] = 0;
            }
        }
    }
}

int count(int n) {
    int i, cnt = n > 1 ? 1 : 0;
    for(i = 3; i <= n; i += 2) {
        cnt += chk[i];
    }
    return cnt;
}

Measured memory_bytes: 1568
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll N;cin>>N;
    priority_queue<ll,vector<ll>,less<ll>> que;
    REP(i,3*N){
        ll a;cin>>a;
        que.push(a);
    }
    ll ans=0;
    REP(i,N){
        que.pop();
        ll a=que.top();que.pop();
        ans+=a;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 6256
n,p = map(int,input().split())
s = input()

def solve():
    if p in [2,5]:
        ret = 0
        for i in range(n):
            if int(s[n-1-i]) % p == 0: ret += n-i
        return ret
    val = [0]*p
    ten = 1
    cur = 0
    val[cur] += 1
    for i in range(n):
        cur = (cur + int(s[n-1-i]) * ten) % p
        ten = ten * 10 % p
        val[cur] += 1
    ret = 0
    for i in range(p):
        ret += val[i] * (val[i] - 1) // 2
    return ret

print(solve())

Measured memory_bytes: 3500
import java.util.Scanner;


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

			Scanner sc = new Scanner(System.in);
			
			char[] s = sc.next().toCharArray();
			int ret = 0;
			
			for(int i=0;i<s.length-1;i++) {
				if(s[i]!=s[i+1]) {
					ret++;
				}
			}
			System.out.println(ret);
	    }
		
	}
	


Measured memory_bytes: 39660
n,m=map(int,input().split())
a=[0]*(n+1)
for i in range(m):
  x,y=map(int,input().split())
  a[x]+=1
  a[y]+=1
ans='YES'
for i in range(1,n+1):
  if a[i]%2==1:
    ans='NO'
    break
print(ans)

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

int gcd(int a,int b){
    while(1){
        int t;
        if(a<b){
            t=a;
            a=b;
            b=t;
        }
        if(a%b==0){
            break;
        }else{
            a=a%b;
        }
    }
    return b;
}

int main() {
    int N,X;
    cin>>N>>X;
    vector<int> x(N);
    for(int i=0;i<N;i++){
        cin>>x.at(i);
    }
    if(N==1){
        cout<<abs(X-x.at(0))<<endl;
    }else{        
        int g[N-1];
        g[0]=gcd(abs(X-x.at(0)),abs(X-x.at(1)));
        for(int i=1;i<N-1;i++){
            g[i]=gcd(g[i-1],abs(X-x.at(i+1)));
        }
        cout<<g[N-2]<<endl;
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll s,w; cin >> s >> w;
	if(s > w) puts("safe");
	else puts("unsafe");
}

Measured memory_bytes: 3592
#include <iostream>

void call(int n){
    using namespace std ;
    
    int i = 1;
CHECK_NUM:
    int x = i;
    if ( x % 3 == 0 ){
        cout << " " << i;
        goto END_CHECK_NUM;
    }
INCLUDE3:
    if ( x % 10 == 3 ){
        cout << " " << i;
        goto END_CHECK_NUM;
    }
    x /= 10;
    if ( x ) goto INCLUDE3;
END_CHECK_NUM:
    if ( ++i <= n ) goto CHECK_NUM;
    
    cout << endl;
}

void call2(int n) {
    
    for (int i=1; i<=n; i++) {
        bool END_CHECK_NUM = false ;
        
        int x = i ;
        
        // CHECK_NUM
        while (1) {
            
            if ( x % 3 == 0 ){
                std::cout << " " << i;
                END_CHECK_NUM = true ;
                if(END_CHECK_NUM) break ;
            }
            break ;
        }
        
        // INCLUDE3
        while (1) {
            if(END_CHECK_NUM) break ;
            if ( x % 10 == 3 ){
                std::cout << " " << i;
                END_CHECK_NUM = true ;
                if(END_CHECK_NUM) break ;
            }
            if(END_CHECK_NUM) break ;
            x /= 10;
            if ( x ) {} else {break;}
        }
    }
    std::cout << std::endl;
}


int main(int argc, const char * argv[]) {
    
    int n ;
    
    std::cin >> n ;
    
    call2(n) ;
    
    return 0 ;
}


Measured memory_bytes: 3080
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
char s1[101],s2[101];
int main()
{
    gets(s1);
    gets(s2);
    int s=strlen(s1);
    int m=strlen(s2); 
    sort(s1,s1+s);
    sort(s2,s2+m);
    for(int i=0;i<fmax(s,m);i++)
    {
        if(s1[i]<s2[m-i-1])
        {
            printf("Yes\n");
            return 0;
        }
        if(s1[i]>s2[m-i-1])
            break;
    }
    printf("No\n");
    return 0;
} 

Measured memory_bytes: 128
#include <cstdio>

int main(){
    int n,x,d;
    for(int a = 0;;a++){
        scanf("%d%d",&n,&x);
        if(n == 0 && x == 0){
            break;
        }
        d = 0;
        for(int i = 1;i < n - 1;i++){
            for(int j = i + 1;j < n;j++){
                for(int k = j + 1;k <= n;k++){
                    if(i + j + k == x){
                        d++;
                    }
                }
            }
        }
        printf("%d\n",d);
    }
    return 0;
}


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

void prians(bool answer) {
  if(answer)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

string s;
int x, y;

bool solve();
int main() {
  cin >> s >> x >> y;

  prians(solve());
  return 0;
}

bool solve() {
  bitset<20000> bs[2];
  bs[0][8000] = bs[1][8000] = 1;
  bool now = 0, first = 1;
  for(int i = 0; i < s.size(); ++i) {
    int cnt = 0;
    while(i < s.size() && s[i++] == 'F') ++cnt;
    if(first) {
      bs[now] = (bs[now] << cnt);
      first = 0;
    }
    else
      bs[now] = (bs[now] << cnt) | (bs[now] >> cnt);
    now = !now;
    --i;
  }
  return bs[0][x + 8000] && bs[1][y + 8000];
}


Measured memory_bytes: 256
X = int(input())

for i in range(100):
    for j in range(100):
        if i ** 5 + j ** 5 == X:
            print(i, -j)
            exit()
            
        if i ** 5 + j ** 5 > X:
            continue

for i in range(2000):
    for j in range(2000):
        if j ** 5 - i ** 5 == X:
            print(j, i)
            exit()
            
        if j ** 5 - i ** 5 > X:
            continue


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

int main() {
    int n;
    cin >> n;
    if (n == 3) {
        cout << 2 << " " << 5 << " " << 63 << endl;
        return 0;
    }
    for (int i = 2; i < n; i += 2){
        if (n - i <= 15000 && (n - i) % 3 != 1) {
            for (int j = 1; j <= i; j++)
                cout << (j - 1) * 6 + 3 << " ";
            for (int j = 1; j <= n - i; j++)
                cout << 2 * j << " ";
            return 0;
        }
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define     ll          long long int
#define     REP(i,x,n)    for(ll i=x;i<n;i++)
#define     SZ(v)       (ll)v.size()
#define     endl        "\n"
#define     ff          first
#define     ss          second
#define     PQ_MIN      priority_queue <ll, vector<ll>, greater<ll> >
#define     PQ          priority_queue <int>
#define     pbds        tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define     setbit(x)   __builtin_popcount(x)
#define     prec(n)     fixed<<setprecision(n)
#define     pb(n)       push_back(n)
#define     mp(a,b)     make_pair(a,b)
#define     clr(n)      memset(n,0,sizeof(n))
#define     reset(n)    memset(n,-1,sizeof(n))
#define     ii          pair<ll,ll>
#define     vll         vector<ll>
using namespace std;
using namespace __gnu_pbds;
bool comp(pair<ll,ll> a,pair<ll,ll> b) {       }
const ll MOD=1e9+7;
void print(vector<vector<ll> >&v)
{
    ll n=v.size();
    ll m=v[0].size();
    cout<<"\n";
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
            cout<<v[i][j]<<" ";
        cout<<"\n";
    }
}
void print(vector<ll>&v)
{
    ll n=v.size();
    cout<<"\n";
    for(ll i=0;i<n;i++)
    {
            cout<<v[i]<<" ";
    }
        cout<<"\n";

}
void print(set<ll>&s)
{

cout<<endl;

set<ll>::iterator it;
for(it=s.begin();it!=s.end();it++)
    cout<<*it<<" ";
cout<<endl;
}
ll __lcm(ll a,ll b)
{
    return ((a*b)/__gcd(a,b));
}
ll power(ll a,ll p)
{
    ll res=1;
    while(p>0)
    {
        if(p&1){
            res=(res*a)%MOD;
            p--;
        }
            a=(a*a)%MOD;
            p/=2;
    }

    return res%MOD;
}
const ll INF=1e16;
const ll nxm=55;


void solve(){



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


while(b<=a && k>0)
{
    b*=2;
    k--;
}
while(c<=b && k>0)
{
    c*=2;
    k--;
}

if(a<b && b<c)
    cout<<"Yes";
else
    cout<<"No";




}
int main(){
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
//	cin>>t;
    REP(i,1,t+1)
    {
//    cout<<"Case #"<<i<<":"<<endl;
		solve();
    }
	return 0;
}
//  bitset<64>(x).to_ullong() // in my com  _ulong()
//  cout<<bitset<64>(ans).to_string().substr(64-m)<<endl;


Measured memory_bytes: 3560
#include<iostream>
#include<algorithm>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, x, n) for (int i = x; i < (n); ++i)
using namespace std;

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

    int A[110];
    rep(i, N) cin >> A[i];

    sort(A, A + N);
    int max = A[N-1];
    int min = A[0];
    int diff = max - min;

    cout << diff << endl;
    return 0;
}


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

int main(){
  long long n; cin>>n;
  int s=int(sqrt(n));
  for(int i=s;i>0;i--){
    if(n%i==0){
      cout<<(i-1)+(n/i-1)<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n, W;
	cin >> n >> W;
	int w[n];
	long long dp[2][W + 1];
	memset(dp, 0, sizeof dp);
	int curr = 1;
	long long v[n];	
	for(int i = 0; i < n; ++i) {
		cin >> w[i] >> v[i];
	}
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j <= W; ++j) {
			 dp[curr][j] = dp[curr ^ 1][j];
			 if(j - w[i] >= 0) {
			 	dp[curr][j] = max(dp[curr][j], dp[curr ^ 1][j - w[i]] + v[i]);
			 }
			 // cout<<dp[curr][j] <<" ";
		}
		// cout<<endl;
		curr ^= 1;
	}
	cout<<dp[curr^1][W];

}

Measured memory_bytes: 5120
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int s;
  double w, h;
  char gomi;
  while (cin >> s >> gomi >> w >> gomi >> h) {
    if (w / h / h >= 25) cout << s << endl;
  }
}

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

int N, K;
vector<int> A(200010, 0);

int main(){
    cin >> N >> K;

    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N-K; i++){
        if(A[i] < A[i+K]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}







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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll N, M;
ll s, t;
vector<vector<ll>> G;

int main(int argc, char **argv)
{
	cin >> N >> M;
	G.resize(N);
	REP(i, M)
	{
		ll a, b; cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
	}
	cin >> s >> t;
	--s, --t;

	vector<vector<ll>> dist(N, vector<ll>(3, -1));
	queue<P> que;
	dist[s][0] = 0;
	que.push({s, 0});
	while (que.size())
	{
		P p = que.front(); que.pop();
		ll now = p.first;
		ll tmp = p.second;
		ll ntmp = (tmp + 1) % 3;

		for (auto &nv : G[now])
		{
			if (dist[nv][ntmp] != -1) continue;

			dist[nv][ntmp] = dist[now][tmp] + 1;
			que.push({nv, ntmp});
		}
	}

	ll res;
	if (dist[t][0] == -1) res = -1;
	else res = dist[t][0] / 3;
	std::cout << res << std::endl;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n,m,k;
  cin >> n >> m >> k;
  vector<ll> v(n),w(m);
  rep(i,n)cin >> v[i];
  rep(i,m)cin >> w[i];
  vector<ll> sv(n+1,0),sw(m+1,0);
  rep(i,n)sv[i+1] = sv[i]+v[i];
  rep(i,m)sw[i+1] = sw[i]+w[i];
  ll res = 0;
  rep(i,n+1){
    if(sv[i] > k)break;
    int l = 0,r = m+1;
    while(r-l > 1){
      int mid = (l+r)/2;
      if(sw[mid] <= k-sv[i])l = mid;
      else r = mid;
    }
    res = max(res,i+l);
  }
  cout << res << endl;





  return 0;
}

Measured memory_bytes: 9592
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;
LL a[100010];
int main(){
    int n;
    int ans=0;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    
    ans++;
    for(int i=1;i<n;i++){
        if(a[i]>a[i-1]*2)ans=0;
	a[i]+=a[i-1];
	ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

const int N = 1e5 + 5;

int dp[N][5];
int a[N], b[N], c[N];
int n;

int sol(int i, int prv) {
    if(i == n) return 0;

    int &ret = dp[i][prv];
    if(ret != -1) return ret;

    ret = 0;
    if(prv != 1) ret = max(ret, sol(i + 1, 1) + a[i]);
    if(prv != 2) ret = max(ret, sol(i + 1, 2) + b[i]);
    if(prv != 3) ret = max(ret, sol(i + 1, 3) + c[i]);

    return ret;
}

int main(){
    fIO

//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

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

    for(int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];

    cout << sol(0, 0);
}








Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-9;
const long long INF = OO;
const int MAXN = 206, MAXM = 102, Mod = 998244353, MAXLog = 20;



int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout
            << fixed;


    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    vector<pair<int, pair<int, int>>> left, right;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int j = i;
        while (j < n && s[j] == s[i])
            ++j;
        if (s[i] == 'L')
            left.push_back({i > 0 && j < n, {i, j - 1}});
        else
            right.push_back({i > 0 && j < n, {i, j - 1}});
        ans += j - i - 1;
        i = j - 1;
    }

//    cout << ans << '\n';

    if (left.size() <= right.size()) {
        sort(left.rbegin(), left.rend());
        for (int i = 0; i < min((int)left.size(), k); ++i) {
            ans += left[i].first + 1;
        }
    } else {
        sort(right.rbegin(), right.rend());
        for (int i = 0; i < min((int)right.size(), k); ++i) {
            ans += right[i].first + 1;
        }
    }


    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1804
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;


int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int a;
	string s;
	cin >> a >> s;
	if (a < 3200)
		cout << "red";
	else
		cout << s;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) {
    cin >> a[i];
    a[i]--;
  }
  vector<bool> visit(n,false);
  deque<int> rec;
  int cur = 0;
  while(1){
    if(visit[cur]){
      while(rec[0]!=cur){
        k--;
        rec.pop_front();
      
      if(k==0){
        cout << rec[0]+1 << endl;
        return 0;
        }
      }
      break;
    }
    rec.pb(cur);
    visit[cur] = true;
    cur = a[cur];
  }
  cout << rec[k%sz(rec)]+1 << endl;

  return 0;
}

Measured memory_bytes: 4712
import numpy as np

N = int,input()
alist = list(map(int,input().strip().split()))

s = np.array([i for i in range(len(alist))])
slist = alist-s
slist.sort()

abs_slist = list(map(lambda x:abs(x-slist[len(slist)//2]), slist))

print(sum(abs_slist))


Measured memory_bytes: 34152
#include <bits/stdc++.h>
    
using namespace std;
    
#define endl "\n"
#define ll unsigned long long
#define int long long int
#define vi vector <int >
#define vii vector < pii >
#define vll vector <ll >
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
#define double long double
#define a first
#define b second

    
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);	
    int h, a;
    cin >> h >> a;
    cout << h/a + (h%a > 0) << endl;
    
    return 0;
}

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

int main(void) {
	int n, x, y, z;
	int a[2000];
	cin >> n >> x >> y;
	x--;
	y--;
	z = y - x;
	for (int i = 0; i < n - 1; i++) {
		a[i] = 0;
	}

	for (int i = 0; i < n -1; i++) {
		for (int j = i+1; j < n; j++) {
			int k = j - i - 1;
			if (abs(x - i) + abs(y - j) < k ) {
				k = abs(x - i) + abs(y - j);
			}
			a[k]++;
		}
	}
	for (int i = 0; i < n - 1; i++) {
		cout << a[i] << endl;
	}
	 return 0;
	
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

void reader(int &a) { scanf("%d", &a); }
void reader(double &a) { scanf("%lf", &a); }
void reader(char a[]) { scanf("%s", a); }
void reader(char &a) { scanf(" %c", &a); }
void reader(ll &a) { scanf("%lld", &a); }
void reader(ull &a) { scanf("%llu", &a); }
// void reader(string& a){cin >> a;};
template<class T, class U> void reader(T& t, U& u) { reader(t); reader(u); }
template<class T, class U, class V> void reader(T& t, U& u, V& v) { reader(t); reader(u); reader(v); }

void writer(const int a, char c) { printf("%d", a); putchar(c); }
void writer(const ll a, char c) { printf("%lld", a); putchar(c); }
void writer(const ull a, char c) { printf("%llu", a); putchar(c); }
void writer(const double a, char c) { printf("%.20lf", a); putchar(c); }
void writer(const char a[]) { printf("%s", a); };
void writer(const char a[], char c) { printf("%s", a); putchar(c); };
void writer(const char a, char c) { putchar(a); putchar(c); };
template<class T> void writerLn(T t) { writer(t, '\n'); }
template<class T, class U> void writerLn(T t, U u) { writer(t, ' '); writer(u, '\n'); }
template<class T, class U, class V> void writerLn(T t, U u, V v) { writer(t, ' '); writer(u, ' '); writer(v, '\n'); }
template<class T> void writerArr(T x[], int n) { int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }
template<class T> void writerVec(vector<T> x) { int n = x.size(); int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }

vector<string> split(const string &str, char sep) { vector<string> v; stringstream ss(str); string buffer; while (getline(ss, buffer, sep)) { v.push_back(buffer); }return v; }
// #define int ll
bool test = 1;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define MAX 300000
//.....................
ull mod = (int)1e9 + 7;
#define P pair<int,int>
signed main(void)
{
	int i, j, k;
	while (1) {
		int N, M;
		cin >> N >> M;
		if (N == 0) return 0;
		int a[11] = {};
		rep(i, N) {
			int d, p;
			cin >> d >> p;
			a[p] += d;
		}
		int cnt = 0;
		int now_m = M;
		for (i = 10; i > -1; i--) {
			if (a[i] > now_m) {
				cnt += (a[i] - now_m)*i;
				now_m = 0;
			}
			else {
				now_m -= a[i];
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1168
<?php

function isPrime($num, $n) {
    for ($i = 0; $i < $n; $i++) {
        if ($num == 2) {
            return true;
        } elseif ( $num < 2 or $num % 2 == 0) {
            return false;
        } else {
            $start = 3;
            while ($start <= sqrt($num) + 1) {
                if ($num % $start == 0) {
                    return false;
                }
                $start += 2;
            }
            return true;
        }
    }
}

$n = trim(fgets(STDIN));
$count = 0;

for ($i = 0; $i < $n; $i++) {
    $number = (int) fgets(STDIN);
    if (isPrime($number, $n)) $count++;
}

echo $count . PHP_EOL;



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

int main(void)
{
  unsigned int i;
  unsigned int n;
  unsigned int *p;
  unsigned int flag;

  scanf("%d", &n);
  p = (int *)malloc(sizeof(unsigned int) * n);
  if (!p) return (1);

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

  flag = 1;
  for (i = 0; i < n; i++)
  {
    if ((p[i] % 2) != 0) continue;
    if ((p[i] % 3) == 0) ;
    else if ((p[i] % 5) == 0) ;
    else
    {
      flag = 0;
      break;
    }
  }
  if (flag)
    printf("APPROVED\n");
  else
    printf("DENIED\n");

  free(p);
  return (0);
}


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

int main(){
  char s1,s2;
  cin>>s1>>s2;
  if(s1>s2)cout<<'>'<<endl;
  if(s1<s2)cout<<'<'<<endl;
  if(s1==s2)cout<<'='<<endl;  
}

Measured memory_bytes: 256