akhauriyash/Code-Regression huggingface dataset:
// DATA STRUCTURES
#include <vector>

// MISCELLANEOUS
#include <algorithm>//min/max/sort(rand-access it)/merge
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific

typedef unsigned long long ull;

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

using namespace std;

int main(void)
{
    size_t n;
    cin >> n;
    n *= 3;
    vector<ull> a;
    for (size_t i = 0; i < n; ++i) {
        int temp; cin >> temp;
        a.push_back(temp);
    }
    sort(a.begin(), a.end());

    ull total = 0UL;
    for (size_t i = n/3; i < n; i += 2) {
        total += a[i];
    }
    cout << total << '\n';
    return 0;
}


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

// 桁数
int GetDigit(int a) {
  return log10(a) + 1;
}

int main() {
  int a, b, c, d;
  cin >> a >> b;
  
  c = a * pow(10, GetDigit(b)) + b;
  d = sqrt(c);
  
  if(d * d == c) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import math
def fact(n):
    ans = 1
    for i in range(2, n+1):
        ans*= i
    return ans
def comb(n, c):
    return fact(n)//(fact(n-c)*c)

k = int(input())
a,b = map(int, input().split())
val = math.ceil(a/k)
if(b >= k*val):
    print('OK')
else:
    print('NG')


Measured memory_bytes: 62008
from collections import Counter

N, K = list(map(int,input().split()))
H = [int(input()) for _ in range(N)]
H = sorted(H,reverse = False)

ans = 999999999999999
for i in range(N-K+1):
    ans =min(ans , H[K-1+i] - H[i])
print(ans)

Measured memory_bytes: 8512
N = int(input())
 
counter = {}
 
for i in range(N):
    temp = input()
    if temp not in counter:
        counter.update({temp : 1})
    else:
        counter.update({temp : counter[temp] + 1})
 
m = max(counter.values())
        
ans = []    
 
for a,b in counter.items():
    if b == m:
        ans.append(a)
    
ans.sort()
 
for i in ans:
    print(i)

Measured memory_bytes: 92376
import java.util.Scanner;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Long> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            a.add(sc.nextLong());
        }
        Collections.sort(a);
        long ans = gcd(a.get(0), a.get(1));
        for (int i = 2; i < n; i++) {
            ans = gcd(ans, a.get(i));
        }
        System.out.println(ans);
    }
    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }
}


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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int h,w; cin >> h >> w;
	string s[h];
	vector<bool>row(h,1),col(w,1);
	for(int i=0; i<h; i++){
		cin >> s[i];
		for(int j=0; j<w; j++){
			if(s[i][j]=='#'){
				row[i]=0;
				col[j]=0;
			}
		}
	}
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(!row[i]&&!col[j])cout << s[i][j];
		}
		if(!row[i])cout << endl;
	}
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int num[100001]={0};
  int N,i,j,k,tmp;
  int two=0,ans=0;
  
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&tmp);
    num[tmp]++;
  }

  for(i=0;i<100001;i++){
    if(num[i]==0) continue;
    ans++;
    num[i]=(num[i]%2)?1:2;
    if(num[i]==2) two++;
  }

  ans-=two%2;
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        System.out.println(solve(S));
    }

    private static String solve(String S) {
        if (S.toUpperCase().equals(S)) return "A";

        return "a";
    }
}

Measured memory_bytes: 35668
#include <cmath>
#include <iostream>
#include <string>
#include <utility>

using namespace std;

#define FOR(i,n) for(int i = 0; i < (n); ++i)

