akhauriyash/Code-Regression huggingface dataset:
N = int(input())
S = str(input())

l = 0
r = 0

for i in range(N):
    if S[i] == "(":
        r += 1
    elif S[i] == ")":
        if r >= 1:
            r -= 1
        else:
            l += 1

print("(" * l + S + ")" * r)


Measured memory_bytes: 38384
a = 753
s = input()
min = 1000
n = len(s)
for i in range(n-2):
    t = int(s[i]+s[i+1]+s[i+2]) - 753
    if t>=0 and min> t:
        min = t
    if t<0 and min > -t:
        min = -t
print(min)


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

bool isPrime(int n) 
{
	if (n == 2)
		return true;
	if (n % 2 == 0)
		return false;

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

int main()
{
	int x;
	cin >> x;
	while (true)
	{
		if (isPrime(x))
			break;
		x++;
	}
	cout << x << endl;
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

#define Rad2Deg 180.0 / PI

void solve()
{
	double a, b, x;
	cin >> a >> b >> x;
	double v = a * a * b;


	if (x < v / 2.0)
	{
		printf("%.7f\n", atan2(a * b * b, 2.0 * x) * Rad2Deg);
	}
	else
	{
		printf("%.7f\n", atan2(2.0 * (a * b - x / a), a * a) * Rad2Deg);
	}
	
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    if(A == 0) {
        cout << 0 << endl;
        return 0;
    }
    ll k = N / (A + B);
    if(k == 0) {
        cout << min(A, N) << endl;
        return 0;
    }
    ll r = N % (A + B);
    // cout << A * k + r << endl;
    cout << A * k + min(r, A) << endl;
    return 0;
}


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

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	string s;
	cin >> s;
	int N;
	cin >> N;
	map<string, int> mp;
	for (int i = 0; i < s.length(); ++i) {
		for (int j = 0; j <= min((int)s.length(), N + 2); ++j) {
			string _s = s.substr(i, j);
			mp[_s]++;
		}
	}

	auto x = mp.begin();
	for (int i = 0; i < N; ++i) {
		++x;
	}
	cout << x->first << endl;


	return 0;
}

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

int main(){
  int A, B;
  cin >> A >> B;
  if(A+B==3){
    cout << "3" << endl;
  }else if(A+B==4){
    cout << "2" << endl;
  }else{
    cout << "1" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const P = arg[1].split(" ").map(n=>parseInt(n));
    
    let answer = 0;
    
    for(let i in P) {
        if(parseInt(i) + 1 === P[i]) {
            let temp = P[i];
            P[i] = P[parseInt(i) + 1];
            P[parseInt(i) + 1] = temp;
            answer++;
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 22104
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <math.h>

using namespace std;

int main()
{
    int n,m,i,flag=0;
    char s[110],t[110],str[120];
    cin>>s;
    cin>>t;
    n=strlen(s);
    m=strlen(t);
    if(n==m)
    {
    strcpy(str,s);
    for(i=0;i<n;i++)
    {
        //cout<<str<<endl;
        if(!(strcmp(str,t)))
        {
            flag=1;
            break;
        }
        strcpy(s,str);
        str[0]=s[n-1];
        str[1]='\0';
        strcat(str,s);
        str[n]='\0';

    }

    if(flag)
        cout<<"Yes";
    else
        cout<<"No";
    }
    else
        cout<<"No";


    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
int main(void) {
	int s[4][3][10] = {};
	int n,b,f,r,v;
	scanf("%d\n",&n);
	for(;n;n--){
		scanf("%d %d %d %d\n",&b,&f,&r,&v);
		s[b-1][f-1][r-1] += v;
	}
	for(b=0;b<4;b++){
		if(b){printf("####################\n");};
		for(f=0;f<3;f++){
			for(r=0;r<10;r++){
				printf(" %d",s[b][f][r]);
			}
			printf("\n");
		}
	}
	return 0;
}

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

using namespace std;

#define li long long int
#define pb push_back

int main()
{
    li N,K;
    cin>>N;
    vector<li> A(N);
    li i,j,k;
    for(i=0;i<N;i++)
    {
        cin>>A[i];
    }
    li money=1000,stock=0;
    for(i=0;i<N;i++)
    {
        money+=(stock*A[i]); stock=0;
        if((i+1 < N)&&(A[i]<A[i+1]))
        {
            stock=money/A[i];
            money-=(stock*A[i]);
        }
    }
    cout<<money;
}


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

int r,d,x;
long long ans;

int main()
{
    scanf("%d %d %d",&r,&d,&x);
    ans = x;
    for(int i = 0; i < 10; i++)
    {
        ans = r*ans - d;
        printf("%lld\n",ans);
    }
    return 0;
}


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


int main(){
    Long n;
    cin >> n;
    vector<char> aux;

    while( n ){
        --n;
        int gg = n % 26;
        aux.push_back ( char(gg + 'a') );
        n /= 26;
        if( !n ) break;
    }

    for( int x = aux.size() - 1 ; x >= 0 ; x--) cout << aux[x];
    return 0;
}

Measured memory_bytes: 3600
n,a,b=map(int,input().split())
lists=list(map(int,input().split()))
lists_dis=[]
answer=0
distance=0
for i in range(n-1):
    distance=lists[i+1]-lists[i]
    lists_dis.append(distance)
for some in lists_dis:
    if some*a>b:
        answer+=b
    else:
        answer+=a*some
print(answer)

Measured memory_bytes: 14252
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 100002;

int n;

int a[N_MAX];

ll sum;

ll k;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    for(int i = 1; i <= n; i++)
        sum += a[i];
    k = sum / (1LL * n * (n + 1) / 2);
    if(k * (1LL * n * (n + 1) / 2) != sum)
    {
        cout << "NO\n";
        return 0;
    }
    for(int i = 1; i <= n; i++)
    {
        int j = i - 1;
        if(j == 0)
            j = n;
        ll u = k - (a[i] - a[j]);
        if(u < 0 || u % n != 0)
        {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k;
  cin >> n >> k;
  VI h(n);
  rep(i,n) cin >> h[i];
  int ans = 0;
  rep(i,n) if(h[i] >= k) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
    map<int,int> mp;
    int n;
    cin>>n;
    int x;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        mp[i]=x;
    }
    int moves=0;
    x=1;
    set<int> c;
    while(1)
    {
        int sz=c.size();
        c.insert(x);
        if(c.size()==sz)
        break;
        moves++;
        x=mp[x];
        if(x==2 || x==1)
        break;
    }
    if(x==2)cout<<moves;
    else
    {
        cout<<-1;
    }
    
  }  
  return 0;
}

Measured memory_bytes: 9600
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int m = sc.nextInt();

		int k = n*(n-1)/2 + m*(m-1)/2 ;

		// 出力
		System.out.println(k);
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;

template<typename T> vector<T> Bubble(vector<T> A) {
    int N = A.size();
    for (int i = 0; i < N; i++) {
        for (int j = N-1; j > i; j--) {
            if (A[j].first < A[j-1].first) swap(A[j], A[j-1]);
        }
    }
    return A;
}

template<typename T> vector<T> Selection(vector<T> A) {
    int N = A.size();
    for (int i = 0; i < N; i++) {
        int mn = i;
        for (int j = i; j < N; j++) {
            if (A[j].first < A[mn].first) mn = j;
        }
        swap(A[i], A[mn]);
    }
    return A;
}

template<typename T> vector<T> stablesort(vector<T> A) {
    int N = A.size();
    vector<T> res(N);
    vector<bool> use(N, false);
    for (int p = 0; p < N; p++) {
        int mn = -1, value = INF;
        for (int i = 0; i < N; i++) if (!use[i]) { mn = i; break; }
        for (int i = 0; i < N; i++) if (!use[i]) {
            if (chmin(value, A[i].first)) mn = i;
        }
        res[p] = A[mn]; use[mn] = true;
    }
    return res;
}

void printv(vector<pair<int, char>> &A) {
    for (int i = 0; i < A.size(); i++) {
        cout << A[i].second << A[i].first;
        cout << ((i+1==A.size()) ? "\n" : " ");
    }
}

int main() {
    int N;
    cin >> N;
    vector<pair<int, char>> A;
    for (int i = 0; i < N; i++) {
        char a, b;
        cin >> a >> b;
        A.emplace_back(b-'0', a);
    }
    vector<pair<int, char>> B = Bubble(A);
    vector<pair<int, char>> S = Selection(A);
    A = stablesort(A);
    ///*
    printv(B);
    if(A == B) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    printv(S);
    if(A == S) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    //*/
    //printv(A);
    return 0;
}


Measured memory_bytes: 3104
//


#include <string>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	unsigned long long N;
	string s, n;

	cin >> N;
	cin >> s;
	cin >> n;

	unsigned cur = 0;
	for( unsigned i = 0 ; i < s.length() ; i++)
	{
		if (s[i] == n[cur])
			cur++;
		else
		{
			i -= cur;

			cur = 0;
		}
		
	}


	cout << max((unsigned long long)(s.length() + n.length() - cur), N);


}


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


int main() {
    int k,x;
    cin>>k>>x;
    rep(i,2*k-1){
        cout << max(-1000000,x-k+1+i) <<" ";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, n, m) for(int i = n; i < (int)m; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define pb push_back
using namespace std;
using ll = std::int_fast64_t;
using ld = long double;
using P = pair<ll, ll>;
constexpr ll inf = 1000000000;
constexpr ll mod = 1000000007;
constexpr long double eps = 1e-15;
template<typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2> p) {
	os << to_string(p.first) << " " << to_string(p.second);
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	REP(i, v.size()) {
		if(i) os << " ";
		os << to_string(v[i]);
	}
	return os;
}

/*
template<typename T>
struct Treap {
	double drand() { // random number in [0, 1]
		static random_device rd;
		static mt19937 mt(rd());
		return (unsigned)mt() / (double)numeric_limits<unsigned>::max();
	}
	T v;
	double p;
	int cnt;
	Treap* lch;
	Treap* rch;
	Treap(T v) : v(v), p(drand()), cnt(1), lch(NULL), rch(NULL) { }
	Treap* update() {
		this->size = size(this->lch) + size(this->rch) + 1;
		return this;
	}
	static int size(Treap* t) {
		if(!t) return 0;
		else return t->cnt;
	}
	static Treap* merge(Treap* l, Treap* r) {
		if(!l || !r) {
			if(!l) return r;
			else return l;
		}
		if(l->p >= r->p) {
			l->rch = merge(l->rch, r);
			return l->update();
		} else {
			r->lch = merge(r->lch, l);
			return r->update();
		}
	}
	static pair<Treap*, Treap*> split(Treap* t, int k) {
		// split [0, k) and [k, n)
		if(k == 0) return {NULL, t};
		if(!(t->l)) {
			auto tmp = split(t->r, k - 1);
			t->r = tmp.first;
			return {t->update(), tmp.second};
		} else if(!(t->r)) {
			auto tmp = split(t->r, k - 1);
			t->r = tmp.first;
			return {t->update(), tmp.second};
		} else {

		}
	}
	Treap* insert() {
	}
	Treap* erase() {
	}
	T operator[](int k) {
	}
};
*/

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q;
	cin >> n >> q;
	vector<ll> a(2 * n), b(2 * n);
	REP(i, 2 * n) cin >> a[i];
	REP(i, 2 * n) cin >> b[i];
	ll sum1 = 0, sum2 = 0;
	REP(i, 2 * n) sum1 += a[i];
	set<pair<ll, ll>> st1;
	set<pair<ll, ll>> st2;
	FOR(i, 1, 2 * n - 1) {
		if(b[i] - a[i] >= 0) {
			st1.insert({b[i] - a[i], i});
			sum2 += b[i] - a[i];
		} else {
			st2.insert({b[i] - a[i], i});
		}
	}
	st2.insert({-inf*inf, 0});
	REP(i, q) {
		ll p, x, y;
		cin >> p >> x >> y;
		p--;
		sum1 -= a[p]; sum1 += x;
		if(p != 0 && p != 2 * n - 1) {
			if(b[p] - a[p] >= 0) {
				st1.erase({b[p] - a[p], p});
				sum2 -= (b[p] - a[p]);
			} else {
				st2.erase({b[p] - a[p], p});
			}
			if(y - x >= 0) {
				st1.insert({y - x, p});
				sum2 += y - x;
			} else {
				st2.insert({y - x, p});
			}
		}
		a[p] = x; b[p] = y;
		if((int)st1.size() % 2 == 0) {
			cout << sum1 + sum2 << endl;
		} else {
			cout << max(sum1 + sum2 - st1.begin()->first,
						sum1 + sum2 + (--st2.end())->first) << endl;
		}
	}
	return 0;
}
// ---------------------------------------


Measured memory_bytes: 17408
import java.util.*;
public class Main {
	static int ans = 0;
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		int[][] xy = new int [n][n];
		for (int i = 0;i < n; ++i)Arrays.fill(xy[i], -1);

		int a,x,y;
		for (int i = 0;i < n; ++i){
			a = Integer.parseInt(scan.next());
			for(int k = 0;k < a; ++k){
				x = Integer.parseInt(scan.next());
				y = Integer.parseInt(scan.next());
				xy[i][x-1] =y;
			}
		}

		//bit全探索
		int ans = 0;
		boolean ok;
		int count_honest;
		boolean[] honest = new boolean[n];
		for (int i = 0;i < 1<<n; ++i){
			Arrays.fill(honest, false);
			for (int k = 0;k < n; ++k){
				if ((1 & i>>k) == 1){
					honest[k] = true;
				}
			}

			//証言の確認
			count_honest = 0;
			ok = true;
			for (int k = 0;k < n; ++k){
				if (honest[k]){
					++count_honest;
					for (int j = 0;j < n; ++j){
						if (xy[k][j] != -1 &&
						   ( (xy[k][j] != 1 && honest[j]) || (xy[k][j] != 0 && !honest[j]) ) ){
							ok = false;
						}
					}

					}
				}
				if (ok){
					ans = Math.max(ans, count_honest);
				}
			}

			System.out.print(ans);
		
	}

}


//end

Measured memory_bytes: 24532
def main():
    import collections

    n, x, y = map(int, input().split())

    distance_list = []
    for i in range(1, n):
        for j in range(i+1, n+1):
            distance_list.append(min(j-i, abs(i-x)+abs(j-y)+1))

    distance_count = collections.Counter(distance_list)
    for i in range(1, n):
        print(distance_count[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 67820
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

struct UnionFind {
    vector<P> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2


    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++){
          par[i].first = i;
          par[i].second = 1;
        } 
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    //cout<<"x"<<endl;
        if (par[x].first == x) return x;
        return par[x].first = root(par[x].first);
    }

    llong unite(int x, int y) { // xとyの木を併合
      //cout<<"a"<<endl;
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        //cout<<"b"<<endl;
        if (rx == ry) return 0; //xとyの根が同じ(=同じ木にある)時はそのまま
        //cout<<"c"<<endl;
        par[rx].first = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        //cout<<"d"<<endl;
        llong GJ = (llong)par[rx].second * (llong)par[ry].second;//減った不便さを計算
        //cout<<"e"<<endl;
        par[ry].second += par[rx].second;//併合するときに要素数を合算する
        //cout<<"f"<<endl;
        return GJ;
    }

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

int main(){

  int n,m;
  cin>>n>>m;
  UnionFind UF(n);
  P bridge[m];
  REP(i,m){
    int a,b;
    cin>>a>>b;
    bridge[i].first = a-1;
    bridge[i].second = b-1;
  }

  //cout<<"heihe-i"<<endl;
 
  llong hubensa[m];
  hubensa[m-1] = (llong)n*(llong)(n-1)/(llong)2;
  for(int i=m-2;i>=0;i--){
    int a,b;
    a = bridge[i+1].first;
    b = bridge[i+1].second;
    //cout<<hubensa[i+1]<<endl;
    hubensa[i] = hubensa[i+1] - UF.unite(a,b);
  }

  REP(i,m){
    cout<<hubensa[i]<<endl;
  }


  return 0;
}

Measured memory_bytes: 3712
import java.security.KeyStore.TrustedCertificateEntry
import java.util
import java.util.regex.Pattern
import java.util.{ArrayList, Collections, Comparator, List => JList}

import scala.collection.immutable.TreeMap
import scala.math._
import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.util.{Failure, Success, Try}

object Main{
  val LINE_SEPARATOR = "\n"
  def main(args: Array[String]): Unit = {
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString(LINE_SEPARATOR);
      println(solve(input).trim());
    }
  }

  def init (nRows: Int, nCols: Int, default: Int) = Array.tabulate(nRows,nCols)( (x,y) =>  default)

  def sortIgnoreCase1(list: JList[String]): JList[String] = {
    val r = new ArrayList[String](list)
    Collections.sort(r, new Comparator[String] {
      override def compare(o1: String, o2: String): Int = o1.compareToIgnoreCase(o2)
    })
    r
  }

  def solve(input: String): String = {
    if (input.toSeq.contains('7')) "Yes" else "No"
  }


  def factorize(x: Long): List[Long] = {
    def foo(x: Long, a: Long = 2, list: List[Long] = Nil): List[Long] = a*a > x match {
      case false if x % a == 0 => foo(x / a, a    , a :: list)
      case false               => foo(x    , a + 1, list)
      case true                => x :: list
    }
    foo(x)
  }

  def divisors(n: Long): Vector[Long] = {
    val halfList = (1 to sqrt(n).toInt).toVector.filter(_ % n == 0).map(_.toLong)
    val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)
    halfList ++ reversedList
  }

  def gcd(m: Long, n: Long): Long = n match {
    case 0 => m
    case _ => gcd(n, m % n)
  }
  def lcm(a: Long, b: Long): Long = a * b / gcd(a, b)

  val tests=List(
    """33""".stripMargin -> """2 -1
                              |
                                   |
                                 |
                                   |""".stripMargin,
    """1""".stripMargin -> """0 -1""".stripMargin
  )

  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}
      .zipWithIndex.map{
      case ((input,outputExpect),i)=>{
        val output=solve(input).trim();
        s"test${i+1}:"+(if(output==outputExpect){
          "Passed"
        }else{
          s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
        })
      }}
      .mkString("\n");
  }
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

signed main(void)
{
  stack<int> s;
  int n;
  while(cin >> n) {
    if(n == 0) {
      cout << s.top() << endl;
      s.pop();
    } else {
      s.push(n);
    }
  }
  return 0;
}

Measured memory_bytes: 3012
#include<cstdio>
#include<cstring>
const int N=200005;
typedef long long ll;
int n;
ll cnt[26];
char s[N];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)
        cnt[s[i]-'a']++;
	ll ans=1ll*n*(n-1)/2+1;
	for(int i=0;i<26;i++)
        ans-=cnt[i]*(cnt[i]-1)/2;
	printf("%lld\n",ans);
}


