akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

pair<int, int> field[100][100];
int visit[100][100];

int dfs(int x, int y) {
  if (visit[y][x] == 1) { return 1; }
  if (visit[y][x] == 2) { return 0; }
  visit[y][x] = 1;
  int ret = dfs(field[y][x].first, field[y][x].second);
  visit[y][x] = 2;
  return ret;
}

char str[1000];

int main() {
  int n;
  while (scanf("%d", &n), n) {
    assert(1 <= n && n <= 100);
    MEMSET(visit, 0);
    REP(y, n) {
      REP(x, n) {
        int a, b;
        scanf("%d %d", &a, &b);
        assert(0 <= a && a < n);
        assert(0 <= b && b < n);
        field[y][x] = make_pair(a, b);
      }
    }
    int ans = 0;
    REP(y, n) {
      REP(x, n) {
        if (!visit[y][x]) {
          ans += dfs(x, y);
        }
      }
    }
    printf("%d\n", ans);
  }
  assert(scanf("%s", str) == EOF);
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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 int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        --a[i];
    }
    vector<mint> ans(200005, 0);
    ans[a[0]] = 1;
    rep(i,n-1){
        if(a[i] != a[i+1]) ans[a[i+1]] += ans[a[i]];
    }
    cout << ans[a[n-1]].x << endl;
    return 0;
}


Measured memory_bytes: 5576
def main():
    a,b,c,d = map(int,input().split())
    
    ans = -1 * 10**20
    
    if a*b <= 0:
        ans = 0
    if c*d <= 0:
        ans = 0
    
    for i in (a,b):
        for j in (c,d):
            if i*j > ans:
                ans = i*j
    print(ans)
    
if __name__ == '__main__':
    main()

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

int main() {
  string s;cin>>s;
  string hitati="";
  rep(i,5){
    hitati+="hi";
    if(s==hitati){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();

		long mod = 1000000007;
		long[] cnt = new long[26];
		for (int i = 0; i < N; i++) {
            //System.out.println(S.charAt(i) - 'a');
			cnt[S.charAt(i) - 'a']++;
		}
		long ans = 1;
		for (long i : cnt) {
			ans = (i+1)*ans%mod;
		}
		ans -= 1;
		System.out.println(ans);
	}
}


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


void solve(long long D, long long G, std::vector<long long> p, std::vector<long long> c){
    auto ans = accumulate(p.begin(), p.end(), 0l);
    for(int b=0; b<pow(2, D); b++){
        unsigned long long tmp=b;
        auto total = 0l;
        auto cnt = 0l;
        auto first_i = -1;

        for(int j=0; j<D; j++){
            int i=D-j; // D...1
            if(tmp%2 == 0){
                if(first_i == -1)first_i = i;
            }else{
                total += 100*i*p[i-1]+c[i-1];
                cnt += p[i-1];
            }
            tmp >>= 1u;
        }

        if(total < G && first_i>=0){
            auto n = (long long)ceil((double)(G - total)/(double)(100*first_i));
            if(n < p[first_i-1]){
                total += 100*first_i*n;
                cnt += n;
            }
        }

        if(total >= G && cnt < ans)ans=cnt;
    }

    cout << ans << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long D;
    scanf("%lld",&D);
    long long G;
    scanf("%lld",&G);
    std::vector<long long> p(D);
    std::vector<long long> c(D);
    for(int i = 0 ; i < D ; i++){
        scanf("%lld",&p[i]);
        scanf("%lld",&c[i]);
    }
    solve(D, G, std::move(p), std::move(c));
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int C = scanner.nextInt();
    System.out.println(Math.max(0, C - (A - B)));
  }
}


Measured memory_bytes: 23764
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
//#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

deque<char> d[2];

void hora(int tc) {
	int n;
	cin>>n;
	while(1) {
		bool ada = false;
		for(int i = 0;i < 4;i++) {
			for(auto x: d[0]) cout<<x;
			if(i == 0 || i == 2) cout<<'.';
			else cout<<'#';
			cout<<endl;
			for(auto x: d[1]) cout<<x;
			if(i == 0 || i == 1) cout<<'.';
			else cout<<'#';
			cout<<endl;
			string c;
			cin>>c;
			if(c == "T") {
				ada = true;
				if(i == 0 || i == 2) d[0].PB('.');
				else d[0].PB('#');
				if(i == 0 || i == 1) d[1].PB('.');
				else d[1].PB('#');
				break;
			} else if(c == "end") return ;
		}
		if(ada == false) break;	
	}
	while(1) {
		bool ada = false;
		for(int i = 0;i < 4;i++) {
			if(i == 0 || i == 2) cout<<'.';
			else cout<<'#';
			for(auto x: d[0]) cout<<x;
			cout<<endl;
			if(i == 0 || i == 1) cout<<'.';
			else cout<<'#';
			for(auto x: d[1]) cout<<x;
			cout<<endl;
			string c;
			cin>>c;
			if(c == "T") {
				ada = true;
				if(i == 0 || i == 2) d[0].PF('.');
				else d[0].PF('#');
				if(i == 0 || i == 1) d[1].PF('.');
				else d[1].PF('#');
				break;
			} else if(c == "end") return ;
		}	
	}
}