int
main()
{
  int k, x;
  cin >> k >> x;

  for (int i = (x - k + 1); i <= (x + k - 1); ++i)
    cout << i << " ";

	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = []
for i in range(N):
    S.append(input())
r = ["M","A","R","C","H"]
x = dict()
#O(N)
for i in range(N):
    if S[i][0] not in r:
        continue
    if S[i][0] in x:
        x[S[i][0]] += 1
    else:
        x[S[i][0]] = 1

l = []
num = 0
#O(26)
for idx in x:
    l.append(x[idx])

n = len(l)
ans = 0
if n<=2:
    print(0)
    exit()
#O(26)
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            ans += l[i]*l[j]*l[k]
print(ans)

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

using namespace std;

typedef long long ll;

int main()
{
    ll X;
    cin >> X;
    ll uresisa = 0;
    uresisa = 1000 * (X / 500);
    X = X % 500;
    uresisa += 5 * (X / 5);
    X = X % 5;
    cout << uresisa << endl;
}

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

#define MAX(A, B) (((A) > (B)) ? (A) : (B))

int main () {
  int N, D;
  int a;
  scanf("%d %d", &N, &D);
  
  D = 2 * D + 1;
  a = N / D;
  if (N % D) {
    a++;
  }
  printf("%d\n", a);
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <math.h>
#include <limits>
#include <stdio.h>
#include <queue>
#include <bitset>

template <typename T>
void vc(T t) {
    std::cout << t << " ";
}

template<typename T, typename... Args>
void vc(T t, Args... args) {
// recursive variadic function
    std::cout << t << " ";
    vc(args...) ;
}

int mp[22][22];
int mm[22][1<<22];
std::map<std::pair<int, int>, int> mmp;
int dp(int m, long long flag, int n) {
  std::bitset<4> mf(flag);
  // vc("+", m, mf, mm[m][flag], "\n");
  if (mm[m][flag] != -1) {
    return mm[m][flag];
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    // vc("-", m, i, mp[m][i], flag & (1 << i), "\n");
    if (mp[m][i] == 1 && flag & (1 << i)) {
      ans += dp(m - 1, flag & ~ (1 << i), n);
      ans %= 1000000007;
      // vc("-xxx", m, mf, i, ans, "\n");
    }
  }
  mm[m][flag] = ans;
  // vc("=", m, mf, mm[m][flag], "\n");
  return ans;
}

void once() {
  int n;
  std::cin >> n;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      std::cin >> mp[i][j];

  for (int i = 0; i < 22; ++i)
    for (int j = 0; j < (1 << 22); ++j)
      mm[i][j] = -1;
  mm[0][0] = 1;
  // dp[0][0] = 1;
  // for (int i = 1; i <= n; ++i) {
  //   for (int j = 1; j <= n; ++j) {
  //     dp[i][k] = dp[i - 1][k j
  //   }
  // }
  long long flag = 0;
  for (int i = 1; i <= n; ++i) {
    flag |= (1 << i);
  }
  auto ans = dp(n, flag, n);
  std::cout << ans << std::endl;
}

int
main() {
  int n = 1;
  std::ios::sync_with_stdio(false);
  // std::cin >> n;
  while (n--) {
    once();
  }
}

Measured memory_bytes: 360704
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

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

    int n;
    cin >> n;
    cout << n/3;

    return 0;
}

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

inline void Read(int &x)
{
    x=0;int f=1;char a=getchar();
    while(a<'0'||'9'<a) {if (a=='-') f=-f; a=getchar();}
    while('0'<=a&&a<='9') x=x*10+(a-'0'),a=getchar();
    x*=f;
}

int N,H,n,h; 

int main()
{
    Read(N),Read(H),Read(n),Read(h);
    cout<<N*H-n*H-N*h+n*h<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,ans,l;
string a,s;
multiset<int>pp;
void ch(string t){
  int p=0,x=10,ss=l;
  for(int i=0;i<t.size();i++){
    if(t[i]=='+')p+=ss%x,ss/=x,x=10;
    else x*=10;
  }
    if(ans<=p&&p<=n){
      ans=p,a=t;
      pp.insert(p);
    }
}
void dfs(int d,string t){
  if(d==s.size())ch(t+'+');
  else {
    dfs(d+1,t+'+');
    dfs(d+1,t+'-');
  }
}
int f(string q){
  int o=0;
  for(int i=0;i<q.size();i++)
    o*=10,o+=q[i]-'0';
  return o;
}
string chq(string t){
  reverse(t.begin(),t.end());
  string u;
  u+=t[0];
  for(int i=1;i<t.size();i++){
    if(a[i-1]=='+')u+=' ';
    u+=t[i];
  }
  reverse(u.begin(),u.end());
  return u;
}
int main(){
  while(cin>>n>>s,n){
    pp.clear();
    l=f(s);
    ans=0;
    dfs(0,"");
    if(ans==0)cout<<"error"<<endl;
    else if(pp.count(ans)>=4)cout<<"rejected"<<endl;
    else{
      cout<<ans<<' ';
      string qq=chq(s);
      cout<<qq<<endl;
    }
  }
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int dp[1000005][2];

int main () {
  string s;
  cin >> s;
  //reverse(rng(s));
  s += '0';
  int n = s.size();
  rep(i,n+1)rep(j,2) dp[i][j] = INF;
  dp[0][0] = 0;
  rep(i,n)rep(j,2) {
    int x = s[i]-'0';
    x += j; // 繰り下がり (a-1)-n = a-(n+1)
    rep(a,10) {
      int ni = i+1, nj = 0;
      int b = a-x;
      if (b < 0) {
        nj = 1;
        b += 10;
      }
      dp[ni][nj] = min(dp[ni][nj], dp[i][j]+a+b);
    }
  }
  int ans = dp[n][0];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9220
#include <stdio.h>
int main (void){
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a == b + c){
		printf("Yes\n");
	}else if(b == a + c){
		printf("Yes\n");
	}else if(c == a + b){
		printf("Yes\n");
	}else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;
  ll n,k,r,s,p,ans;
  string t;
void solve()
{
  bool free = false;
  cin>>n>>k>>r>>s>>p;
  cin>>t;
  for (ll i = 0; i < k; ++i)
  {
     ans+= (t[i]=='s')?r :0 + (t[i]=='r')?p:0 + (t[i]=='p')?s:0;
    free = false;
    for(ll j =i+k;j<n;j+=k)
    {
      if(!free and t[j]==t[j-k])
      {
        free = true;
        continue;
      }
      free= false;
      ans+= (t[j]=='s')?r :0 + (t[j]=='r')?p:0 + (t[j]=='p')?s:0;
    }
  }

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

signed main(){
     
      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  ll n;
  cin>>n;
  ll a[5];
  ll mn=1e15;
  rep(i,0,5) {cin>>a[i]; mn=min(mn,a[i]);}
  // cout<<mn<<endl;
  ll ans=(n+mn-1)/mn+4;
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3640
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	vector<string > word(3);
	for(int i=0;i<3;++i){
		cin >> word[i];
	}
	bool flag = true;
	for(int i=0;i<2;++i){
		if( word[i][word[i].size()-1] != word[i+1][0] ){
			flag = false;
			break;
		}
	}
	cout << (flag?"YES":"NO") << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


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

const ll INF = 1LL << 60;

ll N, M;

struct Rerooting {
    /* TODO: start 問題ごとに書き換え */
    struct DP {  // DP の型
        ll dp;
        DP(ll dp_) : dp(dp_) {}
    };

    // 単位元はしっかり定義する(末端でもadd_rootされるので注意)
    const DP identity = DP(1);

    // d:辺eに対応する部分木のdpの値  cost:eのコスト
    function<DP(DP, DP, long long)> merge = [](DP dp_cum, DP d, long long cost) -> DP {
        return DP((dp_cum.dp * d.dp) % M);
    };

    // まとめたDPを用いて、新たな部分木のDPを計算する
    function<DP(DP)> add_root = [](DP d) -> DP {
        // ※ 最後に1回、余分な + 1 がかかる
        return DP(d.dp + 1);
    };
    /* TODO: end 問題ごとに書き換え */

    // グラフの定義
    struct Edge {
        int from;
        int to;
        long long cost;
    };
    using Graph = vector<vector<Edge>>;

    // dp[v][i]: vから出るi番目の有向辺に対応する部分木のDP
    vector<vector<DP>> dp;

    // ans[v]: 頂点vを根とする木の答え
    vector<DP> ans;
    Graph G;

    Rerooting(int N) : G(N) {
        dp.resize(N);
        ans.assign(N, identity);
    }

    void add_edge(int a, int b, long long c = 1) {
        G[a].push_back({a, b, c});
    }
    void build() {
        dfs(0);            // 普通に木DP
        bfs(0, identity);  // 残りの部分木に対応するDPを計算
    }

    DP dfs(int v, int p = -1) {  // 頂点v, 親p
        DP dp_cum = identity;
        int deg = G[v].size();
        dp[v] = vector<DP>(deg, identity);
        for (int i = 0; i < deg; i++) {
            int u = G[v][i].to;
            if (u == p) continue;
            dp[v][i] = dfs(u, v);
            dp_cum = merge(dp_cum, dp[v][i], G[v][i].cost);
        }
        return add_root(dp_cum);
    }
    void bfs(int v, const DP &dp_p, int p = -1) {
        int deg = G[v].size();
        for (int i = 0; i < deg; i++) {  // 前のbfsで計算した有向辺に対応する部分木のDPを保存
            if (G[v][i].to == p) dp[v][i] = dp_p;
        }

        vector<DP> dp_l(deg + 1, identity), dp_r(deg + 1, identity);  // 累積的なDP
        for (int i = 0; i < deg; i++) {
            dp_l[i + 1] = merge(dp_l[i], dp[v][i], G[v][i].cost);
        }
        for (int i = deg - 1; i >= 0; i--) {
            dp_r[i] = merge(dp_r[i + 1], dp[v][i], G[v][i].cost);
        }
        ans[v] = add_root(dp_l[deg]);
        for (int i = 0; i < deg; i++) {
            int u = G[v][i].to;
            if (u == p) continue;

            // 累積同士のmergeなので、edgeは適当に
            bfs(u, add_root(merge(dp_l[i], dp_r[i + 1], 0)), v);
        }
    }
};

int main() {
    // ll a = 3;
    // a *= 3 + 1;
    // cout << a << endl;
    // return 0;
    cin >> N >> M;
    Rerooting reroot(N);
    rep(i, N - 1) {
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        reroot.add_edge(x, y);
        reroot.add_edge(y, x);
    }
    reroot.build();

    rep(i, N) {
        cout << (reroot.ans[i].dp - 1) % M << endl;
    }
}

Measured memory_bytes: 37144
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		boolean a = false;
		out:for(int i = 0;i < c.length();i++) {
			for(int k = i+1;k < c.length();k++) {
				if(c.charAt(i)==c.charAt(k)) {
					System.out.println("no");
					a = true;
					break out;
				}
			}
		}
		if(a == false)System.out.println("yes");
	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t,i,ans;
    cin>>t;
    int p=t/2;
    int a[t],b[t];
    for(i=0;i<t;i++){
        cin>>a[i];

    }
    sort(a,a+t);
    for(i=0;i<t;i++){
        ans=a[p]-a[p-1];

    }
    cout<<ans<<endl;
}



Measured memory_bytes: 640
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
struct Node {
    int key;
    struct Node *prev, *next;
};
 
struct Node *nil;
 
void init() {
    nil = (struct Node *)malloc(sizeof(struct Node));
    nil->next = nil;
    nil->prev = nil;
}
 
void insert(int key) {
    struct Node *x = (struct Node *)malloc(sizeof(struct Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}
 
struct Node* listSearch(int key) {
    struct Node *cur = nil->next;
    while(cur != nil && cur->key != key ) {
        cur = cur-> next;
    }
    return cur;
}
 
void deleteNode(struct Node *t) {
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}
 
void deleteFirst() {
    deleteNode(nil->next);
}
 
void deleteLast() {
    deleteNode(nil->prev);
}
void deleteKey(int key) {
    deleteNode(listSearch(key));
}
 
void printList() {
    struct Node *cur;
    cur = nil->next;
    int isf = 0;
 
    while(1) {
        if (cur == nil) break;
        if(isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}
 
 
int main(void) {
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for (i = 0; i < n; i++) {
        scanf("%s%d",com, &key);
        if(com[0] == 'i') {
            insert(key);
            np ++;
            size++;
        }else if(com[0] == 'd') {
            if(strlen(com) > 6) {
                if( com[6] == 'F') {
                    deleteFirst();
                }else if(com[6] == 'L') {
                    deleteLast();
                }
            }else {
                deleteKey(key);
                nd ++;
            }
            size --;
        }
    }
    printList();
    return 0;
 
}

Measured memory_bytes: 33876
import heapq
t = 1
def max(a,b):
	if a > b:
		return a
	return b
def min(a,b):
	if a < b:
		return a
	return b

while t > 0:
	t -= 1
	# a,b = map(int,input().split())
	n = int(input())
	ans = (n-1)*(n)//2
	print(ans)
	# v = list(map(int,input().strip().split()))[0:n]
	# i = 0
	# ans = 0
	# while i < n:
	# 	j = i
	# 	while j+1 < n and v[j+1] <= v[j]:
	# 		j += 1
	# 	l = j-i+1
	# 	ans = max(ans,l)
	# 	i = j+1
	# print(ans-1) 

Measured memory_bytes: 62376
// counting sort
#include <stdio.h>
#include <stdlib.h>

void CountingSort(int* , int* , int, int);


int main() {
  int i, n, k;
  int *a, *b;
  int max;
  
  // input
  scanf("%d", &n);
  a = (int *)malloc(n * sizeof(int));
  b = (int *)malloc(n * sizeof(int));
  for(i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  // search max
  max = a[0];
  for(i = 1; i < n; i++) {
    if(max < a[i]) max = a[i];
  }
  k = max;

  // sort
  CountingSort(a, b, k, n);

  for(i = 0; i < n; i++) {
    printf("%d", b[i]);
    if(i != n - 1) printf(" ");
  }
  printf("\n");
  
  return 0;
}

void CountingSort(int *a, int *b, int k, int n) {
  int i, j;
  int *c;

  // create an array : c
  c = (int *)malloc((k+1) * sizeof(int));
  // initialization
  for(i = 0; i <= k; i++) {
    c[i] = 0;
  }
  for(j = 0; j < n; j++) {
    c[a[j]] = c[a[j]] + 1;
  }
  for(i = 1; i <= k; i++) {
    c[i] = c[i] + c[i - 1];
  }
  for(j = n - 1; j >= 0; j--) {
    b[c[a[j]] - 1] = a[j];
    c[a[j]] = c[a[j]] - 1;
  }
}



Measured memory_bytes: 17432
#include<stdio.h>
#include<iostream>
#include<algorithm> 
using namespace std; 
int n ,sum = 0;
int main() { 
    cin >> n ;
    sum +=(n/500)*1000;
    n = n % 500;
    sum += (n/5)*5;
    cout << sum ;
    return 0 ;
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 15;
const double eps = 1e-6;

int n, m;
int p[N];
bool st[N];
vector<int> switches[N];

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        int k;
        cin >> k;
        while(k--)
        {
            int s;
            cin >> s;
            switches[i].push_back(s);
        }
    }
    for(int i = 1; i <= m; i++) cin >> p[i];

    int res = 0;
    for(int op = 0; op < (1 << n); op++)
    {
        memset(st, 0, sizeof st);
        for(int i = 0; i < n; i++)
            if((op >> i) & 1)
                st[i + 1] = true;

        bool all_light = true;
        for(int i = 1; i <= m; i++)
        {
            int cnt = 0;
            for(int j = 0; j < switches[i].size(); j++)
            {
                int t = switches[i][j];
                if(st[t]) cnt++;
            }

            if(cnt % 2 != p[i])
            {
                all_light = false;
                break;
            }
        }

        if(all_light) res++;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::*;
use std::ops::*;
use std::*;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused)]
fn rl() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused)]
fn rw<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|word| T::from_str(word).unwrap())
        .collect()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

#[allow(unused)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        {
            let entries = &[
                $((
                    &stringify!($arg).to_string() as &fmt::Debug,
                    &($arg) as &fmt::Debug,
                )),*
            ];
            eprintln!("{:?}", DebugMap(entries));
        }
    };
}

#[allow(unused)]
struct DebugMap<'a>(&'a [(&'a fmt::Debug, &'a fmt::Debug)]);

impl<'a> std::fmt::Debug for DebugMap<'a> {
    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
        let mut m = fmt.debug_map();
        for &(key, value) in self.0.iter() {
            m.entry(key, value);
        }
        m.finish()
    }
}

// -----------------------------------------------
// Polyfill
// -----------------------------------------------

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

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

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

#[allow(unused)]
macro_rules! eprintln {
    ($($arg:expr),*) => { _eprintln(format_args!($($arg),*)) }
}

fn _eprintln(args: fmt::Arguments) {
    let err = std::io::stderr();
    let mut err = err.lock();
    err.write_fmt(args).unwrap();
    err.write(b"\n").unwrap();
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn main() {
    let n = rl().parse::<usize>().unwrap();
    let mut u: Vec<usize> = Vec::new();
    let mut s = 6;
    let mut t = 9;
    while s <= n {
        u.push(s);
        s *= 6;
    }
    while t <= n {
        u.push(t);
        t *= 9;
    }
    u.push(1);
    u.sort();

    // dp[n] = k <=> ちょうど n 円引き出すために必要な最小の手数が k
    let mut dp = vec![n; n + 1];
    dp[0] = 0;

    for i in 0..n + 1 {
        for u in u.iter() {
            if i + u <= n {
                dp[i + u] = min(dp[i + u], dp[i] + 1);
            }
        }
    }

    println!("{}", dp[n]);
    return;
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_ok() {
        assert_eq!(7, 1 + 2 * 3);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#define INF (1 << 28)

using namespace std;

struct mat {
	int a;
	int b;
	int c;
};

int main(void) {
	int N,Ma,Mb;
	cin >> N >> Ma >> Mb;
	int as,bs;
	as = bs = 0;
	vector<mat> data(N);
	for (int i = 0; i < N; ++i) {
		cin >> data[i].a >> data[i].b >> data[i].c;
		as += data[i].a;
		bs += data[i].b;
	}
	vector< vector<int> > dp(as+1,vector<int>(bs+1,INF));
	dp[0][0] = 0;
	for (int k = 0; k < N; ++k) {
		for (int i = 0; i < as+1; ++i) {
			for (int j = 0; j < bs+1; ++j) {
				if (dp[as-i][bs-j] < INF) {
					dp[as-i+data[k].a][bs-j+data[k].b] = min(dp[as-i][bs-j]+data[k].c,dp[as-i+data[k].a][bs-j+data[k].b]);
				}
			}
		}
	}
	int res = INF;
	int an = Ma;
	int bn = Mb;
	while (an <= as && bn <= bs) {
		res = min(dp[an][bn],res);
		an += Ma;
		bn += Mb;
	}
	if (res < INF) {
		cout << res << endl;
	}
	else {
		cout << -1 << endl;
	}
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

// 累積和
struct cumulative_sum {
    using lint = long long int;
    int sz;
    // data[i]:元の数列
    vector<lint> data;
    // cum[i]:[0,i)の和
    vector<lint> sum;
    // 要素数を指定して初期化
    cumulative_sum(const int _sz) : sz(_sz) {
        data.assign(sz, 0);
        sum.assign(sz + 1, 0);
    }
    lint& operator[](const int k) {
        return data[k];
    }
    // dataに基づいてsumを構築
    void build() {
        for (int i = 0; i < sz; i++) sum[i + 1] = sum[i] + data[i];
    }
    // [a,b)の和を求める
    lint query(const int a, const int b) {
        return sum[b] - sum[a];
    }
};

int main() {
    int n;
    cin >> n;
    cumulative_sum a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    a.build();
    lint ans = INT_MAX;
    for (int i = 1; i < n; i++) {
        ans = min(ans, abs(a.query(0, i) - a.query(i, n)));
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;

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

  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];

  // dp[i] := 石の個数が残りi個の局面が勝ちか負けかをbool値で表したもの
  vector<bool> dp(k + 1, false);
  for (int i = 0; i <= k; i++) {
    for (auto e : a) {
      if (e > i)
        continue;
      if (!dp[i - e]) {
        dp[i] = true;
      }
    }
  }

  cout << (dp[k] ? "First" : "Second") << endl;

  return 0;
}


Measured memory_bytes: 3652
// glory be to the sky
#include<cstdio>
#include<bits/stdc++.h> 
using namespace std;
	
typedef long long ll; 

int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);

	int N;

	cin >> N;

	cout << (N * (N + 1)) / 2 << endl;

	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
using P = pair<int, int>;
const long long INF = 1LL << 60;

int main(){
  int N,K; cin >> N >> K;
  double prob = 0;
  rep(i,N){
    int score = i+1,toss = 0;
    while(score<K){
      toss++;
      score = score*2;
    }
    prob += pow(0.5,toss);
    //cout << "prob = " << prob << "toss = " << toss << endl;
  }
  double ans = prob/(double)N;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import collections
n= int(input())
a = list(int(i) for i in input().split())
c = collections.Counter(a)
a2 = list(set(a))
ans = 0
for i in a2:
  tmp = c[i]
  if tmp <i:
   ans += tmp
  else:
   ans += (tmp-i)
print(ans)

Measured memory_bytes: 20588
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
struct z{
  ll x,y,d;
  z(ll a,ll b,ll c):x(a),y(b),d(c){};
};
vector<vector<ll>>dist(1005,vector<ll>(1005,INF));
void bfs(ll h,ll w,ll sx,ll sy,vector<string>&a){
  queue<struct z>que;
  que.emplace(sx,sy,0);
  while(!que.empty()){
    auto pos = que.front();
    que.pop();
    if(dist[pos.x][pos.y]<=pos.d)continue;
    dist[pos.x][pos.y]=pos.d;
    for(ll i=0;i<4;i++){
      ll x=pos.x+dx[i],y=pos.y+dy[i],d=pos.d+1;
      if(x<0||x>=h||y<0||y>=w)continue;
      que.emplace(x,y,d);
    }
  }
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll h,w;cin>>h>>w;
  vector<string>a(h);
  rep(i,0,h)cin>>a[i];
  vector<ll>v(h*w);
  iota(ALL(v),0);
  shuffle(ALL(v),mt);
  for(auto x:v){
    ll i=x/w,j=x%w;
    //cout<<i spa j<<endl;
    if(a[i][j]=='#')bfs(h,w,i,j,a);
  }
  rep(i,0,h)rep(j,0,w)chmax(res,dist[i][j]);
  cout<<res<<endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
	ll H,W; cin>>H>>W;
  ll ans=LLONG_MAX;
	for(ll i=1;i<=H/2;i++){
    	ll half=(H-i)/2;
      	ans=min(ans,(max(i,max(half,H-i-half))-min(i,min(half,H-i-half)))*W);
      half=W/2;
      ans=min(ans,max(i*W,max((H-i)*half,(H-i)*(W-half)))-min(i*W,min((H-i)*half,(H-i)*(W-half))));
    }
  swap(H,W);
  for(ll i=1;i<=H/2;i++){
    	ll half=(H-i)/2;
      	ans=min(ans,(max(i,max(half,H-i-half))-min(i,min(half,H-i-half)))*W);
      half=W/2;
      ans=min(ans,max(i*W,max((H-i)*half,(H-i)*(W-half)))-min(i*W,min((H-i)*half,(H-i)*(W-half))));
    }
  printf("%lld",ans);
}

Measured memory_bytes: 256
a=int(input())
if a>=400 and a<=599 :
  print("8")
elif a>=600 and a<=799 :
  print("7")
elif a>=800 and a<=999 :
  print("6")
elif a>=1000 and a<=1199 :
  print("5")
elif a>=1200 and a<=1399 :
  print("4")
elif a>=1400 and a<=1599 :
  print("3")
elif a>=1600 and a<=1799 :
  print("2")
elif a>=1800 and a<=1999 :
  print("1")

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

#define  ll long long int
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define si(a) a.size()
#define p pair< ll,ll >
#define v vector< ll >
#define vi vector<p>
#define mem(tabl,i) memset(tabl, i, sizeof(tabl))
#define sp(x,y) fixed<<setprecision(y)<<lf(x)
#define debug(c) cout << #c << " = " << c << endl;
#define  f(i,a,b) for(int i=a;i<b;i++)
#define fe(i,a,b) for(int i=a;i<=b;i++)
#define Mod 1000000007

const int N = 1e5 + 5;

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

           string s;
           ll n,k,b,c,x,y,z;
           ll counter=0,counter1=0,counter2=0;
           ll sum=0,result=0,ans=-1, flag=0;
           cin>>n;
           vector<ll>vec(n+1,0);
           f(i,0,n-1)
           {
               cin>>x;
               vec[x]++;
           }

           fe(i,1,n)
           cout<<vec[i]<<endl;
}



Measured memory_bytes: 4752
#include<stdio.h>

int main(){
  int n,m;
  int i;

  scanf("%d %d",&n,&m);
  while((n!=0)&&(m!=0)){
    int board[n];
    int dice[m];
    int stts=0;
    int f=0;

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

    i=0;
    while(f==0){
      stts=stts+dice[i];

      if(stts<n-1){
	stts=stts+board[stts];
	if(stts>=n){
	  f=1;
	}
      }
      else{
	f=1;
      }

      i++;
    }
    printf("%d\n",i);
    scanf("%d %d",&n,&m);
  }

  return 0;
}

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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main(){
    int n;
    cin>>n;
    int counter=0;
    fori(n){
        int hoge;
        cin>>hoge;
        if(hoge!=i+1){
            if(counter==2){
                cout<<"NO";
                return 0;
            }
            counter++;
        }
    }
    cout<<"YES";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,s[20],ans;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++)cin>>s[i];
    for(int i=1;i<n-1;i++){
        if(s[i]>s[i-1]&&s[i]<s[i+1])ans++;
        if(s[i]<s[i-1]&&s[i]>s[i+1])ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
a,b=map(int,input().split())

import math
a_min=math.ceil(a/0.08)
a_max=math.ceil((a+1)/0.08)-1
b_min=math.ceil(b/0.1)
b_max=math.ceil((b+1)/0.1)-1

if a_max<b_min or b_max<a_min:
    ans=-1
else:
    ans=max(a_min,b_min)
print(ans)


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

typedef struct point {
    int m, f, r;
    struct point *next;
} point;

int main()
{
    point *head = NULL, *cur = NULL;
    while( 1 ){
        point *new = (point *)malloc(sizeof(point));
        if( new == NULL ) exit(-1);
        scanf("%d%d%d", &new->m, &new->f, &new->r);
        if( new->m == -1 && new->f == -1 && new->r == -1 ){
            free(new);
            break;
        }
        new->next = NULL;
        if( head == NULL ) head = new;
        else cur->next = new;
        cur = new;
    }

    int score;
    cur = head;
    while( cur ){
        score = cur->m + cur->f;
        if( cur->m == -1 || cur->f == -1 || score < 30 ) printf("F\n");
        else if( 80 <= score ) printf("A\n");
        else if( 65 <= score && score < 80 ) printf("B\n");
        else if( 50 <= score && score < 65 ) printf("C\n");
        else if( 30 <= score && score < 50 && 50 <= cur->r ) printf("C\n");
        else printf("D\n");
        cur = cur->next;
    }

   return 0;
}

Measured memory_bytes: 584
#include<stdio.h>
void dicemove(char com,int *A);
int main(void)
{
  int i,A[6];
  char com[101];
  for(i=0;i<6;i++)
    {
      scanf("%d",&A[i]);
    }
    scanf("%s",&com);
    for(i=0;com[i];i++)
      {
	dicemove(com[i],A); 
      }
printf("%d\n",A[0]);
 return 0;
}
void dicemove(char comi,int *A){	
  int temp;
  switch(comi){
	case 'E':
	  temp=A[0]; A[0]=A[3]; A[3]=A[5];A[5]=A[2]; A[2]=temp;
	  break;
	case 'N':
	  temp=A[0]; A[0]=A[1]; A[1]=A[5]; A[5]=A[4]; A[4]=temp;
	  break;
	case 'S':
	  temp=A[0]; A[0]=A[4]; A[4]=A[5]; A[5]=A[1]; A[1]=temp;
	  break;
	case 'W':
	  temp=A[0]; A[0]=A[2]; A[2]=A[5]; A[5]=A[3]; A[3]=temp; 
	  break;
	}
}

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

using namespace std;

typedef vector<int> vi;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k , s;
  cin >> n >> k >> s;
  int p = 2;
  while (s%p == 0) ++p;
  for (int i = 0; i < n; ++i) {
    if (i) cout << ' ';
    if (i < k) cout << s;
    else cout << p;
  }
  cout << endl;
}


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

using namespace std;


int main()
{
      int n;
      cin >> n;
      pair <pair <string, int>, int> v[n];
      for (int i = 0; i < n; i++)
      {
          string s;
          int p;
          cin >> s >> p;
          v[i] = make_pair(make_pair(s, -p), i);
      }
      sort(v, v+n);
        for (int i = 0; i < n; i++)
        {
            cout << v[i].second + 1 << endl;
        }
}


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

int main(){
  int n,k;
  cin >> n >>k;
  vector<bool>s(100);
  int d;
  for(int i=0;i<k;i++){
    cin >>d;
    int g;
    for(int m=0;m<d;m++){
      cin>>g;
      s.at(g-1)=1;
    }
  }
  int ans;
  for(int i=0;i<n;i++){
    if(s.at(i)==0){
      ans++;
    }
  }
  cout << ans << endl;
    
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1
#define sosuu 1000000007

int main(){
  int N, R;
  cin >> N >> R;
  if(10<=N)
    cout << R << endl;
  else{
    cout <<  R+100*(10-N) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef int64_t ll;
typedef int32_t ii;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  int32_t N; cin >> N;
  map<int32_t, vector<ii>> mp;
  vector<ii> visited(N+1);
  visited.assign(N+1, 0);
  queue<pair<int32_t, int32_t>> q1;

  REP(i, N-1) {
    int32_t k, v;
    cin >> k >> v;
    if (mp.find(k) == mp.end()) mp[k] = vector<ii>();
    if (mp.find(v) == mp.end()) mp[v] = vector<ii>();
    mp[k].push_back(v);
    mp[v].push_back(k);
  }
  visited[1] = 1;
  visited[N] = 2;
  q1.push(pair<int32_t, int32_t>(1, 1));
  q1.push(pair<int32_t, int32_t>(N, 2));
  while (q1.size()) {
    while (q1.size() && q1.front().second == 1) {
      int v = q1.front().first;
      q1.pop();
      for (const auto& nx: mp[v])
      if (!visited[nx]) {
        q1.push(pair<ii,ii>(nx, 1));
        visited[nx] = 1;
      }
    }
    while (q1.size() && q1.front().second == 2) {
      int v = q1.front().first;
      q1.pop();
      for (const auto& nx: mp[v]) {
        if (!visited[nx]) {
          q1.push(pair<ii,ii>(nx, 2));
          visited[nx] = 2;
        }
      }
    }
  }
  // println(visited);
  ii feneck = 0, sunuke = 0;
  RNG(i, 1, N+1) {
    if (visited[i] == 1) feneck += 1;
    if (visited[i] == 2) sunuke += 1;
  }
  // cout << feneck << " " << sunuke << endl;
  if (feneck > sunuke) {
    cout << "Fennec" << endl;
  } else {
    cout << "Snuke" << endl;
  }

  return 0;
}


Measured memory_bytes: 14584
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<vector>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;;
using ll = long long;

int main() {
	string S;
	cin >> S;
	int Flag = 0;
	if (S[2] == S[3]) {
		Flag++;
	}
	else {
		cout << "No" << endl;
		return 0;
	}
	if (S[4] == S[5]) {
		Flag++;
	}
	if (Flag == 2) {
		cout << "Yes" << endl;
		
	}
	else { cout << "No" << endl; }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

ll dp[3010][3010];
void solve(std::string s, std::string t)
{
    int n = s.size();
    int m = t.size();
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (s[i - 1] == t[j - 1])
            {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
            }
            else
            {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }

    string ans = "";

    while (n > 0 && m > 0)
    {
        if (dp[n][m] == dp[n][m - 1])
        {
            m--;
        }
        else if (dp[n][m] == dp[n - 1][m])
        {
            n--;
        }
        else
        {
            n--;
            m--;
            ans.push_back(s[n]);
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

int main()
{
    std::string s;
    std::cin >> s;
    std::string t;
    std::cin >> t;
    solve(s, t);
    return 0;
}


Measured memory_bytes: 70784
import java.io.*;
 
class Main {
    public static void main(String[] arg)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int l = str.length();
        char ch[] = str.toCharArray();
        for(int i=0;i<l;i++){
            if(Character.isUpperCase(ch[i])){
                ch[i] = Character.toLowerCase(ch[i]);
            }
            else if(Character.isLowerCase(ch[i])){
                ch[i] = Character.toUpperCase(ch[i]);               
            }
        }
        System.out.println(ch);     
    }
}   

Measured memory_bytes: 24068
n, k = map(int, input().split())

m = (n-1) * (n-2) // 2

if m < k:
    print(-1)
    exit()
else:
    print(n-1 + m - k)
    
    for i in range(n-1):
        print(1, i+2)
    
a = m - k
b = 3
for j in range(2, n):
    for l in range(b, n+1):
        if a == 0:
            exit()
        print(j,l)
        a -= 1
    b += 1

Measured memory_bytes: 3608