akhauriyash/Code-Regression huggingface dataset:
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#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 complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct UnionFind {
    vector<int> par, w;
    
    UnionFind(int n) : par(n, -1), w(n, 0) { }
    void init(int n) { par.assign(n, -1); w.assign(n, 0); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) {
            ++w[x];
            return false;
        }
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        w[x] += w[y];
        ++w[x];
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
 
    int wei(int x) {
        return w[root(x)];
    }
};

void solve() {
	int n, m, k; cin >> n >> m >> k;
    UnionFind uf(n);
    vector<int> a(m), b(m), c(k), d(k);
    rep(i, m) {
        cin >> a[i] >> b[i];
        --a[i]; --b[i];
        uf.merge(a[i], b[i]);
    }
    rep(i, k) {
        cin >> c[i] >> d[i];
        --c[i]; --d[i];
    }
    vector<int> ans(n);
    rep(i, n) {
        ans[i] = uf.size(i) - 1; //自分
    }
    rep(i, m) {
        ans[a[i]] --;
        ans[b[i]] --;
    }
    rep(i, k) {
        if(uf.issame(c[i], d[i])) {
            ans[c[i]] --;
            ans[d[i]] --;
        }
    }
    rep(i, n) {
        cout << ans[i] << " ";
    }
    cout << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3584
#include "bits/stdc++.h"
using namespace std;

long long GCD(long long X, long long Y) {
	return (Y == 0 ? X : GCD(Y, X % Y));
}

long long LCM(long long X, long long Y) {
	return X * (Y / GCD(X, Y));
}

int main() {
	long long A, B;
	cin >> A >> B;
	cout << LCM(A, B) << endl;
}

Measured memory_bytes: 256
object Main extends App {
  val scanner = new java.util.Scanner(System.in)
  val n = scanner.nextInt()

  val having = (1 to n).map { _ =>
    (scanner.next(), scanner.nextInt())
  }

  val cards =
    for {
      suit <- List("S", "H", "C", "D")
      num  <- 1 to 13
    } yield (suit, num)
  
  val outputs = cards.filter(!having.contains(_))
  
  outputs.foreach(t => println(s"${t._1} ${t._2}"))
}

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

stack<int> S;
int a, b, x;
string s;

int main(){
	while(cin >> s) {
		if(s[0] == '+'){
			a = S.top();S.pop();
			b = S.top();S.pop();
			S.push(a+b);
		}else if(s[0] == '-'){
			b = S.top();S.pop();
			a = S.top();S.pop();
			S.push(a-b);
		}else if(s[0] == '*'){
			a = S.top();S.pop();
			b = S.top();S.pop();
			S.push(a*b);
		}else{
			S.push(atoi(s.c_str()));
		}
	}
	cout << S.top() << endl;
	return 0;
}



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

int main()
{
  int64_t N, a, b, fennec = 0, snuke = 0;
  cin >> N;
  vector<int> Color(N, -1); // -1: none, 0: black, 1: white
  vector<vector<int64_t>> Graph(N);
  for (int i = 0; i < N - 1; i++)
  {
    cin >> a >> b;
    a--;
    b--;
    Graph[a].push_back(b);
    Graph[b].push_back(a);
  }
  queue<int> Q0, Q1, next;
  Q0.push(0);
  Q1.push(N - 1);
  for (int i = 0; i < N; i++)
  {
    if (i % 2)
    {
      while (Q1.size())
      {
        int qf = Q1.front();
        Q1.pop();
        if (Color[qf] == -1)
        {
          Color[qf] = 1;
          snuke++;
        }
        for (int j = 0; j < Graph[qf].size(); j++)
        {
          if (Color.at(Graph[qf][j]) == -1)
            next.push(Graph[qf][j]);
        }
      }
      while (next.size())
      {
        Q1.push(next.front());
        next.pop();
      }
    }
    else
    {
      while (Q0.size())
      {
        int qf = Q0.front();
        Q0.pop();
        if (Color[qf] == -1)
        {
          Color[qf] = 0;
          fennec++;
        }
        for (int j = 0; j < Graph[qf].size(); j++)
        {
          if (Color.at(Graph[qf][j]) == -1)
            next.push(Graph[qf][j]);
        }
      }
      while (next.size())
      {
        Q0.push(next.front());
        next.pop();
      }
    }
  }
  cout << ((fennec > snuke) ? "Fennec" : "Snuke") << endl;
}

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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a+b > c+d){
    cout << "Left" << endl;
  }else if(a+b == c+d){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int X = sc.nextInt();

        int sum = 0;

        for(int i=1; i<=X; i++){
            sum += i - 1;
            if(sum>=X-i){
                System.out.println(i);
                break;
            }
        }
    }
}

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

int main() {
	int a;
	cin >> a;
	string b = "No";
	if (a / 10 % 111 == 0) {
		b = "Yes";
	}
	if (a % 1000 % 111 == 0) {
		b = "Yes";
	}
	cout << b << endl;
	return 0;
}

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

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

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

using int64 = long long;

