akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std ;

#define ll long long int

vector<vector<int>> groups;
vector<bool> visited;

void dfs(int x,int &size)
{
    if(visited[x]) return ;
    visited[x] = true ;
    size++;
    for(int next : groups[x])
        dfs(next,size);
    return ;
}
int solvere()
{
    int n,p,i,j,x,y;
    cin>>n>>p;
    visited.resize(n+1,false),groups.resize(n+1);
    for(i=0;i<p;i++)
    {
        cin>>x>>y;
        groups[x].push_back(y);
        groups[y].push_back(x);
    }
    int ans=0,size;
    for(i=1;i<=n;i++)
    {
        if(!visited[i])
        {
            size = 0;
            dfs(i,size);
            ans=max(ans,size);
        }
    }
    cout<<ans<<endl;
    return 0;    
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    
    int t=1;
    //cin>>t;
    while(t--)
    solvere();
    return 0;
}


Measured memory_bytes: 20252
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto ps = new bool[](10^^5+1);
    ps[] = true;
    ps[0] = ps[1] = false;
    foreach (i; 3..10^^5+1) if (ps[i]) {
        if (i%2 == 0) {
            ps[i] = false;
            continue;
        }
        int j = i*2;
        while (j <= 10^^5) {
            ps[j] = false;
            j += i;
        }
    }
    auto PS = new int[](10^^5+1);
    foreach (n; 3..10^^5+1) {
        PS[n] += PS[n-1];
        if (n%2 == 0) continue;
        if (ps[n] && ps[(n+1)/2]) PS[n] += 1;
    }

    auto Q = readln.chomp.to!int;
    foreach (_; 0..Q) {
        auto lr = readln.split.to!(int[]);
        writeln(PS[lr[1]] - PS[lr[0]-1]);
    }
}

Measured memory_bytes: 3708
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    sc.close();
    List<Integer> list = new ArrayList<Integer>();
    for(long i=1;i<=Math.sqrt((double)n);i++) {
    	if(n%i == 0) {
        	if(!list.contains(f(i,n/i))) {
        		list.add(f(i,n/i));
        	}
    	}
    }
    Collections.sort(list);
    System.out.println(list.get(0));
  }
  private static int f(long a, long b) {
	  return Math.max((int)(Math.log10(a))+1, (int)(Math.log10(b))+1);
  }
}

Measured memory_bytes: 23764
#include <iostream>
using namespace std;
int main()
{
    int a, b, c, d;
    cin >> a >>b >> c >> d;
    string s;
    if ((c-1)/b <= (a-1)/d){
        s = "Yes";
    }  else { 
        s = "No";
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3628
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n,y;
    cin>>n>>y;
    y /=1000;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(n>=(i+j))
            {
                int k = n - (i+j);
                if(10*i+5*j+k == y)
                {
                    cout<<i<<" "<<j<<" "<<" "<<k<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"-1 -1 -1\n";
    return 0;
}



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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, X, Y;
  IN(N,X,Y);
  vll ans(N,0);
  FOR(i,1,N+1){
    FOR(j,i+1,N+1){
      ll t1 = j-i;
      ll t2 = abs(j-Y)+1+abs(i-X);
      ans[min(t1,t2)]++;
    }
  }

  FOR(i,1,N){
    OUT(ans[i]);
  }


  return 0;
}

Measured memory_bytes: 256
using System;

namespace abc141_b
{
    static class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            var bad = false;
            for (int i = 0; i < s.Length; i++)
            {
                if (i % 2 == 0)
                {
                    // 奇数文字目に踏みにくいのがある
                    if (s[i] == 'L')
                    {
                        bad = true;
                        break;
                    }
                }
                else
                {
                    // 偶数文字目に踏みにくいのがある
                    if (s[i] == 'R')
                    {
                        bad = true;
                        break;
                    }
                }
            }

            Console.WriteLine($"{(bad ? "No" : "Yes")}");
        }
    }
}