int main(){
//	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}




Measured memory_bytes: 724
from sys import setrecursionlimit
setrecursionlimit(10**5)
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

a,b=map(int,input().split())
if a<b:
    a,b=b,a
print(gcd(a,b))


Measured memory_bytes: 5604
import math

n, k = map(int, input().split())

a = 0
b = []

for i in range(1, n + 1):
    v = math.ceil(math.log2(k/i))
    if v <= 0:
        b.append(1)
    else:
        b.append((1/2) ** v)

print(sum(map(lambda x: 1/n * x, b)))

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;


/*https://atcoder.jp/contests/atc002/tasks/atc002_c
ここで解説されているO(N^3)のDPを行う
Skew heapなどを使えばO(nlogn)でできるらしい
*/

ll dp[405][405];
int N;
vll a(405);
vll Sum(405);

ll rec(int i, int j) { //[i,j)における最小コスト
    if (j == i + 1) return 0;
    if (dp[i][j] != -1) return dp[i][j];
    ll res = INF;
    ll tmp;
    for (int k = i + 1; k < j ; k++) {
        tmp = rec(i, k) + rec(k, j)
              + Sum[j] - Sum[i];
        chmin(res, tmp);
    }

    return dp[i][j] = res;
}

int main() {
    cin >> N;
    rep(i, N) cin >> a[i];
    Sum[0] = 0;
    rep(i, N) Sum[i + 1] = Sum[i] + a[i];

    memset(dp, -1, sizeof(dp));

    cout << rec(0, N) << endl;

}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int A, B;
  st S;
  ci(A, B, S);
  bool f = 1;
  rep(i, A + B + 1){
    if(A == i){
      if(S.at(i) != '-'){
        f = 0;
      }
    }
    else{
      if('0' > S.at(i) || S.at(i) > '9'){
        f = 0;
      }
    }
  }
  if(f){
    co("Yes");
  }
  else{
    co("No");
  }
}


Measured memory_bytes: 256
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

"""
max_b = max(B)
max_c = max(C)
"""

summs_ab = []
summs = []
for a in A:
    for b in B:
        summs_ab.append(a+b)
summs_ab.sort(reverse=True)
summs_ab = summs_ab[:min(3001, X*Y*Z+1)]

for c in C:
    for sab in summs_ab:
        summs.append(sab+c)
summs.sort(reverse=True)
"""
for a in A[:K]:
    if len(summs) >= K and a + max_b + max_c < summs[K-1]:
        break

    for b in B[:K]:
        if len(summs) >= K and a + b + max_c < summs[K-1]:
            break

        for c in C[:K]:
            summ = a + b + c
            if len(summs) >= K:
                min_sum = summs[K-1]    
                if summ < min_sum:
                    break
            summs.append(summ)
        summs = merge_sort(summs)
        summs.reverse()
"""
for i in range(K):
    print(summs[i])

Measured memory_bytes: 141724
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
typedef long long ll;typedef pair<int,int> PII;const ll mod=1e9+7;const int N = 1e6+10;ll a[N];
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int main() {
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s,t,u;
	cin>>s;
	int n = s.size();
	cout<<string(n,'x');
  	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
    long N, A;

    cin >> N;

    bool flag = false;
    for (long n = 0; n < N; n++) {
        cin >> A;
        if (A % 2 == 1) flag = true;
    }

    if (flag)
        cout << "first" << endl;
    else
        cout << "second" << endl;

    return 0;
}


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

using namespace std;

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.14159265358979323846;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

// SegmentTree (0 - indexed)
// T: モノイド
template<typename T>
class SegmentTree {
    int n;
    std::vector<T> data;
public:
    // 要素数を指定して初期化
    SegmentTree(int n_) {
        n = 1;
        while (n < n_)n <<= 1;
        data.resize(2 * n, T());
    }

    // 元となるstd::vectorを用意して初期化
    SegmentTree(std::vector<T> source) {
        n = 1;
        while (n < source.size())n <<= 1;
        data.resize(2 * n, T());
        std::copy(source.begin(), source.end(), data.begin() + n);
        for (int i = n - 1; i > 0; i--)data[i] = data[2 * i] + data[2 * i + 1];
    }

    // [l, r)の区間和を取得
    T getSum(int l, int r) const {
        l += n, r += n;
        T ret = T();
        while (l < r) {
            if (l & 1)ret += data[l], l++;
            if (r & 1)ret += data[r - 1];
            l >>= 1, r >>= 1;
        }
        return ret;
    }