map< int64, int > prime_factor(int64 n)
{
  map< int64, int > ret;
  for(int64 i = 2; i * i <= n; i++){
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return(ret);
}


void solve(long long N){
    auto factors = prime_factor(N);
    vector<i64> table(10010);
    rep(i, 10000) table[i + 1] = table[i] + i + 1;
    i64 ans = 0;
    for(auto factor : factors){
        rep(i, 1, 10000){
            if(table[i] > factor.second){
                ans += i - 1;
                break;
            }
        }
    }
    cout << ans << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3776
#include <cstdio>
#include <algorithm>

using namespace std;

int n, w, h, s, t;
int x[500], y[500];

int solve()
{
  int ans = 0;
  for (int i = 0; i < w - s + 1; ++i) {
    for (int j = 0; j < h - t + 1; ++j) {
      int d = 0;
      for (int k = 0; k < n; ++k) {
	if (i <= x[k] && x[k] < i + s && j <= y[k] && y[k] < j + t) {
	  ++d;
	}
      }
      //ans = max(ans, d);
      if (d > ans) {
	ans = d;
	//printf("  (%d, %d) = %d\n", i, j, d);
      }
    }
  }
  return ans;
}

int main()
{
  for (;;) {
    scanf("%d", &n);
    if (n == 0)
      break;

    scanf("%d %d", &w, &h);
    for (int i = 0; i < n; ++i) {
      scanf("%d %d", &x[i], &y[i]);
      x[i] -= 1;
      y[i] -= 1;
    }

    scanf("%d %d", &s, &t);

    printf("%d\n", solve());
  }

  return 0;
}

Measured memory_bytes: 1032
possible_appearances = ->(dice) {
  table = 
     [[0, 1, 2, 3, 4, 5], [3, 1, 0, 5, 4, 2], [1, 5, 2, 3, 0, 4], [5, 1, 3, 2, 4, 0],
      [1, 2, 0, 5, 3, 4], [3, 5, 1, 4, 0, 2], [5, 4, 2, 3, 1, 0], [2, 1, 5, 0, 4, 3],
      [1, 0, 3, 2, 5, 4], [5, 2, 1, 4, 3, 0], [2, 4, 0, 5, 1, 3], [4, 5, 3, 2, 0, 1],
      [3, 4, 5, 0, 1, 2], [4, 0, 2, 3, 5, 1], [1, 3, 5, 0, 2, 4], [2, 0, 1, 4, 5, 3],
      [0, 4, 3, 2, 1, 5], [4, 2, 5, 0, 3, 1], [4, 3, 0, 5, 2, 1], [2, 5, 4, 1, 0, 3],
      [3, 0, 4, 1, 5, 2], [0, 3, 1, 4, 2, 5], [0, 2, 4, 1, 3, 5], [5, 3, 4, 1, 2, 0]]
  result = []
  table.each do |dice1|
    another = Array.new(6, 0)
    dice1.each_with_index {|n, i| another[n] = dice[i]}
    result << another
  end
  result.uniq
}

n = gets.to_i
dices = []
n.times {dices << gets.split.map(&:to_i)}
result = "Yes"
s = dices.size
(s - 1).times do |i|
  appearances = possible_appearances.(dices[i])
  (i + 1).upto(s - 1) do |j|
    if appearances.include?(dices[j])
      result = "No"
      break
    end
  end
end
puts result



Measured memory_bytes: 7052
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef long long ll;
typedef unsigned long long ull;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( unsigned int i = (unsigned int)( m ); i < (unsigned int)( n ); i++ )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define RALL( c ) (c).rbegin(), (c).rend()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

VI memo;

int solve( int n )
{
	if ( n == 0 )
	{
		return 1;
	}
	else if ( n < 0 )
	{
		return 0;
	}

	if ( memo[n] != -1 )
	{
		return memo[n];
	}

	return memo[n] = solve( n - 1 ) + solve( n - 2 ) + solve( n - 3 );
}

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

		if ( n == 0 )
		{
			break;
		}

		memo.resize( n + 1 );
		fill( ALL( memo ), -1 );

		cout << solve( n ) / 3650 + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 1212
n,m,c=map(int,input().split())
count=0
b=list(map(int,input().split()))
for i in range(n):
    a=list(map(int,input().split()))
    d=c
    for j in range(m):
        d+=a[j]*b[j]
    if d>0:
        count+=1
print(count)

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

using namespace std;
using ll = long long;

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;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;

template <typename T> struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};

template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

template <typename T> vector<T> dijkstra(WeightedGraph<T> &g, int s) {
  vector<T> dist(g.size(), INF<T>);

  using Pi = pair<T, int>;
  priority_queue<Pi, vector<Pi>, greater<Pi>> que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while (!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if (dist[idx] < cost)
      continue;
    for (auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if (dist[e.to] <= next_cost)
        continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}

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

  int V, E, r;
  cin >> V >> E >> r;
  WeightedGraph<int> G(V);
  REP(i, E) {
    int s, t, d;
    cin >> s >> t >> d;
    G.at(s).emplace_back(t, d);
  }
  for (auto dist : dijkstra(G, r)) {
    if (dist == INF<int>) {
      cout << "INF\n";
    } else {
      cout << dist << '\n';
    }
  }

  return 0;
}


Measured memory_bytes: 15476
n=int(input())
l=list(map(int,input().split()))
a=[(n+1)*(i+1) for i in range(n)]
b=a[::-1]
for i in range(n):
    a[l[i]-1]+=i
print(" ".join(map(str,a)))
print(" ".join(map(str,b)))

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int calc(string s){
  assert(s.size()==7);
  stack<int> st;
  REP(i,s.size()){
    char c = s[i];
    if(c=='+'){
      if(st.size()<2) return -1;
      int a = st.top(); st.pop();
      a += st.top(); st.pop();
      st.push(a);
    }else if(c=='-'){
      if(st.size()<2) return -1;
      int a = st.top(); st.pop();
      a -= st.top(); st.pop();
      st.push(a);
    }else if(c=='*'){
      if(st.size()<2) return -1;
      int a = st.top(); st.pop();
      a *= st.top(); st.pop();
      st.push(a);
    }else{
      st.push((int)(c-'0'));
    }
  }
  assert(st.size()==1);
  return st.top();
}

void output(string s){
  stack<string> st;
  REP(i,s.size()){
    char c = s[i];
    if(c=='+' || c=='-' || c=='*'){
      if(st.size()<2) assert(false&&"NO STACK");
      string a = "(";
      a += st.top(); st.pop();
      a += c;
      a += st.top(); st.pop();
      a += ")";
      st.push(a);
    }else{
      st.push(string(1,c));
    }
  }
  assert(st.size()==1);
  cout<<st.top()<<endl;
}

int main(){
  int a[4];
  while(~scanf("%d%d%d%d",a,a+1,a+2,a+3)){
    if(a[0]==0 && a[1]==0 && a[2]==0 && a[3]==0)break;
    // ???????????????????¨????
    vi expr(7,0);
    FOR(i,4,7)expr[i]=1;
    vi numlst(4);
    REP(i,4)numlst[i]=i;
    bool flag = false;
    do{
      if(flag)break;
      if(expr[0]==1 || expr[1]==1) continue;
      if(expr[6]==0) continue;
      REP(exmsk,3*3*3){
        if(flag)break;
        do{
          if(flag)break;
          string s = "";
          int i1=0;
          int tmp = exmsk;
          REP(i,7){
            if(expr[i]==0){
              s += (char)(a[numlst[i1]]+'0');
              ++i1;
            }else{
              s += "+-*"[tmp%3];
              tmp /= 3;
            }
          }
          int res = calc(s);
          if(res==10){
            flag = true;
            output(s);
            break;
          }
        }while(next_permutation(ALL(numlst)));
      }
    }while(next_permutation(ALL(expr)));
    if(!flag)cout<<0<<endl;
  }
  return 0;
}

Measured memory_bytes: 1240
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N, D, X, sum;
		N = sc.nextInt();
		D = sc.nextInt();
		X = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			for (int k = 0; k <= D; k++) {
				if (k * A[i] + 1 <= D) {
					X++;
				}
			}
		}
		sum = X;
		System.out.println(sum);
		sc.close();
	}

}