Measured memory_bytes: 13268
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(){

    int N; cin>>N;
    string S,T; cin>>S>>T;
    for (int i = 0; i < N; ++i) {
        cout<<S[i]<<T[i];
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
typedef long long int ll;
#pragma GCC optimize "trapv"
#define fi first
#define sec second
#define pb push_back
//#define endl '\n'
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void solve(){
	int  n;
	cin>>n;
	vector<bool> pr(n+1,1);
	vector<ll> div(n+1,1);
	for(int i=2;i<=n;i++){
		if(pr[i]){
			div[i]=2;
			for(int k=2;k*i<=n;k++){
				pr[k*i]=0;
				int count=0;
				int temp=k*i;
				while(temp%i==0){
					temp/=i;
					count++;
				}
				div[k*i]*=count+1;
			}
		}
	}
	ll ans=0;
	for(int i=1;i<=n;i++){
		ans+=(ll(i))*div[i];
	}
	cout<<ans<<endl;
}
int main(){
	fio;
	int test;
	//cin>>test;
	test=1;
	while(test--){
		solve();
	}
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    int temp, B[200000];
    for(int i=0;i<N;i++){
        cin >> temp;
        B[i] = temp - (i+1);
    }

    sort(B, B + N);   // 昇順ソート
    int b;
    b = B[N/2];
    // 和を求める
    ll ans = 0;
    for(int i=0;i<N;i++)
        ans += abs(B[i] - b);

    cout << ans << endl;
    return 0;
}


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

int main() {
    ll N; cin >> N;
    vector<ll> A(N); for (ll i = 0; i < N; ++i) cin >> A[i];
    for (ll i = 0; i < N; ++i) A[i] = A[i] - (i + 1);
    sort(A.begin(), A.end());
    vector <ll> candidates;
    ll s_min = 2e18;
    for (ll b = A[N/2] - 1000; b < A[N/2] + 1000; ++b) {
        ll s = 0;
        for (ll i = 0; i < N; ++i) {
            s += abs(b - A[i]);
        }
        if (s < s_min) {
            s_min = s;
        }
    }
    cout << s_min << endl;
    return 0;
}


Measured memory_bytes: 4824
//$ node B.js < B.txt
function Main(input) {
  input = input.split('\n') // 1行目がinput[0], 2行目がinput[1], …に入る
  for(var i=0;i<input.length;i++){
    var tmp = input[i].split(' ')
    input[i] = []
    for(var ii=0;ii<tmp.length;ii++){
      input[i].push(tmp[ii])
    }
  }
  //var list = ['SUN','MON','TUE','WED','THU','FRI','SAT']
  var list = ['SAT','FRI','THU','WED','TUE','MON','SUN']
  
  var ans = list.indexOf(input[0][0]) + 1
  

  console.log(ans)
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 22076
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int N = s[0];
            int L = s[1];

            int sum = 0;
            int tmp = int.MaxValue;

            for (int i = 1; i <= N; i++)
            {
                sum += (L + i - 1);
                if (Abs(L + i - 1) <tmp)
                {
                    tmp = Abs(L + i - 1);
                }
            }

            WriteLine(sum < 0 ? sum + tmp :sum - tmp);

        }
    }
}


