akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std; 
typedef pair<int, int> P;

int main(){
	int N;
	cin >> N;
	vector<int>A(N);
	for (int n = 0;n<N;++n) {
		cin >> A[n];
	}
	multiset<int> st;
	for (int n = 0; n < N; ++n) {
		int now = A[n]; 
		auto itr = st.lower_bound(now);
		if (st.begin() != itr) {
			--itr;
			st.erase(itr);
		}
		st.insert(now);
	}
	cout << st.size()<<endl;
	return 0;
}

Measured memory_bytes: 8296
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto r = readln.chomp.to!double;
  writefln("%.12f", 2 * r * PI);
}


Measured memory_bytes: 3004
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        String s1 = sc.next();
        String s2 = sc.next();
        
        int flag = 0;   //0:> 1:= 2:<
        
        if(s1.length() > s2.length()) flag=0;
        else if(s1.length() == s2.length()){
            for (int i =0;i<s1.length() ; i++){
                int a = Integer.parseInt(s1.substring(i, i+1));
                int b = Integer.parseInt(s2.substring(i, i+1));
                if(a>b) {
                    flag=0;
                    break;
                }
                else if(a==b){
                    if(i== (s1.length()-1)) flag = 1;
                    else continue;  
                } 
                else{
                    flag=2;
                    break;
                }
            }
            
        }
        else flag=2;
        if(flag==0) System.out.println("GREATER");
        else if(flag==1) System.out.println("EQUAL");
        else System.out.println("LESS");
    }
}


Measured memory_bytes: 21844
import java.util.*;
public class Main {
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int a = sc.nextInt();
                int b = sc.nextInt();
                String s = sc.next();
                boolean ebishu = true;
                for(int i = 0 ; i < a + b + 1 ; i++){
                        if(i != a){
                                if(s.charAt(i) < 48 || s.charAt(i) > 58){
                                        ebishu = false;
                                }
                        }
                }
                if(s.charAt(a) != '-') ebishu = false;
                if(ebishu) System.out.println("Yes");
                else System.out.println("No");
        }
}

Measured memory_bytes: 35716
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
	/**
	 * ??\?????????????????? / ????????????????????????
	 */
	public static void main(String[] args) throws Exception {

		// ??\???????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int teamNum = Integer.parseInt(br.readLine());
		int gameNum = teamNum * (teamNum - 1) / 2;
		int[] scoreOfAll = new int[teamNum];
		
		for (int i = 0; i < gameNum; i++) {
			String[] readGame = br.readLine().split(" ");
			int nameOfTeamA = Integer.parseInt(readGame[0]) - 1;
			int nameOfTeamB = Integer.parseInt(readGame[1]) - 1;
			int scoreOfTeamA = Integer.parseInt(readGame[2]);
			int scoreOfTeamB = Integer.parseInt(readGame[3]);
			
			if (scoreOfTeamB < scoreOfTeamA) {
				scoreOfAll[nameOfTeamA] += 3;
			} else if (scoreOfTeamA < scoreOfTeamB) {
				scoreOfAll[nameOfTeamB] += 3;
			} else {
				scoreOfAll[nameOfTeamA] += 1;
				scoreOfAll[nameOfTeamB] += 1;
			}
		}
		
		 
		for (int scoreA : scoreOfAll) {
			int rank = 1;
			for (int scoreB : scoreOfAll) {
				if (scoreA < scoreB) {
					rank += 1;
				}
			}
			System.out.println(rank);
		}
		
	}

}

Measured memory_bytes: 30716
n = input()
s = ""
for i in range(1, n + 1):
    x = i
    if(x % 3 == 0):
        s += " " + str(i)
        continue
    while(x):
        if(x % 10 == 3):
            s += " " + str(i)
            break
        x /= 10
print(s)

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

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

	if ((a + b == c) || (b + c == a) || (c + a == b))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include<time.h>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
int main(){
    int n;cin>>n;
    ll A[MAX];rep(i,n)cin>>A[i];
    ll ans=0;
    bool full=false;
    int c=0;
    int mini=INT_MAX;
    ll sum=0;
    for(int i=0;i<n;i++){
        int x=abs(A[i]);
        sum+=x;
        chmin(mini,x);
        if(A[i]==0)full=true;
        if(A[i]<0)c++;
        }
        if(c%2==0)full=true;
    cout<<(full?sum:sum-mini*2)<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
    int A,B;
    cin >> A >> B;

    int s = 1;
    int c = 0;
    for(int i=0;i<100;i++){
        if (s >= B) break;
        s += A - 1;
        c++;
    }

    cout << c << endl;
    return 0;
}

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

#define ll long long

using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;
	int mins = t.size();
	int minc=1001;
	for(int i = 0; i < (s.size()-t.size()+1); i++)
	{
		string a = s.substr(i, mins);
		int cnt = 0;
		for(int j = 0; j < mins; j++)
			if(a[j] != t[j])
				cnt++;
		minc=min(minc, cnt);
	}
	cout << minc << endl;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

constexpr int d = 365;
constexpr int n = 26;

