akhauriyash/Code-Regression huggingface dataset:
//  Created by conan1024hao in 2020.
//  Copyright © 2020 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e17
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll N,W;cin>>N>>W;
    V<ll>w(N+1),v(N+1);
    for(ll i=0;i<N;i++)
        cin>>w[i]>>v[i];
    ll dp[101][100001];
    ll ans=0;
    memset(dp,0,sizeof(dp));
    for(int j=0;j<=100000;j++)
        dp[0][j]=INF;
    dp[0][0]=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<=100000;j++){
            if(j<v[i])
                dp[i+1][j]=dp[i][j];
            else
                dp[i+1][j]=mmin(dp[i][j],dp[i][j-v[i]]+w[i]);
        }
    }
    for(ll i=0;i<=100000;i++){
        if(dp[N][i]<=W)
            chmax(ans,i);
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------







Measured memory_bytes: 79232
import sys
input = sys.stdin.readline
ri = lambda: int(input())
#rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

N = ri()
A=list(rl())
A.sort()
ans = []
a_min = A[0]
a_max = A[-1]
if a_max <= 0:
    for i in range(1,N-1):
        y = A[i]
        ans.append([a_max,y])
        a_max -= y
    ans.append([a_max,a_min])
elif a_min > 0:
    for i in range(1,N-1):
        y = A[i]
        ans.append([a_min,y])
        a_min -= y
    ans.append([a_max,a_min])
else:
    ind = 0
    for i in range(1,N):
        if A[i] > 0:
            ind = i
            break
    for i in range(1,ind):
        y = A[i]
        ans.append([a_max,y])
        a_max -= y
    for i in range(ind,N-1):
        y = A[i]
        ans.append([a_min,y])
        a_min -= y
    ans.append([a_max,a_min])


print(a_max-a_min)
for x,y in ans:
    print(x,y)
        

Measured memory_bytes: 22528
import numpy as np

N = int(input())
MAXX = 10**6 + 5
num = np.array(input().split(), np.int32)[:]
mark = np.zeros(MAXX, np.int32)

num = np.sort(num)
for n in num:
    if mark[n] < 2:
        mark[n::n] += 1

count = 0
for n in num:
    if mark[n] == 1:
        count += 1

print(count)

Measured memory_bytes: 49780
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}


int n,ans=0;
string s,t;
int main() {
	cin>>s>>t;
	for(int i=0;i<3;++i){
		ans+=(s[i]==t[i]?1:0);
	}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define exit return 0
#define boost ios_base::sync_with_stdio(0)
#define boost1 cin.tie(0)
#define boost2 cout.tie(0)
int main()
{
    boost;
    boost1;
    boost2;
    int a,b;
    cin>>a>>b;
    if(a>9 || b>9)
    {
        cout<<-1<<endl;
    }
    else
    {
        cout<<a*b<<endl;
    }
    exit;

}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main (String [] args){
		//		String [][] boad = new String[4][4];
		List <Integer> list = new ArrayList<Integer>();
		List <String> list2 = new ArrayList<String>();
//		String s = sc.next();
		int answer = 0;
		int in = Integer.parseInt(sc.next());
//		int c = 0;
		String d = "";
		Boolean e = false;
		
		for(int i = in;i <= 999;i++){
			if(i/10 - i/100 == i/100 * 10 && i - i/100 == i/10*10){
				answer =i;
				break;
			}
		}
		
//		for(int i = 0;i<n;i++){
//			list.add(Integer.parseInt(sc.next()));
//		}
		
		System.out.println(answer);
		System.out.flush();
		sc.close();
	}
}

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

#define fst first
#define snd second
#define fore(i,a,b) for(int i=a, ThxDem=b; i<ThxDem; ++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define SZ(s) int(s.size())
#define DBG(x) cerr <<#x << " = " << (x) << "\n"

#define SQR(x) ((x) * (x))

#define PI 3.1415926535897932385
#define INF 1000111222
#define eps 1e-7
#define maxN 11

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<string> vstr;
typedef vector<vll> vvll;
typedef vector<bool> vbool;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<vbool> vvbool;

vll ns,dp;
ll n,k;

ll solve(ll pos){
	ll & d = dp[pos];
	if(d != -1) return d;
	ll v=INF;
	fore(i,pos+1,min(pos+k+1,n)) v = min(v,abs(ns[i]-ns[pos])+solve(i));
	if(pos == (n-1)) v = 0;
	return d = v;
}

