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

typedef long long ll;
#define rep(i,n) for(int i=1;i<=n;i++)

long long modinv(long long a, long long m=MOD) {
    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;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

#define MAXN 200001

#define MAXK 1000000000000000000

int gone[MAXN];

int main(){

    ll N, K;
    int A[MAXN];
    cin >> N >> K;
    rep(i,N)cin >> A[i];
    int cur_place = 1;
    int count = 1;
    rep(i,N) gone[i] = 0;
    gone[1] = 1;
    int diff;
    if(K>N) {
        while(1) {
            cur_place = A[cur_place];
            count++;
            if(gone[cur_place] != 0){
                diff = count - gone[cur_place];
                break;
            }
            gone[cur_place] =count;
        }
        gone[cur_place] -= 1;
        // cout << gone[cur_place] << " " << diff <<" "<<cur_place  << endl;
        K = (K - gone[cur_place])  % diff;
        for(int i=0;i<K;i++) {
            cur_place = A[cur_place];
        }
    }else {
        for(int i=0;i<K;i++) {
            cur_place = A[cur_place];
        }
    }
    

    cout << cur_place << endl;


    
    return 0;
}

Measured memory_bytes: 5208
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ln "\n"
#define pb push_back
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define vll vector<ll>
#define vpll vector<pll>
#define vvll vector<vector<ll>>
#define sll stack<ll>
#define qll queue<ll>
#define mp make_pair
#define f first
#define s second
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define Test ll t;cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define init(x,n,v) for(ll i=0;i<=n;i++) x[i]=v;
#define all(x) x.begin(),x.end()
ll MOD = 1e9+7 , MAX = 1e18;
int main() 
{
	fast_io;
	ll n,i,w,j;
	cin>>n>>w;
	vpll k(n);
	ll dp[n+1][w+1];
	memset(dp,0,sizeof(dp));
	for(auto &i: k) cin>>i.f>>i.s;
	for(i=0;i<=n;i++)
	{
	    for(j=0;j<=w;j++)
	    {
	        if(i==0 || j==0) dp[i][j]=0;
	        else if(k[i-1].f<=j) 
	         dp[i][j]=max(dp[i-1][j],k[i-1].s+dp[i-1][j-k[i-1].f]);
	        else dp[i][j]=dp[i-1][j];
	    }
	}
	cout<<dp[n][w];
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll K;
    cin >> K;
    ll odd = (K+1)/2;
    ll even = K - odd;
    cout << odd * even << '\n';
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define boost ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0)
#define vi vector<int>
#define P push_back
#define F first
#define S second
#define debug(x) cout<<x<<" "
#define pi vector<pair<int,int> >
#define FOR(i,x,n) for(int i=x;i<n;i++)
using namespace std;
int main(){
    boost;
    int n;
    cin>>n;
    pi a(n);
    for(int i=0;i<n;i++)cin>>a[i].S>>a[i].F;
    sort(a.begin(),a.end());
    ll sum=0;
    bool flag=false;
    for(int i=0;i<n;i++){sum+=a[i].S;if(sum>a[i].F){flag=true;break;}}
    if(flag)cout<<"No";
    else cout<<"Yes";


    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

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

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

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

    // for prime mod
    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;}
};

const int cmax = 200010;
mint fac[cmax],finv[cmax],inv[cmax];

