akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
using namespace std;
double a[101];
double ans=0.0;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		ans+=(1.0/a[i]);
	ans=1/ans;
	cout<<ans;
	return 0;
}

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

int n;
string ans;

void dfs(int now,int nn)
{
	if(now==n)
	{
		cout<<ans<<endl;
		return ;
	}
	for(int i = 0;i<=nn+1;i++)
	{
		ans[now] = 'a'+i;
		dfs(now+1,max(nn,i));
	}
}

int main()
{
	cin >> n;
	ans = string(n,'a');
	dfs(0,-1);
}

Measured memory_bytes: 1536
a,b,c,d,e,f = map(int,input().split())

res = [100 * a, 0]
for x0 in range(31):
    for x1 in range(16):
        for x3 in range(1501):
            t1 = e*a*x0+e*b*x1-d*x3
            t2 = f-100*a*x0-100*b*x1-d*x3
            x2 = min(t1,t2) // c
            if x2 >= 0 and \
                (c*x2+d*x3)*res[0]-(100*a*x0+100*b*x1+c*x2+d*x3)*res[1]>0:
                res[0] = 100*a*x0+100*b*x1+c*x2+d*x3
                res[1] = c*x2+d*x3

print('{f} {s}'.format(f=res[0],s=res[1]))

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

int main(){
    int a,b;	cin >> a >> b;
    if(a+b >= 10){
	cout << "error" << endl;
    }else{
	cout << a+b << endl;
    }
}


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

#define MAX_N 1000

using namespace std;

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

    int rez = 0;
    while(n >= k)
    {
        rez ++;
        n /= k;
    }

    cout << rez + 1 << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define ll long long

using namespace std;

ll factorial(ll n){
  if(n == 1) return 1;
  else return n * factorial(n - 1) % 1000000007;
}

int main(void){

  int n;

  cin >> n;

  cout << factorial(n) << endl;

  return 0;

}


Measured memory_bytes: 1792
#include <iostream>

int main(){
    int n, T;
    int minCost = 1010;
    std::cin >> n >> T;
    for(int i = 0; i < n; i++){
        int c, t;
        std::cin >> c >> t;
        if(t <= T){
            minCost = std::min(minCost, c);
        }
    }
    if(minCost == 1010){
        std::cout << "TLE" << std::endl;
    }else{
        std::cout << minCost << std::endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string S, T;
	cin >> S >> T;
	if(S == T.substr(0, S.size()))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int n;
int f[100][10], p[100][11];

string solve(const char ca, const char cb, const char cc, const char cd)
{
  int a = ca - '0';
  int b = cb - '0';
  int c = cc - '0';
  int d = cd - '0';
  string e7 = "=7";
  string plus = "+";
  string minus = "-";
  if      (a + b + c + d == 7) return ca + plus + cb + plus + cc + plus + cd + e7;
  else if (a - b - c - d == 7) return ca + minus + cb + minus + cc + minus + cd + e7;
  else if (a + b + c - d == 7) return ca + plus + cb + plus + cc + minus + cd + e7;
  else if (a + b - c + d == 7) return ca + plus + cb + minus + cc + plus + cd + e7;
  else if (a + b - c - d == 7) return ca + plus + cb + minus + cc + minus + cd + e7;
  else if (a - b + c + d == 7) return ca + minus + cb + plus + cc + plus + cd + e7;
  else if (a - b - c + d == 7) return ca + minus + cb + minus + cc + plus + cd + e7;
  else if (a - b + c - d == 7) return ca + minus + cb + plus + cc + minus + cd + e7;
}

int main()
{
  char ca, cb, cc, cd;
  cin >> ca >> cb >> cc >> cd;
  cout << solve(ca, cb, cc, cd) << endl;
}


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

int main(){
  int A, B;
  cin >> A >> B;
  int y = -1;
  for(int i=1; i <= 1000; i++){
    if(i*8/100 == A && i*10/100 == B){
      y= i;
      break;
    }
  }
  
  cout << y << endl;
}

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

int main()
{
    int n; cin >> n;
    std::vector<string> ans;
    
    string str;
    while(n--){
    	cin >> str;
    	sort(str.begin(),str.end());
    	ans.push_back(str);
    }

    sort(ans.begin(),ans.end());
	long long int count = 0;
	int cur =0;
    for(int i=0;i<ans.size()-1;i++){
    	if(ans[i] != ans[i+1]) cur = 0;
    	else{
    		cur++;
    		count +=cur;
    	}
    }

    cout <<count << endl;

    return 0;
}


Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,rm;
    cin>>n;
    rm=n%10;
    if(rm==3)
        cout<<"bon"<<endl;
    else if(rm==0 || rm==1 || rm==6 || rm==8)
        cout<<"pon"<<endl;
    else
        cout<<"hon"<<endl;
   return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
 
using namespace std;
 
using i64 = long long;
#define forn(a, e) for (i64 a = 0; a < (i64)(e); a++)
#define forr(a, s, e) for (i64 a = s; a < (i64)(e); a++)
#define fore(e, a) for (auto& e : a)
 
#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif
 
using iip = pair<int, int>;
using llp = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;
 
template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }
 
template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }
 