int main(){FIN
	
	cin >> n >> k;
	ns.resize(n);
	dp.assign(100010,-1);
	fore(i,0,n)cin >> ns[i];
	
	solve(0);
	
	cout << dp[0] << "\n";

	return 0;
}


Measured memory_bytes: 11264
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, K;
    string S;
    cin >> N >> K >> S;
    char before = 'A';

    int H = 0;
    REP(i, N) {
        if (S[i] == before) H++;
        before = S[i];
    }
    cout << min(N - 1, H + K * 2) << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0){
                break;
            }
            int i,j;
            for(i=0; i<H; i++){
                for(j=0; j<W; j++){
                    if((i+j)%2==0){
                        System.out.printf("#");
                    }else if((i+j)%2==1){
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
    }
}


Measured memory_bytes: 62948
using System;
using System.Collections.Generic;

public class CSharp
{
    public static void Main()
    {
        Kyopuro chokudai = new Kyopuro();
        chokudai.AtCoder();
    }
}

public class Kyopuro
{

    int n, xs, xt;
    long ans;
    string t;
    char[] s;

    public void AtCoder()
    {
        string[] input;
        //input = Console.ReadLine().Split(' ');
        t = Console.ReadLine();
        n = t.Length;
        s = new char[n];
        for (int i = 0; i < n; i++) s[i] = t[i];

        xs = -1;
        xt = -2;
        ans = 0;
        bool f = false;

        for(int i=0; i<n-2; i++)
        {           
            if(s[i] == 'A')
            {
                if (!f)
                {
                    xs = i;
                    xt = i;
                    f = true;
                }
                else
                {
                    xt = i;
                }
                if (s[i + 1] == 'B' && s[i + 2] == 'C')
                {
                    ans += xt - xs + 1;
                    xs += 2;
                    xt += 1;
                    i += 1;
                    s[i + 1] = 'A';
                }
            }
            else
            {
                f = false;
            }
        }
        
        Console.WriteLine(ans);
    }
    public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
}


Measured memory_bytes: 14176
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};

use std::io::prelude::*;