    // 要素iをxに更新
    void update(int i, T x) {
        i += n;
        data[i] = x;
        while (i > 1) {
            i >>= 1;
            data[i] = data[2 * i] + data[2 * i + 1];
        }
    }
};

class Magma {
public:
    int val;

    Magma operator+(const Magma obj) {
        return Magma(min(val, obj.val));
    }

    Magma &operator+=(const Magma &obj) {
        val = (*this + obj).val;
        return *this;
    }

    Magma() : val((1 << 31) - 1) {}

    Magma(int val) : val(val) {}
};

int n,q;

signed main() {
    cin >> n >> q;
    SegmentTree<Magma> st(n);
    for (int i = 0; i < q; i++) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0)st.update(x, y);
        else cout << st.getSum(x, y + 1).val << endl;
    }
}


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

int main(){
    int N;
    int h[100002];
    long mincost[100002];

    cin >> N;
    for(int i=0;i<N;i++) cin >> h[i];
    mincost[0] = 0;
    mincost[1] = abs(h[1] - h[0]);
    for(int i=2;i<N;i++){
        mincost[i] = min(mincost[i-2] + abs(h[i]-h[i-2]),
                         mincost[i-1] + abs(h[i]-h[i-1]));
    }

    cout << mincost[N-1] << "\n";
    return 0;
}

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

int main(){
  // (x, y) r
  double a[3],b[3];
  int n;

  cin >> n;
  while(n > 0){
    // input
    for(int i = 0; i < 3; i++){
      cin >> a[i];
    }
    for(int i = 0; i < 3; i++){
      cin >> b[i];
    }

    // distance
    double distance;
    distance = sqrt(pow(a[0] - b[0], 2) + pow(a[1] - b[1], 2));

    // judgment
    if(distance > a[2] + b[2]){
      cout << "0" << endl;
    }
    else if(distance < a[2] - b[2]){
      cout << "2" << endl;
    }
    else if(distance < b[2] - a[2]){
      cout << "-2" << endl;
    }
    else{
      cout << "1" << endl;
    }
    
    n--;
  }

  return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] array = new int[n];
    for(int i=0; i<n; i++){
      array[i] = sc.nextInt();
    }

    int sum = 0;
    int v1 = 0;
    int v2 = 0;

    for(int i=0; i<n;i++){
        v1 = array[i];
      for(int j=i+1; j<n; j++){
        v2 = array[j];
        sum += v1 * v2;
      }
    }

    System.out.println(sum);
  }

}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define pb push_back
#define vi vector<int >
#define vii vector < pair<int ,int > >
#define IO ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define IOfiles freopen("input.txt","r+",stdin) ; freopen("output.txt","w+",stdout)
#define PI 3.14159265
const long long mod = 1e9 + 7LL;
typedef long long ll;
typedef pair<int, int> ii;
typedef double db;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;}
ll pwr(ll x , ll n) { ll ans = 1; while (n) {ans *= x; n--;} return ans;}

void solve(){
    ll a,b,n;
    cin>>a>>b>>n;
    ll x=min(b-1,n);
    cout<<(a*x)/b<<endl;
}

int main()
{
    IO;
    solve();
}

Measured memory_bytes: 3600
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1e9+1
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  vector<int>A(n-1);
  for (int i = 0; i < n-1; ++i)
  {
    cin >> A[i];
  }
  int ans = A[0]+A[n-2];
  for (int i = 1; i < n-1; ++i)
  {
    ans += min(A[i-1],A[i]);
  }
  cout << ans << endl;
	return 0;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    while(1){
        if(n<=1000) break;
        n-=1000;
    }
    cout << 1000-n << "\n";
    return 0;
}   

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  ll s;cin >> s;
  ll x2,y2,x3,y3;
  ll sqrt_s = (ll)sqrt(s);
  while(sqrt_s*sqrt_s < s){
    ++sqrt_s;
  }
  x3 = sqrt_s;
  y2 = sqrt_s;
  ll rest = sqrt_s*sqrt_s-s;
  x2 =1;
  y3=rest;
  cout << "0 0 "<< x2 << " " << y2 << " "<< x3 << " " << y3 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