void com_init() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2; i<cmax; i++) {
        fac[i]=fac[i-1]*i;
        inv[i]=-inv[MOD%i]*(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}

ll com(int n, int k) {
    if (n<k) return 0;
    if (n<0||k<0) return 0;
    mint ret=fac[n]*finv[k]*finv[n-k];
    return ret.x;
}

int main() {
	ll n, m, k;
	cin >> n >> m >> k;

	mint a[2 * N + 1];
	a[2] += 1;
	for(int i = 3; i <= n * m; i++) {
		a[i] = a[i - 1] * 2 - a[i - 2] + i - 1;
	}

	com_init();
	mint ans = (a[n] * m * m + a[m] * n * n) * com(n * m - 2, k - 2);
	cout << ans.x << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
    cin >> s;
    int slen = s.length();
    vector<char> in;
    for(int i = 0; i < slen; ++i) {
        if(s.at(i) == '0') {
            in.push_back('0');
        }else if(s.at(i) == '1') {
            in.push_back('1');
        }else {
            if(!in.empty()) {
                in.pop_back();
            }
        }
    }

    int ilen = in.size();
    for(int i = 0; i < ilen; ++i) {
        cout << in.at(i);
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    if(s[0] == s[1] && s[1] == s[2] || s[1] == s[2] && s[2] == s[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

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

using ll = long long;
using P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

int main() {
    int N;
    cin>>N;
    string S;
    cin>>S;
    int cnt = 0;
    for(auto x:S){
        if(x=='R') cnt++;
    }
    int ans = 0;
    rep(i,cnt){
        if(S[i]=='W') ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3752
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
typedef long long ll; 
ll arr[20005]; 
inline int calc(ll x)
{
	int res = 0; 
	while (x)
	{
		res += x % 10; 
		x /= 10; 
	}
	return res; 
}
int main()
{
	// freopen("ARC099-D.in", "r", stdin); 
	int len = 0, n; 
	ll cur = 0, coef = 1; 
	for (int i = 0; i <= 15; i++)
	{
		for (int j = 0; j < 1000 && j * coef + cur <= 1e15; j++)
			arr[len++] = j * coef + cur; 
		cur += coef * 9;
		coef *= 10; 
	}
	std::sort(arr, arr + len);
	len = std::unique(arr, arr + len) - arr; 
	scanf("%d", &n);
	for (int i = 1; i < len && n; i++)
	{
		int sum = calc(arr[i]); 
		bool f = true; 
		for (int j = i + 1; j < len && f; j++)
			f &= arr[j] * sum >= arr[i] * calc(arr[j]); 
		if (f)
		{
			n--; 
			printf("%lld\n", arr[i]);
		}
	}
	return 0; 
}


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

int main()
{
    std::string s,t;
    std::cin >> s;

    for(int i = 0; i < (int)s.size(); i++){
        if(s[i] == '0')t.push_back('0');
        if(s[i] == '1')t.push_back('1');
        if(s[i] == 'B' && t.size())t.pop_back();
    }
    std::cout << t << std::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() {
  string s; cin >> s;
  ll k; cin >> k;

  int len = s.length();
  int one=0;
  int oneend;
  rep(i,len){
    if(s[i] == '1') one++;
    else{
      oneend = i;
      break;
    }
  }

  //cout <<"oneend= "<< oneend << endl;
  if(k<=one) cout << 1 << endl;
  else cout << s[oneend] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
// rep(i, 1, 4) --> {1,2,3,4}
// rep(i, 4, 1) --> {4,3,2,1}
// rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    cout << (1900*m+100*(n-m))*pow(2,m);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
x = []
u = []
for _ in range(N):
    a, b = input().split()
    x.append(float(a))
    u.append(b)
ans = sum(t[0] if t[1] == 'JPY' else t[0] * 380000 for t in zip(x, u))
print(ans)


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

const int N = 1000005;

int n, ans = 1;
std::string s, t;
std::queue<int> q;

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> s >> t;
	if (s == t) return std::cout << "0\n", 0;
	for (int i = n - 1, k = n - 1; ~i; --i) if (!i || t[i] != t[i - 1]) {
		k = std::min(k, i); while (~k && s[k] != t[i]) --k;
		if (k < 0) return std::cout << "-1\n", 0;
		if (i == k) {while (q.size()) q.pop(); continue;}
		while (q.size() && q.front() - q.size() >= i) q.pop();
		q.push(k), ans = std::max(ans, (int) q.size() + 1);
	}
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 6300
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"regexp"
)

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, sum int

func main() {
	var S string
	fmt.Scan(&S)
	r := regexp.MustCompile(`^(dream|dreamer|erase|eraser)*$`)
	if r.MatchString(S) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; 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
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main() {
    int n,k;
    ll ans=1;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        if(i==0)
            ans*=k;
        else
            ans*=k-1;
    }
    cout<<ans<<"\n";
    }

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

using namespace std;

/* Template file for Online Algorithmic Competitions */
/* Typedefs */
    /* Basic types */
    typedef long long           ll;
    typedef long double         ld;
    typedef unsigned long long ull;
    /* STL containers */
    typedef vector <int>    vi;
    typedef vector <ll>     vll;
    typedef pair <int, int> pii;
    typedef pair <ll, ll>   pll;
    typedef vector < pii >  vpii;
    typedef vector < pll >  vpll;
    typedef vector <string> vs;
    typedef vector < vi >   vvi;
    typedef vector < vll >  vvll;
    typedef vector < vpii > vvpii;
    typedef set <int>       si;
/* Macros */
    /* Loops */
    #define fl(i, a, b)     for(int i(a); i <= (b); i ++)
    #define rep(i, n)       fl(i, 1, (n))
    #define loop(i, n)      fl(i, 0, (n) - 1)
    #define rfl(i, a, b)    for(int i(a); i >= (b); i --)
    #define rrep(i, n)      rfl(i, (n), 1)
    /* Algorithmic functions */
    #define srt(v)          sort((v).begin(), (v).end())
    /* STL container methods */
    #define pb              push_back
    #define mp              make_pair
    #define eb              emplace_back
    /* String methods */
    #define dig(i)          (s[i] - '0')
    #define slen(s)         s.length()
    /* Shorthand notations */
    #define fr              first
    #define sc              second
    #define re              return 
    #define sz(x)           ((int) (x).size())
    #define all(x)          (x).begin(), (x).end()
    #define sqr(x)          ((x) * (x))
    #define fill(x, y)      memset(x, y, sizeof(x))
    #define clr(a)          fill(a, 0)
    #define endl            '\n'
    /* Mathematical */
    #define IINF            0x3f3f3f3f
    #define LLINF           1000111000111000111LL
    #define PI              3.14159265358979323
    /* Debugging purpose */
    #define trace1(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
    /* Fast Input Output */
    #define high_functioning_sociopath                  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
/* Constants */
    const ll MOD = 1000000007LL;
    const ll MAX = 100010LL;
/* Templates */

template<typename T> T power(T x, T y, ll m = MOD){T ans = 1; x %= m; while(y > 0){ if(y & 1LL) ans = (ans * x)%m; y >>= 1LL; x = (x*x)%m; } return ans%m; }

int main(){

   

    high_functioning_sociopath;    
    ll n;
    cin>>n;
    cout<<180*(n-2)<<"\n";
    

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

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

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

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

    bool ans = (n % 10) == (n / 100);
    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fup(i,a,b) for(int i=a;i<=b;++i)
#define fdw(i,a,b) for(int i=a;i>=b;--i)
#define sync ios::sync_with_stdio(false);cin.tie(0)
#define cl(a) memset(a,0,sizeof(a))
#define gcd __gcd
#define fi first
#define se second
#define pb push_back
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
//ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//ll ksm(ll a,ll b,ll mod){ll res=1;a%=mod;for(;b;b>>=1){if(b&1) res=res*a%mod;a=a*a%mod;}return res;}
//ll oula(ll n){ ll res=n;for(ll i=2;i*i<=n;i++){if(n%i==0){ res=res-res/i;while(n%i==0) n/=i;}}if(n>1) res=res-res/n;return res;}
//bool MRT(ll x){if(x==2)return true;fup(i,1,50){ll now=rand()%(x-2)+2;if(ksm(now,x-1,x)!=1)return false;}return true;}
//void shai(int n)fup(i,2,n){if(isprime[i]){v.push_back(i);for(int j=2*i;j<=10000;j+=i)isprime[j]=0;}}//"埃氏筛筛选素数"
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const double eps=1e-7;
const int N=4e5+10;
int main()
{

    sync;
    int a,b;
    cin>>a>>b;
    int l=b*10,r=b*10+9;
    ll ans=0;
    fup(i,l,r)
    {
        if(i*0.08>=a&&i*0.08<(a+1))
        {
            ans=i;
            break;
        }
    }
    if(ans)
        cout<<ans<<endl;
    else cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [0] + list(map(int, input().split())) + [0]
c = 0
for i in range(1, len(a)): c += abs(a[i] - a[i - 1])
for i in range(1, len(a) - 1):
	print(c - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]))


Measured memory_bytes: 14048
#include <iostream>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

int main()
{
    int n, m;
    cin >> n >> m;
    ll x[100005], y[100005];
    for(int i = 0; i < n; i++) cin >> x[i];
    for(int i = 0; i < m; i++) cin >> y[i];
    ll dx[100005], dy[100005];
    for(int i = 1; i < n; i++) dx[i] = x[i] - x[i - 1];
    for(int i = 1; i < m; i++) dy[i] = y[i] - y[i - 1];
    ll p = 0, q = 0;
    for(ll i = 1; i < n; i++) p = (p + i * (n - i) % MOD * dx[i]) % MOD;
    for(ll i = 1; i < m; i++) q = (q + i * (m - i) % MOD * dy[i]) % MOD;
    cout << p * q % MOD << endl;
}


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

int main()
{
int X;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> X;

	if( X == 7 || X == 5 || X == 3 )
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string a,b;
    cin>>a>>b;

    if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0]){
        cout<<"YES"<<endl;
    }
    else {
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
S = 'CODEFESTIVAL2016'

def main(argv)
  s = gets.chomp

  c = 0
  S.size.times do |i|
    c += 1 if S[i] != s[i]
  end

  puts c.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    int N;
    cin >> N;
    REP(i, N) {
        int a;
        cin >> a;
        if (a % 2 == 1) {
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;
    return 0;
}

Measured memory_bytes: 256
n, k, q = map(int, input().split())
a = list(int(input()) for i in range(q))
add = [0] * n
def func(x) :
    return k-q+x
for i in range(q) :
    add[a[i]-1] += 1
point = list(map(func, add))
for _ in range(n) :
    if point[_] <= 0 :
        print("No")
    else :
        print("Yes")


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

struct p{
  ll b;
  ll x;
  ll y;
};
int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll n,t;cin>>n>>t;
  vector<ll>a(n);
  vector<struct p> q;
  for(i=0;i<n;i++)cin>>a[i];
  l=INF;r=0;buf=0;buf2=0;
  ll lbuf=0,rbuf=0,lbuf2=0;
  for(i=0;i<n;i++){
    if(l>a[i]){
      q.push_back({buf,lbuf,rbuf});
      lbuf=0;rbuf=0;
      l=a[i];
      lbuf2=1;
      r=0;
    }
    else if(l==a[i]){
      lbuf2++;
    }
    if(r<a[i]){
      r=a[i];
      rbuf=1;
      lbuf=lbuf2;
      buf=r-l;
      chmax(buf2,buf);
    }
    else if(r==a[i]){
      rbuf++;
      lbuf=lbuf2;
    }
  }
  q.push_back({buf,lbuf,rbuf});
  for(i=0;i<q.size();i++){
    if(q[i].b==buf2){
      res+=min(q[i].x,q[i].y);
      //cout<<q[i].b spa q[i].x spa q[i].y<<endl;
    }
  }
  cout<<res<<endl;
  
  return 0;
}

Measured memory_bytes: 2680
#include <stdio.h>

int max(int p0,int p1){
  return(p0>p1?p0:p1);
}
int main(){
  long a,m;
  int i,j,l[2][100000],np,p[100000];
  p[0]=2;
  np=1;
  for(i=3;i<100000;i+=2){
    for(j=1;j<np;j++){
      if(i%p[j]==0) break;
    }
    if(j==np){
      p[np]=i;
      np++;
    }
  }
  for(i=0;i<2;i++){
    scanf("%ld",&a);
    for(j=0;j<np;j++){
      l[i][j]=0;
      while(a%p[j]==0){
        a/=p[j];
        l[i][j]++;
      }
    }
  }
  m=1;
  for(i=0;i<np;i++){
    for(j=max(l[0][i],l[1][i]);j>0;j--){
      m*=(long)p[i];
    }
  }
  printf("%ld",m);
  return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[100+1][100000+1];
ll wt[100001];
ll v[100001];
    
ll ks(ll w,ll n)
{
   
    if((n==0)||(w==0))
    {
     dp[n][w]=0;
    return 0;
    }
     if(dp[n][w]!=-1)
    return dp[n][w];
    
    if(wt[n-1]>w) {
        return ks(w,n-1);    
    }  
    else{
    dp[n][w]=max(ks(w,n-1),v[n-1]+ks(w-wt[n-1],n-1));
    }
    return dp[n][w];
}

int main()
{
    ll n,w;
    cin>>n>>w;
    
   
    for(ll i=0;i<n;i++)
    {
        cin>>wt[i]>>v[i];
    }
    
    for(ll i=0;i<=100;i++)
    {
        for(ll j=0;j<=100000;j++)
        dp[i][j]=-1;
    }
    
    cout<<ks(w,n)<<endl;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(LL, a);
	IN(string, s);
	LL b = (s[0] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
	OUT(a * b / 100);
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class388
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(long.Parse).ToArray();

            Array.Sort(A);
            var d = new long[N];
            d[0] = A[0];
            for (int i = 0; i < N-1; i++)
            {
                d[i + 1] = d[i] + A[i + 1];
            }

            long ans = 1;
            for (int i = N - 2; i >= 0; i--)
            {
                if (d[i] * 2 >= A[i + 1]) ans++;
                else break;
            }
            Console.WriteLine(ans);
        }
    }
}


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

int main() {
  vector<string> cards;
  while (true) {
    int m;
    string now;
    cin >> now;
    if (now == "-")
      break;
    cin >> m;
    for (int i=0;i<m;i++) {
      int h;
      cin >> h;
      now = now + now.substr(0, h);
      now = now.substr(h);
    }
    cards.push_back(now);
  }
  for (int i=0;i<cards.size();i++)
    cout << cards[i] << endl;
}



Measured memory_bytes: 3152
N, X = map(int, input().split())
A = list(map(int, input().split())) + [X]

a = sorted(A)

def yu(a, b):
	ma = max([a, b])
	mi = min([a, b])
	while (ma % mi):
		t = ma
		mi = ma % mi
		ma = t
	return mi

ld = a[1] - a[0]
for n in range(2, N + 1):
	d = a[n] - a[n - 1]
	ld = yu(ld, d)

print(ld)


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

using namespace std;

int main()
{
    string s ;
    long long k ;
    cin>>s>>k ;
    int cnt = 0 ;
    for(int i = 0 ; i < s.size() ; ++i)
        if(s[i] == '1')
        cnt++;
        else
            break;
    for(int i = 0 ; i < s.size() ; ++i)
    {
        if(s[i] == '1' && cnt >= k)
        {
            cout<<s[i];
            return 0 ;
        }
        else if(s[i] == '1')
        {
            continue;
        }
        else
        {
            cout<<s[i];
            return 0 ;
        }
    }
    cout<<"1";
    return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9 + 7;

signed main(){
    int n,k;
    cin >> n >> k;
    vector<int> oks(n + 1,true);
    for(int i = 0; i < k; i++){
        int a;
        cin >> a;
        oks[a] = false;
    }
vector<int> dp(n + 1);
dp[0]= 1;
for(int  now = 0; now < n; now++){
    for(int next = now + 1; next <= min(n,now + 2); next++){
        if(oks[next]){
            dp[next] += dp[now];
            dp[next] %= mod;
        }
    }
}
cout << dp[n] << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=18,M=66666;
const int mo=1000000007;
int n,m,ans,a[N];
int f[N][M],val[M];
int fac[M],inv[M];
void init(){
	fac[0]=inv[0]=inv[1]=1;
	For(i,2,M-1) inv[i]=1ll*inv[mo%i]*(mo-mo/i)%mo;
	For(i,1,M-1) inv[i]=1ll*inv[i-1]*inv[i]%mo;
	For(i,1,M-1) fac[i]=1ll*fac[i-1]*i%mo;
}
int C(int x,int y){
	if (x<0||y<0||y>x) return 0;
	return 1ll*fac[x]*inv[y]%mo*inv[x-y]%mo;
}
int main(){
	init();
	scanf("%d%d",&n,&m);
	For(i,1,m) scanf("%d",&a[i]);
	sort(a+1,a+m+1);
	f[m][0]=1;
	Rep(i,m,1) For(j,0,(1<<n)-1) if (f[i][j]){
		int suf=((1<<n)-a[i])-j;
		f[i-1][j]=(f[i-1][j]+f[i][j])%mo;
		For(k,0,n-1) if ((1<<k)-1<=suf&&!(j&(1<<k)))
			f[i-1][j|(1<<k)]=(f[i-1][j|(1<<k)]+mo-1ll*f[i][j]*C(suf,(1<<k)-1)%mo)%mo;
	}
	val[0]=1;
	For(i,1,(1<<n)-1){
		int low=i&(-i);
		val[i]=1ll*val[i-low]*C(i,low)%mo;
	}
	For(i,0,(1<<n)-1)
		ans=(ans+1ll*f[0][i]*val[(1<<n)-1-i])%mo;
	For(i,0,n-1) ans=1ll*ans*fac[1<<i]%mo;
	ans=ans*(1ll<<n)%mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 4608
A, B, C, X, Y = gets.split.map(&:to_i)

n = [X, Y].max

result = []
0.upto(n) do |i|
  an = X - i
  an = 0 if an < 0
  a = A * an

  bn = Y - i
  bn = 0 if bn < 0
  b = B * bn

  c = (i * 2 * C)

  result << a + b + c
end

puts result.min

Measured memory_bytes: 2684
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

int main() {
	int n, a, b;
	string s;
	cin >> n >> a >> b;
	cin >> s;
	int in = 0, out = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'a') {
			if (in < a + b) {
				cout << "Yes" << endl;
				in++;
			}
			else cout << "No" << endl;
		}
		if (s[i] == 'b') {
			if (in < a + b && out < b) {
				cout << "Yes" << endl;
				in++; out++;
			}
			else cout << "No" << endl;
		}
		if (s[i] == 'c') {
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 896
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli H, W, h, w;
    cin>>H>>W>>h>>w;
    out((H*W)-(h*W+H*w-h*w));
}

Measured memory_bytes: 3640
n = int(input())
heights = [int(_) for _ in input().split()]
cost = [0, abs(heights[0] - heights[1])]

for i in range(1,n-1):
    diff = abs(heights[i+1] - heights[i]) + cost[i]
    diff2 = abs(heights[i+1] - heights[i-1]) + cost[i-1]
    if diff2 > diff:
        cost.append(diff)
    else:
        cost.append(diff2)
        
print(cost[-1])

Measured memory_bytes: 13928
import java.io.*;
import java.util.*;
public class Main {
	public static class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch (Exception e) {}
			} return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next()); }
		long nextLong() { return Long.parseLong(next()); }
	}

	public static void main(String[] args) {
		FS in = new FS();
		int n = in.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = in.nextLong();

		long mod = (long)1e9 + 7;
		long[][] cs = new long[60][n + 1];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 60; j++) {
				cs[j][i] = (a[i] & (1L << j));
				cs[j][i] %= mod;
			}
		}
		for (int i = 0; i < 60; i++)
			for (int j = 1; j <= n; j++) {
				cs[i][j] += cs[i][j - 1];
				cs[i][j] %= mod;
			}

		long ans = 0;
		for (int i = 0; i < n - 1; i++)
			for (int j = 0; j < 60; j++) {
				long cnt = cs[j][n] - cs[j][i];
				if ((a[i] & (1L << j)) == 0) {
					ans += cnt;
					ans %= mod;
				}
				else {
					long sub = (1L << j) % mod;
					sub = (sub * (n - 1 - i)) % mod;
					cnt = sub - cnt;
					ans += cnt;
					ans %= mod;
				}
			}
		ans = ((ans % mod) + mod) % mod;
		System.out.println(ans);
	}
}


Measured memory_bytes: 252516
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

struct mint {
	ll x;
	mint(ll x = 0) :x(x% mod) {}
	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;
	}

	// for prime mod
	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;
	}
};

mint dp0[2005][2005];
mint dp1[2005][2005];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> s(n + 1), t(m + 1);
	rep(i, n) cin >> s[i];
	rep(i, m) cin >> t[i];
	dp0[0][0] = 1;
	rep(i, n + 1)rep(j, m + 1) {
		dp0[i + 1][j] += dp0[i][j];
		dp1[i][j] += dp0[i][j];
		dp1[i][j + 1] += dp1[i][j];
		if (s[i] == t[j]) {
			dp0[i + 1][j + 1] += dp1[i][j];
		}
	}
	printf("%d\n", dp1[n][m]);
	return 0;
}


Measured memory_bytes: 63104
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())

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

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

	map<int, int> mp;
	for (int i = 0; i < N; i++)
		mp[a[i]]++;

	int ans = 0;
	for (auto p: mp) {
		int x = p.first;
		int n = p.second;
		if (n < x) ans += n;
		else ans += n - x;
	}

	cout << ans << endl;
}


