akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i,first,last) for(int i=first;i<=last;++i)
#define DOW(i,first,last) for(int i=first;i>=last;--i)
using namespace std;
inline int Read()
{
	int x(0),f(1);
	char c(getchar());
	while(c<'0'||'9'<c)
	{
		if(c=='-')
		{
			f=-1;
		}
		c=getchar();
	}
	while('0'<=c&&c<='9')
	{
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return f*x;
}
void Write(int x)
{
	if(x<0)
	{
		printf("-");
		x=-x;
	}
	if(9<x)
	{
		Write(x/10);
	}
	putchar(x%10+'0');
}
inline void Writeln(int x)
{
	Write(x);
	puts("");
}
struct Point
{
	double x,y;
	Point(double fx=0,double fy=0)
	{
		x=fx;
		y=fy;
	}
	void Read()
	{
		scanf("%lf%lf",&x,&y);
	}
	double operator ^(Point const b)const
	{
		return x*b.x+y*b.y;
	}
	double operator *(Point const b)const
	{
		return x*b.y-b.x*y;
	}
	double operator ==(Point const b)const
	{
		return sqrt((x-b.x)*(x-b.x)+(y-b.y)*(y-b.y));
	}
};
struct Vector
{
	Point a,b;
	Vector(Point f=Point(0,0),Point e=Point(0,0))
	{
		a=f;
		b=e;
	}
	double operator |(Vector const c)const
	{
		return (a.x-b.x)*(c.a.y-c.b.y)-(c.a.x-c.b.x)*(a.y-b.y);
	}
};
const int MAXN=1e5+5;
Point p0,p1,p2;
void Work()
{
	p2.Read();
	double c=Vector(p0,p1)|Vector(p0,p2);
	if(0<c)
	{
		printf("COUNTER_CLOCKWISE\n");
		return;
	}
	if(c<0)
	{
		printf("CLOCKWISE\n");
		return;
	}
	if(p0.x==p1.x&&p0.y==p1.y)
	{
		printf("ONLINE_FRONT\n");
		return;
	}
	if(p0.x==p2.x&&p0.y==p2.y)
	{
		printf("ON_SEGMENT\n");
		return;
	}
	if((p1.x<p0.x)^(p2.x<=p0.x)&&(p1.y<p0.y)^(p2.y<=p0.y))
	{
		printf("ONLINE_BACK\n");
		return;
	}
	double dis1=p0==p1;
	double dis2=p0==p2;
	if(dis1<dis2)
	{
		printf("ONLINE_FRONT\n");
		return;
	}
	printf("ON_SEGMENT\n");
}
int main()
{
	p0.Read();
	p1.Read();
	int q;
	scanf("%d",&q);
	REP(i,1,q)
	{
		Work();
	}
	return 0;
}


Measured memory_bytes: 3248
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e3+5;
char a[N];
int numn=0;
int nums=0;
int numw=0;
int nume=0;
bool check(){
    return (nums==numn||(nums&&numn))&&(nume==numw||(nume&&numw));
}
int main(){
    cin >> a;
    int n=strlen(a);
    
    for(int i=0;i<n;i++){
        if(a[i]=='S')nums++;
        if(a[i]=='E')nume++;
        if(a[i]=='W')numw++;
        if(a[i]=='N')numn++;
    }
    if(check()){
        cout << "Yes";
    
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct Edge {
    int from, to, cost;
};

int main() {
    int n, m, p;
    cin >> n >> m >> p;
    vector<Edge> edges(m);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        edges[i] = {a, b, -(c-p)};
    }

    vector<ll> d(n, 1e18), rev(n, 1e18);
    rev[n-1] = 0;
    for (int i = 0; i < n-1; i++) {
        for (auto &e: edges) {
            if (rev[e.to] == 1e18) continue;
            rev[e.from] = min(rev[e.from], rev[e.to]+e.cost);
        }
    }
    d[0] = 0;
    for (int i = 0; i < n; i++) {
        bool update = false;
        for (auto &e: edges) {
            if (d[e.from] == 1e18) continue;
            if (rev[e.to] == 1e18) continue;
            ll t = d[e.from] + e.cost;
            if (d[e.to] > t) {
                update = true;
                d[e.to] = t;
            }
        }
        if (i == n-1 && update) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    cout << max(-d[n-1], 0LL) << endl;
    
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

constexpr int MAX_N = 8000;

int pToIndex(int p) {
  return p+MAX_N;
}

int indexToP(int i) {
  return i-MAX_N;
}

bool is_valid(const vi& v, int p) {

  vvi dp(2, vi(MAX_N*2+1));
  dp[0][pToIndex(0)] = 1;

  for (auto m : v) {
    for (int i=0; i<=MAX_N*2+1; i++) {
      if (dp[0][i]) {
        int fromP = indexToP(i);
	for (int sign : {-1, 1}) {
	  int toP = fromP + sign*m;
	  int toIndex = pToIndex(toP);
	  dp[1][toIndex] = 1;
	}
      }
    }
    dp[0].swap(dp[1]);
    vi newV(MAX_N*2+1);
    dp[1].swap(newV);
  }

  return dp[0][pToIndex(p)];

  return false;
}

int main(int argc, char** argv) {
  string s;
  cin >> s;
  int x, y;
  cin >> x >> y;

  int i=0;
  for (; i<int(s.size()); i++) {
    if (s[i] == 'T') break;

    x--;
  }

  vvi moves(2);
  // 0: vertial moves
  // 1: horizontal moves

  int d = 1;
  for (; i<int(s.size()); i++) {
    if (s[i] == 'T') {
      d = d == 0 ? 1 : 0;
      moves[d].emplace_back(0);
    } else if (s[i] == 'F') {
      vi& v = moves[d];
      assert(!v.empty());
      v[v.size()-1]++;
    }
  }

  bool ok = is_valid(moves[0], y) && is_valid(moves[1], x);
  cout << (ok ? "Yes" : "No") << endl;


  return 0;
}


Measured memory_bytes: 580
#include<iostream>
//#include<vector>

int main(){
	long long int a,b,c,k;
	std::cin>>a>>b>>c>>k;

	if (k < a+b) {
		std::cout << k << std::endl;
	}else {
		std::cout << 2*a+b-k << std::endl;
	}



	//std::cout<<n<<std::endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 111111;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t;
    cin>>s>>t;
    int res=0;
    if(s[0]==t[0])res++;
    if(s[1]==t[1])res++;
    if(s[2]==t[2])res++;
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
using namespace std;

int main(){
    int A,B,C,X,Y;cin>>A>>B>>C>>X>>Y;
    long long ans;
    if(A+B<=2*C)ans=X*A+Y*B;
    else{
        int M,m,D;
        if(X>=Y){
            M=X-Y,m=Y;
            D=A;
        }
        else{
            M=Y-X,m=X;
            D=B;
        }
        ans=2*m*C;

        if(D>=2*C) ans+=2*C*M;
        else ans+=D*M;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
k = int(input())
X = list(map(int,input().split()))
for xi in X:
  ans += min(xi,abs(k-xi))*2
print(ans)


Measured memory_bytes: 3444
def euclid(a,n):
    a0 = a
    a1 = n
    x0 = 1
    x1 = 0
    while (a1!=1):
        q = a0 // a1
        temp = a1
        a1 = a0 - a1*q
        a0 = temp
        temp = x1
        x1 = x0 - q*x1
        x0 = temp
    if (x1 < 0):
        x1 = n + x1
    return x1


n, k = map(int, input().split())
r = n-k
z = 10**9+7
tm = [1]
for i in range(1, n+1):
    tm.append(tm[-1]*i%z)
tm.append(1)
print(r+1)
c = min(k, r+1)
a = tm[r+1]
i=1
for i in range(2,c+1):
    b = tm[k-1]*euclid(tm[i-1]*tm[k-i], z)%z
    print(b*a*euclid(tm[i]*tm[r-i+1]%z, z)%z)
for j in range(i, k):
    print(0)


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

int main(){
    int N;
    cin >> N;
    vector<string> s(N);
    string end_a[N];
    string first_b[N];
    string all[N];
    int cou_a = 0;
    int cou_b = 0;
    int cou_all = 0;
    int numb = N;

    for(int i = 0; i < N; i++){
        cin >> s[i];
    }

    for(int i = 0; i < numb; i++){
        if(s[i].substr(0,1) == "B" && s[i].substr(s[i].length() - 1, 1) == "A"){
            all[cou_all] = s[i];
            cou_all++;
            s.erase(s.begin() + i);
            numb--;
            i--;
        }else if(s[i].substr(0,1) == "B"){
            first_b[cou_b] = s[i];
            cou_b++;
            s.erase(s.begin() + i);
            numb--;
            i--;
        }else if(s[i].substr(s[i].length() - 1, 1) == "A"){
            end_a[cou_a] = s[i];
            cou_a++;
            s.erase(s.begin() + i);
            numb--;
            i--;
        }
    }

    string q;
    int ka = 0;
    int kb = 0;
    int kall = 0;

    if(cou_a != 0){
        q += end_a[ka];
        ka++;
    }else if(cou_all != 0){
        q += all[kall];
        kall++;
    }

    int ju = 0;

    while((cou_a + cou_all + cou_b) != (ka + kb + kall)){
        if((cou_all - kall) != 0){
            q+= all[kall];
            kall++;
            continue;
        }
        
        if((cou_b - kb) != 0 && ju == 0){
            q += first_b[kb];
            kb++;
            ju = 1;
        }else if((cou_a - ka)!= 0 && ju == 1){
            q += end_a[ka];
            ka++;
            ju = 0;
        }else{
            if((cou_a - ka) != 0){
                q += end_a[ka];
                ka++;
            }else{
                q += first_b[kb];
                kb++;
            }
        }
    }

    for(int i = 0; i < numb; i++){
        q += s[i];
    }

    int ans = 0;

    for(int i = 0; i < (q.length() - 1); i++){
        if(q.substr(i, 2) == "AB"){
            ans++;
        }
    }
    cout << ans << endl;

    /*cout << "nokori" << endl;
    for(int i = 0; i < numb; i++){
        cout << s[i] << endl;
    }

    cout << endl << "A" << endl;
    for(int i = 0; i < cou_a; i++){
        cout << end_a[i] << endl;
    }

    cout << endl << "B" << endl;
    for(int i = 0; i < cou_b; i++){
        cout << first_b[i] << endl;
    }

    cout << endl << "all" << endl;
    for(int i = 0; i < cou_all; i++){
        cout << all[i] << endl;
    }*/
}

Measured memory_bytes: 1152
# Node
class Node
  attr_accessor :id, :edges, :cost, :done

  def initialize(id, edges = [], cost = nil, done = false)
    @id, @edges, @cost, @done = id, edges, cost, done
  end
end

# Edge
class Edge
  attr_accessor :to, :cost

  def initialize(to, cost)
    @to, @cost = to, cost
  end
end

# Prim
class Prim
  attr_accessor :nodes

  def initialize(data)
    @nodes = {}
    data.each do |id, edges|
      edges.map! { |edge| Edge.new(*edge) }
      @nodes[id] = Node.new(id, edges)
    end
  end

  def start(id)
    cost = 0

    @nodes.each do |id, node|
      node.done = false
    end

    node = @nodes[id]
    node.done = true
    queue = node.edges

    until queue.empty?
      queue.sort! { |l, r| r.cost <=> l.cost }
      edge = queue.pop
      done_node = @nodes[edge.to]
      next if done_node.done
      done_node.done = true
      cost += edge.cost
      queue += done_node.edges
    end

    cost
  end
end

data = {}

n = gets.chop.to_i

n.times do |i|
  data[i] = []
  gets.chop.split.each_with_index do |item, index|
    item = item.to_i
    next if item == -1
    data[i] << [index, item]
  end
end

prime = Prim.new data
puts prime.start 0

Measured memory_bytes: 8432
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << (H - h) * (W - w) << endl;
  return 0;
}


Measured memory_bytes: 256
/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
//别急 dp找状态 问题看看本身的规律 贪心找方法
ll a[maxn];
ll fact[maxn],infact[maxn];
ll qmi(ll a,ll b) {
	ll res=1;
	while(b) {
		if(b&1) res=res*a%mod;
		b>>=1;
		a=a*a%mod;
	}
	return res;
}
void init(int n) 
{
	fact[0]=infact[0]=1;
	for(int i=1;i<=n;i++) {
		fact[i]=fact[i-1]*i%mod;
		infact[i]=infact[i-1]*qmi(i,mod-2)%mod;
	}
}
ll C(int a,int b) {
	ll ans=fact[a]*infact[a-b]%mod*infact[b]%mod;
	return ans;
}
int Xiaobo()
{	
	int  n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) {
		scanf("%lld",&a[i]);
	//	if(a[i]<0) a[i]+=mod;
 	}
	init(n);
	sort(a+1,a+1+n); 
	ll ans1=0,ans2=0;
	for(int i=k;i<=n;i++) {
		ans1+=C(i-1,k-1)*a[i]%mod;
		ans1%=mod;
	}
	for(int i=1;i<=n-k+1;i++) {
		ans2+=C(n-i,k-1)*a[i]%mod;
		ans2%=mod;
	}
//	cout<<ans1<<' '<<ans2<<'\n';
	cout<<(ans1-ans2+mod)%mod;
	return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

string s[] = { "AAA", "AA", "A", "B", "C", "D", "E" };
double a, b, table[2][7] = { { 35.5, 37.5, 40, 43, 50, 55, 70 },
{ 71, 77, 83, 89, 105, 116, 148 } };

int main(){
	while (cin >> a >> b){
		for (int i = 0; i < 7; i++){
			if (a < table[0][i] && b < table[1][i]){
				cout << s[i] << endl;
				break;
			}
			if (i == 6)cout << "NA\n";
		}
	}
}

Measured memory_bytes: 1228
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

#define PI 3.141592653589793238
#define INF 1050000000

using namespace std;



//cout << fixed << setprecision(15) << << endl;
//cout << << endl;

int main() {

	int X,A,B;

	cin >>X>> A>>B;

	if (B - A <= 0) {
		cout << "delicious" << endl;
	}
	else if (B - A <=  X) {
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}

	
	return 0;
}

Measured memory_bytes: 256
from functools import reduce
N = int(input())
A = list(map(int,input().split()))
B = list(map(lambda x: x+0.5, A))
C = reduce(lambda a, b: a*b, B)
D = sorted(list(map(abs, A)))
if C < 0:
	print(sum(D)-2*D[0])
else:
	print(sum(D))

Measured memory_bytes: 16060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    int s[1000], n, i;
    double standard = 0.0, sum = 0.0, average = 0.0;
    
    while((scanf("%d" ,&n) != EOF) && (n != 0))
    {
        double standard = 0.0, sum = 0.0, average = 0.0;
    
        for(i = 0; i < n; i++)
        {
            scanf("%d" ,&s[i]);
            sum += s[i];
        }
        average = sum / n;
        for(i = 0; i < n; i++)
            standard += (s[i] - average) * (s[i] - average);
        printf("%f\n", sqrt(standard/n));
    }
    return 0;
}
    



Measured memory_bytes: 2708
// デバッグ実行：Ctrl+F5

using System;

class Program
{
    static void Main(string[] args)
    {
        String line;
        line = Console.ReadLine();
        String[] words = line.Split(' ');
		int N;
		int i;
		N = int.Parse(words[0]);
		i = int.Parse(words[1]);
		
        Console.WriteLine(N-i+1);
    }
}

Measured memory_bytes: 13140
#n=int(input())
n,m=map(int,input().split())
#al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append([a,b])

l.sort(key=lambda x: x[0])
count=0;cost=0
for i in range(n):
    a,b=l[i][0],l[i][1]
    if count+b>=m:
        cost+=a*(m-count)
        break
    else:
        cost+=a*b
        count+=b
print(cost)

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

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 300;

long long A[N][N];
bool f[N][N];

int main() {
	int n;cin>>n;
	rep(i,n) rep(j,n) {cin>>A[i][j];f[i][j]=false;}
	rep(i,n) {
		rep(j,i) {
			rep(k,n) {
				if (k==i || k==j) continue;
				if (f[i][j]) continue;
				if (A[i][j]==A[i][k]+A[k][j]) f[i][j]=true;
				else if (A[i][j]>A[i][k]+A[k][j]) {cout<<-1<<endl;return 0;}
			}
		}
	}
	long long ans=0;
	rep(i,n) rep(j,i) if(!f[i][j]) ans+=A[i][j];
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#define MAX 100
int main(void){
  int i, j, cnt = 0, minj, k,temp;
  int numbers[100];
 
  scanf("%d", &k);
   
  for(i = 0;i < k;i++){
    scanf("%d", &numbers[i]);
  }
 
  for(i = 0; i < k; i++ ) {
    minj = i;
    for(j= i; j < k; j++)  {
      if(numbers[j] < numbers[minj]) {
         minj = j;
      }
    }
      if(numbers[minj] < numbers[i]) {
         temp = numbers[i];
         numbers[i] = numbers[minj];
         numbers[minj] = temp;
         cnt++;
      }
  }
  


  for(i=0; i<k; i++) {
      printf("%d", numbers[i]);
      if(i<k-1){
      printf(" ");
      }
  }


  printf("\n");
  printf("%d\n", cnt);

  return 0;  
}


Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    int n; cin >> n;

    double v[n];
    for(int i=0; i<n; i++){
        cin >> v[i];
    }

    sort(v, v+n);

    double ans = v[0];
    for(int i=1; i<n; i++){
        ans = (ans + v[i])/2.0;
    }

    cout << ans;



    return 0;
}

Measured memory_bytes: 256
X = int(input())
if X >= 2100:
    print(1)
    exit()

for a in range(21):
    for b in range(21-a):
        for c in range(21-a-b):
            for d in range(21-a-b-c):
                for e in range(21-a-b-c-d):
                    for f in range(21-a-b-c-d-e):
                        if 100*a +101*b +102*c +103*d +104*e + 105*f == X:
                            print(1)
                            exit()

print(0)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
#include <array>
#include <chrono>
#include <random>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
// VAR(int, x);
#define VAR(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { std::cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { std::cin >> first; Scan(rest...); }
#define OUT(d) std::cout<<d;
#define FOUT(n, d) std::cout<<std::fixed<<std::setprecision(n)<<d;
#define SOUT(n, c, d) std::cout<<std::setw(n)<<std::setfill(c)<<d;
#define SP std::cout<<" ";
#define TAB std::cout<<"\t";
#define BR std::cout<<"\n";
#define ENDL std::cout<<std::endl;
#define FLUSH std::cout<<std::flush;
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define MAT(type, c, m, n) std::vector<std::vector<type>> c(m, std::vector<type>(n));for(auto& r:c)for(auto& i:r)std::cin>>i;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
#define PAIR std::pair<int, int>
#define IN(a, x, b) (a<=x && x<=b)
#define IN2(a0, y, a1, b0, x, b1) (a0<=y && y<a1 && b0<=x && x<b1)
#define SHOW(d) {std::cout << #d << "\t:" << d << "\n";}
#define SHOWVECTOR(v) {std::cout << #v << "\t:";for(const auto& i : v){std::cout << i << " ";}std::cout << "\n";}
#define SHOWVECTOR2(v) {std::cout << #v << "\t:\n";for(const auto& i : v){for(const auto& j : i){std::cout << j << " ";}std::cout << "\n";}}
#define SHOWPAIRVECTOR2(v) {std::cout << #v << "\t:\n";for(const auto& i : v){for(const auto& j : i){std::cout<<'('<<j.first<<", "<<j.second<<") ";}std::cout << "\n";}}
#define SHOWPAIRVECTOR(v) {for(const auto& i:v){std::cout<<'('<<i.first<<", "<<i.second<<") ";}std::cout<<"\n";}
#define CHECKTIME(state) {auto start=std::chrono::system_clock::now();state;auto end=std::chrono::system_clock::now();auto res=std::chrono::duration_cast<std::chrono::nanoseconds>(end-start).count();std::cerr<<"[Time:"<<res<<"ns  ("<<res/(1.0e9)<<"s)]\n";}

#define int ll
using ll = long long;
constexpr int INFINT = 1 << 30;
constexpr ll INFLL = 1LL << 60;
constexpr double EPS = 0.0000001;
constexpr int MOD = 1000000007;

signed main() {
	INIT;
	VAR(ll, n, x);
	ll ans = n;
	ll a = x, b = n - x;
	while (true) {
		if (b % a == 0) {
			ans += b / a * 2 * a - a;
			break;
		}
		else {
			ans += b / a * 2 * a;
			ll t = b;
			b = a;
			a = t - (t / a) * a;
		}
	}
	OUT(ans)BR;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <map>

using namespace std;
using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    vector<int> a1;
    vector<int> a2;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        if (i%2==0) a1.push_back(a);
        else a2.push_back(a);
    }

    sort(a1.begin(), a1.end());
    sort(a2.begin(), a2.end());

    vector<P> al1;
    al1.emplace_back(0, -1);
    al1.emplace_back(0, a1[0]);
    for (int i=0; i<n/2; i++) {
        if (al1.back().second == a1[i]) al1.back().first++;
        else al1.emplace_back(1, a1[i]);
    }

    vector<P> al2;
    al2.emplace_back(0, -1);
    al2.emplace_back(0, a2[0]);
    for (int i=0; i<n/2; i++) {
        if (al2.back().second == a2[i]) al2.back().first++;
        else al2.emplace_back(1, a2[i]);
    }

    sort(al1.rbegin(), al1.rend());
    sort(al2.rbegin(), al2.rend());

    int ans = 0;
    if (al1[0].second == al2[0].second) {
        int _1 = (n/2 - al1[0].first) + (n/2 - al2[1].first);
        int _2 = (n/2 - al1[1].first) + (n/2 - al2[0].first);
        ans = min(_1, _2);
    } else {
        ans = (n/2 - al1[0].first) + (n/2 - al2[0].first);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1784
using System;

namespace ITP1_6_C
{
    class Program
    {
        static void Main()
        {
            for (; ; )
            {
                string[] Point = Console.ReadLine().Split(' ');
                int m = int.Parse(Point[0]);
                int f = int.Parse(Point[1]);
                int r = int.Parse(Point[2]);
                int sum = m + f;

                if (m == -1 && f == -1 && r == -1) break;

                else if (m == -1 || f == -1) Console.WriteLine("F");

                else if (sum >= 80) Console.WriteLine("A");

                else if (sum >= 65) Console.WriteLine("B");

                else if (sum >= 50 || r >= 50) Console.WriteLine("C");

                else if (sum >= 30) Console.WriteLine("D");

                else Console.WriteLine("F");
            }
        }
    }
}

Measured memory_bytes: 8912
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, A;
ll dp[100][5010];

void solve() {
	cin >> N >> A;
	dp[0][2500] = 1;
	rep(i, 0, N) {
		int a; cin >> a; a -= A;
		rep(j, 0, 5000) {
			if(!dp[i][j]) continue;
			dp[i + 1][j] += dp[i][j];
			dp[i + 1][j + a] += dp[i][j];
		}
	}
	cout << dp[N][2500] - 1 << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n;
  cin>>n;
  int sum=0;
  int mx=0;
  REP(i,n) {
    int p;
    cin>>p;
    sum+=p;
    mx=max(mx,p);
  }
  cout<<(sum-mx/2)<<endl;
  return 0;
}


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

int main(void)
{
	int n, m, A[100][100] = { {} }, Sum=0;
	cin >> n >> m;

	for (int i = 0; i < n; i++)
	{
		int sum = 0;
		for (int j = 0; j < m; j++)
		{
			cin >> A[i][j];
			sum += A[i][j];
			cout << A[i][j] << " ";
		}
		cout << sum <<endl;
		Sum += sum;
	}
	for (int j = 0; j < m; j++)
	{
		int sum = 0;
		for (int i = 0; i < n; i++)
		{
			sum += A[i][j];
		}
		cout << sum << " ";
	}
	cout << Sum << endl;
	return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <stdio.h>
#include <set>
#include<bits/stdc++.h>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;
int pos(int a ){
    if(a>=0){return a;}
    return -a;
}
int arr[1000006];
int main(){
    int n;
    cin>>n;
    vector <int> v;
    v.push_back(0);
    for(int i = 1;i<=n;i++){
        int z;
        scanf("%d",&z );
        arr[z] += 1;
        v.push_back(z);
    }
    int answer = 0;
    for(int i = 1;i<=n;i++){
        arr[v[i] ]--;
        bool good = true;
        for(int j = 1;j*j<=v[i];j++ ){
            if(v[i]%j==0 ){
                if(arr[j ] ){
                    good = false;
                    break;
                }
                if(arr[v[i]/j ] ){
                    good = false;
                    break;
                }
            }
        }
        if(good){
            answer++;
        }
        arr[v[i] ]++;
    }
    cout<<answer;
}


Measured memory_bytes: 8236
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
 
int a[100000];
vector<int>E[100000];
 
int dfs(int u) {
	vector<int>V;
	for (int v : E[u]) {
		V.push_back(dfs(v));
	}
	sort(V.begin(), V.end(), greater<int>());
	int a = 1;
	int res = 0;
	for (int t : V) {
		res = max(res, a + t);
		a++;
	}
	return res;
}
signed main() {
	int n; scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		scanf("%d", &a[i]); a[i]--;
		E[a[i]].push_back(i);
	}
	printf("%d\n", dfs(0));
}


Measured memory_bytes: 13952
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, m, cnt, x, y, d[MAXN];
vector <int> a[MAXN];
void dfs(int pos, int from) {
	if (pos == x && from) return;
	if (pos == y) {
		cnt++;
		return;
	}
	for (auto x : a[pos])
		if (x != from) dfs(x, pos);
}
int main() {
	read(n), read(m);
	if (m < n + 2) {
		puts("No");
		return 0;
	}
	for (int i = 1; i <= m; i++) {
		int x, y; read(x), read(y);
		d[x]++, d[y]++;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	for (int i = 1; i <= n; i++)
		if (d[i] % 2) {
			puts("No");
			return 0;
		}
	x = 0, y = 0;
	for (int i = 1; i <= n; i++)
		if (d[i] > 2) {
			if (d[i] > 4) {
				puts("Yes");
				return 0;
			}
			if (x == 0) x = i;
			else if (y == 0) y = i;
			else {
				puts("Yes");
				return 0;
			}
		}
	dfs(x, 0);
	if (cnt == 4) puts("No");
	else {
		assert(cnt == 2);
		puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 9600
import java.util.*;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(); //500yen
		int b = sc.nextInt(); //100yen
		int c = sc.nextInt(); //50yen
		int x = sc.nextInt(); //all
		int ans = 0;
		
		for(int i=0; i<a+1; i++) {
			for(int j=0; j<b+1; j++) {
				for(int k=0; k<c+1; k++) {
					if(i*500 + j*100 + k *50 == x) {
						ans++;
					}
				}
			}
		}
		
		System.out.println(ans);
		
		sc.close();
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,m,i,j;
    cin>>n>>m;
    vector<string> a,b;
    string s;
    for (i=0;i<n;i++)
    {
        cin>>s;
        a.pb(s);
    }
    for (i=0;i<m;i++)
    {
        cin>>s;
        b.pb(s);
    }
    int x,y,ans=0;
    for (x=0;x<n-m+1;x++)
    {
        for (y=0;y<n-m+1;y++)
        {
            int f=0;
            for (i=0;i<m;i++)
            {
                for (j=0;j<m;j++)
                {
                    if (b[i][j]!=a[x+i][y+j])
                    {
                        f=1;
                        break;
                    }
                }
                if (f)
                    break;
            }
            if (!f)
            {
                ans=1;
                break;
            }
        }
        if (ans)
            break;
    }
    if (ans)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpii = vector<pll>;

int main(){
  ll a, b, h;
  cin >> a >> b >> h;

  cout << (a + b) * h / 2 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool is_prime(int n) {
  for (int i = 2; i * i < n; i++) {
    if (n % i == 0) {
      return false;
    }
  }

  return true;
}

int main(int argc, const char *argv[]) {
  int x;
  cin >> x;
  while (!is_prime(x)) {
    x++;
  }

  cout << x << "\n";
  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 y = sc.nextInt();// 人が座る幅
        int z = sc.nextInt();// 間の幅

        x -= z;// はじめの間をあける
        int count = 0;
        while (x > 0 && x - (y+z) >= 0) {
            x -= y;
            x -= z;
            count++;
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 23764
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

long long f[30000000];
int i,u1,u2,u3,v1,v2,v3;
long long n,s;

int main()
{
	scanf("%lld",&n);
	scanf("%d%d%d%d%d%d",&u1,&u2,&u3,&v1,&v2,&v3);
	for (i=u1;i<=n;i++) f[i]=max(f[i],f[i-u1]+v1);
	for (i=u2;i<=n;i++) f[i]=max(f[i],f[i-u2]+v2);
	for (i=u3;i<=n;i++) f[i]=max(f[i],f[i-u3]+v3);
	for (i=0;i<=n;i++) s=max(s,f[i]+n-i);
	n=s;
	memset(f,0,sizeof(f));
	for (i=v1;i<=n;i++) f[i]=max(f[i],f[i-v1]+u1);
	for (i=v2;i<=n;i++) f[i]=max(f[i],f[i-v2]+u2);
	for (i=v3;i<=n;i++) f[i]=max(f[i],f[i-v3]+u3);
	for (i=0;i<=n;i++) s=max(s,f[i]+n-i);
	printf("%lld",s);
	return 0;
}

Measured memory_bytes: 234496
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, X, Y;
  cin >> N >> X >> Y;
  X--;
  Y--;
  vl A(N, 0);
  REP(i, N - 1) A[i + 1] = N - 1 - i;
  // REP(i, N - 1) cout << A[i] << endl;
  REP(i, N) FOR(j, i + 1, N) {
    /*if (j <= X)
      continue;
    else if (Y <= i)
      continue;*/
    if (i >= j)
      continue;
    ll po = abs(X - i) + abs(Y - j) + 1;
    if (j - i > po) {
      A[j - i]--;
      A[po]++;
      // cout << i << "," << j << "," << j - i << "," << po << endl;
    }
  }
  REP(i, N - 1) cout << A[i + 1] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a,b;
  cin>>a>>b;
  if(a.at(0)==b.at(2) && a.at(1)==b.at(1) && a.at(2)==b.at(0)){
    cout<<"YES"<<endl;
    return 0;
  }
    cout<<"NO"<<endl;
}
  


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
#define coa cout << ans << endl; return 0;
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;


int main(){
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i, n) cin >> s[i];

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

    string ans = "";
    for(auto iter = s.begin(); iter != s.end(); iter++){
        ans += *iter;
    }

    coa;
}


Measured memory_bytes: 3636
n = int(input())
a = list(map(int,input().split()))
ans = True
for i in a:
  if i % 2 == 0:
    if not (i % 3 == 0 or i % 5 == 0):
      ans = False
      break
if ans:
  print('APPROVED')
else:
  print('DENIED')


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

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    if(M != N)
        No();
    else
        Yes();
    return 0;
}

Measured memory_bytes: 256
(N,M),*AB = $<.map{|ln| ln.split.map(&:to_i) }

友達の輪と大きさ = [-1]*(N+1)
輪 = lambda{|人|
	next 友達の輪と大きさ[人]<0 ? 人 : 友達の輪と大きさ[人]=輪[友達の輪と大きさ[人]]
}
輪の大きさ = lambda{|人|
	next -友達の輪と大きさ[輪[人]]
}
友達です = lambda{|人人|
	輪1,輪2 = 人人.map(&輪)
	next if 輪1 == 輪2

	輪小,輪大 = 友達の輪と大きさ[輪1]<友達の輪と大きさ[輪2] ? [輪2,輪1] : [輪1,輪2]
	友達の輪と大きさ[輪大] += 友達の輪と大きさ[輪小]
	友達の輪と大きさ[輪小] = 輪大
}

AB.each(&友達です)

p(-友達の輪と大きさ.min)


Measured memory_bytes: 33996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int N;
    cin >> N;
    ll A[N], sum = 0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        sum += A[i];
    }

    ll left = 0, right, dif ;
    for(int i=0;i<N;i++){
        left += A[i];
        right = sum - left;
        if(left >= right){
            cout << min(left - right, dif) << endl;
            return 0;
        }
        dif = right - left;
    }

}

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

int main() {
  ll n; cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  rep(i, n) {
    cin >> a.at(i);
    b.at(i)=a.at(i);
  }

  sort(a.begin(), a.end());
  ll M1=a.at(n-1);
  ll M2=a.at(n-2);
  
  if(M1==M2) rep(i, n) cout << M1 << endl;
  else {
    rep(i, n) {
      if(b.at(i)==M1) cout << M2 << endl;
      else cout << M1 << endl;
    }
  }
}


Measured memory_bytes: 4736
import sys
import numpy as np
input = sys.stdin.readline

N=int(input())

inp=[]

for _ in range(N):
    try:
        inp.append(list(map(int, input().split())))
    except:
        quit();
        #または、quit(),os.exit()をして止める。

abc=[]

for i in range(N):
    abc.append([0,0,0])

for i in range(N):
    for j in range(3):

        if i-1>=0:
            max_1= -float('inf')
            for k in range(3):
                kou=abc[i - 1][k]
                if k != j and kou >=max_1:
                    max_1 = kou
            abc[i][j] = inp[i][j] + max_1
        else:
            abc[i][j] = inp[i][j]

print(max(abc[N-1]))



Measured memory_bytes: 56420
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

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

	int r = 0;
	int w = 0;
	REP(i, n) { (c[i] == 'R' ? r : w) += 1; }
	int result = 0;
	REP(i, r) { result += c[i] == 'R' ? 0 : 1; }
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 3692
t = input()

n = False
s = False
e = False
w = False

for i in range(len(t)):
    n = n or t[i] == 'N'
    s = s or t[i] == 'S'
    e = e or t[i] == 'E'
    w = w or t[i] == 'W'

ok = True
ok = (n and s) or (not n and not s)
ok = ok and ((e and w) or (not e and not w))
print('Yes' if ok else 'No')


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

int main() {
	int N, M, i, j;
	cin >> N >> M;
	vector<int> vec(100), vec2(N);

	

	for (i = 0; i < 2*M; i+=1) {
		cin >> vec.at(i);
	}

	for (i = 0; i < N; i++) {
		for (j = 0; j < 2*M; j++) {
			if (i + 1 == vec.at(j)) {
				vec2.at(i) += 1;
			}
		}
	}

	for (i = 0; i < N; i++) {
		cout << vec2.at(i) << endl;
	}
	
}

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

const ll MAX_N = 500000;
ll n, k;
ll rnk[MAX_N + 1];
ll tmp[MAX_N + 1];

bool compare_sa(ll i, ll j) {
  if(rnk[i] != rnk[j]) return rnk[i] < rnk[j];
  ll ri = i + k <= n ? rnk[i + k] : -1;
  ll rj = j + k <= n ? rnk[j + k] : -1;
  return ri < rj;
}

vector<ll> construct_sa(const string &S) {
  n = S.length();
  vector<ll> sa(n + 1);
  REP(i, 0, n + 1) sa[i] = i;
  REP(i, 0, n + 1) rnk[i] = i < n ? S[i] : -1;
  for(k = 1; k <= n; k *= 2) {
    sort(sa.begin(), sa.end(), compare_sa);
    tmp[sa[0]] = 0;
    REP(i, 1, n + 1) tmp[sa[i]] = tmp[sa[i - 1]] + (compare_sa(sa[i - 1], sa[i]) ? 1 : 0);
    REP(i, 0, n + 1) rnk[i] = tmp[i];
  }
  return sa;
}

int main(void) {
  ll N, H;
  string S;
  cin >> N >> H >> S;

  vector<ll> a(N, 0);
  REP(i, 0, N - 1) if(S[i] == '0') a[i + 1] += a[i] + 1;

  vector<ll> imos(N + 2, 0);
  REP(i, 0, N) {
    if(S[i] != '0') {
      imos[1] += a[i] + 1;
      imos[N - i + 1] -= a[i] + 1;
    } else {
      imos[1] += a[i] + 1;
      imos[2] -= a[i] + 1;
    }
  }
  REP(i, 0, N + 1) imos[i + 1] += imos[i];

  ll x = 1, cnt = 1;
  while(1) {
    if(cnt <= H && H < cnt + imos[x]) break;
    cnt += imos[x];
    x++;
  }

  vector<ll> sa = construct_sa(S);
  REP(i, 1, N + 1) {
    ll j = sa[i];
    if((x == 1 || S[j] != '0') && j + x <= N) {
      if(cnt <= H && H < cnt + a[j] + 1) {
        cout << S.substr(j, x) << endl;
        break;
      }
      cnt += a[j] + 1;
    }
  }
}



Measured memory_bytes: 6916
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int n;
  string s,t;
  cin >> s >> t;
  n=s.size();
  if(t.substr(0,n)==s)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3132