vector<int> c(n);
vector<vector<int>> s(d,vector<int>(n));

double Score(const vector<int>&v){
  double score = 0;
  vector<int> last(n,-1);
  for(int i = 0; i < d; ++i){
    for(int j = 0; j < n; ++j){
      if(v[i] == j){
	score += s[i][j];
	last[j] = i;
      } else {
	score -= c[j]*(i-last[j]);
      }
    }
  }
  return score;
}

int main(){
  cin.ignore(3);
  cin >> c;
  for(auto&e:s)cin >> e;
  vector<int> ans(d);
  vector<int> last(n,-1);
  for(int i = 0; i < d; ++i){
    int maxp = -1001001001;
    int argi = 0;
    for(int j = 0; j < n; ++j){
      if(ChangeMax(maxp,s[i][j] + c[j]*(i-last[j])))argi = j;
    }
    ans[i] = argi;
    last[argi] = i;
  }

  random_device seed_gen;
  default_random_engine engine(seed_gen());
  uniform_int_distribution<> dist1(0, d-1);
  uniform_int_distribution<> dist2(0, n-1);

  double pre = Score(ans);

  for(int i = 0; i < 50000; ++i){
    int x = dist1(engine);
    int y = dist2(engine);
    int z = ans[x];
    ans[x] = y;    
    if(!ChangeMax(pre,Score(ans)))ans[x] = z;
  }
  
  for(auto e:ans)cout << e+1 << endl;
  return 0;
}


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

const int WMAX = 1500000;
const int NMAX = 100;

int n, m, a[NMAX];

bool check(int w) {
  int p, q, r;
  p = q = r = 0;
  while (p < m) {
    if (q + a[r] > w) {
      ++p;
      q = a[r];
    } else {
      q += a[r];
    }
    ++r;
    if (r >= n) {
      break;
    }
  }
  return (p<m);
}

int main() {
  int l, r, c, minw;
  bool b;
  while (1) {
    cin >> m >> n;
    if (!m && !n) break;
    minw = 0;
    for (int i=0; i<n; i++) {
      cin >> a[i];
      if (minw < a[i]) {
        minw = a[i];
      }
    }
    l = minw;
    r = WMAX;
    c = (l+r)/2;
    while (l != r) {
      b = check(c);
      if (b) {
        r = c;
      } else {
        l = c+1;
      }
      c = (l+r)/2;
    }
    cout << l << endl;
  }
  return 0;
}

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

int main(){
    int k,a,b;
    cin >> k;
    cin >> a >> b;
    for(int i=0 ; i<1000;i++){
        if(k*i <= b && k*i >= a ){
            cout << "OK" << endl;
            return 0;
        }
        else if(k*i > 1000)break;
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3576
//ABC142D
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans = min(a,b) + min(c,d);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    string s;
    cin >> s;
    s[5] = ' ';
    s[13] = ' ';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;

double Main(double &a, double &b, double &x)
{
    double h = x / (a * a);
    double r = 0.0;
    if(h >= b / 2)
    {
        r = atan2(b-h, a/2);
    }
    else
    {
        double y = 2 * x / (a * b);
        r = atan2(b, y);
    }
    return r * 180 / acos(-1);
}

int main(void)
{
    double A, B, x;
    cin >> A >> B >> x;
    printf("%.10f\n", Main(A, B, x));
    return 0;
}

Measured memory_bytes: 256
vs = [int(i) for i in input().strip()]
n = (len(vs) - 2)//2
def main(vs):
    if vs[0] != 1:
        print(-1)
        return -1
    if vs[-1] != 0:
        print(-1)
        return -1
    if vs[-2] != 1:
        print(-1)
        return -1
    for i in range(n):
        if vs[i+1] != vs[-2-i-1]:
            print(-1)
            return

    temp = 1
    for i in range(n+1 if len(vs) % 2 == 0 else n+2):
        print(1, temp+1)
        temp += 1
    temptemp = temp
    temp = 1
    for i in range(n):
        x = 1+n-i
        if vs[n-i] == 1:
            print(temptemp, temptemp+1)
            temp = temptemp
            temptemp += 1
        else:
            print(temp, temptemp+1) 
            temptemp += 1

main(vs)


Measured memory_bytes: 51420
import           Control.Applicative
import           Control.Monad
import           Data.List

main :: IO ()
main = do
  a:b:c:_ <- (map read . words) <$> getLine
  putStrLn $ convertIntList $ sortThreeNumbers a b c

sortThreeNumbers :: Int -> Int -> Int -> [Int]
sortThreeNumbers x y z = sort [x, y, z]

convertIntList :: [Int] -> String
convertIntList list = foldl1 concatWithBrank $ map show list

concatWithBrank :: String -> String -> String
concatWithBrank a b = a ++ " " ++ b

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
bool p(string v){string w(v);reverse(w.begin(),w.end());return w==v?true:false;}
int main(){string s;cin>>s;int n=s.size()/2;string a=s.substr(0,n),b=s.substr(n+1,n);if(p(s)&&p(a)&&p(b))puts("Yes");else puts("No");}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

struct bit {
	ll n;
	vl a;

	bit(ll n): n(n), a(n+2) { }
	
	void add(ll i, ll v) {
		for (i++; i <= n+1; i += i & -i) a[i] = max(a[i],v);
	}
	
	ll get(ll i) {
		ll res = 0;
		for (; i; i -= i & -i) res = max(res,a[i]);
		return res;
	}
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vl h(n), a(n);
	FOR(i,0,n) cin >> h[i];
	FOR(i,0,n) cin >> a[i];

	vl is(n);
	iota(all(is),0);
	sort(all(is),[&](ll i, ll j) { return h[i] < h[j]; });
	
	bit B(n);
	vl dp(n);
	for (ll i: is) {
		dp[i] = a[i] + B.get(i);
		B.add(i,dp[i]);
	}
	cout << *max_element(all(dp)) << endl;
}



Measured memory_bytes: 8064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int a = in.nextInt();
		int b = in.nextInt();
		double t = in.nextDouble();
		
		int ans = 0;
		for(int i=a; i<=t+0.5; i+=a) {
			ans += b;
		}
		
		System.out.println(ans);
		
		in.close();
	}

}