Measured memory_bytes: 13268
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(){
    ll n, t;
    cin >> n >> t;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    int r=a[0], l=a[0], diff=0, cnt=0;
    REP(i, n) {
        if(a[i]<l) {
            //r = a[i];
            l = a[i];
        }
        else {
            if(diff < (a[i] - l)) {
                diff = a[i] - l;
                cnt = 1;
            } else if (diff == (a[i] - l)) {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}


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

struct node {
  int key;
  struct node *next;
  struct node *prev;
};

typedef struct node *NodePointer;
NodePointer nil;

NodePointer listSearch(int key){
  NodePointer c;
  c = nil->next;
  while( c != nil && c->key != key ){
    c = c->next;
  }
  return c;
}

void init(){
  nil = (NodePointer)malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer c = nil->next;
  int isf = 0;
  while( 1 ){
    if( c == nil ) break;
    if( isf++ > 0 ) printf(" ");
    printf("%d", c->key);
    c = c->next;
  }
  printf("\n");
}

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

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

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

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  NodePointer x = (NodePointer)malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next =x;
  x->prev = nil;
}

int main(){
  int key, n, i, size=0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for( i = 0 ; i < n ; i++ ){
    scanf("%s%d",com,&key);
    if( com[0] == 'i' ){
      insert(key);
      np++;
      size++;
    }
    else if( com[0] == 'd' ){
      if( strlen(com) > 6 ){
	if( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      }
      else {
	deleteKey(key);
	nd++;
      }
      size--; 
    }
  }
  printList();
  return 0;
}



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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

class U {
public:
  int n;
  vector<int> p, s;

  U(int _) {
    n = _;
    p.resize(n);
    s.resize(n);
    for (int i = 0; i < n; i++) {
      p[i] = i;
      s[i] = 1;
    }
  }

  bool connect(int a, int b) {
    int ap, bp;
    for (ap = p[a]; ap != p[ap]; ap = p[ap]);
    for (bp = p[b]; bp != p[bp]; bp = p[bp]);
    if (ap == bp)
      return true;
    int mi = min(ap, bp), ma = max(ap, bp);
    p[ma] = mi;
    s[mi] += s[ma];
    s[ma] = 0;
    for (int pp = a; pp != mi;) {
      int next = p[pp];
      p[pp] = mi;
      pp = next;
    }
    for (int pp = b; pp != mi;) {
      int next = p[pp];
      p[pp] = mi;
      pp = next;
    }
    return false;
  }

  int q(int a) {
    int ap;
    for (ap = a; ap != p[ap]; ap = p[ap]);
    return s[ap];
  }

  int parent(int a) {
    int ap;
    for (ap = a; ap != p[ap]; ap = p[ap]);
    return p[ap];
  }

  bool query(int a, int b) { return parent(a) == parent(b); }
};

struct N {
  int i, s, t;
  double ddist;
};

bool operator<(const N &l, const N &r) {
  return l.ddist > r.ddist;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<double> xs(n), ys(n);
  priority_queue<N> q;
  for (int i = 0; i < n; i++) {
    cin >> xs[i] >> ys[i];
  }
  U uf(n);
  vector<N> ns(m);
  for (int i = 0; i < m; i++) {
    cin >> ns[i].s >> ns[i].t;
    ns[i].s--;
    ns[i].t--;
    ns[i].i = i;
    ns[i].ddist = (xs[ns[i].s] - xs[ns[i].t]) * (xs[ns[i].s] - xs[ns[i].t]) +
                  (ys[ns[i].s] - ys[ns[i].t]) * (ys[ns[i].s] - ys[ns[i].t]);
  }
  sort(ns.begin(), ns.end());
  double ans = 0.;
  for (int i = 0; i < m; i++) {
    if (uf.connect(ns[i].s, ns[i].t)) {
      ans += sqrt(ns[i].ddist);
    }
  }
  printf("%.12lf\n", ans);
  return 0;
}



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

using namespace std;

using ll = long long;
using Graph = vector<vector<int>>;
int n;
vector<ll> a(100000), c(100000, -1);
bool f = true;

ll dfs(const Graph &g, int cur, int pre)
{
  int sz = g[cur].size();
  if (pre != -1 && sz == 1)
  {
    // leaf
    return c[cur] = a[cur];
  }
  ll sum = 0;
  vector<int> v;
  for (int i = 0; i < sz; i++)
  {
    int next = g[cur][i];
    if (next == pre)
      continue;
    sum += dfs(g, next, cur);
    v.push_back(next);
  }
  c[cur] = 2 * a[cur] - sum;
  if (c[cur] < 0 || c[cur] > a[cur])
  {
    f = false;
  }
  if ((sum - c[cur]) % 2 || sum - c[cur] < 0)
  {
    f = false;
  }
  ll num = (sum - c[cur]) / 2; // num 組作れるか
  ll cnt = 0;
  for (int i = 0; i < sz; i++)
  {
    int next = g[cur][i];
    if (next == pre)
      continue;
    if (c[next] > num)
    {
      cnt += c[next] - num;
    }
  }
  if (cnt > c[cur])
    f = false;
  return c[cur];
}

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

  cin >> n;
  Graph g(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 0; i < n - 1; i++)
  {
    int st, gt;
    cin >> st >> gt;
    st--;
    gt--;
    g[st].push_back(gt);
    g[gt].push_back(st);
  }
  if (n == 2)
  {
    if (a[0] == a[1])
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
    return 0;
  }
  dfs(g, 0, -1);
  if (g[0].size() > 1 && c[0] != 0)
  {
    f = false;
  }
  if (g[0].size() == 1 && c[0] != a[0])
  {
    f = false;
  }
  if (f)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 19328
n,x=map(int,input().split())
l=[1]
for i in range(50): l+=[l[-1]*2+3]
from functools import lru_cache
@lru_cache(None)
def f(n,x):
  if n<1: return int(x>0)
  if x<=l[n]//2: return f(n-1,x-1)
  return f(n-1,l[n-1])+1+f(n-1,x-l[n-1]-2)
print(f(n,x))

Measured memory_bytes: 9700
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<string>
const int N = 2e5 + 1;
using namespace std;

map<string, int> chs;
vector<string> ans;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	while (cin >> n)
	{
		string a;
		int mm = -1;
		for (int i = 1; i <= n; i++)
		{
			cin >> a;
			chs[a]++;
			mm = max(chs[a], mm);
		}
		map<string, int>::iterator i=chs.begin();
		while (i != chs.end())
		{
			if (i->second == mm)
				ans.push_back(i->first);
			i++;
		}
		sort(ans.begin(), ans.end());
		for (int i = 0; i < ans.size(); i++)
			cout << ans[i]<<endl;
		ans.clear();
		chs.clear();
	}
	return 0;
}


Measured memory_bytes: 25584
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n,m; cin >> n >> m;
    vpl a(n);
    vpl x(m);
    rep(i,n) cin >> a[i].first >> a[i].second;
    rep(i,m) cin >> x[i].first >> x[i].second;
    rep(i,n){
        ll mn = INF;
        ll ans;
        rep(j,m){
            ll dist = 0;
            dist += abs(a[i].first - x[j].first);
            dist += abs(a[i].second - x[j].second);
            if(mn > dist){
                mn = dist;
                ans = j+1;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
n,k,q = map(int,input().split())
correct = [0 for i in range(n)]

for i in range(q):
    a = int(input())
    correct[a-1] += 1

for i in range(n):
    if k-(q-correct[i]) > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4684
#include <iostream>
#include <vector>
#include <set>
using namespace std;
typedef pair<int, int> pii;

const int MAXN = 100000 + 10;
int num0[MAXN], num1[MAXN];
int dp0[MAXN][18], dp1[MAXN][18];
int n;
vector<int> sons[MAXN];
int degree[MAXN];
vector<pii> ret;

struct cmp {
    bool operator() (int a, int b) {
        if (ret[a].first != ret[b].first) return ret[a].first < ret[b].first;
        return ret[a].second < ret[b].second;
    }
};
set<int, cmp> cur;

void make_st(int dp[MAXN][18], int num[]) {
    for (int i = 0; i < n; i++) dp[i][0] = i;
    for (int j = 1; j < 18; j++) {
        for (int i = 0; i < n; i++) {
            if (i+(1<<j)-1 >= n) break;
            int pos1 = dp[i][j-1];
            int pos2 = dp[i+(1<<(j-1))][j-1];
            if (num[pos1] > num[pos2]) dp[i][j] = pos2;
            else dp[i][j] = pos1;
        }
    }
}
int findmin(int dp[MAXN][18], int num[], int a, int b) {
    int length = b - a + 1;
    int j = -1;
    while (length != 0) {
        j++;
        length /= 2;
    }
    int pos1 = dp[a][j];
    int pos2 = dp[b+1-(1<<j)][j];
    if (num[pos1] > num[pos2]) return pos2;
    return pos1;
}

void solve(int a, int b, int fa) {
    if (a > b) return;
    if (a % 2 == 0) {
        int x = findmin(dp0, num0, a/2, b/2);
        int y = findmin(dp1, num1, x, b/2);
        ret.push_back({num0[x], num1[y]});
        int now = ret.size() - 1;
        if (fa != -1) {
            sons[fa].push_back(now);
            degree[now]++;
        }
        else cur.insert(now);
        solve(a, 2*x-1, fa);
        solve(2*x+1, 2*y, now);
        solve(2*y+2, b, fa);
    }
    else {
        int x = findmin(dp1, num1, a/2, (b-1)/2);
        int y = findmin(dp0, num0, x+1, b/2);
        ret.push_back({num1[x], num0[y]});
        int now = ret.size() - 1;
        if (fa != -1) {
            sons[fa].push_back(now);
            degree[now]++;
        }

        else cur.insert(now);
        solve(a, 2*x, fa);
        solve(2*x+2, 2*y-1, now);
        solve(2*y+1, b, fa);
    }
}


int main() {
//    freopen("test.txt", "r", stdin);
    int N;
    scanf("%d", &N);
    n = N / 2;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) scanf("%d", &num0[i/2]);
        else scanf("%d", &num1[i/2]);
    }
    make_st(dp0, num0);
    make_st(dp1, num1);
    solve(0, N-1, -1);

    while (!cur.empty()) {
        auto it = cur.begin();
        printf("%d %d ", ret[*it].first, ret[*it].second);
        int dad = *it;
        cur.erase(it);
        for (int son : sons[dad]) {
            degree[son]--;
            if (degree[son] == 0) cur.insert(son);
        }
    }
    cout << endl;
    return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  cout << max(max(a+b,a-b),a*b);
  return 0;
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const char EOL = '\n';

void solve();

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

void solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(n, vector<int>(m));
    REP(i, n) REP(j, m) {
        cin >> a[i][j];
        a[i][j]--;
    }

    int ans = INF;
    vector<bool> r(m, true);
    REP (k, m) {
        vector<int> s(m, 0);
        REP(i, n) {
            REP(j, m) {
                if (r[a[i][j]]) {
                    s[a[i][j]]++;
                    break;
                }
            }
        }
        int mx = 0;
        int id = -1;
        REP(i, m) {
            if (mx < s[i]) {
                mx = s[i];
                id = i;
            }
        }
        r[id] = false;
        chmin(ans, mx);
    }
    cout << ans << EOL;
}



Measured memory_bytes: 640
///----> bismillahir rahmanir rahim <---- -- { ^ _ ^ }
///     { ^_^ }   { ^ _ ^ }
#include<bits/stdc++.h>
#include<bits/stdc++.h>
using namespace std;

//<--------------------------------------------typo section--------------------------------------------->
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;
typedef priority_queue<int>piwi;
typedef queue<int>kiwi;
typedef map<int,int>mi;
typedef map<string,int>mis;
typedef multimap<int,int>muli;
typedef multimap<string,int>muls;
typedef multiset<int>si;

//<----------------------------------------------------Narcos----------------------------------------------->
#define endl "\n"
#define Y cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define sp " "
#define PB push_back
#define F first
#define S second
#define as(a) (a).begin(),(a).end()
#define ras(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()
#define ki 1LL
#define MOD 1000000007
#define over return 0;
#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))
#define test int t;cin>>t;while(t--)


//<-----------------------------------------------------Const--------------------------------------------------->
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;


//<--------------------------------------------------------------------------------------------------->
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

const long long MAX_SIZE = 1000001; vector<long long >isprime(MAX_SIZE , true); vector<long long >prime; vector<long long >SPF(MAX_SIZE); void manipulated_seive(int N) { isprime[0] = isprime[1] = false ; for (long long int i=2; i<N ; i++) { if (isprime[i]) { prime.push_back(i); SPF[i] = i; } for(int j=0;j < (int)prime.size() && i*prime[j] < N && prime[j] <= SPF[i]; j++) { isprime[i*prime[j]]=false; SPF[i*prime[j]] = prime[j] ; } } }
int man_seive(int n){ manipulated_seive(n); for(int i=0;i<prime.size() && prime[i]<=n;i++)
cout<<prime[i]<<endl;
}
ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }

//continue;

//-----------------------------> YOUR JOURNEY STARTS HERE ------------------------------------>>

int main(){
    optimize();
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll z=a*c;
    ll x=b*d;
    ll y=b*c;
    ll s=a*d;
    cout<<max(max(z,x),max(y,s))<<endl;

over
}


Measured memory_bytes: 18728
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int k;
vector< pair<int,int> > ans;
void solve( int x, int y ){
	if( abs(x) > 2*k || abs(y) > 2*k ){
		int px , py;
		if( x > 0 ) px = -k; else px = k;
		if( y > 0 ) py = -k; else py = k;
		solve( x+px, y+py );
	}
	else if(  abs(x+y) + abs(x-y)  != 2*k ){
		if( abs(x)%2 == 1){
			int px , py;
			if( x > 0 ) px = -k; else px = k;
			if( y > 0 ) py = -k; else py = k;
			solve( x+px, y+py );
		}
		else{
			int px,py;
			if( x > 0 )px = k; else px = -k;
			if( y > 0 )py = y-k; else py = y+k;
			ans.pb( mp( px,py ) );
		}
	}
	ans.pb( mp( x,y ) );
}
signed main(){
	int x,y;
	cin>>k>>x>>y;
	if( k%2 == 0 && abs(x+y)%2 == 1){
		cout<<-1<<endl;
		return 0;
	}
	int wa = x+y, sa = x-y;
	solve( wa, sa );
	cout<<ans.size()<<endl;
	for(int i=0;i<ans.size();i++){
		int cw = ans[i].first;
		int cs = ans[i].second;
		cout<<(cw+cs)/2<<" "<<(cw-cs)/2<<endl;
	}
	return 0;
}

Measured memory_bytes: 15980
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int len = s.length();
    vector<bool> arr(len);
    for(int i = 0; i < len; i++) {
        if(s[i] == '0' || s[i] == '1')
            arr[i] = true;
        else {
            int j = i - 1;
            while(j >= 0 && arr[j] == false)
                j--;
            if(j >= 0)
                arr[j] = false;
        }
    }
    for(int i = 0; i < len; i++) {
        if(arr[i])
            cout << s[i];
    }
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long

int take()
{
    int n;
    scanf("%d",&n);
    return n;

}

ll takes()
{
    ll n;
    scanf("%lld",&n);
    return n;

}
#define M 200005
#define Int take()
#define LL takes()

#define fr(n) for(int i=1;i<=n;i++)
#define rfr(n) for(int i=n;i>=1;i--)
int cas;
#define print printf("Case %d:",++cas)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mk  make_pair
#define fill(x,v) memset(x,v,sizeof x)
using namespace std;

int main(){
    string s;
    cin>>s;
    int a=s[0]-48,b=s[1]-48,c=s[2]-48,d=s[3]-48;
    set<int>s1;
    int g=a-b-c+d;
    int h=a-b-c-d;
    int i=a-b+c-d;
    int k=a-b+c+d;
    int l=a+b+c+d;
    int m=a+b+c-d;
    int n=a+b-c-d;
    int p=a+b-c+d;

    if(g==7){
        printf("%d-%d-%d+%d=7\n",a,b,c,d);
    }
    else if(h==7){
        printf("%d-%d-%d-%d=7\n",a,b,c,d);
    }
    else if(i==7){
        printf("%d-%d+%d-%d=7\n",a,b,c,d);
    }
    else if(k==7){
        printf("%d-%d+%d+%d=7\n",a,b,c,d);
    }
    else if(l==7){
        printf("%d+%d+%d+%d=7\n",a,b,c,d);
    }
    else if(m==7){
        printf("%d+%d+%d-%d=7\n",a,b,c,d);
    }
    else if(n==7){
        printf("%d+%d-%d-%d=7\n",a,b,c,d);
    }
    else
        printf("%d+%d-%d+%d=7\n",a,b,c,d);

return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

struct TopologicalSort {
    int n;
    vector <vector<int>> G;
    vector <bool> used;
    vector <int> indeg; // 入次数
    vector <int> p;

    TopologicalSort(int sz) : n(sz), G(n), used(n), indeg(n), p(0) {}

    void add_edge(int from, int to) {
        G[from].push_back(to);
    }

    void bfs(int s) {
        queue <int> q;
        q.push(s);
        used[s] = 1;

        while (!q.empty()) {
            int v = q.front();
            q.pop();
            p.push_back(v);

            for (int u : G[v]) {
                indeg[u]--;
                if (indeg[u] == 0 && !used[u]) {
                    used[u] = 1;
                    q.push(u);
                }
            }
        }
    }

    vector<int> build() {
        fill(used.begin(), used.end(), 0);
        fill(indeg.begin(), indeg.end(), 0);

        for (int i = 0; i < n; i++) {
            for (int v : G[i]) indeg[v]++;
        }

        for (int i = 0; i < n; i++) {
            if (indeg[i] == 0 && !used[i]) bfs(i);
        }

        return p;
    }

    bool connected(int a, int b) {
        for (int v : G[a]) {
            if (v == b) return true;
        }
        return false;
    }
};

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

    int a[m], b[m];
    TopologicalSort ts(n);
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        ts.add_edge(a[i], b[i]);
    }

    vector <int> ans = ts.build();

    int unique = 0;
    for (int i = 0; i < n; i++) {
        cout << ans[i] + 1 << "\n";
        if (i) if (!(ts.connected(ans[i-1], ans[i]))) unique = 1;
    }

    cout << unique << "\n";
    return 0;
}


Measured memory_bytes: 4600
#!/usr/bin/env python3
import sys
INF = float("inf")

MOD = 1000000007  # type: int


def solve(S: str):
    dp = [0]*13
    dp[0] = 1
    dpn = [0]*13
    keta = 1
    zero = 0
    # print(dp)
    for c in reversed(S):
        if c == "?":
            dpn = [0]*13
            for i in range(10):
                for j in range(13):
                    dpn[j] += dp[(j - i*keta) % 13]
                    dpn[j] %= MOD
            dp = dpn
        else:
            shift = (int(c)*keta) % 13
            dpn = [0]*13
            for i in range(13):
                dpn[i] = dp[(i-shift) % 13]
            # dpn = dp[13-shift:]+dp[:13-shift]
            dp = dpn

        # print(c, dp)
        keta *= 10
        keta %= 13

    print(dp[5])

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()


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

int main(){
    int a,b,c;
    int num[2]={};
    while(scanf("%d,%d,%d", &a, &b, &c)!=EOF){
        if(a+b<=c) continue;
        if(a*a +b*b == c*c) num[0]++;
        if(a==b) num[1]++;
    }
    cout << num[0] << endl << num[1] << endl;
    return 0;
}

Measured memory_bytes: 3036
use std::*;

#[allow(dead_code)]
fn read<T: str::FromStr>() -> T {
    let mut _in = String::new();
    io::stdin().read_line(&mut _in).ok();
    _in.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: str::FromStr>() -> Vec<T> {
    read::<String>().split(' ').map(|w| w.parse().ok().unwrap()).collect()
}

fn main() {
    let v= read_vec::<i32>();
    let (a, b, c) = (v[0], v[1], v[2]);
    if b * c >= a {
        println!("Yes");
    }
    else {
        println!("No");
    }
}

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

typedef pair<int,int> pi;
typedef vector<int> vi;
 
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define pb push_back

template<typename T> void max_self(T &a, T b) { a = max(a,b); return;}
template<typename T> void min_self(T &a, T b) { a = min(a,b); return;}
 
const int nax = 1e5 + 5;
const int mod = 1e9 + 7;

int solve(int a,int b,int c){
	
	a = a % c;	
	if(b == 0) return 1;
	else if((b % 2) == 0) return solve((a * a) % c,b / 2,c) % c;
	else return (a * solve((a * a) % c,b / 2,c) % c) % c;
}

int n;
int arr[405];
ll dp[405][405];
const int INF = 1e16L + 5;

signed main(){
	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int t = 1;
	//cin >> t;
	while(t--){
		cin >> n;
		for(int i = 0; i < n; ++i) cin >> arr[i];
		
		auto sum = [&](int i,int j){
			int ans = 0;
			for(int k = i; k <= j; ++k) ans += arr[k];
			return ans;
		};
				
		memset(dp,INF,sizeof(dp));
		
		for(int i = 0; i < n; ++i) dp[i][i] = 0;		
		
		for(int len = 2; len <= n; ++len){
			for(int i = 0; i <= n - len; ++i){
				int j = i + len - 1;
				int s = sum(i,j);
				for(int iter = i; iter < j; ++iter){
					dp[i][j] = min(dp[i][j],dp[i][iter] + dp[iter + 1][j] + s);
				}
			}
		}
				
		cout << dp[0][n - 1];
	}
	
	return 0;
}





Measured memory_bytes: 4936
#include <iostream>
#include <cmath>
using namespace std;
#define EPS 1e-10

int main(){
  int n;
  double x1,x2,x3,x4,y1,y2,y3,y4;
  cin >> n;
  while(n--){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    if(abs((x4-x3)*(y2-y1) - (x2-x1)*(y4-y3)) < EPS) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

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

int main(){
    int a[5];

    int x;
    int extra = 0;
    vector<pair<long long, long long> > pairs(5);
    for(int i = 0; i< 5; i++){
        cin >> x;
        if(x%10==0) extra = 10;
        else extra = x%10;
        pairs[i] = make_pair(extra, x);
    }

    sort(pairs.begin(), pairs.end());

    int sums = 0;
    for(int i=0;i<5;i++){
        sums += pairs[i].second;
        if(i==0) continue;
        sums += (10 - pairs[i].first);
    }
    cout << sums << endl;    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

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

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

bool comp(pair<int,int> a, pair<int,int> b){
  return a.second < b.second;
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> data(M);
  for(int i = 0; i < M; i++){
    cin >> data[i].first >> data[i].second;
  }
  sort(all(data), comp);
  int ans = 0, b = 0;
  for(int i = 0; i < M; i++){
    //cerr << data[i].first << " " << data[i].second << " " << b << endl;
    if(b <= data[i].first){
      b = data[i].second;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
a, b, c = map(int, input().split())
k = int(input())
ans = 'Yes'
for _ in range(k):
  if a >= b:
    b = 2*b
    k -= 1
    if b > a:
      break
k_2 = k
for _ in range(k_2):
  if b >= c:
    c = 2*c
if not a < b < c:
  ans = 'No'
print(ans) 

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


int main(){
    int a,b;
    cin >> a >> b;
    string ans;
    if(a <= 0 && 0<=b){
        ans = "Zero";
    }
    else if(a > 0 && b >0){
        ans = "Positive";
    }
    else{
        if((b-a+1)%2==0) ans = "Positive";
        else ans = "Negative";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h, w; cin >> h >> w;
  vector<vector<int>> table(h, vector<int>(w));
  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      cin >> table[i][j];
    }
  }
  vector<int> yokowa(h, 0), tatewa(w, 0);
  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++) yokowa[i] += table[i][j];
  }
  for (int i = 0; i < w; i++){
    for (int j = 0; j < h; j++) tatewa[i] += table[j][i];
  }
  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++) cout << table[i][j] << " ";
    cout << yokowa[i] << endl;
  }
  int allsum = 0;
  for (int i = 0; i < w; i++){
    cout << tatewa[i] << " ";
    allsum += tatewa[i];
  }
  cout << allsum << endl;
}


Measured memory_bytes: 3156
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#define LL long long
#define pii pair<int, int>
#define MAXN ()
using namespace std;
int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	if (a > 8 || b > 8)
		puts(":(");
	else
		puts("Yay!");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, c, k;
	cin >> n >> c >> k;
	priority_queue<int, vector<int>, greater<int>> que;
	REP(i, n)
	{
		int a; cin >> a;
		que.push(a);
	}
	int cnt = 1, st = que.top() + k;
	que.pop();
	int ans = 0;
	while (!que.empty())
	{
		int t = que.top();
		que.pop();
		if (cnt == c || st < t)
		{
			ans++;
			cnt = 1;
			st = t + k;
		}
		else cnt++;
	}
	if (cnt > 0) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 892
import sys
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
if n < m:
  # 問題数不足
  print('NO')
  sys.exit()
d.sort()
t.sort()
j=0
for i in range(n):
  if d[i] == t[j]:
    # 一致
    j += 1
  elif d[i] > t[j]:
    print('NO')
    break
  if j == m:
    print('YES')
    break
else:
  print('NO')

Measured memory_bytes: 118228
# 155 B

n = int(input())
s = list(map(int, input().split()))
valid = True

for i in s:
    if i % 2 == 0:
        if i % 3 != 0 and i % 5 != 0:
            valid = False

if valid == True:
    print("APPROVED")
elif valid == False:
    print("DENIED")

Measured memory_bytes: 9104
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

const vector<string> GenerateADBlocks(const string &str)
{
    vector<string> blocks;
    string block;
    for (int i = 0, n = static_cast<int>(str.size()); i < n;)
    {
        if (str[i] == 'A')
        {
            block += 'A';
            ++i;
        }
        else if (str[i] == 'B')
        {
            if (i < n - 1 && str[i + 1] == 'C')
            {
                block += 'D';
                i += 2;
            }
            else
            {
                if (!block.empty()) blocks.push_back(block);
                block = "";
                ++i;
            }
        }
        else
        {
            if (!block.empty()) blocks.push_back(block);
            block = "";
            ++i;
        }
    }
    if (!block.empty()) blocks.push_back(block);
    return blocks;
}

const LLONG CountInversionNumber(const string block)
{
    LLONG count = 0;
    LLONG Anum = 0;
    for (const char ch : block)
    {
        if (ch == 'A') ++Anum;
        else count += Anum;
    }
    return count;
}


int main()
{
    string str;
    cin >> str;
    const auto blocks = GenerateADBlocks(str);
    LLONG count = 0;
    for (const auto &block : blocks)
    {
        count += CountInversionNumber(block);
    }
    cout << count << endl;
    return 0;
}


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

int main() {
    ll n,m;
    std::cin >> n>>m;
    vector<pair<ll,ll>> yp(m);
    map<pair<ll,ll>,ll> pi;
    map<ll,pair<ll,ll>> ip;
    for (int i = 0; i < m; i++) {
        ll p,y;
        std::cin >> p>>y;
        
        yp[i] = {y,p};
        pi[{y,p}] = i;
        ip[i] = {y,p};
    }
    
    sort(yp.begin(),yp.end());
    
    vector<ll> cnt(n+1,0);
    
    vector<ll> ans(m);
    for (int i = 0; i < m; i++) {
        ans[pi[yp[i]]] = cnt[yp[i].second]+1;
        cnt[yp[i].second]++;
    }
    
    for (int i = 0; i < m; i++) {
        cout << setfill('0') << right << setw(6) << ip[i].second;
        cout << setfill('0') << right << setw(6) << ans[i] << endl;
    }
}

Measured memory_bytes: 18832
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int r; cin >> r;
  const double pai = 3.14159265358979;
  cout << fixed << setprecision(10) << 2*pai*r << endl;
  system("pause");
}


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

#define vi vector<int>
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	string s;
	cin >> n >> s;
	s = " " + s;
	if (n % 2 == 1) return cout << "No", 0;
	for (int i = 1; i <= n / 2; i++) {
		if (s[i] != s[n / 2 + i]) return cout << "No", 0;
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int x,y,z;
  cin>>x>>y>>z;
  if(x>=y&&x>=z){
    cout<<y*z/2<<endl;
    return 0;
  }
  if(y>=x&&y>=z){
    cout<<x*z/2<<endl;
    return 0;
  }
  if(z>=x&&z>=y){
    cout<<x*y/2<<endl;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <climits>
#include <cctype>
#include <bitset>
using namespace std;

#define PI 3.14159265359
#define all(v) v.begin(),v.end()
#define sortva(v) sort(all(v))
#define sortvd(v) sort(v.rbegin(),v.rend())
#define sortaa(a,n) sort(a,a+n)
#define sortad(a,n) sort(a,a+n),reverse(a,a+n)
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define sfstr(v) scanf("%s", v);
#define sz(v) (int)v.size()
#define ndl puts("")
#define flush fflush(stdout)
#define SS stringstream
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


int main() {
	//PLAY();

	cout << fixed << setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n*a, b) << endl;


	return 0;
}

Measured memory_bytes: 256
import sys
def decode(s):
    x=""
    for c in s:
        if c in " .": x+=c
        else: x+=chr(ord(c)+1)
    return x.replace(chr(ord("z")+1),"a")

for s in sys.stdin.readlines():
    for i in range(26):
        if "the" in s or "that" in s or "this" in s:break
        s=decode(s)
    print s[:-1]

Measured memory_bytes: 4212