Measured memory_bytes: 21716
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int N=in.nextInt();
			int Q=in.nextInt();
			if((N|Q)==0)
				return;
			String name[]=new String[1001];
			int base[]=new int[1001];
			int era[]=new int[1001];
			
			for(int i=0;i<N;i++)
			{
				name[i]=in.next();
				int j=in.nextInt();
				era[i]=in.nextInt();
				base[i]=era[i]-j+1;
			}
			
			for(int i=0;i<Q;i++)
			{
				int year=in.nextInt();
				int j=0;
				for(;j<N;j++)
				{
					if(base[j]<=year&&year<=era[j])
					{
						System.out.println(name[j]+" "+(year-base[j]+1));
						break;
					}
					
				}
				if(j==N)
					System.out.println("Unknown");
			}
		}
	}
	
	static public void debug(Object... o)
	{
		System.err.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 61592
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 212345
int a[N], b[N];

int main(){
	iota(a, a+N, 0);
	int n; ll k; scanf("%d%lld", &n, &k);
	FOR(i, 1, n+1) scanf("%d", a+i);
	int ans = 1;
	do {
		if(k&1) ans = a[ans];
		REP(i, N) b[i] = a[a[i]];
		swap(a, b);
	}while(k /= 2);
	printf("%d\n", ans);
}


Measured memory_bytes: 5452
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
using namespace std;
#define ll int64_t
#define REP(i, n) for (ll i=0; i<n; i++)

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

    string S;
    cin >> S;
    ll n = S.size();

    bool ans = false;
    REP(i, n+1){
        for (ll j = i; j<n+1; j++){
            string a = S;
            a.erase(i, j-i);
            if (a == "keyence") ans = true;
        } 
    }

    if (ans) cout << "YES" << "\n";
    else cout << "NO" << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int X = scan.nextInt();
        
    switch(X%7){
        case 1:
            System.out.println("fri");
            break;
        case 2:
            System.out.println("sat");
            break;
        case 3:
            System.out.println("sun");
            break;
        case 4:
            System.out.println("mon");
            break;
        case 5:
            System.out.println("tue");
            break;
        case 6:
            System.out.println("wed");
            break;
        case 0:
            System.out.println("thu");
            break;
            
    }
    }
}


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

using namespace std;

int main() {
	int N, K;
	string S;
	cin >> N >> S >> K;

	for(int i = 0; i < S.size(); i++) {
		if (S[K-1] != S[i]) {
			S[i] = '*';
		}
	}

	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())

if w == 1:
  print(1)
  exit()
if h == 1:
  print(1)
  exit()
if w%2 == 0:
  ans = w//2 * h
elif w%2 == 1:
  if h%2 == 0:
    ans = h*w//2
  elif h%2 == 1:
    ans = h*w//2 + 1

print(ans)

Measured memory_bytes: 9116
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include <string>
#include <math.h>
#include <queue>
#include <stack>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i] >>y[i];
typedef long long int ll;
using namespace std;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