Measured memory_bytes: 384
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll n,k;
  cin >> n >> k;
  ll ans = 0;
  for(ll a = 1; a<= n; a++){
    if(2*(k-a+n*k)%k!=0) continue;
    ll bc = (a%k==0) ? n/k : (n+(k-a+n*k)%k)/k;
    ans += bc*bc;
  }
  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;

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

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

bool ch[9][9]={0};
int n,m,co=0;
int perm[8];
bool chp=0;

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

  for(i=0;i<n;i++)perm[i]=i+1;
  do{
    for(i=1;i<n;i++){
      if(chp==0&&ch[perm[i]][perm[i-1]]==0)chp++;
    }
    if(chp==0)co++;
    chp=0;
  }while(next_permutation(&perm[1],perm+n));
  cout << co << endl;
  return 0;
}


Measured memory_bytes: 256
import collections
import sys

n = int(input())
v = list(map(int, input().split()))

even = v[0:n-1:2]
odd = v[1:n:2]

c_even = collections.Counter(even).most_common()
c_odd = collections.Counter(odd).most_common()

if c_odd[0][0] == c_even[0][0]:
  if len(c_even) == 1 and len(c_odd) == 1:
    print(int(n/2))
    sys.exit()
  elif len(c_even) == 1:
    print(int(n/2) - c_odd[1][1])
    sys.exit()

  elif len(c_odd) == 1:
    print(int(n/2) - c_even[1][1])
    sys.exit()
  
  if c_even[1][1] > c_odd[1][1]:
     answer = (len(even)-c_even[1][1])+(len(odd)-c_odd[0][1])
  else:
     answer = (len(even)-c_even[0][1])+(len(odd)-c_odd[1][1])
