akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    ii2(n, k);
    vector<lint> h; lint sum = 0;
    rep(i, n){
        lint x; cin>>x; h.push_back(x); sum += x;
    }
    sort(all(h));
    rep(i, k){
        int j = n - 1 - i;
        if(j < 0) break;
        sum -= h[j];
    }
    out(sum);
}

Measured memory_bytes: 2420
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
const int INF = 1e9;
const int MOD = 1e9+7;


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    
    int N; cin >> N;
    string S; cin >> S;
    int r = 0, l = 0;
    for(int i = N-1; i >= 0; i--)
    {
        if(l > 0 && S[i] == '(') l--;
        if(S[i] == ')') l++;
    }
    REP(i, N)
    {
        if(r > 0 && S[i] == ')') r--;
        if(S[i] == '(') r++;
    }
    REP(i, l) cout << '(';
    cout << S;
    REP(i, r) cout << ')';
    cout << endl;
}


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

using namespace std;

// long long int abs(long long int a){
//     return 0 <= a ? a : -a;
// }

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

    long long int ans = -1;

    if(n < k){
        ans = min(n, abs(n - k));
    }else {
        long long int y = n % k;
        ans = min(y, abs(y - k));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef unsigned int uint;
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

const int MX = 1<<19;
const int MM = 998244353;

map<ll, int> DB;
int P[MX], ad[MX], cnt[MX];
ll D[MX], E[MX];
int N;

vector<int> T[MX];

ll dfs(int x, int p, int lev = 0){
	ll tot = 0;
	for(int c : T[x]){
		tot += dfs(c, x, lev+1);
	}
	return tot + lev;
}

int main()
{
	scanf("%d", &N);
	for(int i = 1; i <= N; i++){
		scanf("%lld", D+i);
		DB[D[i]] = i;
	}
	for(int i = 1; i <= N; i++) ad[i] = i;
	sort(ad+1, ad+N+1, [](int l, int r){
		return D[l] > D[r];
	});

	for(int i = 1; i <= N; i++) cnt[i] = 1;
	for(int i = 1; i < N; i++){
		int c = ad[i];
		ll v = D[c] - (N - cnt[c]*2);
		if(DB.find(v) == DB.end()) return !printf("-1\n");
		P[c] = DB[v];
		cnt[P[c]] += cnt[c];
		
		T[P[c]].push_back(c);
	}
	int r = ad[N];

	if(D[r] != dfs(r, -1)) return !printf("-1\n");
	for(int i = 1; i <= N; i++){
		for(int c : T[i]) printf("%d %d\n", i, c);
	}
}


Measured memory_bytes: 36352
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int mod  = 2019;
int main()
{
    // freopen("a.in","r",stdin);
    // freopen("k.out","w",stdout);
    int a,b;
    scanf("%d %d",&a,&b);
    long long ans = 1e18;
    for(int i=a;i<=min(b,a+4040);i++)
        for(int j=a;j<=min(b,a+4040);j++)
            if(i!=j)
                ans = min(1ll*i%mod*j%mod,ans);
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 100000000000000
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<int, int> P;


//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

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

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}


////////////////////////////////////////////////////////////////////

int main() {
ll n;
cin>>n;
ll a[n];
rrep(i, n){
	cin>>a[i];
}

reverse(a,a+n);

ll dp[n];
rrep(i, n){
	dp[i]=INF;
}

rrep(i, n){
	*lower_bound(dp,dp+n,a[i]+1)=a[i];
}
cout<<lower_bound(dp,dp+n,INF)-dp<<"\n";
return 0;
}




Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
const int maxn = 2e5 + 10;

int n, a[maxn], p, flag = 1;
bool check(int k) {
	std::map<int, int> M; M.clear();
	for (int i = 1; i <= n; ++i) if (a[i] <= a[i - 1]) {
		while (!M.empty() && M.rbegin() -> first > a[i]) M.erase(--M.end());
		for (p = a[i]; p && ++M[p] == k; --p) M[p] = 0;
		if (!p) return false;
	}
	return true;
}

int main() {
	std::ios::sync_with_stdio(false), std::cin.tie(0), std::cout.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; ++i) std::cin >> a[i], flag &= a[i] > a[i - 1];
	if (flag) return std::cout << "1\n", 0;
	int l = 2, r = n, ans = n;
	while (l <= r) {
		int mid = l + r >> 1;
		if (check(mid)) r = mid - 1, ans = mid;
		else l = mid + 1;
	}
	std::cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

string S, T;

int main(void){
    cin >> S >> T;
    int ls = (int) S.size();
    int lt = (int) T.size();

    for(int i = ls-lt; i>=0; i--){
        for(int j = 0; j < lt; j++){
            if(S[i+j] != '?' and S[i+j] != T[j]) break;
            if(j == lt-1){
                for(int k = 0; k < i; k++) cout << ((S[k] == '?') ? 'a' : S[k]);
                cout << T;
                for(int k = i + lt; k < ls; k++) cout << ((S[k] == '?') ? 'a' : S[k]);
                cout << '\n';
                return 0;
            }
        }
    }

    cout << "UNRESTORABLE\n";

    return 0;
}

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


int main() {
  int a, b;
  float f;

  cin >> a >> b;
  double c, d;

  c = static_cast<double>(a);
  d = static_cast<double>(b);


  cout << a / b << " " << a % b << " " << fixed << setprecision(5) << c / d << endl;




}



Measured memory_bytes: 3284
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n], b[n];
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }
    for (int i=0; i<n; i++) {
        cin >> b[i];
    }

    int ans=0;
    int c[n], d[n];
    for (int k=0; k<30; k++) {
        ll tmp = 0;
        ll t = 1ll << k;
        for (int i=0; i<n; i++) {
            c[i] = a[i] % (2 * t);
            d[i] = b[i] % (2 * t);
        }
        sort(d, d+n);
        for (int i=0; i<n; i++) {
            tmp += lower_bound(d, d+n, 2*t-c[i]) - lower_bound(d, d+n, t-c[i]);
            tmp += lower_bound(d, d+n, 4*t-c[i]) - lower_bound(d, d+n, 3*t-c[i]);
        }
        if (tmp % 2 == 1) ans += t;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
# 頂点n個 辺iは頂点aiとbiを結ぶ 各頂点には初期値0のカウンターがある
# 操作j: 頂点pjを根とする部分木に含まれるすべてのカウンターにxj足す
# Q回の操作のあと各カウンターの数値を求める

# 方針: 操作の際に最初に部分木の根にだけ点を加え最後に親の点を子に与えていく
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

n, q = map(int, input().split())
connect = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    connect[a-1].append(b-1)
    connect[b-1].append(a-1)

count = [0 for _ in range(n)]
for _ in range(q):
    p, x = map(int, input().split())
    count[p-1] += x


def dfs(now=0, prev=-1):
    kids = connect[now]
    for kid in kids:
        if kid == prev:
            continue
        count[kid] += count[now]
        dfs(kid, now)


dfs()

for i in range(n):
    print(count[i])


Measured memory_bytes: 265352
// ABC075_C
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>  // std::swap()
using namespace std;
using ll = long long;
 
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define pll pair<ll, ll>
#define F first
#define S second
 
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)
 
    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
 
    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }
 
    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }
 
    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }
 
    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};
 