Measured memory_bytes: 5120
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i=i+2)
	{	
		int sum=0;
		for(int j=1;j<=i;j++)
		{
			if(i%j==0)
			sum++;	
		}	
		if(sum==8)
		ans++;
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
import java.util.*

fun main(args:Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()

    if (a < b && b < c) {
        println("Yes")
    } else {
        println("No")
    }
}


Measured memory_bytes: 25344
N, M = map(int, input().split())

even = M//2
odd = (M+1)//2
B = odd*2
K = B+even*2
ans = []
for n in range(1, odd+1):
    print(n, B-n+1)
for n in range(1, even+1):
    print(B+n, K-n+2)

Measured memory_bytes: 70272
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

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

		Arrays.sort(ab, Comparator.comparing(a -> a[0]));
		long a = 0;
		int idx = 0;

		PriorityQueue<Integer> pq = new PriorityQueue<>(Comparator.reverseOrder());
		for (int i = 1; i <= m; i++) {
			while (idx < ab.length && ab[idx][0] <= i) {
				pq.add(ab[idx++][1]);
			}
			if (!pq.isEmpty()) a += pq.poll();
		}

		System.out.println(a);
	}
}


Measured memory_bytes: 93816
#include <bits/stdc++.h>
using namespace std;
#define MAX 10005