else:
  answer = (len(even)-c_even[0][1])+(len(odd)-c_odd[0][1])
print(answer)

Measured memory_bytes: 21084
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    int n,k;cin>>n>>k;
    if((n-1)*(n-2)/2<k)cout<<-1<<endl;
    else{
        int t=(n-1)*(n-2)/2-k;
        cout<<n-1+t<<endl;
        REP(i,2,n+1){
            cout<<1<<' '<<i<<endl;
        }
        REP(i,2,n){
            REP(j,i+1,n+1){
                if(!t)break;
                cout<<i<<' '<<j<<endl;
                t--;
            }
            if(!t)break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)


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


int main()
{
  int D;cin >> D;
  if (D == 25) cout << "Christmas" << endl;
  else if (D == 24) cout << "Christmas Eve" << endl;
  else if (D == 23) cout << "Christmas Eve Eve" << endl;
  else if (D == 22) cout << "Christmas Eve Eve Eve" << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007  
#define mod2 998244353  

int solve(){
    int n,k,x;
    cin>>n>>k;
    int a[n],b[n];
    rep(i,0,n){
        cin>>a[i];
        if(i==0) b[i]=0;
        else{
            x=abs(a[i]-a[i-1])+b[i-1];
            rep(j,2,k+1){
                if(j>i) break;
                x=min(x,abs(a[i]-a[i-j])+b[i-j]);
            }
            b[i]=x;
        }
    }
    cout<<b[n-1];
    
    return 0;
}   
     
signed main(){
    IOS;
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
      // cout<<" * "<<t<<"\n";
    }
//    return 0;
} 

Measured memory_bytes: 1792
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)