int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N, M, a, b;
    cin >> N >> M;
    vector<pll> vec(M);
    REP(i, M) {
        cin >> a >> b; --a, --b;
        vec[i].F = a;
        vec[i].S = b;
    }
    
    // calculation
    
    ll res = 0;
    REP(i, M) {
      UnionFind uf(N);
        uf.init(N);
        REP(j, M) {
            if (j == i) continue;
            uf.merge(vec[j].F, vec[j].S);
        }
        if (uf.size(0) < N) res++;
    }
    
    cout << res << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
const long double eps = 1e-12;
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*2
#define REP(a,b) for(long long a = 0;a < b;++a)
int dame[(1 << 23)];
int n;
void fill(int now_value, int itr) {
	if (n == itr) return;
	if (((1 << itr) & now_value) == 0) {
		if (dame[now_value + (1 << itr)] == false) {
			dame[now_value + (1 << itr)] = true;
			fill(now_value + (1 << itr), itr + 1);
		}
	}
	fill(now_value, itr + 1);
}
int main(){
	scanf("%d", &n);
	vector<int> geko;
	for (int i = 0; i < (1 << n); ++i) {
		int a;
		scanf("%d", &a);
		geko.push_back(a);
	}
	int ans = 0;
	for (int i = 1; i < geko.size(); ++i) {
		if (geko[i] == 1) {
			if (dame[i] == false) {
				ans++;
				dame[i] = true;
				fill(i, 0);
			}
		}
		else {
			if (dame[i] == true) {
				cout << -1 << endl;
				return 0;
			}
		}
	}
	assert(ans != 0);
	cout << ans << endl;
}


Measured memory_bytes: 11208
n = int(input())
w = [input() for _ in range(n)]
res = True
for i in range(1,n):
    if w[i][0] != w[i-1][-1]:
        res = False
    else:
        continue