class DisjointSet{
    public:
        vector<int> rank,p;

        DisjointSet(){}        
        DisjointSet(int size){
            rank.resize(size,0);
            p.resize(size,0);
            for(int i=0;i<size;i++) makeSet(i);
        }

        void makeSet(int x){
            p[x]=x;
            rank[x]=0;
        }

        bool same(int x,int y){
            return findSet(x)==findSet(y);
        }

        void unite(int x,int y){
            link(findSet(x),findSet(y));
        }

        void link(int x,int y){
            if(rank[x]>rank[y]){
                p[y]=x;
            }
            else{
                p[x]=y;
                if(rank[x]==rank[y]) rank[y]++;
            }
        }

        int findSet(int x){
            if(x!=p[x]){
                p[x]=findSet(p[x]);
            }
            return p[x];
        }
};

int n,m;

class Edge{
    public:
        int source,target,cost;
        Edge(){}
        Edge(int source,int target,int cost):source(source),target(target),cost(cost){}
        bool operator<(const Edge &e){
            return cost<e.cost;
        }
};

int kruskal(int n,int m,vector<Edge> &e){
    int totalCost=0;
    sort(e.begin(),e.end());
    DisjointSet ds(n);
    for(int i=0;i<m;i++){
        if(ds.findSet(e[i].source)!=ds.findSet(e[i].target)){
            ds.unite(e[i].source,e[i].target);
            totalCost+=e[i].cost;
        }
    }
    return totalCost;            
}