int main(){
   int n,k; cin >>n>>k;
   if((n-1)*(n-2)/2<k){
    cout << -1 << endl;
    return 0;
   }
   cout << (n-1)+(n-1)*(n-2)/2-k << endl;
   for(int i=2;i<=n;i++){
    cout << 1 << " " << i <<endl;
   }
   int cnt=0;
   for(int i=2;i<=n;i++){
    for(int j=i+1;j<=n;j++){
        if(cnt==(n-1)*(n-2)/2-k)return 0;
        cout << i << " " << j << endl;
        cnt++; 
    }
   }
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    immutable T = ["A":0,"B":1,"AB":2,"O":3];
    int[4] c;
    foreach(v;stdin.byLine().map!(s=>T[s.split(",")[1]])) ++c[v];
    foreach(v;c) writeln(v);
}

Measured memory_bytes: 1072
n = int(input())
h = list(map(int,input().split()))
flag = 0
k = 0
for i in range(n-1,0,-1):
    if(h[i-1]<=h[i]):
        continue
    elif(h[i-1]-1==h[i]):
        h[i-1]-=1
    else:
        flag = 1

if(flag==0):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
#include <iostream>
#include <cmath>

using namespace std;
typedef long long ll;

ll pow_2(ll e, ll r){
  ll ans = 1;
  for (ll i=0; i<r; i++){
    ans *= e;
  }
  return ans;
}

bool is_runrun(ll x){
  ll d = (ll)floor(log10(x));
  bool ret = true;
  for (int i=0; i<d; i++){
    ll d1 = (x / pow_2(10, i+1)) % 10;
    ll d2 = (x / pow_2(10, i)) % 10;
    if (abs(d1 - d2) > 1){
      ret = false;
      break;
    }
  }
  return ret;
}