if res == True and len(w) == len(set(w)):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        String[] inputs = input();
//        String[] inputs = mockup();
        String[] inputs4S = inputs.clone();

        int swapCount = bubbleSort(inputs);
        output(inputs);
        System.out.println("Stable");

        int swapCount4S = selectionSort(inputs4S);
        output(inputs4S);

        boolean isStable = true;
        for (int i=0; i<inputs.length; i++) {
            isStable &= inputs[i].equals(inputs4S[i]);
        }
        System.out.println(isStable ? "Stable" : "Not stable");

    }

    /** bubble sort
     *
     * @param inputs
     * @return
     */
    private static int bubbleSort(String inputs[]) {
        int swapCount = 0;
        for (int i = 0; i < inputs.length; i++) {
            for (int j = inputs.length - 1; j > i; j--) {
                if (compare(inputs[j], inputs[j-1])) {
                    swap(inputs, j, j-1);
                    swapCount++;
                }
            }
        }
        return swapCount;
    }

    /**
     * selection sort
     * @param inputs
     * @return
     */
    private static int selectionSort(String[] inputs) {
        int swapCount = 0;
        int min = 0;

        for (int i = 0; i < inputs.length; i++) {
            min = i;
            for (int j = i; j < inputs.length; j++) {
                if (compare(inputs[j], inputs[min])) {
                    min = j;
                }
            }
            if (i != min) {
                swap(inputs, i, min);
                swapCount++;
            }
        }
        return swapCount;
    }

    private static String[] mockup() {
        String a[] = {"H4","C9","S4","D2","C3"};
        return a;
    }

    private static void swap(String[] inputs, int j, int i) {
        String a = inputs[j];
        String b = inputs[i];
        inputs[i] = a;
        inputs[j] = b;
    }
    private static boolean compare(String a, String b) {
        int iA = Integer.valueOf(a.substring(1));
        int iB = Integer.valueOf(b.substring(1));
        return iA < iB;
    }

    public static void output(String[] inputs) {
        // output
        StringBuilder output = new StringBuilder();
        for (String i : inputs) {
            output.append(i + " ");
        }
        String outputString = output.toString();
        System.out.println(outputString.substring(0,outputString.length() - 1));
    }

    public static String[] input() {
        Scanner in = new Scanner(System.in);
        int count = in.nextInt();
        String[] inputs = new String[count];
        for (int i = 0; i < count; i++) {
            inputs[i] = in.next();
        }
        in.close();
        return inputs;
    }

}

Measured memory_bytes: 17428
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, X, Y;
  X = 0;
  cin >> N;
  Y = N;
  for (int i = 0; i < 8; i++) {
    X += Y%10;
    Y /=10;
    if(Y == 0){
      break;
    }
  }
  if (N%X == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc112_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();

            int min = int.MaxValue;
            for (int i = 0; i < input[0]; i++)
            {
                int[] tmp = ReadLine().Split().Select(int.Parse).ToArray();
                if(input[1]>= tmp[1] && min > tmp[0]){
                    min = tmp[0];
                }
            }

            if(min == int.MaxValue){
                WriteLine("TLE");
            }else{
                WriteLine(min);
            }
        }
    }
}

Measured memory_bytes: 11348
#include <iostream>
#include <string>
#include <vector>

constexpr int nullNum = -3;

class Node{
public:
    Node( int id_, Node* parent_, std::vector<int> children_ ) : 
    id( id_ ), parent( parent_ ), children( children_ ){}

    Node() :
    id( nullNum ), parent( nullptr ), children( std::vector<int>(0) ) {}

    void SetID( int id_ ){
        id = id_;
    }

    void SetChildren( std::vector<int> cld ){
        children = cld;
    }

    void SetParent( Node* prt ){
        parent = prt;
    }

    int& ID(){
        return id;
    }

    int Depth(){
        int depth = 0;
        Node* ptr = Parent();
        while( ptr != nullptr ){
            ++depth;
            ptr = ptr->Parent();
        }
        return depth;
    }

    Node* Parent(){
        return parent;
    }

    std::vector<int>& ChildrenIDs(){
        return children;
    }

    std::string CategoryName(){
        if( !parent ){
            return "root";
        }else if( children.empty() ){
            return "leaf";
        }
        return "internal node";
    }
    
private:
    int id;
    Node* parent;
    std::vector<int> children; // owns children IDs as a vector
};