int main(){
    int source,target,cost;
    cin>>n>>m;
    vector<Edge> e(m);
    for(int i=0;i<m;i++){
        cin>>source>>target>>cost;
        e[i]=Edge(source,target,cost);
    }

    cout<<kruskal(n,m,e)<<endl;
}


Measured memory_bytes: 4160
//Bismillah hirrahmanir Rahim
    #include<bits/stdc++.h>
    #define ll long long
    #define pb push_back
    #define dbug printf("I am here\n");
    #define Fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  using namespace std;
int main() {
    ll int tst,n,x;
  cin>>n>>tst;
  while(tst--){
cin>>x;
n-=x;
  }
  if(n>-1)cout<<n<<endl;
  else cout<<"-1"<<endl;
    return 0;
  }


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

using namespace std;

int my_diff(int a, int b)
{
  return b - a + 1;
}

int main()
{
  int n, result = 0;
  cin >> n;

  for (int i = 0; i < n; i++)
  {
    int a, b;
    cin >> a >> b;
    result += my_diff(a, b);
  }

  cout << result << endl;
}

Measured memory_bytes: 256
import math
a,b,x = map(int,input().split())

if x <= a*a*b/2:
    ans = 90-math.degrees(math.atan((2*x)/(a*b*b)))
else:
    ans = math.degrees(math.atan((2*a*a*b-2*x)/(a*a*a)))