int main(){
  ll K;
  cin >> K;
  if (K <= 10){
    cout << K << "\n";
  }
  else{
    ll ans = 10;
    ll p = 0;
    K -= 10;
    for (ll i=0; i<K; i++){
      ans++;
      p = 0;
      while(!is_runrun(ans)){
        for (int j=(int)log10(ans)-1; j>=0; j--){
          if (abs((ans / pow_2(10, j+1) % 10) - (ans / pow_2(10, j)) % 10) > 1){
            if ((ans / pow_2(10, j+1) % 10) - (ans / pow_2(10, j)) % 10 < 0){
              ans = (ans / pow_2(10, j+1) + 1) * pow_2(10, j+1);
            }
            else{
            	ans += (max((ll)0, (ans / pow_2(10, j+1)) % 10 - 1)) * pow_2(10, j);
            }
          }
        }
        p++;
      }
      //cerr << endl;
    }
    cout << ans << "\n";
  }
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main()
{
  int N;
  long x;
  cin >> N >> x;
  long a[N];
  for (int i = 0; i < N; i++)
    cin >> a[i];
  long ans = 0;
  if (x < a[0])
  {
    ans += a[0] - x;
    a[0] = x;
  }
  for (int i = 0; i < N - 1; i++)
  {
    if (x < a[i] + a[i + 1])
    {
      ans += a[i] + a[i + 1] - x;
      a[i + 1] = x - a[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll ans = 1e18;
    for(ll i = 1; i*i <= n; i++){
        if(n%i != 0) continue;
        chmin(ans, (i-1) + (n/i-1));
    }
    cout << ans << endl;
    return 0;
}

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

vector<vector<int> >vec;
vector<int>v;
int n,m,l,d,cur,dep;
char b;

void go(){
    cur=m,dep=0;
    while(dep<d){
        for(int i=0;i<vec[dep].size();i++){
            if(vec[dep][i]==cur){
                cur=vec[dep][i]+1;
                break;
            }
            if(vec[dep][i]+1==cur){
                cur=vec[dep][i];
                break;
            }
        }
        dep++;
    }
}

int main(){
    while(cin>>n,n){
        vec.clear();
        cin>>m>>l>>d;
        for(int i=0;i<d;i++){
            vec.push_back(v);
            for(int j=1;j<n;j++){
                cin>>b;
                if(b=='1')
                    vec[i].push_back(j);
            }
        }
        go();
        if(cur==l){
            cout<<0<<endl;
            goto ne;
        }
        for(int j=0;j<d;j++){
            for(int i=1;i<n;i++){
                if(find(vec[j].begin(),vec[j].end(),i-1)!=vec[j].end())continue;
                if(find(vec[j].begin(),vec[j].end(),i)!=vec[j].end())continue;
                if(find(vec[j].begin(),vec[j].end(),i+1)!=vec[j].end())continue;
                vec[j].push_back(i);
                go();
                if(cur==l){
                    cout<<j+1<<" "<<i<<endl;
                    goto ne;
                }
                vec[j].pop_back();
            }
        }
        cout<<1<<endl;
    ne:;
    }
    
}

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

using namespace std;


int main(){
 int n;
  cin>>n;
  int a[n];
 
  
  int i=6;
  int p=0;
  while(i<55555 && p<n){
    bool sosu=true;
    for(int j=2;j<=sqrt(i);j++){
      if(i%j==0){sosu=false;
                 break;}
    }
  if(sosu){
    a[p]=i;
  p++;}
      i+=5;}
  for(int i=0;i<n;i++){
    cout<<a[i]<<" ";}
  cout<<endl;
      
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int T_MAX = 11;

int tb[][3][3] = {
	{{9,1,9},
	 {1,0,1},
	 {9,9,9}},

	{{9,1,9},
	 {9,0,1},
	 {9,1,9}},

	{{9,0,9},
	 {1,0,1},
	 {9,1,9}},

	{{9,1,9},
	 {1,0,9},
	 {9,1,9}},
	// +
	{{9,1,9},
	 {1,0,1},
	 {9,1,9}},
};

int cur[9][9],W,H,sx,sy;
int dx[] = {-1,0,0,1} , dy[] = {0,-1,1,0};

bool done[9][9];
int dfs(int x,int y){
	if(done[y][x]) return 0 ;
	else done[y][x] = true;
	if(y == sy && x == sx) return 1;
	if(cur[y][x] != 0) return 0;
	int ans = 1;
	rep(i,4) ans += dfs(x+dx[i],y+dy[i]);
	return ans;
}
void output(){
	rep(i,H+2){
		rep(j,W+2)cout << cur[i][j];
		cout << endl;
	}
}	
bool isTaboo(int c,int x,int y){
	int ans = 0;
	rep(i,9) rep(j,9) done[i][j] = 0;
	rep(i,4) ans+=dfs(x+dx[i],y+dy[i]);
	return c != ans;
}

bool badFlag;
int nest[50] = {0};
int bt(int c,int x,int y){
	if(nest[c]++ > 20000) { badFlag = true;return true;}
	if(c == 0) return (x == sx && y == sy);
	if(cur[y][x] != 0)return false;
	cur[y][x] = 2;
	if(isTaboo(c,x,y)){cur[y][x] = 0;return false;}
	rep(i,4) if( bt(c-1,x+dx[i],y+dy[i]) ) return true;
	cur[y][x] = 0;
	return false;
}
int main(){
	while(cin >> W >> H && W){
		int eCount = 0;
		rep(i,9)rep(j,9) cur[i][j] = 1;
		rep(i,H)rep(j,W) cin >> cur[i+1][j+1] , eCount += !cur[i+1][j+1];
		rep(i,H+2)rep(j,W+2) if(cur[i][j] == 0) sx = j , sy = i;
		rep(i,50)nest[i] = 0;
		badFlag = 0;
		cout << (eCount > 3 && bt(eCount,sx,sy) && !badFlag ? "Yes" : "No") << endl;
	}
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define li long
#define pb push_back
#define mem(arr,x) memset(arr,x,sizeof(arr))

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,i,j;
    cin>>n>>m;
    char a[n][m];
    for(i=0;i<n;i++)
      for(j=0;j<m;j++)
        cin>>a[i][j];

    int dp[n+1][m+1],f=0;
    for(i=0;i<n;i++)
    {
      if(a[i][0]=='.' && f==0)
      dp[i][0]=1;
      else
      {
        f=1;
        dp[i][0]=0;
      }
    }
    f=0;
    for(i=0;i<m;i++)
    {
      if(a[0][i]=='.' && f==0)
      dp[0][i]=1;
      else
      {
        f=1;
        dp[0][i]=0;
      }
    }
    for(i=1;i<n;i++)
    {
      for(j=1;j<m;j++)
      {
        if(a[i][j]=='#')
        dp[i][j]=0;
        else
        dp[i][j]=(dp[i-1][j]%MOD+dp[i][j-1]%MOD)%MOD;
      }
    }
    cout<<dp[n-1][m-1]%MOD;
    return 0;
}

Measured memory_bytes: 8476
while 1:
    n,l = map(int,raw_input().split())
    if n == 0: break
    
    tunnel = [[] for i in xrange(l-1)]
    for i in xrange(1,n+1):
        d,p = raw_input().split()
        tunnel[int(p)-1].append(i if d == "R" else -i)
    t = num = 0
    while sum(len(unit) for unit in tunnel) != 0:
        for i in xrange(l-2,-1,-1):
            for a in tunnel[i]:
                if a > 0:
                    tunnel[i].remove(a)
                    if i == l-2:
                        num = a
                    else:
                        tunnel[i+1].append(a)
        for i in xrange(l-1):
            for a in tunnel[i]:
                if a < 0:
                    tunnel[i].remove(a)
                    if i == 0:
                        num = -a
                    else:
                        tunnel[i-1].append(a)
        for i in xrange(l-1):
            if len(tunnel[i]) > 1:
                tunnel[i] = [-a for a in tunnel[i]]
        t += 1
    print t,num

Measured memory_bytes: 4288
import itertools

n=int(input())
p=list(input().split())
q=list(input().split())
l=[]
for v in itertools.permutations(p,n):
    l.append(list(v))
    
l=sorted(l)
p_val=0
q_val=0
m=0
for i in l:
    if i==p:
        p_val=m
    if i==q:
        q_val=m
    m+=1

print(abs(p_val-q_val))

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

int main(){
    string s;
    cin>>s;

    int n=s.size();
    vector<int> ans(n,0);
    int cnt=0;
    for(int i=0;i<n;++i){
        if(s[i]=='L'){
            if(cnt%2==1){
                ans[i-1]+=cnt/2+1;
                ans[i]+=cnt/2;
            }
            else{
                ans[i]+=cnt/2;
                ans[i-1]+=cnt/2;
            }
            cnt=0;
        }
        else ++cnt;
    }
    /*
    cout<<"R: "<<endl;
    for(int i=0;i<n;++i) cout<<ans[i]<<' ';
    cout<<endl;
    */
    cnt=0;
    for(int i=n-1;i>=0;--i){
        if(s[i]=='R'){
            if(cnt%2==1){
                ans[i+1]+=cnt/2+1;
                ans[i]+=cnt/2;
            }
            else{
                ans[i]+=cnt/2;
                ans[i+1]+=cnt/2;
            }
            cnt=0;
        }
        else ++cnt;
    }

    for(int i=0;i<n;++i) cout<<ans[i]<<' ';
    cout<<endl;
}

Measured memory_bytes: 3852
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

vector<int> divisor;
void findDivisors(int n) 
{ 
  
    // Array to store the count 
    // of divisors 
    divisor.resize(n+1,0);
 //   memset(div, 0, sizeof div); 
  
    // For every number from 1 to n 
    for (int i = 1; i <= n; i++) { 
  
        // Increase divisors count for 
        // every number divisible by i 
        for (int j = 1; j * i <= n; j++) 
            divisor[i * j]++; 
    } 
  

} 

int main()
{
    fast_cin;
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif

    long long N;
    cin>>N;


    long long ans=0;

    findDivisors(N);
    //ans=phi(N);
   // cout<<ans<<"\n";
    for(int i=1;i<=N-1;i++){
        ans+=divisor[i];
    }
    cout<<ans<<"\n";

}


Measured memory_bytes: 7144
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)

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

	string s;
	cin>>s;
	long long int ct=0,flag=0;
	loop(i,s.size()-1,0)
	{
		int v=s[i]-'0';
		if(flag)	v++;
		flag=0;
		if((v>5 )or (v==5 and s[i-1]>='5' and i>0))
		{
			flag=1;
			ct+=(10-v);
		}
		else ct+=v;
	}
	if(flag)	ct++;
	cout<<ct;
	
	return 0;	
}

Measured memory_bytes: 1948
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
lst = []
while l = $stdin.gets do
  if lc == 0
    inputs << l.chomp.split(" ").map(&:to_i)
  else
    lst << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
end

nn = inputs[0][0]

pd nn
pd lst

nums = []
for i in 0..nn-1
  nums << i
end

include Math

pats = nums.permutation(nums.size).to_a
nave = pats.size.to_f

cur = 0.0
pats.each do |pat|
  for i in 1..pat.length-1
    dx = (lst[pat[i]][0] - lst[pat[i-1]][0])
    dx = dx*dx
    dy = (lst[pat[i]][1] - lst[pat[i-1]][1])
    dy = dy*dy
    cur += sqrt(dx + dy)
  end
end

pd cur
pd nave

printf("%.10f\n", cur/nave)


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

using namespace std;

int main(){
  
  //freopen("input.txt","r",stdin);
  //freopen("outputu.txt","w",stdout);
  int n,m,i,j,s(0);
  cin>>m>>n;
  int arr[n];
  for(i=0;i<n;i++){
    cin>>arr[i];
    s+=arr[i];
  }
  if(s>=m)cout<<"Yes";
  else cout<<"No";


  
  


  
 
 
 
    
 
return 0;
}

Measured memory_bytes: 640
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
//long long h[205000];
int main()
{
    long long h,res=1,b=1,i;
    scanf("%lld",&h);
    if(h==1)
        printf("1\n");
    else
    {
        for(i=1; h>1; i++)
        {
            h=h/2;
            b=b*2;
            res+=b;
        }
        printf("%lld\n",res);
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <cassert>
#include <bits/stdc++.h>

using namespace std;

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

const int
	MAXN = 100000,
	MAXLGN = 18;

int N, M;
long long dist[MAXN];
int level[MAXN];
int lca[MAXN][MAXLGN];
vector< pair<int, int> > G[MAXN];

int log2(int x)
{
	int lg = 1;
	while (1 << lg < x) lg++;
	return lg - 1;
}

int queryLCA(int u, int v)
{
	if (level[v] > level[u])
	      swap(u, v);

	for (int i = log2(level[u]); i >= 0; i--)
		if (level[u] - (1 << i) >= level[v])
		      u = lca[u][i];


	if (u == v) return u;

	for (int i = log2(level[u]); i >= 0; i--)
		if (lca[u][i] != lca[v][i])
		{
			u = lca[u][i];
			v = lca[v][i];
		}


	return lca[u][0];
}

int main()
{
	scanf( "%d", &N );
	REP(i, N - 1)
	{
		int u, v, w;
		scanf( "%d %d %d", &u, &v, &w );
        u --, v --;
		G[u].push_back(make_pair(v, w));
		G[v].push_back(make_pair(u, w));
	}

	queue< int > Q;
	for (Q.push(0), level[0] = 1; !Q.empty(); Q.pop())
	{
		int u = Q.front();
		REP(i, G[u].size())
		{
			int v = G[u][i].first;
			int w = G[u][i].second;
			if (level[v]) continue;

			Q.push(v);
			lca[v][0] = u;
			dist[v] = dist[u] + 1LL * w;
			level[v] = level[u] + 1;

			int lg = log2(level[v]);
			for (int i = 1; i <= lg; i++)
				lca[v][i] = lca[ lca[v][i - 1] ][i - 1];
		}
	}
	int k;
	cin >> M >> k;
	k --;
	while (M--)
	{
		int u, v;
		scanf( "%d %d", &u, &v );
		u --, v --;
		int z = queryLCA(u, k);
		long long res = dist[u] + dist[k] - 2 * dist[z];
		z = queryLCA(k, v);
		res += dist[k] + dist[v] - 2 * dist[z];
		cout << res << endl;
	}

	return 0;
}


Measured memory_bytes: 16244
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
using namespace std;

int n;
int b[100005];
vector<int> a;

int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>b[i];
	sort(b,b+n);
	int now=-1;
	for(int i=0;i<n;i++){
		if(now!=-1){
			if(b[i]==now){
				a.push_back(now);
				now=-1;
			}
			else{
				a.push_back(-1);
				now=b[i];
			}
		}else now=b[i];
	}
	int a1=-1,a2=-1;
	for(int i=0;i<a.size();i++){
		if(a[i]>=a1){
			a2=a1;
			a1=a[i];
			continue;
		}
		if(a[i]>=a2){
			a2=a[i];
			continue;
		}
	}
	if(a1==-1||a2==-1) puts("0");
	else cout<<(unsigned long long)a1*(unsigned long long)a2<<endl;
	return 0;
}

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

int n;
char a[200002];

int c_r=0,c_w=0;

int ans = 0;

int main(){

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i] == 'R')c_r++;
		else c_w++;
	}

	// slv
	for(int i=0;i<n;i++){
		if(i<c_r){
			if(a[i]=='W')ans+=2;
		}
		else{
			if(a[i]=='R')ans--;
		}
	}

	cout<<ans<<endl;

	return(0);
}

Measured memory_bytes: 3824
#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<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int n;
vector<vector<int>> p;
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int x;cin>>x;
	if(x>=30){
	    cout<<"Yes"<<endl;
	}else{
	    cout<<"No"<<endl;
	}
	
	return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int h,w ; 
  cin >> h >> w ; 
  vector<vector<char>> D(h ,vector<char> (w));
  rep(i,h){
    rep(j,w){
      cin >> D.at(i).at(j) ;
    }
  }
  
  vector<int> row , column;
  
  rep(i,h){
    int  cnt = 0 ;
    rep(j,w){
      if(D.at(i).at(j) == '.') cnt ++ ;
    }
    if(cnt != w) row.push_back(i) ;
  }
  
  rep(i,w){
    int  cnt = 0 ;
    rep(j,h){
      if(D.at(j).at(i) == '.')  cnt ++  ;
    }
    if(cnt != h) column.push_back(i) ;
  }
  
  
  rep(i,row.size()){
    rep(j,column.size()){
      cout << D.at(row.at(i)).at(column.at(j)) ;
    }
    cout <<endl;
  }
  
}