Measured memory_bytes: 26452
#include <bits/stdc++.h>
using namespace std;
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin>>n>>m;
	FORR(i, 1, m/n+1){
		if(m%i==0){
			cout<<i<<'\n';
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

   string s;
   cin >> s;
   int n=s.size();
   int ans=0,cnt=0;
   rep(i,n) {
       if (s[i]=='R') {
           ++cnt;
       } else {
           cnt=0;
       }
       ans=max(ans,cnt);
   }
   cout << ans << endl;

}


Measured memory_bytes: 3648
import java.util.*;
 
public class Main {
	
	private static List<Integer> group1List = new ArrayList<Integer>();
	private static List<Integer> group2List = new ArrayList<Integer>();
	private static List<Integer> group3List = new ArrayList<Integer>();
	
	
	public static void main(String[] args) {
		createGroup();
		Scanner sc = new Scanner(System.in);
		String in = sc.nextLine();
		String[] inArray = in.split(" ");
		int a = Integer.parseInt(inArray[0]);
		int b = Integer.parseInt(inArray[1]);
		
		if ((isGroup1(a,b)) || (isGroup2(a,b)) || (isGroup3(a,b))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
			
		}
		
		
		sc.close();
	}
	
	private static void createGroup() {
		int[] group1 = {1,3,5,7,8,10,12};
		int[] group2 = {4,6,9,11};
		int[] group3 = {2};
		
		
		for (int i = 0; i < group1.length; i++){
			Integer in1 = new Integer(group1[i]);
			group1List.add(in1);
		}
		for (int j = 0; j < group2.length; j++) {
			Integer in2 = new Integer(group2[j]);
			group2List.add(in2);
		}
		for (int k = 0; k < group3.length; k++) {
			Integer in3 = new Integer(group3[k]);
			group3List.add(in3);
		}
	}
	
	private static boolean isGroup1(int a , int b ) {
		Integer ao = new Integer(a);
		Integer bo = new Integer(b);
		if ((group1List.contains(ao)) && (group1List.contains(bo))){
			return true;
		}
		return false;
	}
	private static boolean isGroup2(int a , int b ) {
		Integer ao = new Integer(a);
		Integer bo = new Integer(b);
		if ((group2List.contains(ao)) && (group2List.contains(bo))){
			return true;
		}
		return false;
	}
	
	private static boolean isGroup3(int a , int b ) {
		Integer ao = new Integer(a);
		Integer bo = new Integer(b);
		if ((group3List.contains(ao)) && (group3List.contains(bo))){
			return true;
		}
		return false;
	}
	
	
}


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

int main() {
  int N;
  cin >> N;
  ll A[N];
  ll s = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    s += A[i];
  }
  ll x = s;
  for (int i = 0; i < N - 1; i += 2) {
    x -= 2 * A[i];
  }
  vector<ll> v;
  v.push_back(x);
  for (int i = N - 2; i >= 0; i--) {
    x = 2 * A[i] - x;
    v.push_back(x);
  }
  for (int i = N - 1; i >= 0; i--) {
    if (i == 0) cout << v[i] << "\n";
    else cout << v[i] << " ";
  }
  return 0;
}

Measured memory_bytes: 3060
N =  int(input())
S = input()
accw = [0]*(N+1)
acce = [0]*(N+1)
for i in range(N):
	if S[i] == 'E':
		acce[i+1] = acce[i]+1
		accw[i+1] = accw[i]
	else:
		accw[i+1] = accw[i]+1
		acce[i+1] = acce[i]


ans = acce[N]
for i in range(1,N-1):
	ans = min(ans,(acce[N]-acce[i+1]) + accw[i])
ans = min(accw[N-1],ans)

print(ans)