int main(){
        int n;
        cin>>n;
        vector<vector<int> > a(n,vector<int> (3,0) );
        for(int i=0;i<n;i++){
                for(int j=0;j<3;j++){
                        cin>>a[i][j];
                }
        }
        vector<vector<int> > dp(n+1,vector<int> (3,0) );
        dp[0][0]=dp[0][1]=dp[0][2] = 0;
        for(int i=1;i<=n;i++)
                for(int j=0;j<3;j++){
                dp[i][j]  = max(dp[i-1][(j+1)%3]+a[i-1][(j+1)%3],dp[i-1][(j+2)%3]+a[i-1][(j+1)%3]);
        }
        cout<<max(dp[n][0],max(dp[n][1],dp[n][2]) )<<endl;

        return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define ll long long
#define _n 2020
#define C continue
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define gc getchar
#define pc putchar
#define mem(a,b) memset(a,b,sizeof(a))
#define _for(i,a,b) for( int i=(a); i<=(b); i++)
#define _rep(i,a,b) for( int i=(a); i>=(b); i--)
using namespace std;
inline int rd()
{
    int x=0,f=1;char ch=gc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=gc();}
    return x*f;
}
char ch[200];
inline void rt(int x )
{
    int cnt=0,tmp=x>0?x:-x;
    if (!x) {pc('0');return;}
    if(x<0) pc('-');
    while(tmp>0) {ch[cnt++]=tmp%10+'0';tmp/=10;}
    while(cnt>0) pc(ch[--cnt]);
}
int main()
{
	int x=rd();
	if (x==1) rt(0);
	if (x==0) rt(1);
	
    return 0;
}




Measured memory_bytes: 3520
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int h,w,n;
  cin >> h >> w >> n;
  int ans[h][w];
  int p[n];
  rep(i,n){
    cin >> p[i];
  }
  int hh=0,ww=0;
  rep(i,n){
    int u=p[i];
    rep(j,u){
      //cout << hh << " " << ww << endl;
      ans[hh][ww]=i+1;
      if(ww==w-1&&hh%2==0)hh++;
      else if(ww==0&&hh%2==1)hh++;
      else{
        if(hh%2==0)ww++;
        else ww--;
      }
    }
  }
  rep(i,h){
    rep(j,w-1){
      cout << ans[i][j] << " ";
    }
    cout << ans[i][w-1] << endl;
  }
}


Measured memory_bytes: 3708
// AOJ 2410: Janken
// 2017.9.27 bal4u@uu
// 2017.12.2

#include <stdio.h>
#include <stdlib.h>

int main()
{
	int n, i, k, me;
	char s[20], ai[20], *p;

	fgets(s, 10, stdin);
	n = atoi(s);
	me = 0;
	for (i = 0; i < n; i++)	{
		fgets(s, 20, stdin);
		for (k = 0, p = s; *p >= ' '; p++) {
			if      (*p == 'o') k += 3;
			else if (*p == '-') k++;
		}
		if (k == 3*n - 2) me = i+1;
	}
	sprintf(s, "%d", me);
	for (i = 0; i < 1000; i++) {
		if (me) puts(s);
		else printf("%d\n", rand() % n + 1);
		fflush(stdout);
		fgets(ai, 10, stdin);
	}
	return 0;
}

Measured memory_bytes: 3368
#include<iostream>

using namespace std;