fn input<T>() -> T
    where T: std::str::FromStr {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let mut a_s: Vec<i64> =
        (0..n).map(|_| input()).collect();
    let mut ans = std::i64::MAX;
    for &s in [1, -1].iter() {
        let mut sign = s;
        let mut sum = 0;
        let mut lans = 0;
        for i in 0..n {
            sum += a_s[i];
            // 意図したモノでない
            if sum * sign <= 0 {
                lans += (sum - sign).abs();
                sum = sign;
            }
            sign *= -1;
        }
        ans = min(ans, lans);
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
A,B,C,D = (int(i) for i in input().split())

ans = "Yes"
turn = "Takahashi"

while True:
  if turn == "Takahashi":
    C -= B
    if C<=0:
      ans = "Yes"
      break
    turn = "Aoki"
  else:
    A -= D
    if A<=0:
      ans = "No"
      break
    turn = "Takahashi"

print(ans)


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

const int INF = 1<<28;

struct Edge {
  int v, w, t;
  bool operator < (const Edge &e) const {
    return w > e.w;
  }
};
typedef vector<vector<Edge> > Graph;

struct Main {
  
  int N, M, L, K, A, H;
  vector<int> F;
  Graph G;

  int dijkstra() {
    priority_queue<Edge> que;
    vector<vector<int> > cost(N, vector<int>(M+1, INF));
    que.push((Edge){A, 0, M});
    cost[A][M] = 0;
    while(que.size()) {
      const Edge s = que.top();
      que.pop();
      if(cost[s.v][s.t] < s.w) continue;
      if(s.v == H) return cost[s.v][s.t];
      if(s.t) {
        for(int i = 0; i < G[s.v].size(); ++i) {
          const Edge &e = G[s.v][i];
          const Edge t = {e.v, s.w + e.w, s.t - e.w};
          if(t.t < 0) continue;
          if(cost[t.v][t.t] <= t.w) continue;
          cost[t.v][t.t] = t.w;
          que.push(t);
        }
      }
      if(F[s.v] && s.t != M) {
        const Edge t = {s.v, s.w + 1, s.t + 1};
        if(cost[t.v][t.t] <= t.w) continue;
        cost[t.v][t.t] = t.w;
        que.push(t);
      }
    }
    return -1;
  }
  
  Main() {
    cin >> N >> M >> L >> K >> A >> H;
    if(!(N|M|L|K|A|H)) exit(0);
    F = vector<int>(N);
    for(int i = 0; i < L; ++i) {
      int a; cin >> a;
      F[a] = 1;
    }
    G = Graph(N);
    for(int i = 0; i < K; ++i) {
      int X, Y, T; cin >> X >> Y >> T;
      G[X].push_back((Edge){Y, T});
      G[Y].push_back((Edge){X, T});
    }
    int res = dijkstra();
    if(res == -1) cout << "Help!" << endl;
    else cout << res << endl;
  }
};

int main() { while(delete new Main(), 1); }

Measured memory_bytes: 1516
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class DMazeMaster {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int H, W;
        vc<int> di = {1, 0, -1, 0}, dj = {0, 1, 0, -1};
        in>>H>>W;
        vc<string> grid(H);
        REP(i, H) in>>grid[i];
        auto bfs = [&](int si, int sj){
            vvc<int> dist(H, vc<int>(W, -1));
            dist[si][sj] = 0;
            queue<pii> que;
            que.emplace(si, sj);
            while(not que.empty()){
                int ci = que.front().first, cj = que.front().second;
                que.pop();
                REP(k, 4){
                    int ni = ci + di[k], nj = cj + dj[k];
                    if(0<=ni and ni<H and 0<=nj and nj<W and grid[ni][nj]=='.' and dist[ni][nj]==-1){
                        dist[ni][nj] = dist[ci][cj] + 1;
                        que.emplace(ni, nj);
                    }
                }
            }
            int res = -1;
            REP(i, H) REP(j, W) chmax(res, dist[i][j]);
            return res;
        };
        int ans = -1;
        REP(i, H) REP(j, W){
            if(grid[i][j]=='#') continue;
            chmax(ans, bfs(i, j));
        }
        out<<ans<<'\n';
    }
};


int main() {
	DMazeMaster solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3652
/*
 * Created by SharpDevelop.
 * User: Administrator
 * Date: 20/08/2017
 * Time: 19:03
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;

namespace Meal_Delivery_AtCoder
{
	class Program
	{
		public static void Main(string[] args)
		{
			String[] s = Console.ReadLine().Split(' ');
			int x = int.Parse(s[0]);
			int a = int.Parse(s[1]);
			int b = int.Parse(s[2]);
			
			if (Math.Abs(a-x)<Math.Abs(b-x)) Console.WriteLine("A");
			else Console.WriteLine("B");
		}
	}
}

Measured memory_bytes: 13140
import sys
import math
import collections
import bisect
import itertools
import decimal
import copy
import heapq

# import numpy as np

# sys.setrecursionlimit(10 ** 6)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))
flush = lambda: sys.stdout.flush()


# ===CODE===
def main():
    n = ni()
    d = [na() for _ in range(n)]

    tINF = 10 ** 15

    max_numR = -INF
    min_numR = INF
    max_numL = -INF
    min_numL = INF

    for x, y in d:
        max_numR = max(max_numR, x + y)
        min_numR = min(min_numR, x + y)

        max_numL = max(max_numL, tINF - x + y)
        min_numL = min(min_numL, tINF - x + y)

    ans = max(max_numR - min_numR, max_numL - min_numL)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 105080
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

const double PI = 3.14159265358979;

int main(){
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    double s = (double)(h/12.0+m/60.0/12.0)*2*PI;
    double l = (double)(m/60.0)*2*PI;
    // cout << l << endl;
    // cout << s << endl;
    double ans = a*a+b*b-2.0*a*b*cos(s-l);
    // cout << a*a+b*b << endl;
    // cout << 2.0*a*b*cos(s-l) << endl;
    // cout << 
    // cout << ans << endl;
    ans = sqrt(ans);
    printf("%.10f\n",ans);
}

Measured memory_bytes: 4136
#include <stdio.h>
const int MAX_V = 999999;
int prime[1000000];
int main(){
	//?´???°??¨??????
	int i, k;
	for( i = 2; i <= MAX_V; i++) {
		prime[i] = 1;
	}
	for( i = 2; i * i <= MAX_V; i++){
		if(prime[i]) {
			for( k = 2 * i; k <= MAX_V; k += i){
				prime[k] = 0;
			}
		}
	}
	//?´???????????±???????
	int sum[MAX_V + 2];
	sum[2] = 0;
	for( i = 2; i <= MAX_V; i++){
		sum[i + 1] = sum[i] + prime[i];
	}
	//??\?????¨??????
	int n;
	while(scanf("%d", &n) != EOF){
		printf("%d\n", sum[n + 1]);
	}
	return 0;
}

Measured memory_bytes: 8408
#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(){
    int n;
    cin >> n;
    bool flag = false;
    if(n%10==7) flag=true;
    n = n/10;
    if(n%10==7) flag = true;
    n = n/10;
    if(n%10==7) flag = true;

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define SORT(c) sort((c).begin(),(c).end())
#define db(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define reprs(i, m, n) for(int i = n; i >= m; i--)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
#define SORTR(c) sort((c).begin(),(c).end(),greater<pair<ll,ll>>())

int main(){

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

  vector<ll> A;
  rep(i,N){
    ll a;
    cin>>a;
    A.emplace_back(a);
  }

  SORT(A);

  vector<pair<ll,ll>> PA;
  rep(i,M){
    ll b,c;
    cin>>b>>c;
    PA.emplace_back(c,b);
  }

  bool da=false;
  SORTR(PA);
  int ctb=0;
  int ctbn=0;
  rep(i,N){
    while(true){
    if(ctb>=M) {
      da=true;
      break;
    }
    if(PA[ctb].second<=ctbn){
      ctb++;
      ctbn=0;
      continue;
    }
    break;
    }
    if(da) break;
    if(PA[ctb].first<=A[i]) break;
    ctbn++;
    A[i]=PA[ctb].first;
  }
  ll ans=0;
  rep(i,N){
    ans+=A[i];
  }
  cout << ans <<endl;
  return 0;
}


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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

signed main()
{
   cin.tie(nullptr);
   ios_base::sync_with_stdio(false);

   int n,cnt=0,ans=0;
   cin>>n;
   vector<int> d(n);

   rep(i,0,n){
      cin>>d[i];
   }
   sort(all(d));

   n /= 2;
   cnt = d[n-1];
   ans = d[n];
   if(cnt == ans){
      cout<<0<<'\n';
      return 0;
   }
   cout<<ans-cnt<<'\n';
   return 0;
}

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

#define HILLS_SIZE 10

int cmp(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main(void){
  int hills[HILLS_SIZE]   = {0},
      i;
  for(i = 0;i < HILLS_SIZE;i++){
    scanf("%d\n",&hills[i]);
  }
  
  qsort(hills,HILLS_SIZE,sizeof(int),cmp);
  for(i = 0;i < 3;i++){
    printf("%d\n",hills[i]);
  }
  return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(x) x.begin(), x.end()
#define pb(x) push_back(x)
#define INF 1000000000000000000
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define x first 
#define y second
const int maxx = 1000006;
const int maxlog = 20;
const ll mod = 1000000007;
int arr[maxx];

int main() {
    IOS
    int N, K;
    cin >> N >> K;
    int count  =0;
    for (int i = 0; i < N; i++) {
        int x; cin >> x;
        if (x >= K) count++;
    }
    cout << count;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n, k, q; cin >> n >> k >> q;
	int a[2000];
	rep(i, n) {
		cin >> a[i];
	}
	int used[2001] = {};
	used[n] = 1;
	int chk = 1e+9;
	rep(aa, n) {
		int now = 0;
		vector<int>v,out;
		rep(i, n+1) {
			if (used[i]) {
				int len = v.size();
				sort(v.begin(), v.end());
				rep(j, len - k + 1) {
					out.push_back(v[j]);
				}
				v.clear();
				now = i+1;
			}
			else {
				v.push_back(a[i]);
			}
		}
		int len2 = out.size();
		if (len2 < q)break;
		sort(out.begin(), out.end());
		chk = min(chk, out[q - 1]-out[0]);
		rep(i, n) {
			if (a[i] == out[0]) {
				used[i] = 1; break;
			}
		}
	}
	cout << chk << endl;
	return 0;
}

Measured memory_bytes: 256
# 入力値の取得
size, sum = gets.chomp.split(" ").map(&:to_i)

# 制約のチェック
raise "お札は1枚以上、2000枚以下" unless size.between?(1, 2000)
raise "金額は1000円以上、2*10^7円以下" unless sum.between?(1000, 2*10**7)
raise "金額は1000の倍数" unless sum % 1000 == 0

# 計算
found = false

0.upto(size) do |yukichi|
  0.upto(size - yukichi) do |ichiyo|
    hideyo = size - (yukichi + ichiyo) 
    yen = yukichi * 10000 + ichiyo * 5000 + hideyo * 1000
    if yen == sum
      puts "#{yukichi} #{ichiyo} #{hideyo}"
      found = true
      break
    end
  end
  break if found
end

puts "-1 -1 -1" unless found 

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		
		int[] list;
		int length;
		int primes = 0;
		
		Scanner keyboard = new Scanner(System.in);
		
		length = keyboard.nextInt();
		
		list = new int[length];
		
		for(int i = 0; i < length; i++) {
			list[i] = keyboard.nextInt();
		}
		
		for(int i = 0; i < length; i++) {
			if(isPrime(list[i])) primes++;
		}
		
		System.out.println(primes);
		
	}
	
	public static boolean isPrime(int a) {
		
	    if(a == 2 || a == 3 || a == 5 || a == 7) {
		    return true;
		    }
	    if(a % 2 == 0) {
		    return false;
		    }
	    for(int j=3;j <= Math.sqrt(a);j++){
	        if(a % j == 0){ 
	            return false;}
	    }
	    return true;
	    }
		
}



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

int main() {
    int M1, M2, D1, D2;
    cin >> M1 >> D1 >> M2 >> D2;

    if(M1+1 == M2)
        cout << "1";
    else
        cout << "0";
    cout << endl;
}

Measured memory_bytes: 256
ABC = list(map(int,input().split()))
ABC.sort()
if ((ABC[2] - ABC[1]) + (ABC[2] - ABC[0])) % 2 == 0:
	ans = (ABC[2] - ABC[1]) + (ABC[2] - ABC[0])
	ans /= 2
	print(int(ans))
else:
	ans = (ABC[2] - ABC[1]) + (ABC[2] - ABC[0])
	ans //= 2
	ans += 2
	print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using VVI = vector<vector<int>>;
const int INF = 1001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
    }
    double ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            int tmp = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
            ans += sqrt(tmp);
        }
    }
    int num = 2;
    for (int i = 2; i < n; i++)
    {
        num *= i;
    }
    int per = 1;
    for (int i = 2; i <= n; i++)
    {
        per *= i;
    }
    ans = ans * num / per;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 3844
#include <bits/stdc++.h>
#define ll long long
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
using namespace std;
const int tINF = (int)INT_MAX;
const long long lINF = (long long)LLONG_MAX;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef DEBUG
			assert(freopen("inp", "r", stdin));
			assert(freopen("out", "w",stdout));
	#else
			#define cerr if(false)cerr
	#endif
    string s;
    cin >> s;
    cout << string(s.size(),'x') << '\n';

    cerr << "Time execute: " << (double)clock() / (double)CLOCKS_PER_SEC 
    << " sec" << endl;
}

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

int main(int argc, const char * argv[]) {
    
    string S;
    cin >> S;
    
    int head = 0, tail = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S.at(i) == 'A') {
            head = i;
            break;
        }
    }
    for (int i = (int)S.size() - 1; i > 0; i--) {
        if (S.at(i) == 'Z') {
            tail = i;
            break;
        }
    }
    
    cout << tail - head + 1 << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <string>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  char a;
  cin >> a;
  if(a<='z'&&a>='a'){
    cout << "a" << endl;
  }
  else{
    cout << "A" << endl;
  }

  return 0;
}

Measured memory_bytes: 3660
n = int(input())
edges = [set() for _ in range(n + 1)]
for _ in range(n - 1):
    a, b, c = map(int, input().split())
    edges[a].add((c, b))
    edges[b].add((c, a))
q, k = map(int, input().split())
stack = [(0, k, None)]
costs = [0] * (n + 1)
visited = set()
while stack:
    c, p, a = stack.pop()
    costs[p] = c
    visited.add(p)
    stack.extend((c + c2, p2, p) for c2, p2 in edges[p] if p2 != a)

print('\n'.join(map(str, (costs[x] + costs[y] for x, y
                          in (map(int, input().split()) for _ in range(q))))))


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
template <class T>
T GCD(T a, T b)
{
    T r;
    while (a)
        r = b, b = a, a = r % a;
    return b;
}
template <class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repd(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<ll> vl;
#define ERASE(x) x.erase(unique(ALL(x)), x.end()); // erase same elements
#define VEC(type, c, n)     \
    std::vector<type> c(n); \
    for (auto &i : c)       \
        std::cin >> i;

// input
#define INIT                          \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define VAR(type, ...) \
    type __VA_ARGS__;  \
    MACRO_VAR_Scan(__VA_ARGS__);
template <typename T>
void MACRO_VAR_Scan(T &t)
{
    std::cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First &first, Rest &... rest)
{
    std::cin >> first;
    MACRO_VAR_Scan(rest...);
}

// output
template <typename T>
void MACRO_OUT(const T t) { std::cout << t; }

#define OUT(...) MACRO_OUT(__VA_ARGS__);
#define SP std::cout << " ";
#define TAB std::cout << "\t";
#define BR std::cout << "\n";
#define ENDL std::cout << std::endl;

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define yes() printf("yes\n")
#define no() printf("no\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
    cout << a;
    ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
    cout << a << ' ';
}

ll ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
long long a, b, c, d, n;
int x, y;
int sum;
char ch;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// cout << (conditon ? (result:  == 1 ): (==0)) << endl; <- output result of if
// long long 型が表せる値の上限はおよそ 9 × 10＾18 です．
int main()
{
    INIT;

    cin >> s >> t;
    s += t;
    n = stoi(s);
    rep(i, n)
    {
        if (i * i == n)
        {
            Yes();
            return 0;
        }
    }
    No();

    return 0;
}


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

struct Node{
	int key;
	struct Node *right, *left , *parent;
};

struct Node *root, *NIL;

struct Node * find(struct Node *u, int k){
	while(u != NIL && k != u->key){
		if(k < u->key){
			u=u->left;
		}else{
			u=u->right;
		}
	}
	return u;
}

void insert(int k){
	struct Node *y = NIL;
	struct Node *x = root;
	struct Node *z;
	
	z = (struct Node *)malloc(sizeof(struct Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	
	while( x != NIL){
		y = x;
		if(z->key < x->key){
			x = x->left;
		}else{
			x = x->right;
		}
	}
	z->parent = y;
	if(y == NIL){
		root = z;
	}else{
		if(z->key < y->key){
			y->left = z;
		}else{
			y->right = z;
		}
	}
}

void inorder(struct Node *u){
	if( u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}

void preorder(struct Node *u){
	if( u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}

int main(void){
	int n, i, x;
	char com[10];
	scanf("%d", &n);
	
	for(int i=0; i<n; i++){
		scanf("%s", com);
		if(com[0]=='f'){
			scanf("%d", &x);
			struct Node *t = find(root, x);
			if(t!=NIL){
				printf("yes\n");
			}else{
				printf("no\n");
			}
		}else if(com[0]=='i'){
			scanf("%d", &x);
			insert(x);
		}else if(com[0]=='p'){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	return 0;
}



Measured memory_bytes: 20460
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    string s;
    cin >> s;
    int a = 0;
    repe(i, s) if(i=='o') a++;
    cout << (a + 15 - s.size() >= 8 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;
bool sr(ll a,ll b){
	return a>b;
}
bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}

template <class T>
void print(const T &value)
{
	std::cout << value << std::endl;
}

int main()
{
	int x,y,z,k;
	cin>>x>>y>>z>>k;
	vector<ll>a(x),b(y),c(z);
	priority_queue<tuple<ll,int,int,int>>abc;
	map<tuple<int,int,int>,bool>used;
	rep(i,x)cin>>a[i];
	rep(i,y)cin>>b[i];
	rep(i,z)cin>>c[i];
	sort(all(a),sr);
	sort(all(b),sr);
	sort(all(c),sr);
	abc.push(make_tuple(a[0]+b[0]+c[0],0,0,0));
	used[make_tuple(0,0,0)]=true;

	
	rep(i,k){
		int l,m,n;
		tuple<ll,int,int,int>tmp=abc.top();
		cout<<get<0>(tmp)<<endl;
		abc.pop();
		l=get<1>(tmp);
		m=get<2>(tmp);
		n=get<3>(tmp);
		if(!used[make_tuple(l+1,m,n)]&&x>l+1){
			abc.push(make_tuple(a[l+1]+b[m]+c[n],l+1,m,n));
			used[make_tuple(l+1,m,n)]=true;
		}
		if(!used[make_tuple(l,m+1,n)]&&y>m+1){
			abc.push(make_tuple(a[l]+b[m+1]+c[n],l,m+1,n));
			used[make_tuple(l,m+1,n)]=true;
		}
		if(!used[make_tuple(l,m,n+1)]&&z>n+1){
			abc.push(make_tuple(a[l]+b[m]+c[n+1],l,m,n+1));
			used[make_tuple(l,m,n+1)]=true;
		}
	}	
}


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

int main(void)
{
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++)
    {
        cin >> d[i];
    }
    sort(d.begin(), d.end());

    int counter = 1;
    for (int i = 0; i < N - 1; i++)
    {
        if (d[i] < d[i + 1])
        {
            // printf("%d < %d\n", d[i], d[i + 1]);
            counter++;
        }
    }
    cout << counter << endl;
    return (0);
}

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

int main(){
  int i, n, min=2000000000, max=0, tmp;
  cin >> n;
  
  for( i=0; i<n; i++ ){
  	cin >> tmp;
    if( tmp < min ){
      min = tmp;
    }
    if( tmp > max ){
      max = tmp;
    }
  }
  
  cout << abs(min-max) << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}


vector<vec> g;
int col[210000];
int dfs(int x,int p,int c){
    col[x]=c;
    for(auto e:g[x]){
        if(e==p)continue;
        dfs(e,x,c^1);
    }
}
main(){
    ios
    string s;cin>>s;
    string t="hi";
    string h="hi";
    rep(i,5){
        if(s==t){
            cout<<"Yes\n";return 0;
        }
        t+=h;
    }
    cout<<"No";
}


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n;

	f(i,1,n) cin>>arr[i];

	f(i,1,n){
	    if(i==n && arr[i]==i){
            swap(arr[i],arr[i-1]);
            count++;
	    }
        if(i<n && arr[i]==i){
            swap(arr[i],arr[i+1]);
            count++;
        }
	}
    cout<<count<<endl;


}


Measured memory_bytes: 640
#include<stdio.h>

int main(){
	int N,T,res,c,t;
	res = 1001;
	scanf("%d %d",&N,&T);
	for(int i = 0; i<N; i++){
		scanf("%d %d",&c,&t);
		if(t>T)continue;
		res = res < c ? res : c;
	}
	if(res==1001)printf("TLE\n");
	else printf("%d\n",res);
	return 0;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  if(a==1 && b==2 || a==2 && b==1)
    cout<<3;
  else if(a==2 && b==3 || a==3 && b==2)
    cout<<1;
  else
    cout<<2;
  return 0;
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N, M;
	cin >> N >> M;
	vector<vector<int>> adj(N);
	for (int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		--a;--b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	vector<int> par(N, -1);
	queue<int> q;
	q.push(0);
	par[0] = 0;
	int cnt = 0;
	while (q.size()) {
		int at = q.front();
		q.pop();
		++cnt;
		for (int c : adj[at]) {
			if (par[c] == -1) {
				q.push(c);
				par[c] = at;
			}
		}
	}
	if (cnt == N) {
		cout << "Yes" << endl;
		for (int i = 1; i < N; ++i) {
			cout << par[i]+1 << endl;
		}
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 10156
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    if(n == 3) {
        cout << 2 << " " << 3 << " " << 25 << endl;
        return 0;
    }

    const int A = 30000;

    if(n == 20000) {
        for(int i = 2; i <= A; i++) {
            if(i%2 == 0 || i%3 == 0) {
                cout << i << " ";
            }
        }
        cout << endl;
        return 0;
    }

    if(n%2 == 1) {
        cout << A/2 << " ";
        n--;
    }

    int cnt = 0;
    for(int i = 2; i < A/2; i++) {

        if(i%2 == 0 || i%3 == 0) {
            cout << i << " " << A - i << " ";
            cnt += 2;
        }

        if(cnt == n) {
            break;
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if(a < b)
		{
			System.out.println("a < b");
		}else if(a > b){
			System.out.println("a > b");
		}else{
			System.out.println("a == b");
		}
	}

}

Measured memory_bytes: 17292
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
 
int main() {
    int m;
    string n;
    cin >> n;
    m=n.size();
    cout<<n[0]<<m-2<<n[m-1]<<endl;  
}

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

int main() {
	
	int n;
	cin>>n;
	int arr[n];
	int res=0;
	int i;
	for(i=0;i<n;i++)
	{
	cin>>arr[i];
		
	res=res^arr[i];	
		
	}
	for(i=0;i<n;i++)
	cout<<(arr[i]^res)<<" ";
	// your code goes here
	return 0;
}

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

int main() {
int a, b, c, k;
  cin >> a >> b >> c >> k;
  
  int num=0;
  while(a>=b){
    b=b*2;
    num++;
  }
  
  while(b>=c){
    c=c*2;
    num++;
  }
  
  if(num<=k){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

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

Measured memory_bytes: 3624
/*
	0576:Homework
*/
#include	<iostream>
#include	<cmath>

using namespace std;

int main(void) {
	int L, A, B, C, D;
	int day = 1;
	
	cin >> L >> A >> B >> C >> D;
	
	for(day; !(A <= 0, B <= 0); day++) {
		A -= C;
		B -= D;
		if( A <= 0 && B <= 0 ) {
			break;
		}
	}
	
	cout << L - day << endl;
	
	return 0;
}

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

#define log(x) cout << (x) << endl
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i,a,b) for (int i = (int)a; i >= (int)b; --i)
#define loop(i,a,b) for(int i = (int)(a); i < (int)(b); ++i)

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

	int x = 1<<20;
	rep (i, n+1) {
		int c=0, t=i;
		while (t>0) c+=t%6,t/=6;
		t=n-i;
		while (t>0) c+=t%9,t/=9;
		x = min(c,x);
	}
	log(x);
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define EQ(a,b) (abs((a)-(b))<eps)
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<double,pii> tri;

const double inf = 1e8;
const double eps = 1e-8;

inline double bottom(int a, int b){ return 30.0 * (b-a); }

int main(){
  int D,n,m,l;
  cin >> D;
  while(D--){
    cin >> n;
    vi b(n+2), h(n+2);
    b[0] = 0; b[n+1] = 100;
    h[0] = h[n+1] = 50;
    rep(i,n)cin >> b[i+1] >> h[i+1];

    vi f(n+1,0);
    cin >> m;
    rep(i,m){
      int tmpf, tmpa;
      cin >> tmpf >> tmpa;
      rep(j,n+1){
	if(tmpf<b[j+1]){ f[j] += tmpa; break; }
      }
    }

    cin >> l;
    vector<tri> q(l);
    rep(i,l){
      int x,t;
      cin >> x >> t;
      q[i] = tri(t,pii(x,i));
    }
    sort(q.begin(),q.end());

    double cur_time = 0;
    int query = 0;
    vector<double> c(n+1,0), ans(l,50);

    while(b.size()>2){
      //calc next event time
      double nxt_time = inf;
      rep(i,f.size()){
	if(f[i]){
	  int minh = min(h[i],h[i+1]);
	  double overtime = (bottom(b[i],b[i+1])*minh - c[i]) / f[i];
	  nxt_time = min(nxt_time, overtime);
	}
      }

      //answer queries preceeding next event
      while(query < l && q[query].first < nxt_time+cur_time + eps){
	rep(i,f.size()){
	  if(q[query].second.first < b[i+1]){
	    double dif_t = q[query].first - cur_time;
	    ans[q[query].second.second] = (c[i] + dif_t*f[i]) / bottom(b[i],b[i+1]);
	    break;
	  }
	}
	query++;
      }

      //flow until next event
      rep(i,f.size())c[i] += nxt_time*f[i];

      //manage overflow
      rep(i,f.size()){
	if(f[i]){
	  int pos = i;
	  while( EQ(h[pos], c[pos] / bottom(b[pos],b[pos+1])) )pos--;

	  if(pos!=i){
	    f[pos] += f[i]; f[i] = 0;
	    if( EQ(h[pos+1], c[pos] / bottom(b[pos],b[pos+1])) ){
	      c[pos] += c[pos+1];
	      b.erase(b.begin()+pos+1); h.erase(h.begin()+pos+1);
	      f.erase(f.begin()+pos+1); c.erase(c.begin()+pos+1);
	    }
	    break;
	  }

	  while( EQ(h[pos+1], c[pos] / bottom(b[pos],b[pos+1])) )pos++;
	  if(pos!=i){
	    f[pos] += f[i]; f[i] = 0;
	    if( EQ(h[pos], c[pos] / bottom(b[pos],b[pos+1])) ){
	      c[pos] += c[pos-1];
	      b.erase(b.begin()+pos); h.erase(h.begin()+pos);
	      f.erase(f.begin()+pos-1); c.erase(c.begin()+pos-1);
	    }
	    break;
	  }
 
	}
      }

      cur_time += nxt_time;
    }

    while(query < l && q[query].first < 150000.0/f[0]){
      ans[q[query].second.second] = q[query].first*f[0] / 3000;
      query++;
    }

    rep(i,l)cout << fixed << setprecision(9) << ans[i] << endl;
  }
}

Measured memory_bytes: 1276