int main(){
    int n;
    std::cin.tie(0);
    std::cin >> n;

    std::vector<Node> tree(n);

    int id;
    int numOfChildren;
    std::vector<int> cld;

    for( auto& elem : tree ){
        elem = Node();
    }
    
    for( int i = 0; i < n; ++i ){
        std::cin >> id >> numOfChildren;
        tree[id].SetID( id );
        cld = std::vector<int>( numOfChildren );
        for( int j = 0; j < numOfChildren; ++j ){
            std::cin >> cld[j];
        }

        tree[id].SetChildren( cld );

        for( const auto& elem : cld ){
            tree[elem].SetParent( &tree[id] );
        }
    }

    for( int i = 0; i < n; ++i ){
        std::cout << "node " << i;
        std::cout << ": parent = " << ( ( !tree[i].Parent() )? -1 : tree[i].Parent()->ID() );
        std::cout << ", depth = " << tree[i].Depth();
        std::cout << ", " << tree[i].CategoryName();
        std::cout << ", [";
        for( int j = 0; j < tree[i].ChildrenIDs().size(); ++j ){
            std::cout << tree[i].ChildrenIDs()[j] << ( ( j != tree[i].ChildrenIDs().size()-1 )? ", " : "" );
        }
        std::cout << "]\n";
    }
}