template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }
template<typename T, size_t N>
istream& operator>>(istream& is, array<T, N>& c) { for (auto& e : c) is >> e; return is; }
 
template<typename ...T>
istream& read(T&... args) { return (cin >> ... >> args); }
 
static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }
 
constexpr int INF = 1e9;
constexpr int MXB = 20;
using bin = bitset<MXB>;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    rande.seed(chrono::steady_clock::now().time_since_epoch().count());
    
    int x, n;
    while (read(x, n)) {
        ivec p(n);
        read(p);

        set<int> ps(p.begin(), p.end());

        int d = INF;
        int bn = -1;
        forn(i, 1000) if (!ps.count(i)) {
            int dd = abs(x - i);
            if (uin(d, dd)) {
                bn = i;
            }
        }
        cout << bn << endl;
    }
}

Measured memory_bytes: 3604
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    long[] a=new long[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextLong();
    }
    Arrays.sort(a);
    boolean flg=true;
    for(int i=1;i<n;i++){
      if(a[i]==a[i-1]){
        flg=false;
        break;
      }
    }
    if(flg){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v;
    v.reserve(n);
    vector<int> c;
    c.reserve(n);
    for (int i = 0; i < n; ++i) cin >> v[i];
    for (int j = 0; j < n; ++j) cin >> c[j];

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (v[i] - c[i] > 0) {
            ans += v[i] - c[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/ruby -Ku

require 'pp'

pow = Hash.new

pow[-4] = 0.0625
for i in -3..7
  pow[i] = pow[i-1]*2
end

loop do
  n = gets.to_f
  break if n < 0

  bnum = String.new
  for i in -7..4
    bnum += n.div(pow[-i]).to_s
    n -= pow[-i] if n >= pow[-i]
    bnum += "." if i == 0
  end
  bnum = "NA" if n != 0
  
  puts bnum
end

Measured memory_bytes: 6280
#include <bits/stdc++.h>
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int a,b,c,d,compare;
    vector<int> vec(3);
    vector<char> vec2(3);
    cin>>a;
    vec[0]=(a/100)%10;
    vec[1]=(a/10)%10;
    vec[2]=a%10;
    a=a/1000;
    for(i=0;i<8;i++){
        compare=a;
        bitset<3> bit(i);
        for(j=0;j<3;j++){
            if(bit[j]==1){
                compare+=vec[j];
                vec2[j]='+';
            }else{
                compare-=vec[j];
                vec2[j]='-';
            }
        }
        //cerr<<compare<<endl;
        if(compare==7)break;
    }
    cout<<a;
    for(j=0;j<3;j++){
        cout<<vec2[j]<<vec[j];
    }
    cout<<"=7"<<endl;
}

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

int main(void)
{
	char List[10][6] = {".,!? ","abc","def","ghi","jkl","mno",
						"pqrs","tuv","wxyz"};
	char mozi[1205], out[76], tmp[2], o;
	int f1, c, p, oc, i, t, n;
	
	scanf("%d",&n);
	for(f1 = 1; f1 <= n; f1++)
	{
		scanf("%s",mozi);
		c = 0;
		p = 0;
		oc = 0;
		o = mozi[0];
		while(mozi[c] != '\0')
		{
				while(o == mozi[c])
				{
					c++;
					p++;
				}
				if(o == '0')
				{
					while(mozi[c] == '0' && mozi[c] != '\0')
						c++;
					o = mozi[c];
				}
				else{		
					tmp[0] = o;
					tmp[1] = '\0';
					i = atoi(tmp);
					t = strlen(List[i-1]);
					p = (p - 1) % t;
					out[oc] = List[i-1][p];
					oc++;
				}
				o = mozi[c];
				p = 0;
			}
		out[oc] = '\0';
		printf("%s\n",out);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
     
    int main(int argc, char* argv[])
    {
      int a, b;
      std::cin >> a;
      std::cin >> b;
      
      if (b % a == 0) {
        std::cout << a + b << std::endl;
      }
      else {
        std::cout << b - a << std::endl;
      }
    }

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 100000

int h,t,A1[N];
char A2[N][10];

void enqueue(char *s, int w)
{
  int i = 0;

  if(isFull()){
    fprintf(stderr,"overflow!\n");
    exit(2);
  }

  A1[t] = w;
  strcpy(A2[t],s);
  if(t + 1 == N) t = 0;
  else t++;
}

int dequeue()
{
  int w;

  if(isEmpty()){
    fprintf(stderr,"underflow!\n");
    exit(1);
  }

  w = h;
  if(h + 1 == N) h = 0;
  else h++;
 
  return w;
}

int isEmpty()
{
  return h == t;

}

int isFull()
{
  return h == (t + 1) % N;
}

void roundschedule(int x, int y)
{
  int i,num,z;
  int total = 0;
  char argv[10];

  for(i=0;i<x;i++){
    scanf("%s%d",argv,&num);
    enqueue(argv,num);
  }

  while(!isEmpty()){
    num = dequeue();
    if(y>=A1[num]){
      total += A1[num];
      printf("%s %d\n",A2[num],total);
    }
    else{
      z = A1[num] - y;
      total += y;
      enqueue(A2[num],z);
    }
  }
}

int main()
{
  int x,y;
  scanf("%d%d",&x,&y);
  roundschedule(x,y);

  return 0;
}



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

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int N = 12, M=1010, inf=1e9;
int n, m, a[M], msk[M], dp[M][1 << N];
void mnm(int &a, int b) { a = min(a, b);}
int main() {
	cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		cin >> a[i]; int b; cin >> b;
		for (int j = 1; j <= b; ++j) {
			int c; cin >> c;
			c--;
			msk[i] |= (1 << c);
		}
	}
	for (int i = 0; i <= m; ++i) fill(dp[i] + 0, dp[i] + (1 << n), inf);
	dp[0][0] = 0; dp[0][msk[1]] = a[1]; int ans = inf;
	for (int i=0; i<=m; ++i)
		for (int j = 0; j < (1 << n); ++j) {
			if (dp[i][j] < inf) {
				mnm(dp[i + 1][j], dp[i][j]);
				mnm(dp[i + 1][j | msk[i + 1]], dp[i][j] + a[i + 1]);
			}
			if (j == ((1 << n) - 1)) mnm(ans, dp[i][j]);
		}
	if (ans == inf) cout << -1 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 16256
if __name__ == "__main__":
    ABC = input().split(" ")
    x = [int(x) for x in ABC]

    if (x[0]<x[2] and x[2]<x[1]) or (x[0]>x[2] and x[2]>x[1]) :
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 2940
class Graph
  attr_accessor :node
  def initialize(n=nil)
    @node = Array.new(n){Node.new}
  end
  def print
    @node.size.times{|i|
      puts "#{i} #{node[i].cost}"
    }
  end
end

class Node
  attr_accessor :edges_to, :edges_cost, :done, :cost
  def initialize
    @edges_to = []
    @edges_cost = []
    @done = false
    @cost = 1.0 / 0.0
  end
  def >(other)
    return self.cost < other.cost ? true : false
  end
  def <(other)
    return self.cost > other.cost ? false : true
  end
end


class Heep
  def initialize
    @node = []
  end
  def insert(num)
    i = @node.size
    @node[i] = num
    p = (i+1)/2-1
    while i > 0 && @node[p] < @node[i]
      @node[i], @node[p] = @node[p], @node[i]
      i = p
      p = (i+1)/2-1
    end
  end
  def extract
    ret = @node[0]
    if @node.size > 1
      @node[0] = @node.pop()
      maxHeapify(0)
    else
      @node = []
    end
    return ret
  end
  def maxHeapify(i)
    h = @node.size
    largest = i
    l = 2 * i + 1
    largest = l if l < h && @node[l] > @node[largest]
    r = 2 * i + 2
    largest = r if r < h && @node[r] > @node[largest]
    if largest != i then
      @node[i], @node[largest] = @node[largest], @node[i]
      maxHeapify(largest)
    end
  end
  def size
    return @node.size
  end
  def contain(node)
    if @node.index(node) == nil
      return false
    else
      return true
    end
  end
end

n = gets.to_i
graph = Graph.new(n)

n.times{
  u, k, *vc = gets.split.map(&:to_i)
  k.times{|i|
    graph.node[u].edges_to << vc[2*i]
    graph.node[u].edges_cost << vc[2*i+1]
  }
}
q = Heep.new
graph.node[0].cost = 0
q.insert(graph.node[0])

loop do
  break if q.size == 0
  doneNode = q.extract
  doneNode.done = true
  doneNode.edges_to.size.times{|i|
    to = doneNode.edges_to[i]
    cost = doneNode.cost + doneNode.edges_cost[i]
    if cost < graph.node[to].cost then
      graph.node[to].cost = cost
      q.insert(graph.node[to])
    end
  }
end

graph.print

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

int main() {
  ll n,t;
  cin >> n >> t;
  vector<ll> time(n);
  rep(i,n) cin >> time[i];
  ll ans = 0;
  for (int i = 1; i < n; i++) {
    int tmp = time[i]-time[i-1];
    if (tmp <= t) {
      ans += tmp;
    } else {
      ans += t;
    }
  }
  ans += t;
  cout << ans << endl;
  return 0;
}

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

int main() {
    string s;
    cin>>s;
    int c=0;
    for(int i=0;i*2<=s.length()-1;i++){
        if(s[i]!=s[s.length()-i-1])c++;
    }
    cout<<c<<"\n";
	return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct BIT //0-indexed
{
	vector<int> node;
	int mn;

	BIT(int mn)
	{
		this->mn = mn;
		node.resize(mn + 1, 0);
	}

	void add(int i, int x)
	{
		i++;
		while (i <= mn)
		{
			node[i] += x;
			i += (i&-i);
		}
	}

	int sum(int i)
	{
		i++;
		int res = 0;
		while (i > 0)
		{
			res += node[i];
			i -= (i&-i);
		}
		return res;
	}
};

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

	int N;
	cin >> N;

	BIT bit(N + 10);

	bit.add(0, 2);
	bit.add(1, -2);

	int A;
	vector<int> AV(N + 1);
	rep(i, 0, N + 1)cin >> AV[i];


	pii p = mp(0, 2);
	int ans = 1;
	rep(i, 0, N + 1)
	{
		A = AV[i];
		if (i == 0)
		{
			if (1 < A)
			{
				cout << -1 << endl;
				return 0;
			}
			else if (A == 1)
			{
				if (N == 0)
				{
					cout << 1 << endl;
				}
				else
				{
					cout << -1 << endl;
				}
				return 0;
			}
		}
		while (A != 0)
		{
			int d = min(A, p.second);
			ans += (i - p.first)*d;
			A -= d, p.second -= d;
			bit.add(p.first + 1, d);
			bit.add(i, -d);
			if (p.second == 0)
			{
				if (A>0&&p.first + 1 == i)
				{
					cout << -1 << endl;
					return 0;
				}
				p = mp(p.first + 1, bit.sum(p.first + 1));
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4764
#include <iostream>
#include <algorithm>

const int INF = 1 << 30;
int X[100 + 1];

int main()
{
	int N;
	std::cin >> N;

	int minI = 110;
	int maxI = 0;

	for (int i = 0; i < N; ++i)
	{
		int x;
		std::cin >> x;
		minI = std::min(minI, x);
		maxI = std::max(maxI, x);
		++X[x];
	}

	int ans = INF;
	for (int p = minI; p <= maxI; ++p)
	{
		int cost = 0;
		for (int i = minI; i <= maxI; ++i)
		{
			if (X[i] == 0) continue;
			cost += (i - p) * (i - p) * X[i];
		}
		ans = std::min(ans, cost);
	}

	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 256
S = input()

ans = [0 for _ in range(len(S))]
r = 0
l = 0
tmp = 0
for i in range(len(S)):
    if(S[i] == "R"):
        if(l > 0):
            ans[tmp] = r//2+l-l//2
            ans[tmp-1] = r-r//2+l//2
            r = 0
            l = 0
        r += 1
    else:
        if(S[i-1] == "R"):
            tmp = i
        l += 1
        if(i == len(S)-1):
            ans[tmp] = r//2+l-l//2
            ans[tmp-1] = r-r//2+l//2
print(*ans)

Measured memory_bytes: 10756
#include <stdio.h>

void quicksort(int bottom, int top, int *data) {
	int lower, upper;
	int temp;
	int div;

	if (bottom >= top)
		return;
	div = data[bottom];
	for (lower = bottom, upper = top; lower < upper; ) {
		while (lower <= upper && data[lower] <= div)
			lower++;
		while (lower <= upper && data[upper] > div)
			upper --;
		if (lower < upper) {
			temp = data[lower];
			data[lower] = data[upper];
			data[upper] = temp;
		}
	}
	temp = data[bottom];
	data[bottom] = data[upper];
	data[upper] = temp;

	quicksort(bottom, upper - 1, data);
	quicksort(upper + 1, top, data);
}

int main(void) 
{
	int n;	/* ??\???: 2 < n < 1000 */
	int a[1000] = { 0 };		/* 1 <= i <= n, 0??\???,1000000??\??? */
	int i;
	int min;
	int minus;


	while (scanf("%d", &n) == 1) {
		if (n == 0) {
			break;
		}
		else {
			for (i = 0; i < n; i++) {
				scanf("%d", &a[i]);
			}

			quicksort(0, n - 1, a);
			

			min = a[1] - a[0];
			for (i = 1; i < n - 1; i++) {
				minus = a[i + 1] - a[i];
				if (minus < min) {
					min = minus;
				}
			}
		}
		printf("%d\n", min);
		/* ????????? */
		for (i = 0; i < n; i++) {
			a[i] = 0;
		}
	}

	return 0;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long a,long long b) {
	if(b==0) return a;
	return gcd(b,a%b);
}
int main() {
	long long a,b;
	cin>>a>>b;
	cout<<a*b/gcd(a,b);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  N %= 10;
  if (N == 3) {
    cout << "bon" << endl;
    return 0;
  }
  vector<int> hon_lst = {2,4,5,7,9};
  if (find(hon_lst.begin(), hon_lst.end(), N) != hon_lst.end()) {
    cout << "hon" << endl;
  } else {
    cout << "pon" << endl;
  }
  return 0;
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			String a=sc.nextLine();
			if(a.equals("1 1 0")||a.equals("0 0 1"))System.out.println("Open");
			else System.out.println("Close"); 
			
	}
}

Measured memory_bytes: 17188
#include<stdio.h>
#define INFTY (1 << 21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
int M[100][100];

void Dijkstra();

int main(){
  int i, j, u, k, v, w;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      M[i][j] = INFTY;
    }
  }

  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&u,&k);

    for(j = 0 ; j < k ; j++){
      scanf("%d%d",&v,&w);
      M[u][v] = w;
    }
  }

  Dijkstra();

  return 0;
}

void Dijkstra(){
  int i;
  int min, u, v;
  int d[100], color[100];

  for(i = 0 ; i < n ; i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;

  while(1){
    min = INFTY;
    u = -1;
    for(i = 0 ; i < n ; i++){
      if(min > d[i] && color[i] != BLACK){
	u = i;
	min = d[i];
      }
    }

    if(u == -1) break;

    color[u] = BLACK;
    for(v = 0 ; v < n ; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
	if(d[v] > d[u] + M[u][v]){
	  d[v] = d[u] + M[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }

  for(i = 0 ; i < n ; i++){
    printf("%d ",i);

    if(d[i] == INFTY) printf("-1\n");
    else printf("%d\n",d[i]);
  }
}
    
  



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

int main(){
	int N, K; cin>>N>>K;
  	if(K>(N-1)*(N-2)/2){
    	cout<<-1<<endl;
    	return 0;
    }
  	printf("%d\n", N-1+(N-1)*(N-2)/2-K);
  	for(int i=0;i<N-1;i++){
    	printf("1\n%d\n", i+2);
    }
  	int index=2, path=3;
  	for(int i=0;i<(N-1)*(N-2)/2-K;i++){
    	printf("%d\n%d\n", index, path);
      	if(path!=N)++path;
      	else{
          index++;
          path=index+1;
        }
    }
  return 0;
}

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

int main() {
	int h,w;cin >> h>>w;
	vector<string> v;
	for (int i=0;i<h;++i){
		string s;cin>>s;
		v.push_back(s);
	}
	for (int j=0;j<h;++j){
		for (int k=0;k<w;++k){
			if(v[j].substr(k,1)==".") {
				int cnt=0;
				for(int l=-1;l<2;++l){
					for(int m=-1;m<2;++m){
						if(j+l>=0 && j+l<h){
							if(k+m>=0 && k+m<w){
								if(v[j+l].substr(k+m,1)=="#"){
									 ++cnt;
								}
							}	
						}
					}	
				}
				v[j].replace(k,1,to_string(cnt));
			}
		}
		cout << v[j] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long, long> > vllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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;
}
bool cmp(pii& a, pii& b) {
  return a.second < b.second;
}
int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  vii v(n);
  fi(0, n) {
    cin >> v[i].first >> v[i].second;
  }
  sort(all(v), cmp);
  ll sum = 0;
  fi(0, n) {
    sum += v[i].first;
    if(sum > v[i].second) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1792
function Main(input) {
  input = input.split('\n')
  var N = parseInt(input[0])
  var A = input[1].split(' ').map(str => parseInt(str))
  var B = input[2].split(' ').map(str => parseInt(str))
  var allMonster = A.reduce((prev, current) => prev + current)

  for (var i = 0; i < N; i++) {
    if (A[i] <= B[i]) {
      B[i] -= A[i]
      A[i] = 0
      if (A[i + 1] <= B[i]) {
        A[i + 1] = 0
      } else {
        A[i + 1] -= B[i]
      }
    } else {
      A[i] -= B[i]
    }
  }

  var remainMonster = A.reduce((prev, current) => prev + current)
  console.log(allMonster - remainMonster)
}

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


Measured memory_bytes: 31840
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll  long long
#define ld double
#define pb push_back
#define mod 1000000007
#define M_PI 3.141592653589
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
ll binpow(ll a,ll b,ll m=mod)
{
    a%=mod;
    ll res=1;
    while(b>0)
    {
        if(b&1)
        res=(a*res)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
main()
{
    IO
    string s;
    ll n;
    cin>>n;
    map<string,ll> a;
    for(int x=0;x<n;x++)
    {
        cin>>s;
        ++a[s];
    }
    cout<<"AC x "<<a["AC"]<<"\n";
    cout<<"WA x "<<a["WA"]<<"\n";
    cout<<"TLE x "<<a["TLE"]<<"\n";
    cout<<"RE x "<<a["RE"]<<"\n";
}


Measured memory_bytes: 3664
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;



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


Measured memory_bytes: 256
n, m = map(int, input().split())
P_Y_list = [list(map(int, input().split()))+[i] for i in range(m)]
sorted_P_Y_list = sorted(P_Y_list, key=lambda x:(x[0], x[1]))

same_id = sorted_P_Y_list[0][0]
counter = 1

for element_list in sorted_P_Y_list:
    if same_id != element_list[0]:
        counter = 1
        same_id = element_list[0]

    element_list[1] = str(counter)
    counter += 1

sorted_P_Y_list.sort(key=lambda x:x[2])

for id in sorted_P_Y_list:
    print("%012d"%int(str(id[0]).zfill(6) + id[1].zfill(6)))

Measured memory_bytes: 35680
#include<bits/stdc++.h>
using namespace std;
int64_t mod=1e9+7;
int main(){
  int64_t h,w,k,i,j;
  vector<int64_t> f(9);
  cin>>h>>w>>k;
  vector<vector<int64_t>> t(w+1,vector<int64_t>(w+1)),c(h+1,vector<int64_t>(w+1));
  f.at(0)=1;
  f.at(1)=1;
  for(i=2;i<=8;i++) f.at(i)=f.at(i-1)+f.at(i-2);
  for(i=1;i<=w;i++){
    t.at(i).at(i)=f.at(i-1)*f.at(w-i);
    if(i>1) t.at(i).at(i-1)=f.at(i-2)*f.at(w-i);
    if(i<w) t.at(i).at(i+1)=f.at(i-1)*f.at(w-i-1);
  }
  c.at(0).at(1)=1;
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      c.at(i).at(j)=c.at(i-1).at(j)*t.at(j).at(j)%mod;
      if(j>1) c.at(i).at(j)=(c.at(i).at(j)+c.at(i-1).at(j-1)*t.at(j-1).at(j))%mod;
      if(j<w) c.at(i).at(j)=(c.at(i).at(j)+c.at(i-1).at(j+1)*t.at(j+1).at(j))%mod;
    }
  }
  cout<<c.at(h).at(k)<<endl;
}

Measured memory_bytes: 3640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
    }

    for i in 0..(n + 4 - 1/ 4){
        for j in 0..(n + 7 - 1/ 7) {
            if i * 4 + j * 7 == n {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}

Measured memory_bytes: 4476
require 'matrix'
mA = []
b = []
n,m = gets.chomp.split.map(&:to_i)
n.times do
    mA << gets.split.map(&:to_i)
end
m.times do
    b << gets.split.map(&:to_i)
end
ans = Matrix.rows(mA) * Matrix.rows(b)
ans.each do |i|
    puts i
end

Measured memory_bytes: 6984
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    lista=[105,135,165,189,195]
    n=INT()
    ct=0
    for i in range(1,n+1,2):
        if i in lista:
            ct+=1
    print(ct)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  map<int, int> m;
  vector<int> ab(6);
  rep(i, 6) {
    cin >> ab[i];
    ab[i]--;
    m[ab[i]]++;
  }

  bool ok = true;
  rep(i, 4) {
    if (m[i] >= 3)
      ok = false;
  }
  if (ok)
    cout << "YES\n";
  else
    cout << "NO\n";
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val N = sc.nextInt()
  val M = sc.nextInt()
  val po = BooleanArray(N + 1)
  val pena = IntArray(N + 1)
  Arrays.fill(pena, 0)
  for (i in 0 until M) {
    val p = sc.nextInt()
    val s = sc.next()
    if (s.equals("WA")) {
      if (!po[p]) {
        pena[p]++
      } else {
      }
    } else if (s.equals("AC")) {
      if (!po[p]) {
        po[p] = true
      }
    }
  }
  var penasum = 0
  var ans = 0
  for (i in 0..N) {
    if (po[i]) {
      ans++
      penasum += pena[i]
    }
  }

  System.out.println("$ans $penasum")
}



Measured memory_bytes: 67492
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    
const int N = 2e5 + 10;

ll gcd(ll a, ll b){
    return b == 0 ? a : gcd(b, a % b);
}
int n;
ll a[N], b[N], g, x, y;



void add_self(ll &a, ll b){
    a += b;
    if(a >= mod)a -= mod;
}



int main(){
   IOS

   cin>>n;

   int c0 = 0, c1 = 0, c2 = 0;

   map<pair<ll, ll>, int> mp;


   for(int i = 1; i <= n; i++){
       cin>>a[i]>>b[i];
       if(a[i] == 0 and b[i] == 0)c0++;
       else if(a[i] == 0)c1++;
       else if(b[i] == 0)c2++;
       else{
           if(b[i] < 0)a[i] *= -1LL, b[i] *= -1LL;
           g = gcd(abs(a[i]), abs(b[i]));           
           mp[{a[i]/g, b[i]/g}]++;
       }
   }

   ll ans = 0;
   ans += c0;

   vector<pii> comp;

   for(auto it : mp){
       if(it.first.first == 0 or it.first.second == 0){
           continue;
       }else{
            x = it.first.first, y = it.first.second;
            if(x < 0){
                comp.pb({it.second, mp[{y, -x}]});
                mp.erase(mp.find({y, -x}));
            }else{
                comp.pb({it.second, mp[{-y, x}]});
                mp.erase(mp.find({-y, x}));
            }
       }
   } 

 

   ll ta = 1LL, tb = 0LL;


   for(auto it : comp){
        tb = pwr(2, it.first) % mod;
        add_self(tb, pwr(2, it.second) % mod);
        tb = (tb -1LL + mod)%mod;
        ta = (ta % mod * tb %mod) % mod;
   }

   tb = pwr(2, c1)%mod;
   add_self(tb, pwr(2, c2)%mod);
   tb = (tb -1LL + mod)%mod;

   ta = (ta % mod * tb % mod)%mod;

 

//    ta = (ta - 1 + mod)%mod;

   ans = (ans + ta -1 + mod)%mod;

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

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 20932
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<string> S(N);
  vector<map<char, ll>> ms(N);
  for (int i = 0; i < N; i++) {
    cin >> S[i];
    for (int j = 0; j < S[i].length(); j++) {
      ms[i][S[i][j]]++;
    }
  }
  string ans = "";
  for (char c = 'a'; c <= 'z'; c++) {
    ll shared_num = 100;
    for (int i = 0; i < N; i++) {
      shared_num = min(shared_num, ms[i][c]);
    }
    ans += string(shared_num, c);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

a,b = li()
print(max(2*a-1, a+b, 2*b-1))

Measured memory_bytes: 3316
package main

import (
        "bufio"
        "fmt"
        "math"
        "os"
)

func solution(n int, p [][2]int) float64 {
        out := 0.0
        f := float64(fact(n))
        pref := float64(fact(n - 1))
        for i := 0; i < n; i++ {
                for j := 0; j < n; j++ {
                        if i != j {
                                x := p[i][0] - p[j][0]
                                y := p[i][1] - p[j][1]
                                out += math.Sqrt(float64(x*x+y*y)) * pref
                        }
                }
        }
        return out / f
}

func fact(x int) int {
        fact := 1
        for i := 1; i <= x; i++ {
                fact *= i
        }
        return fact
}
func main() {
        r := bufio.NewReader(os.Stdin)
        var n int
        fmt.Fscan(r, &n)
        p := make([][2]int, n)
        for i := range p {
                fmt.Fscan(r, &p[i][0], &p[i][1])
        }
        fmt.Println(solution(n, p))
}

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

int main(){
 	int n,m,x;
	cin >>n >> m>>x;
	int tmp;
	int l=0,r=0;
  	for(int i = 0; i < m;i++) {
      cin >> tmp;
      if(tmp < x)
        	l++;
      else
        	r++;
    }
      	cout << min(l,r)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
int n,ans;
int solve(int x) {
	int cnt=0;
	for (int i=1;i*i<=x;i++)
		if (x%i==0) {
			cnt++;
			if (x/i!=i) cnt++;
		}
	return cnt==8&&x%2==1;
}
int main() {

	read(n);
	for (int i=1;i<=n;i++) if (solve(i)) ans++;
	printf("%d\n",ans);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 3704
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

int main()
{
    ll n, y;

    cin >> n >> y;
    for (ll i = 0; i <= n; i++) {
        for (ll j = 0; j <= n; j++) {
            ll k = n - (i + j);

            if (k < 0 || k > n) continue;

            if (i * 1000 +
                j * 5000 +
                k * 10000 == y) {
                printf("%lld %lld %lld\n", k, j, i);
                return 0;
            }
        }
    }

    printf("-1 -1 -1\n");

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {

    // ここから入力
    
    string s;
    cin >> s;
    
    int n = s.size();
    
    if(s[n-1] == 's'){
        s += "es";
    }
    else{
        s.push_back('s');
    }
    
    cout << s << endl;

}


Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set;
using std::queue;
using std::priority_queue;
using std::stack;

typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef vector<string> VS;
typedef pair<int, int> PII;

int main(void) {
    int n;
    while (cin >> n) {
        if (n == 0) {
            break;
        }

        VII table(n);
        int number;
        int temp;
        VI ans;

        for (int i = 0; i < n; i++) {
            cin >> number;
            if (number == 0) {
                continue;
            }
            for (int j = 0; j < number; j++) {
                cin >> temp;
                table[i].push_back(temp);
            }
        }
        for (int j = 0; j < n; j++) {
            sort(table[j].begin(), table[j].end());
        }
        cin >> number;
        for (int j = 0; j < number; j++) {
            cin >> temp;
            ans.push_back(temp);
        }
        sort(ans.begin(), ans.end());


        int count = 0;
        int output;
        for (int i = 0; i < n; i++) {
            /*
               for (int m = 0; m < table[i].size(); m++) {
               cout << table[i][m] <<endl;
               }
               cout << endl;
               if (table[i].size() < ans.size()) {
               continue; 
               }
             */

            int j = 0;
            for (int k = 0; k < table[i].size(); k++) {
                //cout << "J = " << j << endl;
                //cout << table[i][k] << " " << ans[j] << endl;
                if (table[i][k] == ans[j]) {
                    j++;
                }
                if (j == ans.size()) {
                //cout << i << j << k << count << endl;
                    count++;
                    output = i + 1;
                    break;
                }
            }
        }
        if (count != 1) {
            //cout << "C = " << count << endl;
            cout << -1 << endl;
        } else {
            //cout << "C = " << count << endl;
            cout << output << endl;
        }
    }

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> l(n);
    rep(i,n) cin >> l[i];
    int ans = 0;
    
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=j+1; k<n; k++){
                if(i==j || i==k || j==k || l[i]==l[j] || l[i]==l[k] || l[j]==l[k]) continue;
                if(l[i]+l[j]>l[k] && l[j]+l[k]>l[i] && l[k]+l[i]>l[j]) ans++;
            }
        }
    }

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

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

int main() {
  int n;
  cin >> n;
  string a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a.at(i) == b.at(i) && b.at(i) == c.at(i)) {
      continue;
    }
    if (a.at(i) == b.at(i) || b.at(i) == c.at(i) || a.at(i) == c.at(i)) {
      ans++;
      continue;
    }
    ans += 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N,K = gets.chomp.split(" ").map(&:to_i)
h_s = []
N.times do |i|
    h_s << gets.chomp.to_i
end
h_s = h_s.sort
sort_h_s = []
(h_s.length-K+1).times do |i|
    sort_h_s << h_s[i+K-1] - h_s[i]
end
puts sort_h_s.min


Measured memory_bytes: 5152
n=int(input())
s=input()
for i in range(4):
    a=[i%2,i//2]+[1]*n
    for i in range(2,n+2):a[i]^=a[i-2]^a[i-1]^(s[(i-1)%n]=='o')
    if a[:2]==a[-2:]:
        for i in range(n):print('SW'[a[i]],end='')
        exit()
print(-1)

Measured memory_bytes: 6740
#include <bits/stdc++.h>
using namespace std;
const int MAXN=30;
int a,b,ans;
string s,t,r;
int main () {
	cin >> s >> t >> a >> b >> r;
	if (r==s) {printf("%d %d\n",a-1,b);}
	else if (r==t) {printf("%d %d\n",a,b-1);}
	else {printf("%d %d\n",a,b);}
	return 0;
}

Measured memory_bytes: 256
s = input()
k = int(input())

l = len(s)
cnt = 0
cnt_list = [0]

for i in range(l-1):#sの中での連続数
    if s[i] == s[i+1]:
        cnt += 1
        cnt_list.append(cnt)
    else:
        cnt = 0
        cnt_list.append(cnt)
#print(cnt_list)

for i in range(l-1):#sの末尾と最初がつながっているとき
    if s[-1] == s[i]:
        cnt += 1
        cnt_list.append(cnt)
    else:
        break
#print(cnt_list)
L = len(cnt_list)

if len(set(s)) == 1:#1文字のみのとき
    print(l*k//2)
    
elif k == 1:#k = 1の時  
    ans = 0
    for i in cnt_list[:l]:#最初のl文字での回数
        if i % 2 == 1:
            ans += 1
    print(ans)
    
else:
    cnt_ref = cnt_list[L-l:] #繰り返し部分
    ans_ref = 0
    for i in cnt_ref:
        if i % 2 == 1:
            ans_ref += 1
    num_ref = (k*l-L) // l #num回繰り返す 
    #print("ans_ref =" ,ans_ref)
    
    amari = (k*l-L) % l
    ans_amari = 0
    for i in cnt_ref[:amari]:
        if i % 2 == 1:
            ans_amari += 1
    #print("ans_amari", ans_amari)
    #print("cnt_ref[:amari] = ", cnt_ref[:amari])  
    
    ans = 0
    for i in cnt_list:
        if i % 2 == 1:
            ans += 1
    #print("ans = ",ans)
    
    ans += ans_amari + ans_ref * num_ref
    print(ans)

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {
	
	static boolean search(int[] a, int n, int key) {
		a[n] = key;
		int i = 0;
		while (a[i] != key)
			i++;
		return i != n;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n+1];
		for (int i=0; i<n; i++) {
			a[i] = sc.nextInt();
		}
		
		int sum = 0;
		
		int q = sc.nextInt();
		for (int i=0; i<q; i++) {
			int key = sc.nextInt();
			if (search(a, n, key))
				sum ++;
		}
		
		sc.close();
		
		System.out.println(sum);
	}

}



Measured memory_bytes: 40596
n,m = map(int,input().split())
dp = [0]+[10**8+10]*(2**n-1)
for i in range(m):
  a,b = map(int,input().split())
  s = sum([2**(x-1) for x in list(map(int,input().split()))])
  for j in range(2**n):
    dp[j|s] = min(dp[j|s],dp[j]+a)
if dp[-1] <= 10**8:
  print(dp[-1])
else:
  print(-1)


Measured memory_bytes: 48088
#include <bits/stdc++.h>
using namespace std;
const int MAXN=10000010;
int N,M,L,R;char Ans[MAXN],s[MAXN];
int main()
{
	L=R=300000;
	--R;
	scanf("%s",s+1);
	N=strlen(s+1);
	for (int i=1;i<=N;++i) Ans[++R]=s[i];
	cin>>M;
	bool Mark=false;
	for (int i=1;i<=M;++i)
	{
		int type;
		scanf("%d",&type);
		if (type==1) Mark^=1;
		else
		{
			int f;
			scanf("%d",&f);
			char c;
			scanf(" %c",&c);
			if (Mark)
			{
				if (f==1) Ans[++R]=c;
				else Ans[--L]=c;
			}
			else
			{
				if (f==1) Ans[--L]=c;
				else Ans[++R]=c;
			}
		}
	}
	if (Mark)
	{
		for (int i=R;i>=L;--i) printf("%c",Ans[i]);
		printf("\n");
	}
	else
	{
		for (int i=L;i<=R;++i) printf("%c",Ans[i]);
		printf("\n");
	}
	return 0;
}

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

using namespace std;

typedef pair<int,int> pii;
typedef vector<int> vi;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999



int main(){
    int n;
    cin>>n;
    int memo[100010]={};
    rep(i,n){
        int a,b;
        cin>>a>>b;
        memo[a]++;
        memo[b+1]--;
    }
    int ans=0;
    rep(i,100009){
        memo[i+1]=memo[i+1]+memo[i];
    }
    rep(i,100009){
        if(memo[i]+1>=i){
            ans=max(ans,i-1);
        }

    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1556