akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
typedef long long ll;

int main(){

	//int N, M, *A, *B, i, j, *W, *flag, sum=0, start, end, length, tmp;
	int H, W, A, B, C, **ans, flag=0, i, j, ans_0=0, ans_W=0;
	char S[10], T[10], U[10];


	scanf("%d %d %d", &A, &B, &C);


	if ((A==B && A!=C) || (A==C && A!=B) || (B==C && A!=C)){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}


	/*
	ans = (int **)malloc(sizeof(int *)* H);


	for (i = 0; i<H; i++) {
		ans[i] = (int *)malloc(sizeof(int)* W);
	}

	for (i = 0; i < H; i++){
		for (j = 0; j < W; j++){
			ans[i][j] = 0;
		}
	}
	*/

	return 0;

}
    


Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  string S, T;
  cin >> S >> T;

  vvi dp(S.size()+1, vi(T.size()+1, 0));

  rrep(s, S.size() - 1, -1) rrep(t, T.size() - 1, -1){
    chmax(dp[s][t], dp[s][t+1]);
    chmax(dp[s][t], dp[s+1][t]);
    if(S[s] == T[t]){
      chmax(dp[s][t], dp[s+1][t+1] + 1);
    }
  }

  string ans = "";
  i64 s = 0, t = 0;
  while(s!=S.size() and t!=T.size()){
    if(dp[s][t] == dp[s+1][t]){
      s++;
      continue;
    } else if(dp[s][t] == dp[s][t+1]){
      t++;
      continue;
    } else {
      ans += S[s];
      s++;
      t++;
    }
  }

  cout << ans << "\n";


}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

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

int main()
{
    long long int n;
    while(~scanf("%lld",&n))
    {
        if(n>=1&&n<=9)
        {
            printf("%lld\n",n*n*n);
        }
        else
            break;
    }
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        private static void SolveA(string[] args)
        {
            int[] ve = ReadAndParseIntArr();
            int v = ve[0];
            int e = ve[1];
            List<int>[] graph = new List<int>[v];
            // 初期化
            for (int i = 0; i < v; ++i)
            {
                var list = new List<int>();

                graph[i] = list;
            }
            int[] indeg = new int[v];

            for (int i=0;i<e;++i)
            {
                int[] st = ReadAndParseIntArr();
                graph[st[0]].Add(st[1]);
                //graph[st[1]].Add(st[0]);

                indeg[st[1]]++;
            }

            List<int> outList = new List<int>();
            topologicalSort(graph, indeg, outList);

            foreach(int u in outList)
            {
                Console.WriteLine(u);
            }
        }
        private const int kWhite = 0;
        private const int kGray = 1;
        private const int kBlack = 2;
        private static void topologicalSort(List<int>[] graph, int[] indeg, List<int> outList)
        {
            int v = graph.Length;
            int[] color = new int[v];

            for(int u = 0; u < v; ++u)
            {
                if( indeg[u] == 0 && color[u] == kWhite)
                {
                    bfs(u, graph, color, indeg, outList);
                }
            }
        }
        private static Queue<int> Q = new Queue<int>();
        private static void bfs(int s, List<int>[] graph, int[] color, int[] indeg, List<int> outList)
        {
            Q.Enqueue(s);
            color[s] = kGray;
            while(Q.Count >= 1)
            {
                int u = Q.Dequeue();
                outList.Add(u);

                List<int> list = graph[u];
                foreach(int v in list)
                {
                    indeg[v]--;
                    if(indeg[v] == 0 && color[v] == kWhite)
                    {
                        color[v] = kGray;
                        Q.Enqueue(v);
                    }
                }
            }
        }
    }
}



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

