akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
    int A, B, C;
    cin >> A >> B >> C;

    if(C >= A && C <= B){
      cout << "Yes";
    }else{
      cout << "No";
    }
    cout << endl;

    return 0;
}


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

using namespace std;

int main()
{
    int a, b, d;
    
    while (scanf("%d %d %d", &a, &b, &d) && a){
        long long minx = 1000000000, miny = 1000000000;
        
        for (int i = 0; i <= 50000; i++){
            if ((a * i + d) % b == 0){
                if (i + (a * i + d) / b < minx + miny){
                    minx = i;
                    miny = (a * i + d) / b;
                }
                else if (i + (a * i + d) / b == minx + miny && 2 * a * i + d < a * minx + b * miny){
                    minx = i;
                    miny = (a * i + d) / b;
                }
            }
            
            if (a * i >= d && (a * i - d) % b == 0){
                if (i + (a * i - d) / b < minx + miny){
                    minx = i;
                    miny = (a * i - d) / b;
                }
                else if (i + (a * i - d) / b == minx + miny && 2 * a * i < a * minx + b * miny){
                    minx = i;
                    miny = (a * i - d) / b;
                }
            }
            
            if (d >= a * i && (d - a * i) % b == 0){
                if (i + (d - a * i) / b < minx + miny){
                    minx = i;
                    miny = (d - a * i) / b;
                }
                if (i + (d - a * i) / b == minx + miny && d < a * minx + b * miny){
                    minx = i;
                    miny = (d - a * i) / b;
                }
            }
        }
        
        printf("%lld %lld\n", minx, miny);
    }
    
    return (0);
}

Measured memory_bytes: 1188
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (size_t i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(void) {
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;

  vector<ll> div = divisor(N);
  ll Ans = N + 1;
  for (uint i = 0; i < div.size(); i++) {
    ll tmp = N / div[i];
    ll tmp2 = tmp - 1 + div[i] - 1;
    Ans = min(Ans, tmp2);
  }
  cout << Ans << endl;
  return 0;
}


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

int mid(int a,int b,int c){
  return a+b+c-max(max(a,b),c)-min(min(a,b),c);
}
int samecount(string S){
    int A = 0;
    for(int i = 0;i < S.size();i++){
        int QA = 1;
        for(int j = i ;j < S.size() - 1;j++){
           if(S.at(j) == S.at(j + 1)){
               QA++ ;
           }
           if(S.at(j) != S.at(j + 1)){
               break;
           }
           
        }
        A = max(QA,A);
    }
    return A;
}
int main(){
    int A,B;
    cin >> A >> B;
    cout << max(max(A+B,A-B),A*B) << endl;
}

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF =1e9;
const ll LINF=1e18;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a / gcd(a, b)*b;}
int n, m;
// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    rep(i,n) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>m;
    UnionFind uf(n);
    vector<ll> a;
    for(int i=0;i<n;i++){
        ll temp;
        cin>>temp;
        a.push_back(temp);
    }
    for (int i = 0; i < m; i++)
    {
        int temp,temp1;
        cin >> temp>>temp1;
        uf.unite(temp,temp1);
    }
    vector<multiset<ll> > forest(n);
    for(int i=0;i<n;i++){
        forest[uf.find(i)].insert(a[i]);
    }
    multiset<ll> used;
    bool check=true;
    ll ans=0;
    int count=0;
    for(int i=0;i<n;i++){
        if(forest[i].size()==0)continue;
        count++;
        for(auto iter=forest[i].begin();iter!=forest[i].end();iter++){
            if(iter==forest[i].begin())
                ans+=*forest[i].begin();
            else
            used.insert(*iter);
        }
    }
    if(count==1)return cout<<0<<"\n",0;
    auto iter=used.begin();
    for(int i=0;i<count-2;i++){
        if(used.end()==iter)return cout<<"Impossible"<<"\n",0;
        ans+=*iter;
        iter++;
    }
    cout << ans << "\n";
}



Measured memory_bytes: 15860
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=0
for i in range(N-1):
  val=A[i]
  sat=B[val-1]
  if A[i+1]-A[i]==1:
    ans+=(sat+C[val-1])
  else:
    ans+=sat
ans+=B[A[-1]-1]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
7
zenkoku
touitsu
program
)");
#define cin input
#endif