def main():
    n = I()
    s = S()
    aa = [LI_() for _ in range(n-1)]
    e = collections.defaultdict(set)
    for a,b in aa:
        e[a].add(b)
        e[b].add(a)

    sa = []
    for i in range(n):
        if s[i] == '1':
            sa.append(i)

    if len(sa) <= 1:
        return 0

    m = {}
    def f(i,p):
        k = (i,p)
        if k in m:
            return m[k]

        t = 0
        if s[i] == '1':
            t = 1

        h = []
        tk = 0
        tc = 0
        for c in e[i]:
            if c == p:
                continue
            r = f(c,i)
            if r[0] < 1:
                continue
            tc += r[0]
            tk += r[0] + r[1]
            h.append([r[0]+r[1],r[2]])

        if p == -1:
            return h

        mk = 0
        mv = 0
        for u,v in h:
            if mk < u:
                mk = u
                mv = v
        if mk > tk - mk:
            kk = tk - mk
            mk -= kk
            kk += min(mv//2,mk)
            m[k] = (tc+t,tk,kk*2)
        else:
            m[k] = (tc+t,tk,tk//2*2)

        return m[k]

    r = inf

    for i in range(n):
        t = f(i,-1)
        tk = 0
        mk = 0
        for u,v in t:
            tk += u
        if tk % 2 == 1:
            continue

        ff = 1
        for u,v in t:
            kk = u-v
            nk = tk - u
            if kk > nk:
                ff = 0
        # print(i,ff,tk,mk,t)
        if ff == 0:
            continue
        if tk // 2 < mk:
            continue
        v = tk // 2
        if r > v:
            r = v

    if r == inf:
        return -1

    return r


print(main())



Measured memory_bytes: 8900
def q(a,h):
 d[a]=str(h)
 for b in t[a]:q(b,h+1)
t,p,d={},{},{}
for _ in[0]*int(input()):
 e=input().split()
 t[e[0]]=e[2:]
 for i in e[2:]:p[i]=e[0]
r=(set(t)-set(p)).pop()
p[r]='-1'
q(r,0)
print('\n'.join(f"node {i}: parent = {p[i]}, depth = {d[i]}, {'root'if'-1'==p[i]else'internal node'if t[i]else'leaf'}, [{', '.join(t[i])}]"for i in map(str,sorted(map(int,t)))))


Measured memory_bytes: 65356
#include <bits/stdc++.h>
#define fi first
#define se second
#define NAME ""
using namespace std;
typedef long long LL;
typedef double DB;
typedef pair <LL, LL> pLL;
typedef pair <int, int> pii;
const int NMAX = 1e5+3;

double x, y;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(NAME".inp", "r", stdin);
    //freopen(NAME".out", "w", stdout);
    cin >> x >> y;
    cout << x + y/2;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7,INF=1e18;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //Let's Concentrate on learning
    //Rating ka kya hai aaj niche to kl upar...
    ll t=1;
    // cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        int b=0,w=0,n=s.size();
        if(s[0]=='B')
        b++;
        else
        w++;
        for(int i=1;i<n;i++)
        if(s[i]==s[i-1])
        continue;
        else
        {
            if(s[i]=='B')
            b++;
            else
            w++;
        }
        cout<<b+w-1<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3704
#include<iostream>
using namespace std;
int n,d,p,sum;
int main(){
	cin>>n>>d;
	for(int i=0;i<n;i++){cin>>p;if(p>=d)sum+=(p-d);}
	if(sum==0)cout<<"kusoge"<<endl;
	else cout<<sum<<endl;
	return 0;
}

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

int main() {
    int A, B; cin >> A >> B;
  if (A == 1 && B == 2) cout << 3;
  if (A == 1 && B == 3) cout << 2;
  if (A == 2 && B == 1) cout << 3;
  if (A == 2 && B == 3) cout << 1;
  if (A == 3 && B == 1) cout << 2;
  if (A == 3 && B == 2) cout << 1;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
	int n,a = 0,x = 0;
	char s[105];
	scanf("%d",&n);
	scanf("%s",s);
	for(int i = 0;i < n ; i++){
		if(s[i] == 'I'){
			x = x + 1;
			}
		else if (s[i] == 'D'){
			x = x - 1;
			}
		if(a >= x) continue;
		else if (a < x){
			a = x ;
			}
		}
	printf("%d\n",a);
	}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll a,b,v,w,t;
    cin>>a>>v>>b>>w>>t;
    ll diff=abs(a-b);
    ll speed=v-w;
    bool ok=false;
    if(speed>0 && diff<=speed*t)
    {
        ok=true;
    }
    if(ok)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ll,ii>
#define endl '\n'

long long qexp(long long b,long long p,int m){
    long long res=1;
    while (p){
        if (p&1) res=(res*b)%m;
        b=(b*b)%m;
        p>>=1;
    }
    return res;
}


int n;
string s;
int r[4005],g[4005],b[4005];

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

	cin>>n>>s;
	s='$'+s;
	
	for (int x=1;x<=n;x++){
		r[x]=r[x-1]+(s[x]=='R');
		g[x]=g[x-1]+(s[x]=='G');
		b[x]=b[x-1]+(s[x]=='B');
	}
	
	ll ans=0;
	
	for (int x=1;x<=n;x++){
		for (int y=x+1;y<=n;y++){
			if (x==y || s[x]==s[y]) continue;
			
			if (s[x]!='R' && s[y]!='R'){
				ans+=r[y]-r[x-1];
			}
			else if (s[x]!='G' && s[y]!='G'){
				ans+=g[y]-g[x-1];
			}
			else{
				ans+=b[y]-b[x-1];
			}
			
			int temp=x+y;
			if (temp%2==0 && s[temp/2]!=s[x] && s[temp/2]!=s[y]) ans--;
		}
	}
	
	cout<<ans;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<long long,long long>
#define vl vector<long long>
#define vll vector<pll>
#define vi vector<int>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000010;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;    
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;
// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()   
#define trav(a, x) for(auto& a : x)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr<< *it << " = " << a << endl;
	err(++it, args...);
}
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
void solve()
{
    int x,y;
    cin>>x>>y;
    if(y<2*x)
    {
        cout<<"No"<<endl;
        return;
    }    
    else if((y-2*x)%2)
    {
        cout<<"No"<<endl;
        return;
    }
    else
    {
        int b=(y-2*x)/2;
        if(b>x)
        {
            cout<<"No"<<endl;
            return;
        }
        cout<<"Yes"<<endl;
    }
}
int main()
{
    sws
    // tcase{
        solve();
    // }
    return 0;
}


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

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 lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

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

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

int main() {
  ll N,Q;
  cin>>N>>Q;
  dsu d(N);
  rep(i,Q){
    ll t,u,v;
    cin>>t>>u>>v;
    if(t==0) d.merge(u,v);
    else{
      if(d.same(u,v)) cout<<1<<endl;
      else cout<<0<<endl;
    }
  }
}

Measured memory_bytes: 3996
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define fo(x,a,b) for(register int x=a;x<=b;x++)
#define dfo(x,a,b) for(register int x=a;x>b;x--)
#define inf 2147483647
using namespace std;
int a[1005][2],n,m,x,y;
char ch[1005][20];
int main ()
{
	//freopen("timename.in","r",stdin);
	//freopen("timename.out","w",stdout);
	while (true)
	{
		scanf("%d%d\n",&n,&m);
		if (n==0&&m==0) break;
		fo(ii,1,n)
			fo(j,1,16)
				ch[ii][j]='\000';
		fo(ii,1,n)
		{
			int i=0;
			while((ch[ii][++i]=getchar())!=' ');
			ch[ii][i]='\000';
			scanf("%d%d\n",&x,&y);
			a[ii][1]=y;
			a[ii][0]=y-x+1;
		}
		fo(ii,1,m)
		{
			scanf("%d\n",&y);
			bool pd=false;
			fo(i,1,n)
			{
				if(a[i][1]>=y&&a[i][0]<=y){printf("%s %d\n",ch[i]+1,y-a[i][0]+1);pd=true;break;}
			}
			if (pd==false) printf("Unknown\n");
		}
	}

	return 0;
}





Measured memory_bytes: 3184
#include<iostream>
#include<string>
#include<sstream>
#include<stack>
using namespace std;
int main(){
    stack<int> S;
    string ins;
    getline(cin,ins);
    istringstream is(ins);
    int num1,num2;
    while(!is.eof()){
        string s;
        is >>s;
        switch(s[0]){
            case '+':
                num1 = S.top();
                S.pop();
                num2 = S.top();
                S.pop();
                S.push(num2+num1);
                break;
            case '-':
                num1 = S.top();
                S.pop();
                num2 = S.top();
                S.pop();
                S.push(num2-num1);
                break;
            case '*':
                num1 = S.top();
                S.pop();
                num2 = S.top();
                S.pop();
                S.push(num2*num1);
                break;
            default:
                istringstream  is2(s);
                is2 >> num1;
                S.push(num1);
                break;
        }
    }
    cout << S.top()<<endl;
    return 0;
}



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

int main(){
	int h,w;
	cin >> h >> w;
	char grid[1005][1005];
	for (int i = 1; i <= h; ++i){
		for (int j = 1; j <= w; ++j){
			cin >> grid[i][j];
		}
		cin.ignore();
	}
	ll dp[1005][1005];
	memset(dp,0,sizeof(dp));
	dp[0][1] = 1;
	for (int i = 1; i <= h; ++i){
		for (int j = 1; j <= w; ++j){
			if (grid[i][j] == '.') dp[i][j] = dp[i-1][j] + dp[i][j-1];
			dp[i][j] %= 1000000007;
		}
	}
	cout << dp[h][w] << "\n";
	return 0;
}

Measured memory_bytes: 9088
// Created by: WeirdBugsButOkay

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second
#define PI 3.14159265358979323846
#define endl '\n'

using namespace std;

ll ceil(ll a, ll b)
{
	return (a + b - 1) / b;
}

void solve()
{
	ll a, b, v, w, t;
	cin >> a >> v >> b >> w >> t;
	if(v <= w)
		cout << "NO" << endl;
	else
	{
		ll d = abs(b - a);
		ll sc = abs(v - w);
		if(ceil(d, sc) <= t)
			cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

int main()
{
	int q = 1;
	//scanf("%d", &q);
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  string data;
  cin>>data;
  for(int i=0;i<(int)data.size();i++){
    int x=(data.at(i)-'A'+N)%26;
    cout<<char(x+'A');
  }
  cout<<endl;
  return 0;
 }

Measured memory_bytes: 256
/*
貪欲
後ろから見る
DP
順位表をチェック
二分探索


*/
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
using namespace std;
#define INF 3e18+7
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());

int C[10];

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

    ll H,W,N;
    cin>>H>>W>>N;
    map<P,int> M;
    for(int i=0;i<N;i++){
        int a,b;
        cin>>a>>b;
        for(int j=0;j<=2;j++){
            for(int k=0;k<=2;k++){
                int na=a+j,nb=b+k;
                if(na>H || nb>W || na-2<=0 || nb-2<=0) continue;
                M[P(na,nb)]++;
            }
        }
    }
    map<P,int>::iterator it;
    ll count=0;
    for(it=M.begin();it!=M.end();it++){
        C[it->second]++;
        count++;
    }
    cout<<(H-2)*(W-2)-count<<endl;
    for(int i=1;i<=9;i++) cout<<C[i]<<endl;

}

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

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    int MAX_D = 1e5 + 1;
    vector<int> d(MAX_D + 1);

    int n;
    cin >> n;
    for (int i = 0, x; i < n; ++i) {
        cin >> x;
        ++d[x];
    }
    for (int i = 1; i <= MAX_D; ++i) d[i] += d[i - 1];

    ll ans = 0;
    for (int i = 1; i <= MAX_D; ++i) {
        if (2 * d[i] == n) ++ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
using namespace std;


using pi=pair<int,int>;
const long long INF=99999999999999;
struct edge{
	int to,cost;
};

vector<int> djikstra(vector<vector<edge>> &G,int start){
	vector<int> dist(G.size(), INF);
	priority_queue<pi,vector<pi>,greater<pi>> que;
	dist[start]=0;
	// pair(その時点での最短経路,頂点の番号)
	que.push(make_pair(dist[start],start));
	while(!que.empty()){
		int cost=que.top().first;
		int idx=que.top().second;
		que.pop();
		
		if(dist[idx]<cost)continue;
		for(edge e:G[idx]){
			if(dist[e.to]<=cost+e.cost) continue;
			dist[e.to]=cost+e.cost;
			que.push(make_pair(dist[e.to],e.to));
		}
	}
	return dist;
}

signed main(){
	int N; cin>>N;
	vector<vector<edge>> G(N);
	for(int i=0;i<N-1;i++){
		int a,b,c;
		cin >> a>>b>>c; a--; b--;
		G[a].push_back(edge{b,c});
		G[b].push_back(edge{a,c});
	}
	int Q,K; cin>>Q>>K; K--;
	vector<int> dist=djikstra(G,K);
	for(int i=0;i<Q;i++){
		int sta,goa; cin>>sta>>goa; sta--; goa--;
		cout<<dist[sta]+dist[goa]<<endl;
	}

}


Measured memory_bytes: 11120
N = int(input())
S = [input() for _ in range(N)]
mae_B = 0
ushiro_A = 0
docchimo = 0
naka_AB = 0
for s in S:
    for i in range(len(s)-1):
        if s[i] == 'A' and s[i+1] == 'B':
            naka_AB += 1
    if s[0] == 'B' and s[-1] == 'A':
        docchimo += 1
    elif s[0] == 'B':
        mae_B += 1
    elif s[-1] == 'A':
        ushiro_A += 1
ans = naka_AB
ans += max(0, docchimo-1)
if docchimo > 0:
    if mae_B > 0:
        mae_B -= 1
        ans += 1
    if ushiro_A > 0:
        ushiro_A -= 1
        ans += 1
ans += min(mae_B, ushiro_A)
print(ans)

Measured memory_bytes: 3700
#/usr/bin/env python
def ispalindrome(str): return 1 if str == str[::-1] else 0

def main():
    s = input()
    l = len(s)
    s1 = s[:l // 2]
    s2 = s[l // 2 + 1:]

    if ispalindrome(s) and ispalindrome(s1) and ispalindrome(s2):
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()


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

int main()
{
    int n;
    cin >> n;
    ll a[200005], b[200005];
    ll s = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        s += a[i];
    }
    ll l = s;
    for(int i = 0; i < n; i++){
        if(a[i] > b[i]) l = min(l, b[i]);
    }
    cout << s - l << endl;
}


Measured memory_bytes: 3928
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
		ArrayList<Integer> l = new ArrayList<Integer> (Arrays.asList(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51));
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int k = scan.nextInt();
		System.out.println(l.get(k-1));
		scan.close();
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <string>
#define SS(i) scanf("%s",i)
#define SC(i) scanf("%d",&i)
#define SCC(i,j) scanf("%d%d",&i,&j)
#define SCCC(i,j,z) scanf("%d%d%d",&i,&j,&z)
#define PR(i) printf("%d\n",i)
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define CL(i,x) memset(i,x,sizeof(i))
#define IN freopen("in.txt","r",stdin)
#define OUT  freopen("out.txt","w",stdout)
#define PB(i) push_back(i)
#define min(x,y) ((x>y)?(y):(x))
#define max(x,y) ((x<y)?(y):(x))
#define abs(i) (i<0?(-i):i)
#define lson x,m,rt<<1
#define rson m+1,y,rt<<1|1
using namespace std;
const int N=200000+10;


int main()
{
#ifndef ONLINE_JUDGE
    //IN;
#endif

    int a, b;
    SCC(a, b);
    if(a == 1) a+=99;
    if(b == 1) b+=99;
    if(a>b) puts("Alice");
    else if(a==b) puts("Draw");
    else puts("Bob");
    return 0;
}


Measured memory_bytes: 256
N, M, Q = map(int, input().split())
abcd_li = [list(map(int, input().split())) for _ in range(Q)]
ans = 0
for i1 in range(1, M + 1):
    for i2 in range(i1, M + 1):
        for i3 in range(i2, M + 1):
            for i4 in range(i3, M + 1):
                for i5 in range(i4, M + 1):
                    for i6 in range(i5, M + 1):
                        for i7 in range(i6, M + 1):
                            for i8 in range(i7, M + 1):
                                for i9 in range(i8, M + 1):
                                    for i10 in range(i9, M + 1):
                                        arr = [
                                            0,
                                            i1,
                                            i2,
                                            i3,
                                            i4,
                                            i5,
                                            i6,
                                            i7,
                                            i8,
                                            i9,
                                            i10,
                                        ]
                                        tmp = 0
                                        for a, b, c, d in abcd_li:
                                            if arr[b] - arr[a] == c:
                                                tmp += d
                                            ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 72124
N, A, B = map(int, input().split())
L = list(map(int, input().split()))
D = [A * (L[i+1] - L[i]) for i in range(N - 1)]
S = 0
for i in range(N - 1):
  if D[i] > B:
    S += B
  else:
    S += D[i]
print(S)

Measured memory_bytes: 14252