Measured memory_bytes: 3628
n,k = map(int,input().split())
h = [int(input()) for hogehoge in range(n)]
h = sorted(h)
ans = 10 ** 10
for i in range (n - k + 1):
         if (h[i + k - 1] - h[i]) < ans:
                  ans = (h[i + k - 1] - h[i])
print(ans)


Measured memory_bytes: 8280
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int x[11000];
int y[11000];
pair<int,int>p[21000];

vector<int>scc_g[100100];
vector<int>scc_rev[100100];
int v[100100]; // used twice
int num[100100]; // inverse of conv
int conv[100100]; // dfs order of i-th vertex. note that it's kaerigake ordered
int scc[100100]; // the index of scc containing i-th vertex
int fi[100100]; // the first element of each scc
int ss[100100]; // size of each scc
int cur;
void dfs(int a){
	for(int i=0;i<scc_g[a].size();i++){
		if(v[scc_g[a][i]])continue;
		v[scc_g[a][i]]=1;
		dfs(scc_g[a][i]);
	}
	conv[a]=cur;
	num[cur++]=a;
}
void dfs2(int a){
	scc[a]=cur;
	ss[cur]++;
	for(int i=0;i<scc_rev[a].size();i++){
		if(v[scc_rev[a][i]])continue;
		v[scc_rev[a][i]]=1;
		dfs2(scc_rev[a][i]);
	}
}
void query(int a,int b,int c,int d,int e,int f){
	if(c>d)return;
	if(d<a||b<c)return;
	if(c<=a&&b<=d){
		scc_g[f].push_back(e+20000);
		scc_rev[e+20000].push_back(f);
		return;
	}
	query(a,(a+b)/2,c,d,e*2,f);
	query((a+b)/2+1,b,c,d,e*2+1,f);
}
void add_edge(int a,int b){
	a+=32768;
	while(a){
		scc_g[20000+a].push_back(b^1);
		scc_rev[b^1].push_back(20000+a);
		a/=2;
	}
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d%d",x+i,y+i);
		p[2*i]=make_pair(x[i],2*i);
		p[2*i+1]=make_pair(y[i],2*i+1);
	}
	std::sort(p,p+a*2);
	int left=0;
	int right=1000000000;
	while(left+1<right){
		int M=(left+right)/2;
		for(int i=0;i<100100;i++){
			scc_g[i].clear();
			scc_rev[i].clear();
			v[i]=num[i]=conv[i]=scc[i]=fi[i]=ss[i]=0;
		}
		for(int i=0;i<a*2;i++){
			add_edge(i,p[i].second);
		}
		for(int i=0;i<a*2;i++){
			int L=upper_bound(p,p+a*2,make_pair(p[i].first-M,(int)mod))-p;
			query(0,32767,L,i-1,1,p[i].second);
			int R=lower_bound(p,p+a*2,make_pair(p[i].first+M,0))-p-1;
			query(0,32767,i+1,R,1,p[i].second);
		}
		cur=0;
		for(int i=0;i<100100;i++){
			if(v[i])continue;
			v[i]=1;
			dfs(i);
		}
		cur=0;
		for(int i=0;i<100100;i++)v[i]=0;
		for(int i=100100-1;i>=0;i--){
			if(v[num[i]])continue;
			v[num[i]]=1;
			fi[cur]=num[i];
			dfs2(num[i]);
			cur++;
		}
		bool ok=true;
		for(int i=0;i<a;i++){
			if(scc[i*2]==scc[i*2+1])ok=false;
		}
		if(ok)left=M;
		else right=M;
	}
	printf("%d\n",left);
}