print(ans)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int> h(n);
	for(int i = 0; i < n; i++) cin >> h[i];
	int a = 0, b = abs(h[1]-h[0]);
	int c = b;
	for(int i = 2; i < n; i++){
		c = min(a+abs(h[i]-h[i-2]), b+abs(h[i]-h[i-1]));
		a = b;
		b = c;
	}
	cout << c << '\n';
	return 0;
}


Measured memory_bytes: 3780
#include<stdio.h>
#include<vector>
#include<string>
#include<iostream>
using namespace std;

vector<vector<int> >g;
int n,m,q,s,t;

vector<bool>visited;
vector<int>color;
void dfs(int s){
    for(int i=0;i<g[s].size();i++){
        if(color[g[s][i]]==-1){
            color[g[s][i]]=color[s];
            dfs(g[s][i]);
        }
    }
}
bool dfs2(int s,int t){
    if(s==t)return true;
    visited[s]=true;
    for(int i=0;i<g[s].size();i++){
        if(!visited[g[s][i]]){
            if(dfs2(g[s][i],t)){
                return true;
            }
        }
    }
    return false;
}
int main() {
    scanf("%d %d",&n,&m);
    g.resize(n);
    color.resize(n,-1);
    for(int i=0;i<m;i++){
        scanf("%d %d",&s,&t);
        g[s].push_back(t);
        g[t].push_back(s);
    }
    for(int i=0;i<n;i++){
        if(color[i]==-1){
            color[i]=i;
            dfs(i);
        }
    }
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%d %d",&s,&t);
        visited.resize(n,false);
        string s1=(dfs2(s,t)?"yes":"no");
        string s2=(color[s]==color[t]?"yes":"no");
        if(s1!=s2&&s1=="yes")return 1;
        cout<<s2<<endl;
    }
    return 0;
}