int main()
{
	int n;
	string a, b, c;
	cin >> n >> a >> b >> c;

	int r = 0;
	REP (i, n)
		r +=
			(a[i] == b[i] && b[i] == c[i]) ? 0 :
			(a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) ? 1 :
			2;

	cout << r << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+18
#define MOD 1000000007
using namespace std;



int main(){
    int N;
    cin >> N;
    int L[N];
    for(int i=0; i<N; i++){
        cin >> L[i];
    }
    sort(L,L+N);
    for(int i=0; i<N-1; i++){
        L[N-1]-=L[i];
    }
    if(L[N-1]>=0){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  long long x, ans;
  
  cin >> x;

  ans = 2 * (x / 11);

  if(x % 11 > 6){
    ans += 2;
  } else if(x % 11 != 0){
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/*map,set,priority_queue,stack,queue*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define el "\n"
#define pb push_back
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
typedef vector<int> vi;
const int inf = (1e18)+7;
const int neginf = -1*((int)1e18 ) + 7 ;
const int mod = (int)1e9 + 7;
//const int N = 500007;
/*int arr[N];
vector<int> adj[N];

void dfs(int x,int par)
{
    arr[x]+=par;
    arr[par] = 0;
    for(auto child:adj[x])
    {
        if(child==par)
            continue;
        dfs(child,x);
    }
}
*/

int32_t main() 
{
fastio
    int t=1;
    //cin>>t;
    while(t--)
    {
      int n;
      cin>>n;
        int ans = 1;
      for(int i=1;i*i<=n;++i)
      {
          if(n%i==0)
              ans=i;
      }
        cout<<(ans+(n/ans)-2);
      
        
    }
    
    
    return 0;
}


Measured memory_bytes: 256
from collections import deque

# BFSで、B/Wそれぞれのスタート地点から拡張点への距離を取得
def bfs(s, distance):
    visited = [False] * (N+1)
    q = [(s, 1)]
    visited[s] = True

    while q:
        u, dist = q.pop()
        for v in graph[u]:
            if not visited[v]:
                visited[v] = True
                distance[v] = dist
                q.append((v, dist+1))
#    print(distance)


N = int(input())
graph = [deque() for i in range(N+1)]
distance = [[0] * (N+1) for i in range(2)]

for i in range(N-1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

#print(graph)

bfs(1, distance[0])
bfs(N, distance[1])

# 各頂点について、より近いほうが塗れたことに
b = w = 0
for i in range(2, N):
    if distance[0][i] <= distance[1][i]:
        b += 1
    else:
        w += 1
if b <= w:
    print('Snuke')
else:
    print('Fennec')

Measured memory_bytes: 81252
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int n, m, s;
vector<pair<int, pair<int, ll>>> a[60];
ll c[60], d[60];
vector<pair<int, ll>> g[150010];

pair<ll,int> shortest[150010]; // <distance, ancestor>
bool vis[150010];
priority_queue<pair<ll,int>, vector<pair<ll,int>>, greater<pair<ll,int>>> pq;

int start;
ll ans[60];

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    cin >> n >> m >> s;
    forn(i, m)
    {
        int u, v, x, y;
        cin >> u >> v >> x >> y;
        a[u].pb(mp(v, mp(x, y)));
        a[v].pb(mp(u, mp(x, y)));
    }
    Forn(i, n) cin >> c[i] >> d[i];
    Forn(i, n)
    {
        forn(j, a[i].size())
        {
            forn(k, 3000)
            {
                int en = a[i][j].F;
                if(k >= a[i][j].S.F) g[3000*(i-1)+k].pb(mp(3000*(en-1)+k-a[i][j].S.F, a[i][j].S.S));
                if(k!=2999)
                {
                    g[3000*(i-1)+k].pb(mp(3000*(i-1)+min(2999LL, c[i]+k), d[i]));
                }
                /*else
                {
                    ll huan = (a[i][j].S.F-k+c[i]-1)/c[i];
                    g[3000*(i-1)+k].pb(mp(3000*(en-1)+min(2999LL, c[i]*huan+k-a[i][j].S.F), a[i][j].S.S+d[i]*huan));
                }*/
            }
        }
    }

    /*forn(i, 150000)
    {
        forn(j, g[i].size())
        {
            cout << i/3000+1 << " " << i%3000 << " -> " << g[i][j].F/3000+1 << " " << g[i][j].F%3000 << " " << g[i][j].S << endl;
            if(i%3000==20)
            {
                i += 2979;
                break;
            }
        }
        if(i>=10000) exit(1);
    }*/

    start = min(2999, s);
    shortest[start] = mp(0, start);
    for(int i=0; i<150000; i++) if(i!=start) shortest[i] = make_pair(1LL<<60, 0);
    pq.push(mp(0, start));
    while(!pq.empty())
    {
        int st = pq.top().second;
        pq.pop();
        if(vis[st]) continue;
        vis[st] = 1;
        for(int i=0; i<g[st].size(); i++)
        {
            int en = g[st][i].first;
            if(!vis[en])
            {
                if(shortest[en].first > shortest[st].first + g[st][i].second)
                {
                    shortest[en] = make_pair(shortest[st].first + g[st][i].second, st);
                    pq.push(make_pair(shortest[en].first, en));
                }
            }
        }
    }
    Forn(i, n) ans[i] = 1LL<<60;
    for(int i=0; i<150000; i++)
    {
        int ind = i/3000+1;
        if(ind<=n) ans[ind] = min(ans[ind], shortest[i].F);
    }
    for(int i=2; i<=n; i++)
    {
        cout << ans[i] << endl;
    }
}


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

vector <char> MOJI = {'A', 'C', 'G', 'T'};

int main(){
  string s; cin >> s;
  int b = 0; int e = 0;
  bool cl = false;
  int ans = 0;
  
  while(e < s.size()){
    for(int i = b; i <= e; i++){
      cl = false;
      for(int j = 0; j <= 3; j++){
        if(s.at(i) == MOJI.at(j)) cl = true;
      }
      if(!cl) break;
    }
    if(cl) ans = max(ans, e - b + 1);
    else b = e + 1;
    e++;
  }
  cout << ans << endl;
}

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

int main() {
    int k,a,b;
    cin >> k >> a >> b;
    int s=b/k*k;
    cout << ((s>=a)?"OK":"NG") << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
/*#include<iostream>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<climits>*/
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define rep1(i,a,b) for(int i=a;i<=(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define per1(i,a,b) for(int i=a;i>=(b);--i)
#define LL long long
#define inf 0x7f7f7f7f
#define N 100010
using namespace std;
struct node
{
	int p,l,r;
};

node T[N];
int n,D[N];

void print(int u)
{
	int i,c;
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].p);
	printf("depth = %d, ",D[u]);
	
	if(T[u].p==-1) 
		printf("root, ");
	else if(T[u].l==-1)
		printf("leaf, ");
	else
		printf("internal node, ");
		
	printf("[");
	for(i=0,c=T[u].l;c!=-1;i++,c=T[c].r)
	{
		if(i) printf(", ");
		printf("%d",c);
	}
	printf("]\n");
}

int rec(int u,int p)
{
	D[u]=p;
	if(T[u].r!=-1) rec(T[u].r,p);
	if(T[u].l!=-1) rec(T[u].l,p+1);
}
 
int main()
{
	int i,j;
	int n,v,d,c,r,l;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		T[i].p=T[i].l=T[i].r=-1;
	}
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&v,&d);
		for(j=0;j<d;j++)
		{
			scanf("%d",&c);
			if(j==0) T[v].l=c;
			else T[l].r=c;
			l=c;
			T[c].p=v;
		}
	}
	for(i=0;i<n;i++)
	{
		if(T[i].p==-1)
			r=i;
	}
	rec(r,0);
	
	for(i=0;i<n;i++)
	{
		print(i);

	}
	
	
}  


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong N, K, Q;
  vector<llong> A;

  cin >> N >> K >> Q;
  A.resize(Q);
  vector<llong> sum(N+1, 0);
  for (auto &in: A) {
    cin >> in;
    ++sum[in];
  }

  for (int i = 1; i <= N; ++i) {
    if (K - (Q - sum[i]) > 0) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 2176
S = list(input())


def dance_checker(S):
    N = len(S)
    for i in range(N):
        if i % 2 == 0:
            if S[i] == "L":
                return("No")
        else:
            if S[i] == "R":
                return("No")

    return("Yes")


print(dance_checker(S))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1LL<<60; // 無限大を表す値 (十分大きい値に定める)

int main() {
    int N;
    cin >> N;
    vector<long long> h(N);
    for (int i = 0; i < N; ++i) cin >> h[i];

    vector<long long> dp(N, INF);
    dp[0] = 0;
    for (int i = 1; i < N; ++i) {
        if (i-1 >= 0) 
            dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if (i-2 >= 0)
            dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[N-1] << endl;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/12/28  Problem: AOJ 2224 / Link: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2224  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */


/*--------------
kuraskal法(ElogE)
最小全域木を最小の重みの辺を用いて作成する。
その際集合の連結判定を高速に行いたいのでUFをつかう
----------------*/
/* Union Find */
struct UnionFind {
	vector<int> data;
	UnionFind(int n) { data.assign(n, -1); }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
};
struct edge {
	int f, t; long double c;
	edge(int x = 0, int y = 0, long double z = 0) :f(x), t(y), c(z) {}
	bool operator < (const edge &e) const { return c > e.c; };// max spanning tree
};
struct KRUSKAL {

	long double kruskal(int V, int E, vector<edge>& es, UnionFind & uf) {
		sort(es.begin(), es.end());
		//UnionFind uf(V);
		long double min_cost = 0;
		FOR(i, 0, E) {
			if (!uf.same(es[i].f, es[i].t)) {
				min_cost += es[i].c;
				uf.unionSet(es[i].f, es[i].t);
			}
		}
		return min_cost;
	}
};


LL N;

double ans = 0.0;

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

	cin >> N;
	int M; cin >> M;
	vector<edge>ed(M);
	vector<double>x(N), y(N);
	FOR(i, 0, N) {
		cin >> x[i] >> y[i];
	}
	double csum = 0.0;
	FOR(i, 0, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		double c = sqrt((x[a] - x[b])*(x[a] - x[b]) + (y[a] - y[b])*(y[a] - y[b]));
		//debug(c);
		ed[i] = edge(a, b, c);
		csum += c;
	}



	UnionFind uf(N);
	KRUSKAL k;
	ans = (csum) -(k.kruskal(N, M, ed, uf));

	cout << fixed<<setprecision(10)<<ans << "\n";
	return 0;
}

Measured memory_bytes: 4144
#include <iostream>

using std::cout;
using std::endl;
using std::cin;

int main() {
	// Input
	int N;
	int Y;
	cin >> N >> Y;
	// Calculation
	bool satisfied = false;
	for(int x = 0; x <= N; ++x) {
		for(int y = 0; (x + y) <= N; ++y) {
			int z = N - (x + y);
			int amount = x * 10'000 + y * 5'000 + z * 1'000;
			if(amount == Y) {
				satisfied = true;
				// Output
				cout << x << ' ' << y << ' ' << z << endl;
				goto OUT_OF_LOOP;
			}
		}
	}
	OUT_OF_LOOP:
	if(!satisfied) {
		cout << "-1 -1 -1" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
x, n = map(int, input().split())
 
p = list(map(int, input().split()))
p = sorted(p)
 
if n == 0:
    print(x)
    exit()
 
q = [i for i in range(0, 101+1)]
r = []
 
for i in q:
    if i not in p:
        r.append(i)

s = [abs(x-i) for i in r]
 
print(r[s.index(min(s))])

Measured memory_bytes: 9208
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <queue>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <cstring>
#include <cctype>
#include <functional>
#include <climits>
 
using namespace std;
#define pr(...) do { _ost << #__VA_ARGS__ << " = "; ~(_ost,__VA_ARGS__); } while(0);
ostream & _ost = cout;
template <class T>
ostream &operator,(ostream& ost, const T& value) { return ost << value << ","; }
ostream &operator~(ostream& ost) { return ost << endl; }
template <class T>
string tos(const T& var){ ostringstream ss; ss << var; return ss.str(); }
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
 
typedef vector<int> vi;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long ul;
typedef unsigned long long ull;
 
const int mod = 1000000007;
const int INF = 1000000;
const double EPS = 1e-10;

int m,n;
int dp[1][1];

int p[] = {0, 6000,4000,3000,2000};

int main(){
    while(cin>>n>>m){
        cout<<p[n]*m<<endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    for (int i = K; i < N; i++) {
        cout << (A[i] > A[i - K] ? "Yes" : "No") << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll 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');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
string s;
int k,n,C[111][22];
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>s>>k;
	n=s.size();
	if(k==1){
		cout<<9*(n-1)+(s[0]-'0');
		return 0;
	}
	C[0][0]=1;
	C[1][0]=C[1][1]=1;
	fo(i,2,102) fo(j,0,11)C[i][j]=C[i-1][j-1]+C[i-1][j];
	string t="";
	t+=s[0];
	int ans=0;
	fo(i,1,n) fo(x,1,10){
		string t1=t;
		fo(j,0,i-1)t+='0';
		t+=(x+'0');
		if(k>2){
			fo(j,i+1,n) fo(y,1,10){
				string t2=t;
				fo(r,0,j-i-1)t+='0';
				t+=(y+'0');
				while(t.size()<n)t+='0';
				if(t<=s)ans++;
				t=t2;
			}
		}else{
			while(t.size()<n)t+='0';
			if(t<=s)ans++;
		}
		t=t1;
	}
	ans+=(s[0]-'1')*C[n-1][k-1]*pow(9,k-1)+C[n-1][k]*pow(9,k);
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

int main(void){
    
    int n;
    cin >> n;
    
    vector<int> ans(n+1);
    for (int x = 1; x <= 100; x++){
        for (int y = 1; y <= 100; y++){
            for (int z = 1; z <= 100; z++){
                int temp_sum = x*x + y*y + z*z;
                temp_sum += x*y + y*z + z*x;
                
                if (temp_sum <=n) ans[temp_sum]++;
            }
        }
    }
    
    for (int i = 1; i <= n; i++) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<set<int>> tree(N);
    for(int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        tree[a].insert(b);
        tree[b].insert(a);
    }
    vector<int> d(N, 0);
    d[0] = 1, d[N - 1] = -1;
    queue<pair<int, int>> q;
    q.push({0, 1});
    q.push({N - 1, -1});
    while(q.size()) {
        int i, c;
        tie(i, c) = q.front(); 
        for(auto x : tree[i]) {
            if (d[x]) continue;
            d[x] = c;
            q.push({x, c});
        }
        q.pop();
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
        ans += d[i];
    }
    cout << (ans > 0 ? "Fennec" : "Snuke") << endl;
    return 0;
}

Measured memory_bytes: 14720
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

#define INF INT_MAX
int n;
vi seg;
vi lazy;

void update(int index, int x) {
  seg[n + index] += x;
  for (int i = n + index; i >= 2; i /= 2) {
    seg[i/2] = seg[i] + seg[i^1];
  }
}

void propagate(int k) {
  if (lazy[k] == INF) {
    return;
  }
  seg[k] = lazy[k];
  if (k < n) {
    lazy[k*2] = lazy[k];
    lazy[k*2+1] = lazy[k];
  }
  lazy[k] = INT_MAX;
}

// seg[k] : [l, r)
void range_update(int a, int b, int k, int l, int r, int x) {
  if (r <= a || b <= l) {
    return;
  }
  if (a <= l && r <= b) {
    lazy[k] = x;
    propagate(k);
    return;
  } else {
    propagate(k);
    range_update(a, b, k*2, l, (l+r)/2, x);
    range_update(a, b, k*2+1, (l+r)/2, r, x);
  }
}

int range_get(int x, int k, int l, int r) {
  propagate(k);
  if (x < l || r <= x) {
    return INF;
  }
  if (l == x && r == x+1) {
    return seg[k];
  } else {
    return min(range_get(x, k*2, l, (l+r)/2), range_get(x, k*2+1, (l+r)/2, r));
  }
}

int get_query(int x) {
  return range_get(x, 1, 0, n);
}

int main() {
  int n_, q;
  scanf("%d %d", &n_, &q);
  n = (1 << (int)(ceil(log2(n_))));
  seg.assign(2*n, INT_MAX);
  lazy.assign(2*n, INT_MAX);
  int op, s, t, x;
  rep (i, q) {
    scanf("%d", &op);
    if (op == 0) {
      scanf("%d %d %d", &s, &t, &x);
      t += 1;
      range_update(s, t, 1, 0, n, x);
    } else {
      scanf("%d", &x);
      printf("%d\n", get_query(x));
    }
  }

  return 0;
}

Measured memory_bytes: 5136
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n, m;
    cin >> n;
    set<string> st;
    string s[110];
    string t[110];
    imfor(i, n) {
        cin >> s[i];
        st.insert(s[i]);
    }
    cin >> m;
    imfor(i, m) {
        cin >> t[i];
        st.insert(t[i]);
    }
    int ans = 0;
    for (string x : st) {
        int tmp = 0;
        imfor(i, n) {
            if (s[i] == x) {
                tmp++;
            }
        }
        imfor(i, m) {
            if (t[i] == x) {
                tmp--;
            }
        }
        if (tmp > ans) {
            ans = tmp;
        }
    }
    cout << ans << endl;
}

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

int H, W;
char F[10][21];

string get(int y1, int x1, int y2, int x2, int d1, int d2) {
  static int dy[] = { 0, -1, -1, -1, 0, 1, 1, 1 };
  static int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 };
  string tmp;
  int sy1 = y1;
  int sx1 = x1;
  int sy2 = y2;
  int sx2 = x2;
  bool first = true;
  while(true) {
    if(F[y1][x1] != F[y2][x2]) break;
    if(!first && y1 == sy1 && x1 == sx1) break;
    if(!first && y2 == sy2 && x2 == sx2) break;
    first = false;
    tmp += F[y1][x1];
    y1 += dy[d1];
    x1 += dx[d1];
    y2 += dy[d2];
    x2 += dx[d2];
    // mod
    if(y1 < 0) y1 += H;
    if(x1 < 0) x1 += W;
    if(y2 < 0) y2 += H;
    if(x2 < 0) x2 += W;
    y1 %= H;
    x1 %= W;
    y2 %= H;
    x2 %= W;
  }
  return tmp;
}

int main() {
  while(true) {
    cin >> H >> W;
    if(H == 0 && W == 0) break;
    for(int i = 0; i < H; ++i) {
      cin >> F[i];
    }
    string ans;
    for(int y1 = 0; y1 < H; ++y1) {
      for(int x1 = 0; x1 < W; ++x1) {
        for(int y2 = 0; y2 < H; ++y2) {
          for(int x2 = 0; x2 < W; ++x2) {
            for(int d1 = 0; d1 < 8; ++d1) {
              for(int d2 = 0; d2 < 8; ++d2) {
                if(y1 == y2 && x1 == x2 && d1 == d2) continue;
                string tmp = get(y1, x1, y2, x2, d1, d2);
                if(tmp.size() > ans.size() || (tmp.size() == ans.size() && tmp < ans)) {
                  ans = tmp;
                }
              }
            }
          }
        }
      }
    }
    if(ans.size() < 2) cout << 0 << endl;
    else cout << ans << endl;
  }
}

Measured memory_bytes: 1220
n,k=map(int,input().split())
temp={}
a=[0]*n
for i in range(n):
  at,bt=map(int,input().split())
  a[i]=at
  temp[at]=temp.get(at, 0)+bt
a=list(set(a))
a.sort()
cnt=0
for i in range(n):
  cnt=cnt+temp[a[i]]
  if cnt>=k:
    print(a[i])
    break
  

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

int64_t calc(int64_t n) {
  if (n == 0) {
    return 2;
  }
  if (n == 1) {
    return 1;
  }

  int64_t luca = 0;
  int64_t luca_l1 = 1;
  int64_t luca_l2 = 2; 
  for (int i = 2; i <= n; i++) {
    luca = luca_l1 + luca_l2;
    luca_l2 = luca_l1;
    luca_l1 = luca;
  }
  
  return luca;
}

int main() {
  int64_t n; cin >> n;
  cout << calc(n) << endl;
}

Measured memory_bytes: 256
# 上皿天秤は、左の皿に乗っているおもりの重さの合計を L とし、
# 右の皿に乗っているおもりの重さの合計を R としたとき、
# L > R なら左に傾き、 L = R なら釣り合い、
# L < R なら右に傾きます。
#
# 高橋君は、上皿天秤の左の皿に重さ A のおもりと重さ B のおもりを、
# 右の皿に重さ C のおもりと重さ D のおもりを置きました。
#
# 上皿天秤が左に傾くなら Left を、
# 釣り合うなら Balanced を、
# 右に傾くなら Right を出力してください。

# 制約
# 1 ≦ A, B, C, D ≦ 10
# 入力はすべて整数である

# 標準入力から A, B, C ,D の値を取得する
a, b, c, d = map(int, input().split())

# 上皿天秤の状態を判定し、結果を出力する
result = "ret"

if (a + b) > (c + d):
    result = "Left"
elif (a + b) < (c + d):
    result = "Right"
else:
    result = "Balanced"

print(result)


Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pll pair<long long, long long >
#define ll long long
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define maxn 10000000000000
#define endl '\n'
#define trace(x) cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
int mod(int x,int y)
{
  int s;
  s = abs(x)/y;
  if(x<0)s--;
  return x-y*s;
}
int dir8[2][8] = {{1,-1,0,0,1,-1,1,-1},{0,0,1,-1,1,-1,-1,1}};
int dir4[2][4] = {{1,-1,0,0},{0,0,1,-1}};
ll m,n,row,col,k;
ll memo[100006][3];
ll a[100006],b[100006],c[100006];
void solve()
{
  scanf("%lld",&n);
  for(int w=0;w<n;w++)scanf("%lld%lld%lld",&a[w],&b[w],&c[w]);
  memo[n-1][0] = max(b[n-1],c[n-1]);
  memo[n-1][1] = max(a[n-1],c[n-1]);
  memo[n-1][2] = max(a[n-1],b[n-1]);
  for(int i=n-2;i>=0;i--)
  {
    memo[i][0] = max(b[i] + memo[i+1][1], c[i] + memo[i+1][2]);
    memo[i][1] = max(a[i] + memo[i+1][0], c[i] + memo[i+1][2]);
    memo[i][2] = max(a[i] + memo[i+1][0],b[i] + memo[i+1][1]);
  }
  printf("%lld\n",max(memo[0][1],max(memo[0][2],memo[0][0])));

}
void test()
{
  int t;
  //scanf("%d",&t);
  t=1;
  for(int test=1;test<=t;test++)
  {
    //memset(memo,-1,sizeof memo);
    solve();
  }
}
int main()
{
  test();
  return 0;
}


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

int main() {

    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int n;
    cin>>n;
    vector<int> bricks;
    int count = 1;
    for(int i = 0; i < n; i++) {
    	int x;
    	cin>>x;
    	if(x == count) {
    		count++;
    		bricks.push_back(x);
    	}
    }
    int ans = n - bricks.size();
    if(ans == n) 
    	cout<<-1<<endl;
    else
    	cout<<ans<<endl;

	return 0;		
}



Measured memory_bytes: 1400
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

char a[100004], s[4];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    list<char> q;
    scanf("%s", a);
    for (int i = 0; a[i]; i++)
        q.push_back(a[i]);

    int r = 0;
    int t = gi();
    while (t--) {
        if (gi() == 1)
            r = 1-r;
        else {
            int f = gi();
            scanf("%s", s);
            if (r)
                f = 3-f;
            if (f == 1)
                q.push_front(s[0]);
            else
                q.push_back(s[0]);
        }
    }

    if (r) {
        for (auto it = q.rbegin(); it != q.rend(); it++)
            printf("%c", *it);
    } else {
        for (char a : q)
            printf("%c", a);
    }

    printf("\n");

    return 0;
}


Measured memory_bytes: 9984
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
  ll l, r;
  cin >> l >> r;
  ll mod = 2018;
  if (r - l > 2018)
    cout << 0;
  else {
    for (ll i = l; i < r; ++i) {
      for (ll j = i + 1; j <= r; ++j) {
        mod = min(mod, (i * j) % 2019);
        if (mod == 0) goto end;
        ;
      }
    }
  end:
    cout << mod;
  }
  return 0;
 }

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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  int h, w; cin >> h >> w;
  string c;
  for(int i=0; i<h; ++i) {
    cin >> c;
    cout << c << '\n' << c << '\n';
  }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
int n,ans=0,x=0;
string s;
int main()
{
	cin>>n>>s;
	for(int i=0;i<n;++i)
	{
		if(s[i]=='I')
			++x;
		else
			--x;
		ans=max(ans,x); 
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    int N, A, B;
    scanf("%d %d %d", &N, &A, &B);
    std::vector<long long> v(N);
    for(int i=0; i<N; i++) scanf(" %lld", &v[i]);

    std::sort(v.begin(), v.end());
    long long sum = 0;
    int count = 1;
    for(int i=0; i<A; i++) sum += v[N-1-i];
    for(int i=N-1; i>0; i--){
        if(v[i] != v[i-1]) break;
        count++;
    }

    int maxN = 50;
    std::vector<std::vector<long long> > comb(maxN+1, std::vector<long long>(maxN+1, 1));
    for(int i=1; i<=maxN; i++){
        for(int j=1; j<i; j++) comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
    }
    
    // printf("count = %d\n", count);
    printf("%.6f\n", 1.0 * sum / A);
    if(count < A){
        int c1 = 0, c2 = 0;
        for(int i=0; i<N; i++){
            if(v[i] == v[N-A]) c1++;
        }
        for(int i=0; i<A; i++){
            if(v[N-1-i] == v[N-A]) break; c2++;
        }
        // printf("c1, c2 = %d, %d\n", c1, c2);
        std::cout << comb[c1][A-c2] << std::endl;
    }
    else{  
        long long sum_c = 0;
        int m = std::min(count, B);
        for(int i=A; i<=m; i++) sum_c += comb[count][i];
        std::cout << sum_c << std::endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

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

  ll ans = INFL;
  auto d = [](ll x) {
    ll res = 0;
    while (x) {
      res++;
      x /= 10;
    }
    return res;
  };
  for (ll i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      ll a = d(i);
      ll b = d(n / i);
      ll f = max(a, b);
      ans = min(ans, f);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
n,c,k=map(int,input().split())
T=[int(input()) for i in range(n)]
T.sort()
count=1
t=T[0]
number=1
for i in range(1,n):
  if T[i]-t>k or number==c:
    count+=1
    t=T[i]
    number=1
  else:
    number+=1
print(count)

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)
#define YES(b) cout << ((b) ? "YES" : "NO") << endl
#define Yes(b) cout << ((b) ? "Yes" : "No") << endl
#define DOUBLE(d) cout << fixed << setprecision(15) << (d) << endl

class BipartiteMatching {
private:
    vector<vector<int>> G;
    vector<int> match, used;
    vector<bool> isAlive;
    int timestamp;

    void init(int n) {
        G = vector<vector<int>>(n);
        match = vector<int>(n, -1);
        isAlive = vector<bool>(n, true);
        used = vector<int>(n, 0);
        timestamp = 0;
    }

    bool dfs(int u) {
        used[u] = timestamp;
        FORE (v, G[u]) if (isAlive[v]) {
            int to_match = match[v];
            if (to_match == -1 || used[to_match] != timestamp && dfs(to_match)) {
                match[u] = v;
                match[v] = u;
                return true;
            }
        }
        return false;
    }

public:
    BipartiteMatching() {}
    BipartiteMatching(int n) { init(n); }

    void add(int u, int v) {
        G[u].push_back(v);
        G[v].push_back(u);
    }

    vector<pair<int, int>> solve() {
        REP (i, G.size()) if (isAlive[i]) {
            if (match[i] == -1) {
                timestamp++;
                dfs(i);
            }
        }
        vector<pair<int,int>> ret;
        REP (i, G.size()) if (i < match[i]) {
            ret.push_back(make_pair(i, match[i]));
        }
        return ret;
    }
};

const int MAX = 111;

int N, M;
int A[MAX][MAX];

void solve() {
    vvi B(N, vi(M)), C(N, vi(M));

    // 行ごとに、色で分ける
    vector<vector<set<int>>> colorInRow(N, vector<set<int>>(N));
    REP (i, N) REP (j, M) {
        int a = A[i][j], c = (a-1)/M;
        colorInRow[i][c].insert(a);
    }

    // 列ごとに決定する
    REP (j, M) {
        BipartiteMatching bm(2*N);
        REP (i, N) REP (c, N) {
            if (!colorInRow[i][c].empty()) bm.add(i, c+N);
        }

        vi columnOfC;
        FORE (p, bm.solve()) {
            int i, c, a;
            tie(i, c) = p; c -= N;
            a = *colorInRow[i][c].begin();
            colorInRow[i][c].erase(colorInRow[i][c].begin());

            B[i][j] = a;
            columnOfC.push_back(a);
        }

        sort(ALL(columnOfC));
        REP (i, N) C[i][j] = columnOfC[i];
    }

    REP (i, N) {
        REP (j, M) cout << B[i][j] << " ";
        cout << endl;
    }
    REP (i, N) {
        REP (j, M) cout << C[i][j] << " ";
        cout << endl;
    }
}

int main() {
    cin >> N >> M;
    REP (i, N) REP (j, M) cin >> A[i][j];
    solve();
}

Measured memory_bytes: 1664
x, y, z, k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i] + b[j])
ab.sort(reverse=True)
ab = ab[:k]
rec = []
for i in range(min(x*y, k)):
    for j in range(z):
        rec.append(ab[i] + c[j])

rec.sort(reverse=True)
rec = rec[:k]
print(*rec, sep='\n')

Measured memory_bytes: 147772
using System;

namespace abc112_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int years = int.Parse(Console.ReadLine());
            if (years == 1)
            {
                Console.WriteLine("Hello World");
            }else if(years == 2)
            {
                int[] array = new int[2];
                for(int i = 0; i < array.Length; i++)
                {
                    array[i] = int.Parse(Console.ReadLine());
                }
                int answer = array[0] + array[1];
                Console.WriteLine(answer);
            }
        }
    }
}


Measured memory_bytes: 13140
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

class Hash {
    public:
    
    Hash(const char *s, long long base = 1009, long long m = 1000000007) : MOD(m) {
        int n = strlen(s);
        
        hash = (long long *)malloc(sizeof(long long) * (n + 1));
        pow = (long long *)malloc(sizeof(long long) * (n + 1));
        
        hash[0] = 0;
        pow[0] = 1;
        
        for (int i = 0; i < n; i++) {
            hash[i + 1] = (hash[i] * base + s[i]) % MOD;
            pow[i + 1] = pow[i] * base % MOD;
        }
    }
    
    ~Hash() {
        free(hash);
        free(pow);
    }
    
    //xからy文字のハッシュ値
    long long get(int x, int y) {
        return (hash[x + y] - hash[x] * pow[y] % MOD + MOD) % MOD;
    }
    
    private:
    
    long long MOD;
    long long *hash;
    long long *pow;
};

char s[500001];
int b[500001];
vector <int> v[500001];

bool check(int x, int y, Hash &h1, Hash &h2) {
    int c = y - x, i, j;
    
    if (c == 1) return true;
    
    for (i = 0; i < v[c].size(); i++) {
        int z = (y - x) / v[c][i];
        
        for (j = 1; j * 2 <= v[c][i]; j *= 2) {
            if (h1.get(x, z * j) != h1.get(x + z * j, z * j)) break;
        }
        
        if (j * 2 <= v[c][i]) continue;
        
        if (h1.get(x, z * j) != h1.get(y - z * j, z * j)) continue;
        
        for (j = 1; j * 2 <= v[c][i]; j *= 2) {
            if (h2.get(x, z * j) != h2.get(x + z * j, z * j)) break;
        }
        
        if (j * 2 <= v[c][i]) continue;
        
        if (h2.get(x, z * j) != h2.get(y - z * j, z * j)) continue;
        
        return false;
    }
    
    return true;
}

int main() {
    int n, ans = 0, i;
    long long j;
    
    scanf("%s", s);
    
    n = strlen(s);
    
    for (i = 0; i < n; i++) {
        if (s[i] != s[0]) break;
    }
    
    if (i == n) {
        printf("%d\n", n);
        printf("%d\n", 1);
        
        return 0;
    }
    
    for (i = 2; i <= 500000; i++) {
        if (b[i] == 0) {
            b[i] = i;
            
            for (j = (long long)i * i; j <= 500000; j += i) {
                if (b[j] == 0) b[j] = i;
            }
        }
    }
    
    for (i = 1; i <= n; i++) {
        int c = i;
        
        while (c > 1) {
            if (v[i].size() == 0 || v[i].back() != b[c]) v[i].push_back(b[c]);
            
            c /= b[c];
        }
    }
    
    Hash h1(s);
    Hash h2(s, 10009, 1000000009);
    
    if (check(0, n, h1, h2) == true) {
        printf("%d\n", 1);
        printf("%d\n", 1);
        
        return 0;
    }
    
    for (i = 1; i < n; i++) {
        if (check(0, i, h1, h2) == true && check(i, n, h1, h2) == true) ans++;
    }
    
    printf("%d\n", 2);
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 45952
import java.util.*

fun main(args: Array<String>) {
    val (H, W) = readLine()!!.split(" ").map { it.toInt() }
    val s = mutableListOf<CharArray>()
    (1..H).forEach {
        val s1 = readLine()!!.toCharArray()
        s.add(s1)
    }

    var whiteSize = 0
    s.forEach {
        it.forEach {
            if (it == '.') {
                whiteSize++
            }
        }
    }

    val queue : Queue<Pair<Int, Int>> = ArrayDeque()
    val distance = Array(H, { val array = IntArray(W); array.fill(-1); array })
    distance[0][0] = 0
    queue.add(Pair(0, 0))
    val dxList = listOf(-1, 0, 0, 1)
    val dyList = listOf(0, -1, 1, 0)

    while(!queue.isEmpty()) {
        val (h, w) = queue.poll()
        dxList.zip(dyList).forEach {
            val (dx, dy) = it
            if ((0 until  H).contains(h + dx) && (0 until W).contains(w + dy)) {
                if (s[h + dx][w + dy] == '.' && distance[h + dx][w + dy] == -1) {
                    distance[h + dx][w + dy] = distance[h][w] + 1
                    queue.add(Pair(h + dx, w + dy))
                }
            }
        }
    }

    if (distance[H -1][W-1] > 0) {
        println((whiteSize -2) - (distance[H -1][W-1] - 1))
    } else {
        println(-1)
    }
}


Measured memory_bytes: 38504
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	ok := true
	findC := false
	for i := 0; i < len(S); i++ {
		if i == 0 {
			if S[i] != 'A' {
				ok = false
				break
			}
			continue
		}
		if 2 <= i && i <= len(S)-2 {
			if S[i] == 'C' {
				if !findC {
					findC = true
					continue
				} else {
					ok = false
					break
				}
			}
		}
		if !('a' <= S[i] && S[i] <= 'z') {
			ok = false
			break
		}
	}
	if ok && findC {
		fmt.Println("AC")
	} else {
		fmt.Println("WA")
	}
}


Measured memory_bytes: 512