Measured memory_bytes: 7724
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <iomanip>
#include <locale>

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	cout << c << " " << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 256
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> &P){
os << P.first;
os << " ";
os << P.second;
os << "\n";
return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<int> weight;
int N,K;
bool is_ok(int capa){
    int now_weight = 0;
    int track_num = 1;
    REP(i,N){
        int w = weight[i];
        if (w>capa) return false;
        if(now_weight+w > capa){
            now_weight = w;
            track_num++;
            if(track_num>K) return false;
        }else now_weight+= w;
    }
    return true;
}

//fixed<<setprecision(10)<<ans<<endl;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    weight.resize(N);
    int sum = 0;
    REP(i,N){
        cin >> weight[i];
        sum += weight[i];
    }   

    int ok = sum;
    int ng = 0;
    while (abs(ok-ng)>1){
        int mid = (ok+ng)/2;
        if(is_ok(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}


Measured memory_bytes: 3352
# まだ解いてない配点を nokori として持つ
def dfs(i, sum, count, nokori):
    global ans
    if i == d:
        # G 点に満たなければ nokori のうち一番大きいものを解く
        if sum < g:
            use = max(nokori)
            # 解く問題が問題数を超えないように注意
            n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
            count += n
            sum += n * use * 100

        if sum >= g:
            ans = min(ans, count)
    else:
        # 総合スコア、解いた問題数、まだ解いてない問題を更新
        dfs(i + 1, sum, count, nokori)
        dfs(i + 1, sum + pc[i][0] * (i + 1) * 100 + pc[i][1], count + pc[i][0], nokori - {i + 1})


d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = float("inf")

dfs(0, 0, 0, set(range(1, d + 1)))
print(ans)

Measured memory_bytes: 9232
#include<iostream>
#include<deque>
using namespace std;
int main(){
	int n;
	cin >> n;
	deque<int> b;
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		if(i%2!=n%2) b.push_front(a);
		else b.push_back(a);
	}
	for(int i=0;i<n;i++){
		cout << b[i];
		if(i!=n-1) cout << ' ';
		else cout << endl;
	}
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define f first
#define s second
#define int long long
#define pb push_back
#define pencho ios_base::sync_with_stdio(false);cin.tie(NULL);
#define N 100005
#define mod 1000000007


int dp[N], n;
int a[105];

int solveDp(int k) {
       if (dp[k] != -1) return dp[k];
       int x = 1, flag = 0;
       for (int i = 0; i < n; i++) if (k - a[i] >= 0) flag = 1, x = min(x, solveDp(k - a[i]));
       if (flag == 0)   dp[k] = 0;
       else {
              if (x == 0)      dp[k] = 1;
              else dp[k] = 0;
       }
       return dp[k];
}

void solve() {
       pencho
       int k; cin >> n >> k;
       memset(dp, -1, sizeof(dp));
       for (int i = 0; i < n; i++) cin >> a[i], dp[a[i]] = 1;
       dp[0] = 1;

       solveDp(k);
       if (dp[k] == 1)  cout << "First";       else cout << "Second";

}


signed main()
{
/*#ifndef ONLINE_JUDGE
       freopen("input.txt", "r", stdin);
       freopen("o.txt", "w", stdout);
#endif*/

       solve();
}

Measured memory_bytes: 8992
import numpy as np
N, W = map(int, input().split())
w, v = [], []
for i in range(N):
    a, b = map(int, input().split())
    w.append(a)
    v.append(b)

DP = np.zeros((N+1,W+1), dtype=np.int64)

for i in range(N):
    DP [i+1] = np.array(DP[i])
    DP[i+1][w[i]:] = np.maximum(DP[i][:-w[i]]+ v[i], DP[i][w[i]:])

#print(DP)
print(DP[-1][-1])

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

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

    int q;
    cin >> q;

    int t, f;
    string c;
    int count = 0 ;
    for (int i = 0; i < q; i++)
    {
        cin >> t;
        if (t == 1)
        {
            count ++ ;
        }
        else
        {
            cin >> f >> c ;
            if(f==1)
            {
                if(count%2)
                {
                    reverse(s.begin(),s.end());
                }
                s = c+s ;
            }
            else
            {
                if(count%2)
                {
                    reverse(s.begin(),s.end());
                }
                s += c ;
            }
            count = 0 ;
        }
    }
    if(count%2)
    {
        reverse(s.begin(),s.end());
    }
    cout << s << endl  ;
}

Measured memory_bytes: 4728
_,A,_,*E=$<.map{_1.split.map &:to_i}
s=A.sum
A=A.tally
E.map{|x,y|A[x]||=0
A[y]||=0
A[x],A[y]=0,A[y]+t=A[x]
p s+=t*=y-x}

Measured memory_bytes: 30584
n = int(input())
a = list(map(int, input().split()))
color = [0 for i in range(9)]
for e in a:
  if e>=3200:
    color[8] += 1
  else:
    color[e//400] += 1
min_ = 0
for e in color[:8]:
  if e:
    min_ += 1
print(max(1, min_), min_+color[8])

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

struct Node {
    int key;
    struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

Node * find(Node *u, int k) {
    while(u != NIL && k != u->key) {
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
    
int main(void) {
    int n, i, x;
    char com[16];
    scanf("%d",&n);
    
    for(i=0;i<n;i++) {
        scanf("%s",com);
    	if(com[0]=='f'){
    		scanf("%d",&x);
    		Node *t=find(root,x);
    		if(t!=NIL){
    			printf("yes\n");
    		}else{
    			printf("no\n");
    		}
    	}else if(!strcmp(com,"insert")) {
            scanf("%d",&x);
            insert(x);
        } else if(!strcmp(com,"print")) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 20556
import itertools

n = int(input())
city_distance = [list(map(int, input().split())) for _ in range(n)]

city_number = [i for i in range(n)]
permutations_city_number = itertools.permutations(city_number)

sum_distance = 0
cnt = 0

for city in permutations_city_number:
    memo = 0
    for x in city:
        if memo == 0:
            city1 = x
            memo = 1
        sum_distance += ((city_distance[city1][0] - city_distance[x][0]) ** 2 + (city_distance[city1][1] - city_distance[x][1]) ** 2) ** 0.5
    cnt += 1

print(sum_distance/cnt)

Measured memory_bytes: 3188
N = int(input())
ans = []
for i in range(N):
    d = list(map(int, input().split()))
    d.sort()
    if d[2]**2 == d[1]**2+d[0]**2:
        ans.append("YES")
    else:
        ans.append("NO")
for i in range(N):
    print(ans[i])

Measured memory_bytes: 7592
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main( ) {
    // freopen("A.01.in","r",stdin);
    int a;
    scanf("%d",&a);
    int t =a+pow(a, 2)+pow(a, 3);
    printf("%d",t);
    return 0;
}

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

int main(){
  int n, k, x, y, sum=0;
  cin >> n >> k >> x >> y;
  if(n>k)sum = (n-k)*y + k*x;
  else if(n==k)sum = k*x;
  else sum = n*x;
  cout << sum;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9 + 7, A = 1e5 + 5;
int n, k, cnt[A];
int mul(int x, int y) {return (1LL * x * y) % mod;}
int add(int x, int y) {return ((x + y) % mod + mod) % mod;}
int fp(int x, int y)
{
    if (!y) return 1;
    ll acc = fp(x, y / 2);
    acc = mul(acc, acc);
    if (y & 1)
        acc = mul(acc, x);
    return acc;
}
int solve(int x)
{
    int ret = fp(k / x, n);
    for (int i = 2 * x; i <= k; i += x)
        ret = add(ret, -cnt[i]);
    return cnt[x] = ret;
}
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin >> n >> k;
    int ans = 0;
    for (int i = k; i > 0; i--)
        ans = add(ans, mul(i, solve(i)));
    cout << ans;
    return 0;
}

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

// ab を計算して、kc のパターン
int main(){
  int x,y,z,k; cin>>x>>y>>z>>k;
  vector<ll> a(x),b(y),c(z),num(x*y);
  for(int i=0;i<x;i++){
    cin>>a[i];
  }
  for(int i=0;i<y;i++){
    cin>>b[i];
  }
  for(int i=0;i<z;i++){
    cin>>c[i];
  }
  int count=0;
  for(int i=0;i<x;i++){
    for(int j=0;j<y;j++){
      num[count]=a[i]+b[j];
      count++;
    }
  }
  count=0;
  int size=num.size();
  vector<ll> ans(k*z+1,-1);
  sort(num.rbegin(),num.rend());
  for(int i=0;i<min(k,size);i++){
    for(int j=0;j<z;j++){
      ans[count]=num[i]+c[j];
      count++;
    }
  }
  sort(ans.rbegin(),ans.rend());
  for(int i=0;i<k;i++){
    cout<<ans[i]<<endl;
  }
}

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

int po10[]={1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000};

int n,s;
int dp[20][110];
int main(){
	dp[0][0]=dp[1][0]=1;
	for(int i=1;i<=9;i++){
		for(int j=9;j>=1;j--){
			for(int k=100;k>=i;k--){
				dp[j][k]+=dp[j-1][k-i];
			}
		}
	}
	while(true){
		int res=0;
		cin>>n>>s;
		if(n==0&&s==0) break;
		cout<<dp[n][s]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3012
#define _USE_MATH_DEFINES
# include <bits/stdc++.h>
using namespace std;
int main() {
    long long A,B,C,X,Y;
    cin >> A>>B>>C>>X>>Y;
    long long r=1000000000;
    long long l=0;
    while(r-l>1){
        long long mid=(r+l)/2;
        bool ok=false;
        long long c_min=0;
        long long rem=0;//プラスする変えん；
        if(A+B>=2*C){
            c_min=min(2*X,2*Y);
            if(X<=Y){
                if(B>=2*C){
                    c_min+=(Y-c_min/2)*2;
                }else{
                    rem=(Y-c_min/2)*B;
                }
            }else{
                if(A>=2*C){
                    c_min+=(X-c_min/2)*2;
                }else{
                    rem=(X-c_min/2)*A;
                }
            }
            if(c_min*C+rem<=mid){
                ok=true;
            }
        }else{
            if(A*X+B*Y<=mid){
                ok=true;
            }
        }
        (ok ? r :l)=mid;
        // cout<< r << endl;
    }
    cout<< r << endl;
    return 0;
}



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

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

using namespace std;

const int N=200010;
int n,m,l,r;
vector<int> vec[N];
int s[N<<2],lz[N<<2];

void build(int x,int l,int r) {
    if (l==r) {
        s[x]=-m-1+r;
        return;
    }
    int mid=(l+r)>>1;
    build(x<<1,l,mid);
    build(x<<1|1,mid+1,r);
    s[x]=max(s[x<<1],s[x<<1|1]);
}

void push(int x) {
    s[x<<1]+=lz[x];s[x<<1|1]+=lz[x];
    lz[x<<1]+=lz[x];lz[x<<1|1]+=lz[x];
    lz[x]=0;
}

void add(int x,int l,int r,int lq,int rq) {
    if (lq<=l&&r<=rq) {
        s[x]++;
        lz[x]++;
        return;
    }
    if (l>rq||r<lq) return;
    int mid=(l+r)>>1;
    push(x);
    add(x<<1,l,mid,lq,rq);
    add(x<<1|1,mid+1,r,lq,rq);
    s[x]=max(s[x<<1],s[x<<1|1]);
}

int query(int x,int l,int r,int lq,int rq) {
    if (lq<=l&&r<=rq) return s[x];
    if (l>rq||r<lq) return -INF;
    int mid=(l+r)>>1;
    push(x);
    return max(query(x<<1,l,mid,lq,rq),query(x<<1|1,mid+1,r,lq,rq));
}

int main()
{
    scanf("%d%d",&n,&m);
    for (int i=0;i<n;i++) {
        scanf("%d%d",&l,&r);
        vec[l].pb(r);
    }
    build(1,1,m+1);
    int ans=n-m;
    for (int i=0;i<=m;i++) {
        for (int j=0;j<vec[i].size();j++) add(1,1,m+1,1,vec[i][j]);
        int tmp=query(1,1,m+1,i+1,m+1);
        ans=max(ans,query(1,1,m+1,i+1,m+1)-i);
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 14720
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

struct Vector2d {
    long double x, y;
    Vector2d(long double x0, long double y0) : x(x0), y(y0) {}
    long double norm_p2() { return x*x + y*y; }
    long double inner(Vector2d& v){
        return x*v.x + y*v.y;
    }
    Vector2d proj(Vector2d& v){
        return (*this)*(this->inner(v) / this->norm_p2());
    }
    Vector2d operator+(const Vector2d& v){
        return Vector2d(this->x + v.x, this->y + v.y);
    }
    Vector2d operator-(const Vector2d& v){
        return Vector2d(this->x - v.x, this->y - v.y);
    }
    Vector2d operator*(long double k){
        return Vector2d(k*this->x, k*this->y);
    }
    
};

int main(){
    long double x1,y1,x2,y2;
    int q;
    cin >> x1 >> y1 >> x2 >> y2 >> q;

    Vector2d A(x2-x1,y2-y1);
    Vector2d p(x1, y1);
    for(int i = 0; i < q; i++){
        long double x3, y3; 
        cin >> x3 >> y3;
        Vector2d B(x3- x1, y3 - y1);

        Vector2d ans = p + A.proj(B);
        cout << setprecision(15) << ans.x << " " << ans.y << endl;
    }
}


Measured memory_bytes: 3296
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#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
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 2e5+5


int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int n;
        cin >> n;
        int i=pow(n,3);
        cout << i;
        
        

}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a0=sum(a)//2-sum(a[1::2])
ans=[a0*2]
for i in range(n-2):
    ans.append(a[i]*2-ans[-1])
ans.append((a[-1]-a0)*2)
print(*ans)


Measured memory_bytes: 14092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    ll k;
    cin >> k;
    ll n = len(s);
    vector<vector<vector<ll>>> dp(n + 1, vector<vector<ll>>(k + 1, vector<ll>(2, 0)));
    dp[0][0][0] = 1;
    rep(i, n) {
        ll v = (s[i] != '0') ? 1 : 0;
        reps(j, v, k + 1) dp[i + 1][j][0] = dp[i][j - v][0];
        v = s[i] - '0';
        rep(j, k + 1) {
            if (j == 0) {
                dp[i + 1][j][1] += dp[i][j][1];
                if (v > 0) dp[i + 1][j][1] += dp[i][j][0];
            }
            else {
                dp[i + 1][j][1] += dp[i][j][1] + dp[i][j - 1][1] * 9;
                if (v > 0) dp[i + 1][j][1] += dp[i][j][0] + dp[i][j - 1][0] * (v - 1);
            }
        }
    }
    cout << (dp[n][k][0] + dp[n][k][1]) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int mod=(1e9)+7;
const int maxn=(1e5)+10;
int n;
ll dp[maxn][2];
char s[maxn];
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%s",s+1);
	n=strlen(s+1);
	dp[0][1]=1;
	for (int i=0;i<=n;i++) {
		dp[i+1][0]+=dp[i][0]*3;
		if (s[i+1]=='1') dp[i+1][0]+=dp[i][1];
		dp[i+1][0]%=mod;
		if (s[i+1]=='1') dp[i+1][1]+=dp[i][1]*2;
		else dp[i+1][1]+=dp[i][1];
		dp[i+1][1]%=mod;
	}
	printf("%lld\n",(dp[n][0]+dp[n][1])%mod);
	return 0;
}

Measured memory_bytes: 1920
N = int(input())
P = list(map(int,input().split()))
T = [P[0]]+[10**10]*(N-1)
ans = 0

for i in range(N):
    T[i] = min(T[i-1],P[i])
    if P[i] <= T[i]:
        ans += 1

print(ans)

Measured memory_bytes: 32316
Q = 10**9+7
from collections import deque
from itertools import accumulate
#import sys
#input = sys.stdin.readline
def main():
    N, K = map( int, input().split())
    ans = 0
    d = deque()
    e = deque()
    M = int(N**(1/2))*2
    for i in range(1, int(N**(1/2))+1):
        if i**2 == N:
            d.append(i)
            M -= 1
            continue
        d.append(i)
        e.appendleft(N//i)
    T = list(d)+list(e)
    CT = [1]*M
    for i in range(1,M):
        CT[i] = T[i] - T[i-1]
    accT = list( map(lambda x:x%Q, accumulate(CT) ))
    dp = [[0]*M for _ in range(K)]
    for i in range(M):
        dp[1][i] = accT[-i-1]*CT[i]%Q
    for k in range(1, K-1):
        accT[0] = dp[k][0]
        for i in range(M-1):
            accT[i+1] = (accT[i]+dp[k][i+1])%Q
        for i in range(M):
            dp[k+1][i] = accT[-i-1]*CT[i]%Q
    print(sum(dp[K-1])%Q)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 97136
<?php
fscanf(STDIN, "%d %d %d %d", $H, $W, $A, $B);

#そもそも、半分よりABが大きいならNG
if(($A>$W/2) or ($B>$H/2)){
  echo 'No';
  exit;
}

$list = array_fill(0, $H, array_fill(0, $W, 0));

for($j=0; $j<$B; $j++){
  for ($i=0; $i<$A; $i++) {
    $list[$j][$i]=1;
  }
}
for($j=$B; $j<$H; $j++){
  for($i=$A; $i<$W; $i++){
    $list[$j][$i]=1;
  }
}

#出力
foreach ($list as $vH){
  foreach($vH as $v){
    echo $v;
  }
  echo "\n";
}

Measured memory_bytes: 147956
sx, sy, tx, ty = map(int, raw_input().split())
w = tx-sx
h = ty-sy
print "U"*h+"R"*w+"D"*h+"L"*w+"L"+"U"*(h+1)+"R"*(w+1)+"D"+"R"+"D"*(h+1)+"L"*(w+1)+"U"


Measured memory_bytes: 2568
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#define _ ios::sync_with_stdio(false)
using namespace std;
typedef long long int ll;
const int MAXN=100000+10;
int main(){
    int a,b;
    cin>>a>>b;
    if(a+b>=10){
        puts("error");
    }else{
        cout<<a+b;
    }
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll H, W;
  cin>>H>>W;
  ll ans = big;
  ll tmp1, tmp2, tmp3;
  for(ll i=1;i<H;++i) {
    tmp1 = i*W;
    tmp2 = W/2*(H-i);
    tmp3 = (W+1)/2*(H-i);
    ans = min(ans, max(tmp1, max(tmp2, tmp3)) - min(tmp1, min(tmp2, tmp3)));

    tmp2 = (H-i)/2*W;
    tmp3 = (H-i+1)/2*W;
    ans = min(ans, max(tmp1, max(tmp2, tmp3)) - min(tmp1, min(tmp2, tmp3)));
  }
  for(ll i=1;i<W;++i) {
    tmp1 = i*H;
    tmp2 = H/2*(W-i);
    tmp3 = (H+1)/2*(W-i);
    ans = min(ans, max(tmp1, max(tmp2, tmp3)) - min(tmp1, min(tmp2, tmp3)));

    tmp2 = (W-i)/2*H;
    tmp3 = (W-i+1)/2*H;
    ans = min(ans, max(tmp1, max(tmp2, tmp3)) - min(tmp1, min(tmp2, tmp3)));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin >> s;
  if((s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) || (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) || (s[0] == s[3] && s[1] == s[2] && s[0] != s[1])){
      cout << "Yes" << endl;
  }else{
      cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		std::vector<int> num;
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (; x; x /= 10) {
			num.push_back(x % 10);
		}
		while (!num.empty()) {
			putchar(num.back() ^ '0');
			num.pop_back();
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 200005;

long long n, k;

int main() {
	read(n), read(k);
	n %= k;
	print(std::min(n, k - n));
}


Measured memory_bytes: 2304
#include<stdio.h>
int min(int a,int b){
  if(a > b){
    return b;
  }else{
    return a;
  }
}

int main(){
  int N,T;
  scanf("%d %d",&N,&T);
  int t[N],ans = T;
  for(int i = 0;i < N;i++){
    scanf("%d",&t[i]);
    if(i > 0){
      ans += min(T,t[i] - t[i - 1]);
    }
  }
  printf("%d",ans);
  return 0;
}

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

using namespace std;

int main() {
	int N, Y;
	cin >> N >> Y;
	for (int a = 0; a * 10000 <= Y; a++) {
		for (int b = 0; a + b <= N && a * 10000 + (long long) b * 5000 <= Y; b++) {
			int c = N - a - b;
			int R = Y - a * 10000 - b * 5000;
			if (R % 1000 == 0 && R / 1000 == c) {
				cout << a << ' ' << b << ' ' << c << endl;
				return 0;
			}
		}
	}
	puts("-1 -1 -1");
	return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>

int main()
{
  int i,j,v;
  int A[100],N;
  
  scanf("%d",&N);/*number of value*/
  for(i=0; i<N; ++i){
    scanf("%d",&A[i]);/*input number*/
    printf("%d",A[i]);
    if(i!=N-1)printf(" ");
 
 }
  printf("\n");

  for(i=1; i<N; i++){/*sort*/
    v=A[i];
    /*insert A[j] into the sorted sequence A[1,....,i-1]*/
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
      
    }
    A[j+1]=v;
    
    for(j=0;j<N;j++){/*output*/
      printf("%d",A[j]);
      if(j!=N-1)printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
using namespace std;

using ll=long long int;


int main() {

	string s;
	cin >> s;

	int cnt = 0;

	for (int i = 0; i < 3; i++) {
		if (s[i] == '1') {
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}





Measured memory_bytes: 256
a, b, c = gets.chomp.split.map(&:to_i)

a, b, c = [a, b, c].sort

res = (c - a) / 2 
res += (c - b) / 2

a += ((c - a) / 2) * 2
b += ((c - b) / 2) * 2

a, b, c = [a, b, c].sort

if a == b && b == c
  res += 0
elsif a == b
  res += 1
else
  res += 2
end

puts(res)

Measured memory_bytes: 1788