int main(void) {
  int N;
  cin >> N;

  const int cake = 4;
  const int donut = 7;

  for (int i = 0; i <= 25; ++i) {
    for (int j = 0; j <= 15; ++j) {
      if (i * cake + j * donut == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3628
//2020-06-02 
#include <bits/stdc++.h>
using namespace std;
#define loop(v, st, en) for (int v = st; v < en; v++)
#define loopdesc(v, st, en) for (int v = st; v >= en; v--)
#define INF 1E9
#define clr(v, d) memset(v, d, sizeof(v))
#define pb push_back
#define MP make_pair
#define P(x) cout << #x  <<" = { "<< x<<" }\n"
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
const int M=2e5+5;



int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    ll a, b, c,d;cin>>a>>b;
    char cc;cin>>cc;
    cin>>d;
    b*=100;
    b+=d;
    c=a*b;
    cout <<c/100<<endl;
    return 0;
}

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

int main() {
 int a,b,c,k;
  cin >> a >> b >> c >> k;
  int maxx= -2000000000;
  if(a>=k){
          int z=k;
          maxx = max(z,maxx);
  }else if(a+b+c<k && k<=a+b){
              int z=a;
              maxx = max(z,maxx);
  }else{
    int d =k-a-b;
          int z=a+d*(-1);
          maxx = max(z,maxx);
  }
  cout << maxx << endl;
}

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

using namespace std;

int a[3020];
int main(){
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += (a[i] - 1);
    }
    cout << sum << endl;
}

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

int main(){
    using namespace std;
    unsigned long X;
    cin >> X;
    const auto& chkprm = [](auto x) -> bool {
        for(unsigned long i{2}; i * i <= x; ++i)if(x % i == 0)return false;
        return true;
    };
    for(unsigned long i{0}; i < X; ++i)if(chkprm(X + i)){
        cout << X + i << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#include <map>
#include <cstring>
using namespace std;

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

template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

typedef long long ll;
const ll MOD = 1000 * 1000 *1000 + 7 ;
inline void chadd(ll &a, const ll b) { a = (a + b) % MOD;}
inline ll add(const ll a, const ll b){ return (a + b) %  MOD;}
inline void chsub(ll &a, const ll b) { a = (a + MOD - b) % MOD;}
inline ll sub(const ll a, const ll b){ return (a + MOD -  b) %  MOD;}

ll dp[128][100000+10];
int a[128];

int main() {
  int N, K; cin>>N>>K;
  REP(i,N) cin>>a[i];
  dp[0][0] = 1;
  for(int i = 1; i <= N; i++) {
    ll sum = 0;
    for(int j = 0; j <= K; j++) {
      chadd(sum, dp[i-1][j]);
      if(j - a[i-1] - 1 >= 0) chsub(sum, dp[i-1][j-a[i-1]-1]);
      dp[i][j] = sum;
      //      cout << i << " " << j << " " << dp[i][j] << endl;
    }
  }
  ll ans = dp[N][K];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 79360
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define SZ(x) (int)(x.size())
#define F0(i,n) for(int i=0;i<n;i++)
#define F1(i,n) for(int i=1;i<=n;i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define P(x) cerr << #x << "=" << x << endl

const int inf = 1000002013;
const double pi = atan(1.0)*4.0;
const double eps = 1e-8;
ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
int bc(int n) { return n ? bc((n-1)&n)+1 : 0; }

int i, j, k, m, n, l, M;

int f(int x) {
    if (x == 0) return 0;
    return f(x / 10) + x % 10;
}


int main() {
    //freopen("x.in", "r", stdin);

    while (cin >> n) {
        int ans = 1e9;
        F1(i, n - 1) {
            int v = f(i) + f(n - i);
            ans = min(ans, v);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 764
N = int(input())
A = list(map(int, input().split()))

MAX = [1] * (N+1)
ans = [0] * (N+1)
INF = 10**15

if N == 0 and A[0] != 1:
    print(-1)
    exit()

for i in range(1, N+1):
    MAX[i] = min((MAX[i-1] - A[i-1]) * 2, INF)
    if MAX[i] < A[i]:
        print(-1)
        exit()

ans[N] = A[N]

for i in reversed(range(N)):
    ans[i] = min(ans[i+1]+A[i], MAX[i])

print(sum(ans))

Measured memory_bytes: 20068
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int N;
    cin >> N;
    
    int C[510], S[510], F[510];
    for (int i = 0; i < N-1; i++){
        cin >> C[i] >> S[i] >> F[i];
    }
    for (int i = 0; i < N; i++) {
        int sum = 0;
        for (int j = i; j < N-1; j++) {
            if (sum < S[j]) {
                sum = S[j];
            }else if(sum % F[j] == 0){
            }else{
                sum = sum + F[j] - sum % F[j];
            }
            sum += C[j];
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int a, b;
  	cin >> a >> b;
	cout << (a-1)*(b-1) << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())

c = []
s = []
f = []

for i in range(n-1):
    c_, s_, f_ = map(int, input().split())
    c.append(c_)
    s.append(s_)
    f.append(f_)

for i in range(n-1):
    time = 0
    for j in range(i, n-1):
        if  time < s[j]:
            time = s[j]
        elif time % f[j] == 0:
            pass
        else:
            time += f[j] - (time % f[j])
        time += c[j]
    print(time)
print(0)

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiil;
typedef pair<pll, ll> pplll;
typedef pair<pli, int> pplii;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<pll>> vvpll;
#define rep(i, a, b) for (ll i=(a); i<(b); i++)
#define rrep(i, a, b) for (ll i=(a); i>(b); i--)
#define pb push_back
#define tostr to_string
#define mkp make_pair
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

void print(ld out) { cout << fixed << setprecision(12) << out << '\n'; }
template<typename T> void print(T out) { cout << out << '\n'; }
template<typename T1, typename T2> void print(pair<T1, T2> out) { cout << out.first << ' ' << out.second << '\n'; }
template<typename T> void print(vector<T> A) { rep(i, 0, A.size()) { cout << A[i]; cout << (i == A.size()-1 ? '\n' : ' '); } }
template<typename T> void print(set<T> S) { vector<T> A(S.begin(), S.end()); print(A); }

template<typename T> inline bool chmax(T &x, T y) { return (y > x) ? x = y, true : false; }
template<typename T> inline bool chmin(T &x, T y) { return (y < x) ? x = y, true : false; }

ll sum(vector<ll> A) { ll res = 0; for (ll a: A) res += a; return res; }
ll max(vector<ll> A) { ll res = -INF; for (ll a: A) chmax(res, a); return res; }
ll min(vector<ll> A) { ll res = INF; for (ll a: A) chmin(res, a); return res; }

ll toint(string s) { ll res = 0; for (char c : s) { res *= 10; res += (c - '0'); } return res; }
int toint(char c) { return c - '0'; }
char tochar(int i) { return '0' + i; }

inline ll pow(int x, ll n) { ll res = 1; rep(_, 0, n) res *= x; return res; }
inline ll pow(ll x, ll n, int mod) { ll res = 1; while (n > 0) { if (n & 1) { res = (res * x) % mod; } x = (x * x) % mod; n >>= 1; } return res; }

inline ll floor(ll a, ll b) { if (a < 0) { return (a-b+1) / b; } else { return a / b; } }
inline ll ceil(ll a, ll b) { if (a >= 0) { return (a+b-1) / b; } else { return a / b; } }

int popcount(ll S) { return __builtin_popcountll(S); }
ll gcd(ll a, ll b) { return __gcd(a, b); }

ll N;
vector<ll> A, L, ans;
vvl nodes;

void rec(ll u, ll prev, vector<ll> &L) {

    bool inc = false;
    ll tmp, idx;
    if (A[u] > L.back()) {
        L.pb(A[u]);
        inc = true;
    } else {
        idx = lower_bound(L.begin(), L.end(), A[u]) - L.begin();
        tmp = L[idx];
        L[idx] = A[u];
    }
    ans[u] = L.size();

    for (auto v : nodes[u]) {
        if (v == prev) continue;
        rec(v, u, L);
    }

    if (inc) {
        L.pop_back();
    } else {
        L[idx] = tmp;
    }
    return;
}

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

    cin >> N;
    A.resize(N);
    nodes.resize(N);
    ans.resize(N);
    rep(i, 0, N) cin >> A[i];
    ll a, b;
    rep(i, 0, N-1) {
        cin >> a >> b;
        a--; b--;
        nodes[a].pb(b);
        nodes[b].pb(a);
    }

    L.pb(A[0]);
    rec(0, -1, L);

    for (ll a : ans) {
        print(a);
    }
    return 0;
}


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

int main () {
    int n, m, x;
    std::cin >> n >> m >> x;

    std::vector<int> c(n);
    std::vector<std::vector<int>> a(n, std::vector<int>(m));
    for (int i = 0; i < n; i++)
    {
        std::cin >> c[i];
        for (int j = 0; j < m; j++) {
            std::cin >> a[i][j];
        }
    }

    std::vector<int> anss;
    for (int bit = 0; bit < (1 << n); bit++)
    {
        std::vector<int> S;
        for (int i = 0; i < n; ++i)
        {
            if (bit & (1 << i))
            { // i が bit に入るかどうか
                S.push_back(i);
            }
        }

        bool f = true;
        int yen = 0;
        for (int k = 0; k < m; k++)
        {
            int sum = 0;
         
            for (int j = 0; j < (int)S.size(); j++)
            {
                sum += a[S[j]][k];
                if(k == 0) {
                    yen += c[S[j]];
                }
            }

            if(sum < x) {
                f = false;
                break;
            }
        }

        if(f) {
            anss.push_back(yen);
        }
    }

    if(anss.empty()) {
      anss.push_back(-1);
    }

    std::cout << *std::min_element(anss.begin(), anss.end()) << "\n";
}

Measured memory_bytes: 3636
void main() {
	auto ip = readAs!(int[]), H = ip[0], W = ip[1];
	auto S = readMatrix!char(H, W);
	alias Pair = Tuple!(ulong, "y", ulong, "x");
	
	int[] dy = [1, 0, -1, 0], dx = [0, 1, 0, -1];
	Pair[] stack;
	foreach(i, iv; S) foreach(j, jv; iv) {
		if(jv == '#') stack ~= Pair(i, j);
	}
	ulong res;
	bool[][] done = new bool[][](H, W);
	
	//ulong res2;
	while(stack != []) {
		auto p = stack.front;
		stack.popFront;
		if(done[p.y][p.x]) continue;
		Pair[] stack2;
		stack2 ~= Pair(p.y, p.x);
		ulong wh, bl;
		
		while(stack2 != []) {
			auto p2 = stack2.front;
			stack2.popFront;

			foreach(k; 0..4) {
				auto ry = p2.y + dy[k];
				auto rx = p2.x + dx[k];
				if(0 <= ry && ry < H && 0 <= rx && rx < W && S[ry][rx] != S[p2.y][p2.x] && !done[ry][rx]) {
					if(S[ry][rx] == '.') { res++; wh++; }
					else bl++;
					stack2 ~= Pair(ry, rx);
					//visited[ry][rx] = true;
					done[ry][rx] = true;
					//res2++;
					//writefln("%d, %d -> %d, %d", p.y, p.x, ry, rx);
				}
			}
			done[p2.y][p2.x] = true;
		}
		res += wh * bl;
	}
	res.writeln;
	//es2.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 5372
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int N, M;
vector<vector<int>> d(100, vector<int>(100, INF));

void warshall_floyd() {
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    return;
}

int main() {
    cin >> N >> M;
    vector<int> a(M), b(M), c(M);
    for (int i = 0; i < M; i++) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        d[a[i]][b[i]] = c[i];
        d[b[i]][a[i]] = c[i];
    }

    warshall_floyd();

    int count = 0;
    for (int i = 0; i < M; i++) {
        if (c[i] > d[a[i]][b[i]]) {
            count++;
        }
    }
    cout << count << endl;
}

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

int main(){
	int n, m, l;
	cin >> n >> m >> l;
	int a[101][101], b[101][101];
	long int c[101][101] = {0};
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	for(int j = 0; j < m; j++){
		for(int k = 0; k < l; k++){
			cin >> b[j][k];
		}
	}
	for(int i = 0; i < n; i++){
		for(int k = 0; k < l; k++){
			for(int j = 0; j < m; j++) c[i][k] += a[i][j] * b[j][k];
		}
		for(int k = 0; k < l-1; k++) cout << c[i][k] << ' ';
		cout << c[i][l-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1328
n=[int(i) for i in input().split()]
array=[]
for i in range(n[0]):
  array.append(int(input()))
array.sort()
ans=abs(array[0]-array[n[1]-1])
for i in range(n[0]-(n[1]-1)):
  if(ans>abs(array[i]-array[i+n[1]-1])):
    ans=abs(array[i]-array[i+n[1]-1])
print(ans)
  

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

int main() {
  int s, h, r, t, o;
  cin >> s;
  h=(s-(s%100))/100;
  r=s-100*h;
  t=(r-(r%10))/10;
  o=r-10*t;
  cout << h+t+o << endl;
}


Measured memory_bytes: 3572
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int mod = 1e+7;

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

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

  int n;
  cin >> n;
  while(true) {
    if(is_prime(n)) {cout << n << endl; return 0;}
    n++;
  }

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


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

	vector<map<ll, ll>> vdic(3, map<ll, ll>());
	rep(i, 0, 3) {
		ll A;
		repeq(j, 1, N) {
			std::cin >> A;
			vdic[i][A]++;
		}
	}

	vll cnt(N + 1, 1);
	rep(i, 0, 2) {

		vll stat(N + 1, 0);

		ll idx1 = -1;
		ll idx2 = 0;
		auto itr2 = vdic[i + 1].begin();
		for (auto itr1 = vdic[i].begin(); itr1 != vdic[i].end(); itr1++) {
			idx1++;
			while (itr2 != vdic[i + 1].end() && itr1->first >= itr2->first) {
				itr2++;
				idx2++;
			}
			if (idx2 < N) {
				stat[idx2 + 1] += itr1->second;
			}
		}

		ll idx = 0;
		for (auto itr = vdic[i + 1].begin(); itr != vdic[i + 1].end(); itr++) {
			stat[idx + 1] += stat[idx];
			itr->second *= stat[idx + 1];
			idx++;
		}
	}

	ll ans = 0;
	for (auto itr = vdic[2].begin(); itr != vdic[2].end(); itr++) {
		ans+=itr->second;
	}
	std::cout << ans << endl;
	return 0;
}


Measured memory_bytes: 20608
// g++ -O3 -fmax-errors=1 -fsanitize=undefined -fsanitize=address -sanitize=leak 
#include <bits/stdc++.h>

// length 2^{M+1} string "a"
// each number in [0, 2^M) appears exactly twice
//
// XOR の fact: 0 xor 1 xor ... xor 2^{n-1}-1 = 0000 (n even) if n >= 2
//
using namespace std;

int main() {
  int m, k;
  cin >> m >> k;
  if (m == 0) {
    // 0 0
    if (k == 0) {
      cout << "0 0" << endl;
    } else {
      cout << "-1" << endl;
    }
  } else if (m == 1) {
    // 0 => 0 0 1 1
    if (k == 0) {
      cout << "0 0 1 1" << endl;
    } else {
      cout << "-1" << endl;
    }
  } else {
    int n = (1 << m);
    if (k >= n) {
      cout << "-1" << endl;
      return 0;
    }
    vector<int> ans;
    for (int i = 0; i < n; ++i) 
      if (i != k) ans.emplace_back(i);
    ans.emplace_back(k);
    for (int i = n-1; i >= 0; --i)
      if (i != k) ans.emplace_back(i);
    ans.emplace_back(k);
    for (int i = 0; i < ans.size(); ++i) {
      if (i > 0) cout << ' ';
      cout << ans[i];
    }
    cout << endl;
  }
}


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

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

	int k, n;
	cin >> k >> n;

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

	int res = k;
	for (int i = 0; i < n; ++i) {
		// take pos round and go back to prev
		if (i != 0) {
			res = min(res, k - a[i] + a[i - 1]);
		} else {
			res = min(res, a[n - 1]);
		}

		// take negative round back to prev
		if (i != n - 1) {
			res = min(res, a[i] + k - a[i + 1]);
		} else {
			res = min(res, a[i] - a[0]);
		}
	}

	cout << res;

	return 0;
}



Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
long double X[200100];
int N;
long long Count(long double len)
{
  long long Ans=0;
  for(int i=0;i<N;i++)
  {
    //Ans+=(long long)(X[i]/len);//解答引っ張ってきた人の条件。なぜか通る
    Ans+= ceil(X[i]/len)-1;//多少遅くなるがこっちが正解
  }
  return Ans;
}

int main()
	{
	  long long K;
	  cin>>N>>K;
	  for(int i=0;i<N;i++)
	{
		cin>>X[i];
		//X[i]-=0.1;
	}

  long double l=1,r=1e9;
  //while(l<r-0.1)//解答を引っ張ってきた人の条件。なぜかOKだったが、lとｒの整数部が異なる状態でループを出ると問題になるはず
	for(int i=0;i<300;i++)//OK log2(10^9)=30.二分探索だとこのやり方安定する。ただし、浮動小数のせいか34以上でないと通らず。
  //while(!((ceil(r)-ceil(l)) == 0))//NG:左端が初期値0のままだと、右端のceilは0にならず、無限ループ
	//while(!((floor(r)-floor(l)) == 0))//OK:右端がぴったり整数にならなければ成立.(あまりよくない)
  {
    long double mid=(l+r)/2;
    if(Count(mid)<=K) r=mid;
    else	l=mid;
  }
  cout<<(long long)(l+0.999)<<endl;
  return 0;
}

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


int main()
{
  int N;
  string S;
  cin >> N >> S;
  if (N%2) cout << "No" << endl;
  else if ( S.substr(0,N/2) == S.substr(N/2, N)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use ascii::AsciiChar;
use ascii::AsciiStr;
use itertools::Itertools as _;
use permutohedron::LexicalPermutation as _;
use petgraph::algo::dijkstra;
use petgraph::algo::min_spanning_tree;
use petgraph::data::FromElements;
use petgraph::graph::NodeIndex;
use petgraph::graph::UnGraph;
use petgraph::unionfind::UnionFind;
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;
use proconio::marker::Usize1;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use superslice::Ext as _;

#[fastout]
fn main() {
    input! {
        S: Chars,
    }

    let N = S.len();

    let mut ans: i64 = 0;
    let mut g_cnt: i64 = 0;
    let mut p_cnt: i64 = 0;

    // とりあえず貪欲でやってみる
    for i in 0..N {
        let top_c = S[i];

        if p_cnt < g_cnt {
            // 両方の手を出せる
            // でもパーの方が得
            match top_c {
                'p' => {
                    p_cnt += 1;
                }
                'g' => {
                    p_cnt += 1;
                    ans += 1;
                }
                _ => {}
            }
        } else {
            // グーしか出せない
            g_cnt += 1;
            match top_c {
                'p' => {
                    ans -= 1;
                }
                _ => {}
            }
        }
    }

    println!("{}", ans);
}


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

int main(){
    int N,i;
    double *x,sum=0;
    char **u;
    cin >> N;
    x = new double[N];
    u = new char*[N];
    for(i=0;i<N;i++){
        u[i] = new char[3];
    }
    for(i=0;i<N;i++){
        cin >> x[i] >> u[i];
        if(u[i][0]=='J'){
            sum += x[i];
        }else{
            sum += x[i] * 380000;
        }
        //cout << sum << endl;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  char a[100]; scanf("%s",a);int i=0,f=0;
  while(a[i]!='\0'){
    //printf("%c",a[i]);
    if(a[i]=='R' || a[i]=='U' || a[i]=='D');
    else f=1;
    i++;
    if(a[i]=='\0') break;
    if(a[i]=='L' || a[i]=='U' || a[i]=='D');
    else f=1;
    i++;
  }
  if(f==0) printf("Yes\n");
  else printf("No\n");
  return 0;
}

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

using namespace std;

#define allof(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define exists(s, e) (s.find(e)!=s.end())
#define INF 0x3f3f3f3f
#define endl '\n'
#define mp make_pair
#define watch(x) cout << (#x) << " is " << (x) << endl;

typedef pair<int, int> pii;
typedef long long ll;

ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

void solve() {
    int a; cin >> a;
    if(a==7 or a==5 or a==3) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void read(int &x){
	char ch=getchar();x=0;
	for (;ch==' '||ch=='\n';ch=getchar());
	for (;ch!=' '&&ch!='\n';x=x*10+ch-'0',ch=getchar());
}
void write(int x){
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
int n;
vector<int>g[200004],tp[2],ver,mod[3],cv;
int ans[200004];
void dfs(int x,int par,int col){
	tp[col].push_back(x); 
	for (int i=0;i<g[x].size();i++) if (g[x][i]!=par)
		dfs(g[x][i],x,col^1);
}
int main(){
	read(n);
	for (int i=1;i<n;i++){
		int u,v;read(u),read(v);
		g[u].push_back(v),g[v].push_back(u);  
	}
	dfs(1,-1,0);
	if (tp[0].size()>tp[1].size()) swap(tp[0],tp[1]);
	for (int i=0;i<2;i++) for (int j=0;j<tp[i].size();j++) ver.push_back(tp[i][j]); 
	for (int i=1;i<=n;i++) mod[i%3].push_back(i);
	if (tp[0].size()<mod[2].size()){
		for (int i=0;i<mod[0].size();i++) cv.push_back(mod[0][i]); 
		for (int i=0;i<mod[1].size();i++) cv.push_back(mod[1][i]); 
		for (int i=0;i<mod[2].size();i++) cv.push_back(mod[2][i]); 
	}else{
		for (int i=0;i<mod[2].size();i++) cv.push_back(mod[2][i]);
		for (int i=0;i<mod[0].size();i++) cv.push_back(mod[0][i]);
		for (int i=0;i<mod[1].size();i++) cv.push_back(mod[1][i]);   
	}
	for (int i=0;i<n;i++) ans[ver[i]]=cv[i];
	for (int i=1;i<=n;i++) write(ans[i]),putchar(' ');
}

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

ll N, K, W[100000], D[100000];

bool ok(ll x) {
  ll s = 0;
  REP(i, 0, N) if(x - W[i] >= 0) s += (x - W[i]) / D[i] + 1;
  return s >= K;
}

int main(void) {
  cin >> N >> K;
  REP(i, 0, N) cin >> W[i] >> D[i];

  ll l = 0, h = INF;
  while(l + 1 < h) {
    ll m = (l + h) / 2;
    if(ok(m)) h = m;
    else l = m;
  }
  cout << h << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>

#define MAX 500000
#define INFINITY 2000000000

int cnt;
int L[(MAX/2)+2];
int R[(MAX/2)+2];

void merge(int[],int,int,int);
void mergeSort(int[],int,int);


int main()
{
  int n,A[MAX],i;
  cnt=0;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);

  mergeSort(A,0,n);

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

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

  return 0;
}

void merge(int A[],int left,int mid,int right)
{
  int i,j,k,n1,n2;

   n1=mid-left;
   n2=right-mid;
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=INFINITY;
  R[n2]=INFINITY;
  i=0;
  j=0;
  for(k=left;k<right;k++)
    {
      cnt++;
      if(L[i]<=R[j]){
	A[k]=L[i++];
      }
      else {
	A[k]=R[j++];
      }
    }
}

void mergeSort(int A[],int left,int right)
{
  int mid;  
  if(left+1<right){
    mid = (left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

Measured memory_bytes: 4504
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;

class UnionFind {
public:
  // 親の番号を格納する。親だった場合は-(その集合のサイズ)
  vector<int> parent;

  // 作るときは parent の値を全て -1 にする
  // こうすると全てバラバラになる
  UnionFind(const int& n = 0) : parent(n, -1) {}

  // x がどのグループに属しているか調べる
  int find(const int& x) {
    if (parent[x] < 0) return x;
    return parent[x] = find(parent[x]);
  }

  // x と y をくっつける  O(log n)
  bool unite(int x, int y) {
    // x と y を直接くっつけるのではなく，root(x) に root(y) をくっつける
    x = find(x);
    y = find(y);
    if (x == y) return false;  // すでにくっついているからくっつけない

    // 大きい方(x) に小さい方(y)をくっつけたい 大小が逆だったらひっくり返す
    if (size(x) < size(y)) swap(x, y);

    parent[x] += parent[y];  // x のサイズを更新する
    parent[y] = x;  // y の親を x に変更する
    return true;
  }

  // 自分のいるグループの頂点数を調べる
  int size(const int& x) { return -parent[find(x)]; }

  // x と y が同じグループに属しているか否か
  bool same(const int& x, const int& y) { return find(x) == find(y); }
};

using P = pair<int, int>;

// a 番目の edge が橋なら true を返す
bool check(const vector<P>& edges, const int& n, int a) {
  UnionFind uf(n);
  for (int i = 0; i < edges.size(); i++) {
    if (i == a) continue;
    uf.unite(edges[i].first, edges[i].second);
  }
  return uf.size(0) != n;
}

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

  int n, m;
  cin >> n >> m;

  vector<P> edges;
  rep(i, m) {
    int a, b; cin >> a >> b; a--; b--;
    edges.push_back({a, b});
  }

  int ans = 0;
  rep(i, m) if (check(edges, n, i)) ans++;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int a;
    cin >> a;
    int ans = a + a * a + a * a * a;
    cout << ans << endl;
}

Measured memory_bytes: 3632
from functools import reduce
import fractions

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

a,b = map(int,input().split(" "))
ans = lcm(a,b)

print(ans)

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

using namespace std;
const int MOD = 1e9+7;
// DP
vector<long long> memo;

long long dp(int S){
	if(memo[S] != -1) return memo[S];
	if( S == 0 || S == 3) return memo[S] = 1;
	if( S < 3 ) return memo[S] = 0;

	long long res = 0;
	for(long long i = 3; i <= S; i++) {
		res = (res + dp(S-i))%MOD;
	}
	return memo[S] = res;
}
int main() {
	int S; cin >> S;
	memo.resize(S+1, -1LL);
	cout << dp(S) << '\n';
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    int n; cin >> n;

    std::vector<string> strs(0);

    rep(i,n){
        string s; cin >> s;

        std::vector<int> v(26,0);
        rep(j,s.length()){
            v[s[j]-'a']++;
        }

        string x = "";

        rep(j,26){
            rep(k, v[j]){
                x+='a'+j;
            }
        }
        strs.push_back(x);
    }

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

    ll cnt =0LL;
    ll i=0, current_streak=1;
    while(i<n-1){

        if(strs[i] == strs[i+1]){
            current_streak++;
        } else {
            if(current_streak != 1){
                cnt+=current_streak*(current_streak-1LL)/2;
                current_streak = 1;
            } 
        }
        i++;
    }

    if(current_streak != 1){
        cnt+=current_streak*(current_streak-1LL)/2;
    }   

    cout << cnt << endl;
    

    return 0;
}

Measured memory_bytes: 7284
#include<stdio.h>
#include<string.h>

int main() {
	char s[16], t[16], u[16];
	int n, m;
	scanf("%s %s", &s, &t);
	scanf("%d %d", &n, &m);
	scanf("%s", &u);
	if (strcmp(s,u)==0) {
		n = n - 1;
	}
	else {
		m = m - 1;
	}
	printf("%d %d", n, m);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int ara[100000];
vector<int> vec;
int main()
{
    int i,j,k;
    int n,color=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&ara[i]);
    color=1;
    vec.push_back(ara[n-1]);
    for(i=n-2;i>=0;i--){
        j=upper_bound(vec.begin(),vec.end(),ara[i])-vec.begin();
        if(j==vec.size()){
            color++;
            vec.push_back(ara[i]);
        }
        else
            vec[j]=ara[i];
    }
    printf("%d",color);
}


Measured memory_bytes: 1276
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int n;
    scanf("%d", &n);
    char s[n+1];
    scanf("%s", s);
    int sum_w[n+2], sum_b[n+2];
    sum_b[0] = 0;
    rep(i, 0, n){
        sum_b[i+1] = sum_b[i];
        if(s[i] == '#'){
            sum_b[i+1]++;
        }
    }
    sum_b[n+1] = sum_b[n];
    sum_w[n+1] = 0;
    revrep(i, n-1, -1){
        sum_w[i+1] = sum_w[i+2];
        if(s[i] == '.'){
            sum_w[i+1]++;
        }
    }
    sum_w[0] = sum_w[1];
    int ans = 200000;
    rep(i, 0, n+1){
        int buf = sum_b[i] + sum_w[i+1];
        if(buf < ans){
            ans = buf;
        }
    }
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const int MAXN = 100100;

int N;
pair <int, int> loc[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);

    int ans = 0;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> loc[i].first >> loc[i].second;
        loc[i].second++;

        ans = max (ans, loc[i].second - loc[i].first);
    }

    sort (loc, loc + N);
    reverse (loc, loc + N);

    int nfar = -1e9;
    for (int i = 0; i < N; i++)
        nfar = max (nfar, loc[i].second);

    int nbest = -1e9;
    for (int i = 0; i < N; i++)
    {
        int cv = loc[i].second;
        nbest = max (nbest, max (nfar, cv) - loc[i].first);

        nfar = min (nfar, cv);
    }

    int lh = -1e9, rl = 1.1e9;
    for (int i = 0; i < N; i++)
    {
        lh = max (lh, loc[i].first);
        rl = min (rl, loc[i].second);
    }
    ans = max (ans, nbest + rl - lh);
    cout << ans << "\n";
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef pair<int,int> pii;
typedef long long ll;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

vector<int> tsort(const Graph &g) {
  int n = g.size();
  vector<int> num(n);
  REP(i, n) FOR(e, g[i]) num[e->dst]++;
  queue<int> Q;
  REP(i, n) if (num[i] == 0) Q.push(i);
  vector<int> res;
  while(!Q.empty()) {
    int v = Q.front(); Q.pop();
    res.push_back(v);
    FOR(e, g[v]) {
      if (num[e->dst]) {
        num[e->dst]--;
        if (num[e->dst] == 0) Q.push(e->dst);
      }
    }
  }
  REP(i, n) if (num[i]) return vector<int>();
  return res;
}

int main() {
  int n,m;
  while(cin >> n >> m) {
    Graph g(n);
    REP(i,m) {
      int a, b, c;
      cin >> a >> b >> c;
      g[a].push_back(Edge(a,b,c));
    }
    int dp[n];
    memset(dp,0,sizeof(dp));
    vector<int> order = tsort(g);
    REP(i,n) {
      FOR(it, g[order[i]]) {
        chmax(dp[it->dst], dp[it->src] + it->weight);
      }
    }
    cout << *max_element(dp,dp+n) << endl;
  }
}

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

int s, n, d[15], a[1000005];
string ta;
int main()
{
	int i, t;
	cin >> ta;
	ta = "00" + ta;
	n = ta.size();
	for (i = 0; i < n; i++) a[i] = ta[i] - '0';
	for (i = n - 1; i >= 0; i--) {
		t = a[i];
		if (t >= 10) {
			a[i] -= 10;
			a[i - 1]++;
		} else if (t >= 6) {
			s += 10 - t;
			a[i] = 0;
			a[i - 1]++;
		} else if (t == 5) {
			s += 5;
			a[i] = 0;
			if (a[i - 1] >= 5) {
				a[i - 1]++;
			}
		}
	}
	for (i = 0; i <= 5; i++) d[i] = i;
	for (i = 6; i <= 9; i++) d[i] = 11 - i;
	for (i =0; i < n; i++) {
		s += d[a[i]];
	}
	cout << s << endl;
    return 0;
}


Measured memory_bytes: 5296
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
const ll p=1000000007;
int main(){
  ll n;
  cin >> n;
  rep(i,3500){
    rep(j,3500){
      ll a=4*(j+1)*(i+1)-n*(j+i+2);
      if(a>0){
        if(n*(i+1)*(j+1)%a==0){
          cout << i+1 << " " << j+1 << " " << n*(i+1)*(j+1)/a << endl;
          return 0;
        }
      }
    }
  }
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll x; cin>>x;
  if(x<=6) cout<<1<<endl;
  else{
    ll ans=x/11*2;
    if(x%11>6) ans+=2;
    else if(x%11<=6&&x%11!=0) ans++;
    
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        boards: [Chars; h],
    }

    let mut ans = 0;
    for mask_r in 0..1<<h {
        for mask_c in 0..1<<w {
            let mut black = 0;
            for i in 0..h {
                for j in 0..w {
                    if ((mask_r>>i) & 1) == 0 && ((mask_c>>j) & 1) == 0 && boards[i][j] == '#' {
                        black+=1;
                    }
                }
            }
            if black == k {
                ans+=1;
            }
        }
    }

        println!("{}", ans);    
}

Measured memory_bytes: 2196
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long int lli;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
const lli inf = 1e18;

struct UnionFindTree{
    vector<int> v;
    vector<int> rank;
    int size;

    UnionFindTree(int n): v(n, -1), rank(n, 0), size(n){}
    int Find(int x){
        if(v[x] < 0) return x;
        return v[x] = Find(v[x]);
    }
    void Union(int a, int b){
        a = Find(a);
        b = Find(b);
        if(a == b) return;
        size--;
        if(rank[a] < rank[b]) swap(a, b);
        if(rank[a] == rank[b]) rank[a]++;
        v[b] = a;
    }
};
int main(){
	int n,m;
	cin >> n >> m;
	UnionFindTree uf(n);
	for(int i=0; i<m; i++){
		int u,v,w;
		cin >> u >> v >> w;
		u--; v--;
		uf.Union(u,v);
	}
	cout << uf.size << endl;
    return 0;
}

Measured memory_bytes: 1024