Measured memory_bytes: 11840
# ABC138D - Ki
from collections import deque


def dfs(r: int) -> None:
    stack = deque([(r, -1)])
    while stack:
        v, p = stack.popleft()
        x = cnt[v]
        for u in T[v]:
            if u != p:
                cnt[u] += x
                stack.append((u, v))


def main():
    # Ai (A[i][0]) may be not a parent of Bi (A[i][1])
    global T, cnt
    N, Q, *A = map(int, open(0).read().split())
    E, P = A[: (N - 1) * 2], A[(N - 1) * 2 :]
    T = [[] for _ in range(N + 1)]
    for v, u in zip(*[iter(E)] * 2):
        T[v].append(u), T[u].append(v)
    cnt = [0] * (N + 1)
    for p, x in zip(*[iter(P)] * 2):
        cnt[p] += x  # increase vertex p by x
    dfs(1)
    print(*cnt[1:])


if __name__ == "__main__":
    main()

Measured memory_bytes: 92900
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ
int main()
{
    string s;
    cin >> s;
    cout << "ABC" << s;
}

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

#define pb push_back
#define all(a) (a).begin(), (a).end()

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

template<typename T> using V = vector<T>;

// borrowed from neal's code
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

const double PI = acos(-1);

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int n, m; cin >> n >> m;
    vector<int> a(m);
    int s = 0;

    for (auto &i : a) {
        cin >> i;
        s += i;
    }

    if (s > n) cout << -1;
    else {
        cout << n - s;
    }

}