Measured memory_bytes: 25344
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int W[N];
  int sum=0;
  for (int i=0;i<N;i++){
    cin >> W[i];
    sum+=W[i];
  }
  int ans=sum;
  for (int i=0;i<N;i++){
    sum-=2*W[i];
    ans=min(ans,abs(sum));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <cstdio>

using namespace std;

void split(string str, char del, vector<string> &result)
{
    int first = 0;
    int last = str.find_first_of(del);
  
    if (last == string::npos) last = str.size();

    while (first < str.size()) {
        string subStr(str, first, last - first);
 
        if (subStr.length() > 0 && subStr.compare(" ")) {
            result.push_back(subStr);
        }

        first = last + 1;
        last = str.find_first_of(del, first);
 
        if (last == string::npos) {
            last = str.size();
            if (last <= first) break;
        }
//cout << "first=" << first << " last=" << last << endl;
    }
}



int main()
{
    string s;
    string word;
    int lens;
    int num;
    const char* END = "END_OF_TEXT";

    cin >> word;                // 単語

    num = 0;

    while (1) {
        getline(cin, s);
//cout << s << endl;
        if ((lens = s.length()) == 0) continue;

        // 改行を削除
        if (s.at(lens-1) == '\n') {
            s.resize(lens-1);
        }

        if (s.compare(END) == 0) break;         // 終了

        char del = ' ';
 
        vector<string> result;

        split(s, del, result);

        vector<string>::iterator ip;
    
        for (ip = result.begin(); ip != result.end(); ip++) {
            string ss = *ip;

            string::const_iterator it = ss.begin();    // 入力用のイテレーター
            string::iterator res = ss.begin();         // 結果用のイテレーター
 
            while (it != ss.end()) {
                *res = tolower(*it);        // 一文字ずつ tolower を適応して result に入れる
                ++it;                       // 入力用イテレーターを進める
                ++res;                      // 出力用のイテレーターを進める
            }
 
           int l = ss.length();
           if (l > 0) {
               if (ss.at(l-1) == '.') {
                    ss.resize(l-1);       
               }
           }
           if (word.compare(ss) == 0) {
                num++;
           }
//cout << num << " : " << ss << endl;
        }
    }

    cout << num << endl;

    return 0;
}


Measured memory_bytes: 3200
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const int MXN = 1e6 + 200;
const long long MNN = 2e3 + 200;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

int n, m;
llong a[MNN], b[MNN], dp[MNN][MNN];

int main () {
    ios;
    cin >> n >> m;
    for(int i = 1; i <= n; i ++){
        cin >> a[i];
    }
    for(int j = 1; j <= m; j++){
        cin >> b[j];
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            dp[i][j] = (dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - 1] + MOD) % MOD;
            if(a[i] == b[j]){
                dp[i][j] = (dp[i][j] + dp[i - 1][j - 1] + 1) % MOD;
            }
        }
    }
    cout << (dp[n][m] + 1) % MOD;
    return 0;
}


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