Measured memory_bytes: 17536
n,m,x = map(int,input().split())
ls = [list(map(int,input().split())) for i in range(n)]
ans = 10**18
for i in range(2**n):
  uds = [0]*m
  cost = 0
  for j in range(n):
    if i&1<<j:
      for k in range(m):
        uds[k] += ls[j][k+1]
      cost += ls[j][0]
  if min(uds) >= x:
    ans = min(ans,cost)
if ans == 10**18:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 68584
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  string a;cin>>a;
  for(ll i=0;i<a.size();i+=2)cout<<a[i];
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main() {
    int N; cin >> N;
    rng(n,1,N+1) {
        int ans = 0;
        rng(y,1,101) rng(z,1,101) {
            int b = y + z;
            int c = y*y + z*z + y*z - n;
            double D = b*b - 4*c;
            if (D < 0) continue;
            if (pow(int(sqrt(D)),2) != D) continue;
            if ((-b + int(sqrt(D))) % 2 != 0) continue;
            int x = (-b + sqrt(D)) / 2;
            if (x >= 1) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main(){

  int N, C, K; cin >> N >> C >> K;
  vector <int> T(N);
  for (int i = 0; i < N; i++) cin >> T[i];
  sort(T.begin(), T.end());

  int ans = 0, people = 0, timelimit = 0;

  for (int i = 0; i < N; i++){
    if (people == 0){
      timelimit = T[i] + K;
      people ++;
    }else{
      if (T[i] <= timelimit){
        people++;
      }else{
        ans++;
        people = 1;
        timelimit = T[i] + K;
      }
    }
    if (people == C){
      ans++;
      people = 0;
    }
    if (i == N - 1 && people > 0){
      ans ++;
    }
  }

  cout << ans << endl;
  

  return 0;
}

Measured memory_bytes: 640
n = int(input())
X = list(map(float,input().split()))
Y = list(map(float,input().split()))

p1 = 0
for i in range(n):
    p1 += abs(X[i]-Y[i])
    
p2 = 0
for i in range(n):
    p2 += (abs(X[i]-Y[i]))**2
p2 = p2 ** 0.5

p3 = 0
for i in range(n):
    p3 += (abs(X[i]-Y[i]))**3
p3 = p3 ** (1/3)


p4 = 0
for i in range(n):
    if p4 < abs(X[i]-Y[i]):
        p4 = abs(X[i]-Y[i])
    
print(p1)
print(p2)
print(p3)
print(p4)


Measured memory_bytes: 5656
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		c,h,i,j,k,l,m=INF,n,x,y;
	ll		ans = INF;
	string	s;
	cin >> x >> n;
	set<ll>	p;
	for(i=0;i<n;i++) {
		cin >> j;
		p.insert(j);

	}
	for(i=-1;i<=101;i++) {
		if (p.count(i)) continue;
		c = abs(i-x);
		if (c < m) {
			ans = i;
			m = c;
		} else if (c == m) {
			ans = min(ans,i);
		}
	}

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


Measured memory_bytes: 3648
S=input()
if S[0]=='R':
    if S[1]=='R':
        if S[2]=='R':
            print(3)
        else:
            print(2)
    else:
        print(1)
else:
    if S[1]=='R':
        if S[2]=='R':
            print(2)
        else:
            print(1)
    else:
        if S[2]=='R':
            print(1)
        else:
            print(0)
        

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

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

    vector<int>C;
    int c, t;
    for(int i=0; i<N; i++){
        cin >> c >> t;
        if(t<=T){
            C.push_back(c);
        }
    }
        

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

    if(C.size()==0){
        cout << "TLE" << endl;
        return 0;
    } 

    cout << C[0] << endl;

    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
string s;
int main() {
    DAU
    cin >> s;
    if (s == "ABC")
        cout << "ARC";
    else cout << "ABC";
    PLEC
}


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


void solve () {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int mid = n / 2;
    cout << a[mid] - a[mid - 1];

}

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


Measured memory_bytes: 3708
#include "bits/stdc++.h"
#define esc(ret) cout << (ret) << endl,quick_exit(0)
#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define repD(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) repU(i,0,(n) - 1)
#define rep1(i,n) repU(i,1,(n))
#define all(v) begin(v),end(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define qceil(n,d) ((n) > 0 ? ((n) - 1) / (d) + 1 : (n) / (d))
#define parity(a,b) (a & 1 ^ b & 1 ^ 1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<db,int> pdi;

const pii dir[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int mod = 1e9 + 7;
const int inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;


int N,M,Q,K;
string S;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N;
	for(ll h = 1; 4 * h <= 3 * N; ++h){
		repU(n,h,3500){
			ll t = N * h * n;
			ll u = 4 * h * n - N * (h + n);
			if(u > 0 && t % u == 0){
				cout << h << ' ' << n << ' ' << t / u << endl;
				return 0;
			}
		}
	}
}




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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<ll int, ll int>> seito,point;
    REP(i, n){
        ll int a,b;
        cin >> a >> b;
        seito.pb(mp(a,b));
    }
    REP(i,m){
        ll int c,d;
        cin >> c >> d;
        point.pb(mp(c,d));
    }
    REP(i,n){
        int ans = 0;
        int old = 0;
        REP(j,m){
            int dis = abs(seito[i].first - point[j].first) + abs(seito[i].second - point[j].second);
            if(j == 0){
                old = dis;
            } else{
                if(old > dis){
                    old = dis;
                    ans = j;
                }
            }
        }
        cout << ans+1 << endl;
    }
}


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int n, l;
    cin >> n >> l;
    int eaten = 65536;
    for(int i=l;i<l+n;i++) if(abs(eaten) > abs(i)) eaten = i;
    int64_t sum = 0;
    for(int i=l;i<l+n;i++) sum += i;

    cout << sum - eaten << endl;
    
    return 0;
}


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

int main(void)
{
  int N;
  cin >> N;
  int ret;
  if(N%2==0)
  {
    ret=N/2-1;
  }
  else
  {
    ret=N/2;
  }
  
  cout << ret;
  return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    a = (a + 11) % 13;
    b = (b + 11) % 13;
    if (a > b) {
        cout << "Alice" << endl;
    } else if (a < b) {
        cout << "Bob" << endl;
    } else {
        cout << "Draw" << endl;
    }
}

Measured memory_bytes: 256
import math
def main():
    h = int(input())
    cnt = 0
    ans = 0
    tmp = 1
    a = int(math.log2(h)) +1
    # cnt = 2 **a
    ans = (1-2**a)//(1-2)
    print(ans)

if __name__=='__main__':
    main()


Measured memory_bytes: 3188
#include <sstream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <sstream>
#include <functional>
#include <set>
#include <typeinfo>
using namespace std;

int main(){
  while(true){
    //    vector<int> a;
    int n;
    string tmpa;
    set<int> nums;
    int cnt = 1;
    vector<int> keep(21,10000000);
    cin >> tmpa >> n;
    if(n == 0 && tmpa == "0")break;
    nums.insert(atoi(tmpa.c_str()));
    keep[0] = atoi(tmpa.c_str());
    while(true){
      //      cout << "aa" << endl;
      vector<int> a(n,0);
      vector<int> b(n,0);
      for(int i = 0;i < tmpa.size();i++){
	a[i] = tmpa[i] - '0';
	b[i] = tmpa[i] - '0';
      }
      sort(a.begin(),a.end(),greater<int>());
      sort(b.begin(),b.end());
      int c = 1;
      int an,bn;
      an = 0;bn = 0;
      for(int i = 0;i < n;i++){
	an = an+a[i]*c;
	bn = bn+b[i]*c;
	c = c*10;
      }
      //      cout << an << " " << bn <<  endl;
      //return 0;
      int ans = bn - an;
      
      if( nums.find(ans) == nums.end() ){
	  nums.insert(ans);
	  keep[cnt] = ans;
	  /*c = 10;
	  for(int i = 0;i < n;i++){
	    tmpa[i] = IntToString(ans%c);
	    c = c*10;
	    }*/
	  stringstream ss;
	  ss << ans;
	  tmpa = string(ss.str());/*
	  for(int i  = 0;i < n;i++){
	    cout << tmpa[i];
	  }
	  cout << " "<< ans<< endl;
				  */
	  cnt++;
      }else{
	for(int i = 0;i < 21;i++){

	  if(ans==keep[i]){
	    cout << i << " " << ans << " " << cnt - i << endl;
	    break;
	  }
	}
	break;
	
      }

    }

    
  }
  return 0;
}

Measured memory_bytes: 1252
#include <stdio.h>

int main(void) {
   
    int n,i,j;
    scanf("%d",&n);
    for (i=1; i<=n; i++){
        if (i%3==0) printf(" %d",i);
        else{
        for (j=i; j>0; j/=10) {
            if (j%10==3){printf(" %d",i);
            break;
            }}
        
   //   else if(i%10==3)printf(" %d",i);
    //  else if(i/10%10==3)printf(" %d",i);
    //  else if(i/100%10==3)printf(" %d",i);
    //  else if(i/1000%10==3)printf(" %d",i);
       
        }}
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
void sort(int A[], int len_A){
    int i, j, tmp;
    for (i = 0; i < len_A - 1; i++){
        for (j = 0; j < len_A - 1; j++){
            if (A[j + 1] < A[j]){
                tmp = A[j];
                A[j] = A[j + 1];
                A[j + 1] = tmp;
            }
        }
    }
}

int main(void){
    int n, x;
    scanf("%d%d", &n, &x);
    int m[n];
    for (int i = 0; i < n; i++){
        scanf("%d", &m[i]);
    }

    int sum = 0;
    for (int i = 0; i < n; i++){
        sum += m[i];
    }
    sort(m, n);
    int min = m[0];

    int ans = n + (x - sum) / min;
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <cmath>
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 1; i < (n); i ++)
using ll = long long;
using namespace std;

vector<ll> prime;


int main(int argc, const char * argv[]) {
    int n;
    int temp = 0;
    int ans = 0;
    cin >> n;
    
    rep(i, n){
        temp = (n - 1) / i;
        ans += temp;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3184
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i <= n; i++)

#define PI 3.1415926535897932

typedef long long ll;

using namespace std;

int main()
{
    double a, b, x, v, res;
    cin >> a >> b >> x;
    v = a * a * b;

    if(x >= v / 2.0)
    {
        res = atan(2.0 / a * (b - (x/(a * a))))*180.0 / PI;
        cout << setprecision(10) << res << endl;
    }
    else
    {
        res = atan(a * b * b / (2.0 * x))*180.0 / PI; 
        cout << setprecision(10) << res << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(ll i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
//const ll MOD = 998244353ll;
const dou pi=3.141592653589793*2;

int main(){
    int n;
    std::cin >> n;
    n=n%10;
    if(n==2||n==4||n==5||n==7||n==9)std::cout << "hon"<< std::endl;
    else if(n==0||n==1||n==6||n==8)std::cout << "pon" << std::endl;
    else std::cout << "bon" << std::endl;
}

Measured memory_bytes: 3628
n = gets.to_i

#複数行に複数要素が存在する場合
d = []
while line = gets
    d << line.chomp.split(' ')
end

ck=Array.new(d.size,0)

for i in 0..d.size-1 do
	if d[i][0] == d[i][1] then
		ck[i]=1
	end
end


renzoku=0
for i in 0..ck.size-1 do
	if ck[i]==1 then
		renzoku+=1
		if renzoku == 3 then
			puts "Yes"
			exit
		end
	else
		renzoku=0
	end
end
puts "No"

Measured memory_bytes: 14404
#include<bits/stdc++.h>
using namespace std;
const int M=1e5+5;
const int N=405;
int n,m,x[M],y[M],vis[N],vi[N][N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%d%d", &x[i],&y[i]);
	for(int i=1;i<=n;i++){
		vi[i][i]=m+1;
		for(int j=m;j;j--){
			if(vi[i][x[j]]&&vi[i][y[j]]){
				vis[i]=1;
				break;
			}
			if(vi[i][x[j]]||vi[i][y[j]]){
				if(!vi[i][x[j]])	vi[i][x[j]]=j;
				if(!vi[i][y[j]])	vi[i][y[j]]=j;
			}
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(vis[i])	continue;
		for(int j=i+1;j<=n;j++){
			if(vis[j])	continue;

			int f=1;
			for(int k=1;k<=n;k++)
				if(vi[i][k]&&vi[j][k]&&vi[i][k]!=vi[j][k]){
					//cout<<i<<' '<<j<<' '<<k<<' '<<vi[i][k]<<' '<<vi[j][k]<<endl;
					f=0;
				}
			ans+=f;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(NULL);
    ios::sync_with_stdio(false);
    // freopen("tc.txt", "r" ,stdin);
    int h1,s1,h2,s2;
    cin >> h1 >> s1 >> h2 >> s2;
    int answer = 0;
    while(true){
        h2 -= s1;
        if (h2 <= 0) {
            answer = 1;
            break;
        }
        h1 -= s2;
        if (h1 <= 0) {
            answer = 2;
            break;
        }
    }

    if (answer == 2){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
    static Scanner sc =new Scanner(System.in);
    public static void main(String[] args) {
        int h1 = sc.nextInt();
        int m1 = sc.nextInt();
        int h2 = sc.nextInt();
        int m2 = sc.nextInt();
        int k = sc.nextInt();

        int startTime = h1 * 60  + m1;
        int endTime = h2 * 60 + m2;

        int wakeUp = endTime - startTime;

        int sleepTime = wakeUp - k;

        System.out.println(sleepTime);

    }
}


Measured memory_bytes: 35780
N = int(input())
L = list(map(int,input().split()))

ans = 0

for i in range(N):
  for j in range(N-1-i):
    for k in range(N-2-j-i):
      if L[i]==L[j+1+i] or L[j+1+i]==L[k+2+j+i] or L[k+2+j+i]==L[i]:
        continue
      elif max(L[i], L[j+1+i], L[k+2+j+i]) <  L[i] +  L[j+1+i] + L[k+2+j+i] - max(L[i], L[j+1+i], L[k+2+j+i]):
        ans += 1

print(ans)


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  string s;
  cin>>s;

  reverse(rng(s));
  int n=s.size();
  vector<int>sum(n+1,0);
  int ten=1;
  for(int i=0;i<n;i++)sum[i+1]=(sum[i]+((s[i]-'0')*ten)%2019)%2019,ten=(ten*10)%2019;
  map<int,int>m;
  ll ans=0;
  for(int i=0;i<=n;i++){
    ans+=m[sum[i]];
    m[sum[i]]++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4348
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
 
using namespace std;
 
int main(){
    int n;
    cin >> n;
    long long a[n];
    for(int i = 0; i < n; i++)cin >> a[i];
    
 
    long long sum = a[0];
    long long ans = 0;
    if(sum == 0){
        sum = 1;
        ans++;
    }
    for(int i = 1; i < n; i++){
        long long  tmp = sum + a[i];
        if(sum > 0 && tmp > 0){
            ans += tmp+1;
            sum = -1;
        }
        else if(sum < 0 && tmp < 0){
            ans += -tmp+1;
            sum = 1;
        }
        else if(tmp == 0){
            ans++;
            if(sum < 0)sum = 1;
            else sum = -1;
        }
        else sum = tmp;
    }

    sum = a[0];
    long long ans2 = 0;
    if(sum == 0){
        sum = -1;
        ans2++;
    }
    else {
        sum = -1*a[0]/abs(a[0]);
        ans2 = abs(a[0])+1;
    }

    for(int i = 1; i < n; i++){
        long long  tmp = sum + a[i];
        if(sum > 0 && tmp > 0){
            ans2 += tmp+1;
            sum = -1;
        }
        else if(sum < 0 && tmp < 0){
            ans2 += -tmp+1;
            sum = 1;
        }
        else if(tmp == 0){
            ans2++;
            if(sum < 0)sum = 1;
            else sum = -1;
        }
        else sum = tmp;
    }
 
 
    
    cout << min(ans2, ans);
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;


int main() {
	int N;
	cin >> N;
	VL a(N + 1, 0);
	REP(i, N) cin >> a[i];
	a[N] = 10000000000 + 1;
	SORT(a);

	int c = 1,d = 0;
	REP(i, N) {
		if (a[i] == a[i + 1]) c++;
		if (a[i] != a[i + 1]) {
			if (c > a[i]) d += (c - a[i]);
			if (c < a[i]) d += c;
			c = 1;
		}
	}
	cout << d << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  string a;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='B'&&a.size()!=0){
      a=a.substr(0,a.size()-1);
    }
    else if(s.at(i)!='B') a+=s.at(i);
  }
  cout<<a;
  
}

Measured memory_bytes: 256
#include <stdio.h>
main(){
  int h[10];
  int st,nd,rd,i;
  st = 0;
  nd = 0;
  rd = 0;
  for(i=0;i<10;i++){
    scanf("%d",&h[i]);
    if(h[i]>st){
      rd = nd;
      nd = st;
      st = h[i];
    }else if(h[i]>nd){
      rd = nd;
      nd = h[i];
    }else if(h[i]>rd){
      rd = h[i];
    }
  }
  printf("%d\n%d\n%d\n",st,nd,rd);
} 

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

int main(){
  string S;cin>>S;
  int N=S.size();
  bool ans=true;
  for(int i=0;i<N/2;i++) if(S.at(i)!=S.at(N-1-i)){
    ans=false;
    break;
  }
  for(int i=0;i<N/4;i++) if(S.at(i)!=S.at(N/2-i-1)) ans=false;
  for(int i=0;i<N/4;i++) if(S.at(N/2+1+i)!=S.at(N-1-i)) ans=false;
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
  


Measured memory_bytes: 3612
n, m = gets.chomp.split(" ").map(&:to_i)
dist = Array.new(n, -1)
dist[0] = 0
queue = [0]
inputs = Array.new(n).map{Array.new}
m.times do
    a, b = gets.chomp.split(" ").map(&:to_i)
    inputs[a-1] << b-1
    inputs[b-1] << a-1
end
until queue.empty?
    island = queue.shift
    inputs[island].each do |v|
        next if dist[v] != -1
        dist[v] = dist[island] + 1
        queue << v
    end
end

puts dist[n-1] == 2 ? "POSSIBLE" : "IMPOSSIBLE"

Measured memory_bytes: 24828
using System;
using System.Linq;
//using System.Collections.Generic;

class Test
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();

        int times = 0;
        int flag = 1;
        while (flag == 1)
        {
            flag = 0;
            for (int j = N - 1; j > 0; j--)
            {
                if (A[j] < A[j - 1])
                {
                    int temp = A[j];
                    A[j] = A[j - 1];
                    A[j - 1] = temp;
                    times++;
                    flag = 1;
                }
            }
        }

        for (int i = 0; i < A.Length; i++)
        {
            Console.Write(A[i]);
            Console.Write(i == A.Length - 1 ? "\n" : " ");
        }
        Console.WriteLine(times);
    }
}


Measured memory_bytes: 18336
#define s(X,Y,Z)(t=X,X=Y,Y=t,f(Z?&X:&Y),a&7)
f(int*a){*a=*a%8<<4|*a>>4;}m,a,b,c,t,r;main(n){while(scanf("%d",&n),n){for(r=1,a=97,b=82,c=67;n--;scanf(" %c%*s",&t),m=t-76,r+=m%6==0?s(c,b,m):1<m&m<8?s(b,a,m^7):s(c,a,m>0));printf("%d\n",r);}}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
using namespace std;
int main() {
	int a = 0;
	for (int i = 0;i < 4;++i) {
		int b;
		scanf("%d", &b);
		a += b;
	}
	printf("%d\n%d\n", a / 60, a % 60);
}


Measured memory_bytes: 1188
#include <iostream>
#include <vector>

using namespace std;

class Edge {
public:
	int to, weight;
	Edge(int t, int w) : to(t), weight(w) {}
};

int memo[100001] = {0};

inline int height(const vector< vector<Edge> > &Graph, const int root) {
	if (memo[root]) return memo[root];
	int ret = 0;
	for (int i=0; i<(int)Graph[root].size(); ++i) {
		ret = max(ret, Graph[root][i].weight + height(Graph, Graph[root][i].to));
	}
	return memo[root] = ret;
}

inline int diameter(const vector< vector<Edge> > &Graph, const int root) {
	int ret = 0;
	int h1 = 0, h2 = 0;
	for (int i=0; i<(int)Graph[root].size(); ++i) {
		int h = Graph[root][i].weight + height(Graph, Graph[root][i].to);
		if (h1 < h) {
			h2 = h1;
			h1 = h;
		} else if (h2 < h) {
			h2 = h;
		}
		ret = max(ret, diameter(Graph, Graph[root][i].to));
	}
	ret = max(ret, h1 + h2);
	return ret;
}

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

	int n, s, t, w;
	cin >> n;
	vector< vector<Edge> > Graph(n + 1);
	for (int i=1; i<=n-1; ++i) {
		cin >> s >> t >> w;
		Graph[s].push_back(Edge(t, w));
	}
	cout << diameter(Graph, 0) << endl;

	return 0;
}

Measured memory_bytes: 11968
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>

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

int main()
{
    int n, k, a[100000];
    int sp = 0, ans = 0;

    cin >> n >> k;
    rep(i, 0, n) cin >> a[i];
    while (1)
    {
        sp += k - 1;
        ans++;
        if (sp >= n - 1)
            break;
    }
    cout << ans << endl;
}


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

int main() {
    string s;
    cin >> s;
    map<char, int> mp { {'a', 0}, {'b', 0}, {'c', 0} };
    for (int i = 0; i < s.size(); i++)
    {
        mp[s[i]]++;
    }
    
    vector<int> a;
    for (auto x : mp) {
        a.push_back(x.second);
    }

    int minv = *min_element(a.begin(), a.end());
    for (int i = 0; i < 3; i++) a[i] -= minv;

    if (a[0] < 2 && a[1] < 2 && a[2] < 2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 3756
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include <math.h>
using namespace std;
signed main() {
	string a, b, c;
	cin >> a >> b >> c;
	int ta = 0, mu = 0, rin = 0;
	char ym = 'a';
	while (1) {
		if (ym == 'a') {
			if (ta == a.size()) {
				cout << 'A' << endl;
				return 0;
			}
			ym = a[ta];
			ta++;
		}
		else if (ym == 'b') {
			if (mu == b.size()) {
				cout << 'B' << endl;
				return 0;
			}
			ym = b[mu];
			mu++;
		}
		else {
			rin++;
			if (rin == c.size()) {
				cout << 'C' << endl;
				return 0;
			}
			ym = c[rin];
		}
		
	}
	getchar(); getchar();
}

Measured memory_bytes: 256
/********************************
*** ******** ********** *********
*** * ****** ********* * ********
*** ** ***** ******** *** *******
*** *** **** ******* ***** ******
*** **** *** ****** ******* *****
*** ***** ** ***** +++++++++ ****
*** ****** * **** *********** ***
*** *******  *** ************* **
*** ******** ** *************** *
**********_**********************
* |   /  / \  \     /    /\     *
* |  /  |   |  \   /    /  \    *
* | /   |   |   \ /    /    \   *
* |+\   |   |    |    /______\  *
* |  \  |   |    |   |        | *
* |   \  \_/     |   |        | *
********************************/
#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define lsb(i) (i & -i)
#define Pi 3.141592653589793238
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define all(a) a.begin(), a.end()
#define remax(a, b) (a = ((a<b) ? b : a))
#define remin(a, b) (a = ((a<b) ? a : b))
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define precise(a) cout<<fixed<<setprecision(a)
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

lli power(lli x,lli y,lli p = MOD) { 
	lli res = 1;	 
	x = x % p; 
	while (y > 0) 
	{ 
		if (y & 1) 
			res = (res*x) % p; 
		y = y>>1; 
		x = (x*x) % p; 
	} 
	return res; 
} 

const lli N = 1e5 + 1;
lli n, a[N], sm = 0, b, c, q;

void solve(){
    char c;
	cin >> c;
	if(c >= 'A' && c <= 'Z') cout << "A";
	else cout << "a";
    return;
}
        
int main(){
    fastIO;
    lli t = 1;
    // cin>>t;
    NA(i,0,t){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<string>
#define in register int
#define rr read()
#define re register
using namespace std;
inline bool isdigit(re char ch){return ch>='0'&&ch<='9';}
string s;
int h[100],tot;
signed main()
{
	cin>>s;
	in ls=s.size();
	for(in i=0;i<ls;i++)
	{
		if(isdigit(s[i]))h[++tot]=s[i];
		else tot=tot?tot-1:0;
	}
	for(in i=1;i<=tot;i++)
	{
		putchar(h[i]);
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 256