Measured memory_bytes: 3668
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		double C = Math.PI*stdIn.nextInt()/180;
		double S = a*b*Math.sin(C)/2;
		double c = Math.pow(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(C),(double)1/2);
		double L = a + b + c;
		double h = Math.sin(C)*b;
		System.out.printf("%.5f\n",S);
		System.out.printf("%.5f\n",L);
		System.out.printf("%.5f\n",h);
	}
}

Measured memory_bytes: 17268
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s = str(readline().rstrip().decode('utf-8'))
    t = str(readline().rstrip().decode('utf-8'))
    lt = len(t)
    for i in range(len(s) - lt, -1, -1):
        ts = s[i:i+lt]
        b = True
        for j in range(len(ts)):
            if ts[j] != "?" and ts[j] != t[j]:
                b = False
                break
        if b:
            ans = []
            for j in range(len(s)):
                if i <= j < i + lt:
                    ans.append(t[j-i])
                else:
                    if s[j] == "?":
                        ans.append("a")
                    else:
                        ans.append(s[j])
            print("".join(ans))
            exit()
    print("UNRESTORABLE")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, k;

signed main() {
	cin >> n >> k;
	if (k>(n - 1)*(n - 2) / 2) {
		cout << -1 << endl;
		return 0;
	}
	cout << (n - 1) + ((n - 1)*(n - 2) / 2 - k) << endl;
	for (int i = 2; i <= n; i++)cout << 1 << " " << i << endl;
	int cnt = (n - 1)*(n - 2) / 2 - k;
	for (int i = 2; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			if (cnt) {
				cout << i << " " << j << endl;
				cnt--;
			}
			else break;
		}
	}
}

Measured memory_bytes: 256
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
# 締切順にソート
AB = sorted(AB, key=lambda x: x[1])
now = 0
ans = 'Yes'

for i in range(N):
    now += AB[i][0]
    if now <= AB[i][1]:
        pass
    else:
        ans = 'No'

print(ans)

Measured memory_bytes: 55196