int main(void){
	int a[11],fir,n;
	int i;
	cin>>n;
	while(n--){
		int sec = 0;
		for(i=0;i<10;i++){
			cin>>a[i];
		}
		fir=a[0];
		for(i=1;i<10;i++){
			if(fir<a[i])fir=a[i];
			else if(sec<a[i])sec=a[i];
			else break;
		}
		if(i==10)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;

}

Measured memory_bytes: 1152
function main(arg) {
    let tmp = arg.trim().split("\n")[0]
    let N = Number(tmp.split(" ")[0])
    let M = Number(tmp.split(" ")[1])
    let H = arg.trim().split("\n")[1].split(" ").map(Number)
    tmp = arg.trim().split("\n")
    tmp.shift()
    tmp.shift()
    // let AB = tmp.map(e => e.split(" ").map(Number))
    let ans = new Array(H.length).fill(true)
    for (let i = 0; i < tmp.length; i++) {
        let row = tmp[i].split(" ").map(Number)
        let Ai = row[0] - 1
        let Bi = row[1] - 1
        let A = H[Ai]
        let B = H[Bi]
        if (A >= B) {
            ans[Bi] = false
        }
        if (B >= A) {
            ans[Ai] = false
        }
    }
    let counter = 0
    for (let i = 0; i < ans.length; i++) {
        if (ans[i]) {
            counter++
        }
    }
    // console.log(ans)
    console.log(counter)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;
using ll = long long;
constexpr ll mod = 1e9+7;
constexpr ll md = mod;
constexpr ll inf = 1e15;
int main(){
    int n;
    cin>>n;
    vector<int> b(n);
    for(auto &a : b)cin>>a;
    vector<int> ret;
    for(int i=0;i<n;++i){
        for(int j=b.size()-1;j>=0;j--){
            if(b[j] == j+1){
                b.erase(b.begin()+j);
                ret.push_back(j+1);
                break;
            }
        }
    }
    if(!b.empty()){
      cout << -1 << endl;  
    }else{
        reverse(ret.begin(),ret.end());
        for(auto &a : ret){
            cout << a << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <sstream>
#include <iostream>
#include <map>
#include <cstring>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
using namespace std;

#define rep(i,n) for(int i = 0;i<n;i++)
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int main() {
	while(true){
		int s,n,sum = 0,ans = 0;
		cin >> n >> s;
		if(s + n ==0) break;
		int comb = (1 << n) - 1;
		while(comb < 1 << 10){
			sum = 0;
			for(int p = 0;p<10;p++){
				if(comb & (1 << p)){
					sum+=p;
				}
			}
			if(sum == s){
				ans++;
			}
			int x = comb & -comb, y = comb+x;
			comb = ((comb & ~y) / x >> 1)|y;
		}
		cout << ans << endl;
	}
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;
typedef vector<string> vecst;
ll mod = 1000000007;

const int MAX = 510000;
const int MOD = 1000000007;

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    ull N, K;
    cin >> N >> K;
    
    // 前処理
    COMinit();

    for(ll i = 1; i <= K; i ++){
        if(i <= N - K + 1) cout << (COM(K-1, i-1) % mod) * (COM(N-K+1, i) % mod) % mod << endl;
        else cout << 0 << endl;
    }
}

Measured memory_bytes: 12288
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll h=in(),n=in();
    ll sum=0;
    for(ll i=0;i<n;++i)sum+=in();
    cout<<(sum>=h?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(auto x:v) cout<<" "<<x; cout<<endl;
int power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int t=1;
	//cin>>t;
	while(t--){
		int n,k,c;
		cin>>n>>k>>c;
		string s;
		cin>>s;
		vector<int> dp1(n,-1),dp2(n,-1);
		int l=-c-1,tot=0;
		for(int i=0;i<n;i++){
			if(s[i]=='o'&&i>=l+c+1&&tot<k){
				tot++;
				dp1[i]=tot;
				l=i;
			}
		}
		l=n+c,tot=k;
		for(int i=n-1;i>=0;i--){
			if(s[i]=='o'&&i<=l-c-1&&tot>0){
				dp2[i]=tot;
				tot--;
				l=i;
			}
		}
		vector<int>ans;
		for(int i=0;i<n;i++){
			if(s[i]!='x'&&dp1[i]==dp2[i]&&dp1[i]>0)
				ans.pb(i+1);
		}
		if(ans.empty())cout<<endl;
		else{
			for(auto c:ans)cout<<c<<endl;
		}
	}	
}


Measured memory_bytes: 5956
import java.util.*;
 
class Main {
	
    public static void main(String[] args) {
         
       Scanner cin=new Scanner(System.in);
       
       while(true) {
    	   int M=cin.nextInt(),T=cin.nextInt(),P=cin.nextInt(),R=cin.nextInt();
    	   
    	   if(M==0)break;
    	   
    	   Score data[]=new Score[T+1];
    	   for(int i=0;i<=T;i++) {
    		   data[i]=new Score();
    		   data[i].team=i;
    	   }
    	   
    	   int wa[][]=new int[T+1][P+1];
    	   
    	   for(int i=0;i<R;i++) {
    		   int m=cin.nextInt(),t=cin.nextInt(),p=cin.nextInt(),j=cin.nextInt();
    		   if(j==0) {
    			   data[t].acpt++;
    			   if(wa[t][p]>0)data[t].tt+=m+20*wa[t][p];
    			   else data[t].tt+=m;
    		   }
    		   else {
    			   wa[t][p]++;
    		   }
    		   
    	   }
    	   
    	   //sort
    	   boolean flag=true;
    	   for(int i=0;flag;i++) {
    		   flag=false;
    		   for(int j=data.length-1;j>=2;j--) {
    			   
    			   if(data[j].acpt>data[j-1].acpt) {
    				   
    				   Score temp=data[j-1];
    				   data[j-1]=data[j];
    				   data[j]=temp;
    				   flag=true;
    			   }
    			   else if(data[j].acpt==data[j-1].acpt && data[j].tt<data[j-1].tt) {
    				   
    				   Score temp=data[j-1];
    				   data[j-1]=data[j];
    				   data[j]=temp;
    				   flag=true;
    			   }
    			   else if(data[j].acpt==data[j-1].acpt && data[j].tt == data[j-1].tt && data[j].team>data[j-1].team) {
    				   
    				   Score temp=data[j-1];
    				   data[j-1]=data[j];
    				   data[j]=temp;
    				   flag=true;
    			   }
    			   
    		   }
    	   }
    	   
    	   System.out.print(data[1].team);
    	   for(int i=2;i<=T;i++) {
    		   if(data[i].acpt<data[i-1].acpt || (data[i].acpt == data[i-1].acpt && data[i].tt > data[i-1].tt))System.out.print(","+data[i].team);
    		   else System.out.print("="+data[i].team);
    	   }
    	   System.out.println();
       }
    }
}

class Score{
	int team=0,acpt=0,tt=0;
}


Measured memory_bytes: 68276
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

typedef long long ll;

int main (int argc, char* argv[]) {
	int n;
	cin >> n;
	vector<int> b(n);
	for (int i = 0; i < n - 1; i++) {
		cin >> b[i];
	}
	int res = b[0];
	for (int i = 0; i < n - 1; i++) {
		res += min(b[i], ((i + 1 < n - 1) ? b[i + 1] : b[i]));
	}
	cout << res << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) = println(run {
    val n = readLine()!!.toInt()
    val d = readLine()!!.split(" ").map { it.toInt() }

    var sum = 0
    d.indices.map { i ->
        (i+1..d.lastIndex).sumBy { j -> d[i] * d[j] }
    }.sum()

})

Measured memory_bytes: 36252
import Control.Monad
import Data.Char

solve :: String -> [Int] -> String
solve s xs = foldl (\a x -> drop x a ++ take x a) s xs

main :: IO ()
main = do
    s <- getLine
    if s == "-"
        then return ()
        else do
            n  <- readLn
            xs <- replicateM n readLn
            putStrLn $ solve s xs
            main

Measured memory_bytes: 4184
using System;

namespace abc164
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ');
            var ah = int.Parse(nm[0]);
            var aa = int.Parse(nm[1]);
            var bh = int.Parse(nm[2]);
            var ba = int.Parse(nm[3]);
            while(true)
            {
                bh -= aa;
                if (bh <= 0)
                {
                    Console.WriteLine("Yes");
                    break;
                }
                ah -= ba;
                if (ah <= 0)
                {
                    Console.WriteLine("No");
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 17836
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <utility>
#include <numeric>
#include <iomanip>

using namespace std;

int main() {
    int X; cin >> X;

    for (int i = 1; i <= 1000; i++)
    {
        if (X >= 100*i && X <= 105*i)
        {
            cout << 1 << endl;
            break;
        }
        
        if (i == 1000)
        {
            cout << 0 << endl;
        }
        
        
    }
    
}


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

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

    int a, b;
    cin >> a >> b;

    if(a<=8 && b<=8) puts("Yay!");
    else puts(":(");
}

Measured memory_bytes: 256
//Author:- S_Aditya

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const ll mod=1e9+7;         
const int N=3e3+4;

//dp[i][j] tells the probability of getting j heads after the first i tosses.
 
double dp[N][N];

int main()                  
{
    int n;
    
    scn(n);
    
    dp[0][0]=1.0; //probability of getting 0 heads after 0 tosses is 1
    
    rep(i,1,n+1)
    {
        double prob;
        
        scanf("%lf",&prob);
        
        rep(j,0,i+1)
        {
            //we get a tail in the current toss, so need the same no. of heads in the previous toss
            dp[i][j]=(1.0-prob)*dp[i-1][j];
            
            //we get a head in the current toss, so need one less in the previous toss
            if(j)
            dp[i][j]+=(prob*dp[i-1][j-1]);
        }
    }
    
    double ans=0.0;
        
    int lim=(n+1)/2;
        
    rep(i,lim,n+1)
    ans+=dp[n][i];
    
    printf("%.10lf",ans);
} 

Measured memory_bytes: 68992
#include<stdio.h>

#define BLACK -1
#define GRAY  -2
#define WHITE -3

void DFSvisit(int);

int G[100][100],d[100],f[100],color[100];
int n,time;

void DFS(int n){
  int i;

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

void DFSvisit(int u){
  int i;

  color[u]=GRAY;
  time++;
  d[u]=time;

  for(i=0;i<=n;i++){
    if(G[u][i] && color[i]==WHITE){
      DFSvisit(i);
    }
  }
  color[u]=BLACK;
  f[u]=++time;
}

main(){
  int  i,j,k,m;

  scanf("%d",&n);

  for(i=0;i<100;i++){
    for(j=0;j<100;j++){
      G[i][j]=0;
    }
    color[i] = WHITE;
  }

  for(i=0;i<n;i++){ 
    scanf("%d%d",&j,&k);
    for(j=0;j<k;j++){
      scanf("%d",&m);
      G[i][m-1]=1;
    }
  } 
 
  DFS(n);

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

Measured memory_bytes: 1068
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
 
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000
 
using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
 
int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0,0 };
 
int main(void){

	while(1){
		string g;
		int y,m,d;

		cin>>g;
		if(g=="#"){
			break;
		}
		cin>>y>>m>>d;

		if(y<=30){
			cout<<g<<" "<<y<<" "<<m<<" "<<d<<endl;
		}else if(y==31){
			if(m<=4){
				cout<<g<<" "<<y<<" "<<m<<" "<<d<<endl;
			}else{
				cout<<"?"<<" "<<y-30<<" "<<m<<" "<<d<<endl;
			}
		}else{
			cout<<"?"<<" "<<y-30<<" "<<m<<" "<<d<<endl;
		}

	}

}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

ll d[210][210];


int main(int argc, char const *argv[]) {
    int n, m, R;
    cin >> n >> m >> R;
    vector<int> r(R);
    REP(i,R) cin >> r[i];
    REP(i,210) REP(j,210) d[i][j] = INF;
    REP(i,210) d[i][i] = 0;
    REP(i,m) {
        int a, b, c;
        cin >> a >> b >> c;
        d[a][b] = d[b][a] = c;
    }
    sort(r.begin(), r.end());
    for(int i = 1; i <= n; ++i) 
        for(int j = 1; j <= n; ++j) 
            for(int k = 1; k <= n; ++k) 
                d[j][k] = min(d[j][k], d[j][i]+d[i][k]);
    
    ll ans = LINF;
    do {
        ll cans = 0;
        REP(i,R-1) cans += d[r[i]][r[i+1]];
        ans = min(ans, cans);
    } while (next_permutation(r.begin(), r.end()));
    cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int a,b,c,d;
    string ans="No";
    cin>>a>>b>>c>>d;
    if(abs(b-a)<=d&&abs(c-b)<=d||abs(c-a)<=d)ans="Yes";
    cout<<ans<<endl;
}

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

int main(){
	/*input*/
	int n;	cin >> n;
	/*output*/
	switch(n){
		case 1:
			cout << "Hello World" << endl;
		break;
		case 2:
			int a, b;	cin >> a >> b;
			cout << a + b << endl;
		break;
	}
}


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

#define PI acos(-1)
#define pb push_back
#define int long long int
#define mp make_pair
#define pi pair<int, int>
#define pii pair<int, pi>
#define fir first
#define sec second
#define MAXN 100001
#define MAXL 20
#define mod 998244353
#define INF 9999999

signed main()
{
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> ans;
  for (int i = 0; i < n; i++)
    cin >> v[i];
  int sum_xor = 0;
  for (int i = 0; i < n; i++)
    sum_xor = sum_xor ^ v[i];
  for (int i = 0; i < n; i++)
    ans.pb(sum_xor ^ v[i]);
  for (auto const &i : ans)
    cout << i << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 6804
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
  int a, b, c;
  int ans;
  cin >> a >> b >> c;
  ans = max(a, b);
  ans = max(ans, c);

  cout << ans*10 + a + b + c - ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
typedef long long ll;
using namespace std;
int p[100100];
int n, m, q;
int g;
int root(int x) { return p[x] == x ? x : p[x] = root(p[x]); }
int main()
{
	scanf("%d%d%d", &n, &m, &q);
	for (int i = 1; i <= n; i++) p[i] = i;
	g = n;
	vector<pair<int, int>> es;
	for (int i = 1; i <= q; i++)
	{
		int u, v, w;
		scanf("%d%d%d", &u, &v, &w);
		u++; v++;
		if (w == 0) { //u,v belong to the same tree
			int ur = root(u), vr = root(v);
			if (ur != vr)
			{
				p[root(u)] = root(v);
				g--; m--;
			}
		}
		else es.push_back(make_pair(u, v));
	}
	vector<pair<int, int>> es2;
	for (auto& e : es)
	{
		int ur = root(e.first), vr = root(e.second);
		if (ur == vr)
		{
			printf("No\n"); // nodes in same tree can't have multiple paths
			return 0;
		}
		es2.push_back(make_pair(min(ur, vr), max(ur, vr)));
	}
	if (g == 1) // graph is a tree
	{
		printf("%s\n", m == 0 ? "Yes" : "No");
		return 0;
	}
	if (g == 2) // two supernodes
	{
		if (es2.size()) printf("No\n"); // can't make multiple paths
		else if (m != 1) printf("No\n"); // graph needs to be connected
		else printf("Yes\n");
		return 0;
	}
	// g>=3 supernodes left, any pair in es2 need multiple paths in between, using m edges
	ll ub = (ll)(g) * (ll)(g - 1) / 2; // max number of edges can be added
	ll lb = es2.empty() ? g - 1 : g; // min number of edges need to be added
	// graph is connect so we need at least g-1, but if we need multiple paths we need at least one more
	if (lb <= m && m <= ub) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 2932
#include<stdio.h>

int array[50];

int fib(int a){
  int ans;


  if(a  ==0 || a  ==1){
    return array[a]=1;
  }
  if(array[a]!=-1)return array[a];


  else {return array[a]=fib(a-1)+fib(a-2);}
  

}



int main(){

  int number;
  int ans;
  int i;

  
  for(i=0;i<50;i++){array[i]=-1;}
  
  scanf("%d",&number);

  ans=fib(number);


  

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

  


  return 0;
}



Measured memory_bytes: 2040
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first) {
        return a.first < b.first;
    } else {
        return a.second < b.second;
    }
}
const int ININF = 1000000;
long long maxnear(vector<long long> v, long long a) {
    int dai = lower_bound(v.begin(), v.end(), a) - v.begin();
    if(dai == 0) {
        return v[dai] - a;
    } else if(dai == v.size()) {
        return a - v[dai - 1];
    } else {
        return min(v[dai] - a, a - v[dai - 1]);
    }
}

int main() {
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<long long> s(A + 2);
    vector<long long> t(B + 2);
    vector<long long> q(Q);
    s[0] = -INF;
    t[0] = -INF;
    rep(i, 1, A + 1) { cin >> s[i]; }
    rep(i, 1, B + 1) { cin >> t[i]; }
    s[A + 1] = INF;
    t[B + 1] = INF;
    rep(i, 0, Q) { cin >> q[i]; }
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    // vector<long long> sTot(A);
    // vector<long long> tTos(B);
    // rep(i, 0, A) { sTot[i] = maxnear(t, s[i]); }
    // rep(i, 0, B) { tTos[i] = maxnear(s, t[i]); }
    // rep(i, 0, A) { cout << "sTot[" << i << "]:" << sTot[i] << endl; }
    // rep(i, 0, B) { cout << "tTos[" << i << "]:" << tTos[i] << endl; }
    rep(i, 0, Q) {
        long long x = q[i];
        long long minres = INF;
        int sdai = lower_bound(s.begin(), s.end(), x) - s.begin();
        int ssyo = sdai - 1;
        int tdai = lower_bound(t.begin(), t.end(), x) - t.begin();
        int tsyo = tdai - 1;
        chmin(minres,
              (abs(x - s[sdai]) + abs(s[sdai] - t[tdai]) ));
        chmin(minres,
              (abs(x - s[sdai]) + abs(s[sdai] - t[tsyo]) ));
        chmin(minres,
              (abs(x - s[ssyo]) + abs(s[ssyo] - t[tdai]) ));
        chmin(minres,
              (abs(x - s[ssyo]) + abs(s[ssyo] - t[tsyo]) ));
        chmin(minres,
              (abs(x - t[tdai]) + abs(t[tdai] - s[sdai]) ));
        chmin(minres,
              (abs(x - t[tdai]) + abs(t[tdai] - s[ssyo]) ));
        chmin(minres,
              (abs(x - t[tsyo]) + abs(t[tsyo] - s[sdai]) ));
        chmin(minres,
              (abs(x - t[tsyo]) + abs(t[tsyo] - s[ssyo]) ));
        // int tdai = lower_bound(t.begin(), t.end(), x) - t.begin();
        // if(tdai == ) {
        //     chmin(minres, t[tdai] - x + tTos[tdai]);
        // } else if(tdai == t.size()) {
        //     chmin(minres, x - t[tdai-1] + tTos[tdai-1]);
        // } else {
        //     chmin(minres, min(t[tdai] - x + tTos[tdai],
        //                       x - t[tdai - 1] + tTos[tdai - 1]));
        // }
        cout << minres << endl;
    }
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(void) {
  string s;
  map<char, bool> m;
  cin >> s;
  for (int i = 0; i < s.size(); i++)
    m[s[i]] = true;
  char ans = 'a' - 1;
  for (int i = 'a'; i <= 'z'; i++) {
    if (m[i] == false) {
      ans = i;
      break;
    }
  }
  if (ans == 'a' - 1)
    cout << "None" << endl;
  else
    cout << ans << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();

		System.out.println(a.substring(0, 1) + b.substring(1, 2) + c.substring(2, 3));

		sc.close();
	}
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define lowbit(x) ((x)&(-(x)))
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;
const LL LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
const int maxn = 2e5 + 10;
int N, u[maxn], v[maxn];
vector<int> g[maxn];
int main()
{
    scanf("%d", &N);
    for(int i = 1; i <= N - 1; i++)
    {
        scanf("%d %d", &u[i], &v[i]);
        g[u[i]].push_back(v[i]);
        g[v[i]].push_back(u[i]);
    }
    LL ans = 0;
    for(int i = 1; i <= N; i++)
        ans += (LL) i * (N - i + 1);
    for(int i = 1; i <= N - 1; i++)
    {
        if(u[i] > v[i])
            swap(u[i], v[i]);
        ans -= (LL) u[i] * (N - v[i] + 1);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 16572
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
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; }
typedef long long ll;
#define pint pair<int,int>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int cnt = 1;
    vector<int> lis = {v.back()};
    rrep(i,n-1) {
        if(lis.back()<=v[i]) lis.push_back(v[i]);
        else {
            auto iter = upper_bound(ALL(lis),v[i]);
            *iter = v[i];
        }
    }
    
    cout << lis.size() << endl;
    return 0;
}

Measured memory_bytes: 1276