int n, m, s;
int main()
{
	int i;
	cin >> n >> m;
	for (s = 1, i = 0; i < n; s *= 2, i++);
	s--;
	if (s < m || n == 1 && m == 1) {
		cout << -1;
		return 0;
	}
	if (n == 1 && m == 0) {
		cout << "0 1 1 0";
		return 0;
	}
	cout << m << " ";
    for (i = 0; i <= s; i++) {
		if (i == m) continue;
		printf("%d ", i);
    }
    cout << m << " ";
    for (i = s; i >= 0; i--) {
		if (i != m) printf("%d ", i);
    }
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector <int> ar(s.size(), 0);
	for(int i=0; i<s.size()-1; i++){
		if(s[i] == 'A' and s[i+1] == 'C')
			ar[i+1]++;
	}	
	for(int i=1; i<s.size(); i++) ar[i] += ar[i-1];
	while(q--){
		int l, r;
		cin >> l >> r;
		r--;
		l--;
		int res = ar[r];
		if(l > 0){
			res -= ar[l];
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 1488
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  string walls[H+2];
  for(int i = 0;i<H+2;i++){
    for(int j =0;j<W+2;j++){
      walls[i] += "#";
    }
  }
  for(int i = 1;i<=H;i++){
    string s;
    cin >> s;
    for(int j = 1;j<=W;j++){
      walls[i].at(j) = s.at(j-1);
    }
  }
  for(int i = 0;i<H+2;i++){
    cout << walls[i] <<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    int N,K,S;
    cin>>N>>K>>S;
    if(S<1e9){
        rep(i,K){cout<<S<<endl;}
        rep(i,N-K){cout<<S+1<<endl;}
    }
    else{
        rep(i,K){cout<<S<<endl;}
        rep(i,N-K){cout<<1<<endl;}
    }
}

Measured memory_bytes: 1280