akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int n;
    cin >> n;
    map<P,ll> m;
    rep2(i,1,n+1) {
        int le = i;
        while(le >= 10) le /= 10;
        int ri = i%10;
        m[{le,ri}]++;
    }
    ll ans = 0;
    rep2(i,1,10) rep2(j,1,10) {
        ll anum = 0,bnum = 0;
        if(m.count({i,j})) anum = m[{i,j}];
        if(m.count({j,i})) bnum = m[{j,i}];
        ans += anum*bnum;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, 0, 3)
    {
        if(s[i] == t[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


map<char,int> ma;

int main() {
	ma['I'] = 1, ma['V'] = 5, ma['X'] = 10, ma['L'] = 50;
	ma['C'] = 100, ma['D'] = 500, ma['M'] = 1000;
 
	string str;
	while (cin >> str) {
		int res = 0;
		int n = str.size();
		for (int i = 0; i < n-1; ++i) {
			if ( ma[str[i]] < ma[str[i+1]] ) res -= ma[str[i]];
			else res += ma[str[i]];
		}
		res += ma[str[n-1]];

		cout << res << endl;
	}
    return 0;
}


Measured memory_bytes: 1180
n,k,c = map(int,input().split())
s = input()


def solve_shortest(s):

    sche = []
    t = 0
    day = 0
    for i,ch in enumerate(s):
        if (ch=="o") & (i>=t):
            sche += [i]
            t = i+c+1
            day += 1
        if day == k: break
    else:
        return
    
    return sche

sche1 = solve_shortest(s)
sche2 = solve_shortest(s[::-1])

ans = []
for x,y in zip(sche1,sche2[::-1]):
    if x+y == n-1:
        ans.append(x+1)
print("\n".join(map(str,ans)))

Measured memory_bytes: 41152
#include <iostream>
#include <string>
using namespace std;
#define debug 0
int main(){
	string s;
	int count;
	int tmp;
	char c,ans;
	while(1){
		count=tmp=0;
		c=ans='?';
		cin>>s;
		
		if(s=="0")break;//debug
		
		for(int i=0;i<s.size();i+=3){
			if(s[i]!=c)count++;
			else count=1;
			c=s[i];
			if(count>tmp){
				tmp=count;
				ans=s[i];
			}
			if(s[i]=='c')i+=4;
		}
		if(ans=='e')cout<<"egg"<<endl;
		else cout<<"chicken"<<endl;
		
		if(debug==0)break;//debug
	}
	return 0; 
}


Measured memory_bytes: 1196
def calc(n, k):
    length = len(n)
    dp = [[[0]*(k + 1) for _ in range(2)] for _ in range(length+1)]
    dp[0][0][0] = 1
    for i in range(length):
        max_digit = int(n[i])
        for flag_less in range(2):
            for non_zero in range(4):
                range_digit = 9 if flag_less else max_digit
                for d in range(range_digit+1):
                    flag_less_next = 0
                    non_zero_next = non_zero
                    if flag_less == 1 or d < max_digit:
                        flag_less_next = 1
                    if d != 0:
                        non_zero_next = non_zero + 1
                    if non_zero_next < k + 1:
                        dp[i+1][flag_less_next][non_zero_next] += dp[i][flag_less][non_zero]
    return dp[length][0][k]+dp[length][1][k]

n = input()
k = int(input())

print(calc(n, k))

Measured memory_bytes: 40816
import sys
readline = sys.stdin.readline
from math import floor, ceil

def main():
    N = int(readline())
    inp = [tuple(map(int, readline().rstrip().split())) for _ in range(N)]
    scr_t, scr_a = 1, 1
    for t, a in inp:
        # n = max(ceil(scr_t/t), ceil(scr_a/a))
        n = max((scr_t//t)+(scr_t%t!=0), (scr_a//a)+(scr_a%a!=0))
        scr_t = n * t
        scr_a = n * a

    print(scr_t + scr_a)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef pair<int,bool> P;
typedef vector<unordered_map<int,bool> > graph;

int calc(int now, int prev, graph &src, graph &ans, vector<bool> &arrived) {
	//cout << prev<<"->"<<now << endl;
	if(arrived[now]) {
		//cout << prev<<"->"<<now << " : " << ((src[now][prev])?1:0) << endl;;
		return (src[now][prev])?1:0;
	}
	arrived[now] = true;
	int pre = -1;
	//for(int i = 0; i < src[now].size(); i++) {
		//int next = src[now][i];
	for(P p : src[now]) {
		int next = p.first;
		//cout << "in" << now << "," << next << endl;
		bool liv = p.second;
		if(next==prev) continue;
		if(!liv) continue;
		int res = calc(next,now,src,ans,arrived);
		if(res==1) {
			if(pre==-1) {
				pre = next;
			}else {
				ans[now][pre] = true;
				ans[now][next] = true;
				//cout << now << "," << pre << "," << next << endl;
				src[pre][now] = false;
				src[next][now] = false;
				src[now][pre] = false;
				src[now][next] = false;
				pre = -1;
			}
		}
	}
	if(pre==-1) return 1;
	else {
		if(prev==-1) return 0;
		else {
			ans[now][pre] = true;
			ans[now][prev] = true;
			//cout << now << "," << pre << "," << next << endl;
			src[pre][now] = false;
			src[prev][now] = false;
			src[now][pre] = false;
			src[now][prev] = false;
			return 0;
		}
	}
}

int main() {
	int n,m;
	cin>>n>>m;
	if(m%2==1) {
		cout << -1 << endl;
		return 0;
	}
	graph src(n);
	graph ans(n);
	for(int i = 0; i < m; i++) {
		int a,b;
		cin>>a>>b;
		src[a-1][b-1]=true;
		src[b-1][a-1]=true;
	}
	vector<bool> arrived(n);
	calc(0,-1,src,ans,arrived);
	for(int i = 0; i < n; i++) {
		for(P p : ans[i]) {
			cout << (i+1) << " " << (p.first+1) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 36608
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
	long long n,m,a,b,c[10],i,j,k,l,p=0;
	cin>>n>>m;
	for(i=0;i<n;i++)
		c[i]=-1;
	for(i=0;i<m;i++)
	{
		cin>>a>>b;
		if(c[a-1]==-1||c[a-1]==b)
			c[a-1]=b;
		else
			p++;
	}
	if(p==0)
	{
		if(c[0]==0)
		{
			if(n>1)
			{
				cout<<"-1";
				return 0;
			}
			if(n==1)
				cout<<"0";
		}
		else
		{
			if(c[0]==-1&&n>1)
				cout<<"1";
			if(c[0]==-1&&n==1)
				cout<<"0";
			if(c[0]>0)
				cout<<c[0];
			for(i=1;i<n;i++)
			{
				if(c[i]==-1)
					cout<<"0";
				else
					cout<<c[i];
			}	
		}
	}
	else
		cout<<"-1";
 } 

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for(int i=1; i<n-1; i++){
        int count = 0;
        string a, b;
        a = s.substr(0, i);
        b = s.substr(i, n-i);
        map<char, int>mp;
        for(int j=0; j<i; j++){
            mp[a[j]] = 1;
        }
        for(int j=0; j<n-i; j++){
            if(mp[b[j]]==1){
                count++;
                mp[b[j]]++;
            }
        }
        ans = max(ans, count);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
int main(void)
{
	char str[51][51];
	int i,j, h, w,lot;
	lot = 19;
	scanf("%d %d", &h, &w);
	for (i = 0; i < h; i++)
	{
		scanf("%s", &str[i]);
	}
	for (i = 0; i < h; i++)
	{
		if (i == 0) {
			for (j = 0; j < w; j++)
			{
	            if (str[i][j] == '.'&&i == h - 1 && j == w - 1)
				{
					printf("Yes\n");
					lot = 1;
					break;
				}
				else if (str[i][j] == '.')
				{
					continue;
				}
				
				if (j == 0)
				{
					if ((str[i][j] == '#'&&str[i][j + 1] == '#') || (str[i][j] == '#'&&str[i + 1][j] == '#'));
					else
					{
						lot = 0;
						break;
					}
				}
				else if (j == w - 1)
				{
					if ((str[i][j] == '#'&&str[i + 1][j] == '#') || (str[i][j] == '#'&&str[i][j - 1] == '#'));
					else
					{
						lot = 0;
						break;
					}
				}
				else
				{
					if ((str[i][j] == '#'&&str[i][j + 1] == '#') || (str[i][j] == '#'&&str[i + 1][j] == '#')|| (str[i][j] == '#'&&str[i][j - 1] == '#'));
					else
					{
						lot = 0;
						break;
					}
				}
			}
		}
		else if (i == h - 1)
		{
			for (j = 0; j < w; j++)
			{
				if (str[i][j] == '.'&&i == h - 1 && j == w - 1)
				{
					printf("Yes\n");
					lot = 1;
					break;
				}
				else if (str[i][j] == '.')
				{
					continue;
				}
				if (j == 0)
				{
					if ((str[i][j] == '#'&&str[i][j + 1] == '#') || (str[i][j] == '#'&&str[i - 1][j] == '#'));
					else
					{
						lot = 0;
						break;
					}
				}
				else if (j == w - 1)
				{
					if ((str[i][j] == '#'&&str[i - 1][j] == '#') || (str[i][j] == '#'&&str[i][j - 1] == '#'));
					else
					{
						lot = 0;
						break;
					}
				}
				else
				{
					if ((str[i][j] == '#'&&str[i - 1][j] == '#') || (str[i][j] == '#'&&str[i][j + 1] == '#') || (str[i][j] == '#'&&str[i][j - 1] == '#'));
					else
					{
						lot = 0;
						break;
					}
				}
			}
		}
		else
		{
			for (j = 0; j < w; j++)
			{
				if (str[i][j] == '.'&&i == h - 1 && j == w - 1)
				{
					printf("Yes\n");
					lot = 1;
					break;
				}
				else if (str[i][j] == '.')
				{
					continue;
				}
				if (j == 0)
				{
					if ((str[i][j] == '#'&&str[i][j + 1] == '#') || (str[i][j] == '#'&&str[i - 1][j] == '#') || (str[i][j] == '#'&&str[i + 1][j] == '#'));
					else
					{
						lot = 0;
						break;
					}
				}
				else if (j == w - 1)
				{
					if ((str[i][j] == '#'&&str[i][j - 1] == '#') || (str[i][j] == '#'&&str[i - 1][j] == '#') || (str[i][j] == '#'&&str[i + 1][j] == '#'));
					else
					{
						lot = 0;
						break;
					}
				}
				else
				{
					if ((str[i][j] == '#'&&str[i][j - 1] == '#') || (str[i][j] == '#'&&str[i - 1][j] == '#') || (str[i][j] == '#'&&str[i + 1][j] == '#') || (str[i][j] == '#'&&str[i][j + 1] == '#'));
					else
					{
						lot = 0;
						break;
					}
				}
			}
		}

		if (lot == 0)
		{
			printf("No\n");
			break;
		}
		else if (lot == 1)
		{
			;
		}
		else if (i == h - 1)
		{
			printf("Yes\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    bool counter = true,judge = true;;
    int n,a[100010];
    cin >> n;
    for(int i = 0;i < n;i++){cin >> a[i];}
    sort(a,a + n);
    for(int i = a[n / 2];i > 0;i--)
    {
        judge = true; counter = true;
        for(int j = 0;j < n / 2;j++)
        {
            if(n % 2 == 1 && j == 0)
            {
                if(a[n / 2] % i != 0)
                {
                    if(counter){counter = false;}
                    else{judge = false; break;}
                }
            }
            if(a[j] % i != 0)
            {
                if(counter){counter = false;}
                else{judge = false; break;}
            }
            if(a[n - j - 1] % i != 0)
            {
                if(counter){counter = false;}
                else{judge = false; break;}
            }
        }
        if(judge){cout << i << endl; break;}
    }
    if(!judge){cout << 1 << endl;}
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>

#define abs(a) (( (a) > 0) ? (a) : -(a))

long double custom_pow(long double a) {
    return a * a;
}

int main (){
    int A;
    int B;
    int H;
    int M;
    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &H);
    scanf("%d", &M);
    long double dA = (long double) A;
    long double dB = (long double) B;
    long double dM = (long double) M;
    long double dH = (long double) H;
    long double nasu_kaku;
    if (6.0 * dM > dH * 30.0 + 30.0 * dM / 60.0)
        nasu_kaku = (6.0 * dM - (dH * 30.0 + 30.0 * dM / 60.0));
    else
        nasu_kaku = (dH * 30.0 + 30.0 * dM / 60.0) - (6.0 * dM);
    //printf("360: %Lf\n", nasu_kaku);
    nasu_kaku = (nasu_kaku > 180.0) ? 360.0 - nasu_kaku : nasu_kaku;
    //printf("180 inai: %Lf\n", nasu_kaku);
    nasu_kaku = 1.0 / 360.0 * 2 * 3.1415926535897932384626 * nasu_kaku;
    //printf("pi: %Lf\n", nasu_kaku);
    long double ans = sqrtl(abs(custom_pow(dA) + custom_pow(dB) - 2.0 * dA * dB * cosl(nasu_kaku)));
    printf("%4.20Lf\n", ans);

    return 0;
}


Measured memory_bytes: 2584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long h,w,n;cin >> h>>w>>n;
  vector<long long> count(10,0),vec;
  for (int i=0;i<n;i++) {
    long long a,b;cin >> a >> b;
	for (int ja=-2;ja<=0;ja++) {
	  for (int jb=-2;jb<=0;jb++) {
	    if (a+ja>0 && a+ja+2<=h && b+jb>0 && b+jb+2<=w) {vec.push_back((a+ja-1)*w+b+jb);}
	  }
	}
  }
  sort(vec.begin(),vec.end());
  long long i=0;
  while (i<vec.size()) {
    if (i==vec.size()-1) count[1]++;
	else {
	  long long r=1;
	  for (int j=1;j<9;j++) {
	    if (i+j<vec.size() && r==j) {
		  if (vec[i]==vec[i+j]) r++;
        }
	  }
      count[r]++;i+=r-1;
	}
    i++;
  }
  cout << (h-2)*(w-2)-count[1]-count[2]-count[3]-count[4]-count[5]-count[6]-count[7]-count[8]-count[9] << endl;
  for (int i=1;i<=9;i++) cout << count[i]<< endl;
}

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

const int INF = 1 << 30;

int cnt(int left_pos, int right_pos, string dir, bool is_left) {
    int res = 0;
    for (int i = 2; i < dir.size(); i++) {
        int now_pos = dir[i] - '1';
        if (is_left) {
            if (now_pos % 3 > right_pos % 3) {
                right_pos = now_pos;
                res++;
            }
            else {
                left_pos = now_pos;
                is_left = false;
            }
        }
        else {
            if (now_pos % 3 < left_pos % 3) {
                left_pos = now_pos;
                res++;
            }
            else {
                right_pos = now_pos;
                is_left = true;
            }
        }
    }
    return res;
}

void solve(string s) {
    if (s.size() <= 2) {
        cout << 0 << endl;
        return;
    }
    int ans = INF;
    int first_pos = s[0] - '1', second_pos = s[1] - '1';
    if (first_pos % 3 < second_pos % 3) {
        ans = min(ans, cnt(first_pos, second_pos, s, true));
    }
    else if (first_pos % 3 > second_pos % 3) {
        ans = min(ans, cnt(second_pos, first_pos, s, false));
    }
    else {
        ans = min(ans, cnt(first_pos, second_pos, s, true));
        ans = min(ans, cnt(first_pos, second_pos, s, false));
        ans = min(ans, cnt(second_pos, first_pos, s, true));
        ans = min(ans, cnt(second_pos, first_pos, s, false));
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    while (true) {
        cin >> s;
        if (s == "#") break;
        solve(s);
    }
    return 0;
}


Measured memory_bytes: 3280
import sys
input = sys.stdin.readline
A, B = (int(i) for i in input().split())

cd = [1]
factors = {}
temp = A
for i in range(2, int(-(-A**0.5//1))+1):
    if temp%i==0:
        cnt = 0
        while temp%i==0:
            #print(temp)
            cnt+=1
            temp //= i
        factors[i] = 1
if temp!=1:
    factors[temp] = 1
#print(factors)
temp = B
for i in range(2, int(-(-B**0.5//1))+1):
    if temp%i==0:
        cnt = 0
        while temp%i==0:
            cnt+=1
            temp //= i
        #print(i)
        if i in factors:
            factors[i] = 2
        else:
            pass
if temp!=1:
    if temp in factors:
        factors[temp] = 2
#print(factors)
count = 1
for k, v in factors.items():
    if v==2:
        count+=1

print(count)


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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007

int n,H[25],ans;
int main(){
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> H[i];
    if(i==0){
      ans++;
      continue;
    }
    for(int j = 0; j <i; j++){
      if(H[i] >= H[j]){
        if(i-1==j) ans++;
      }else{
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" a : "<<a<<"\n"
#define debug2(a,b) cout<<" a : "<<a<<" b : "<<b<<"\n"
#define debug3(a,b,c) cout<<" a : "<<a<<" b : "<<b<<" c : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" a : "<<a<<" b : "<<b<<" c : "<<c<<" d : "<<d<<"\n"
// #define M 421412341324321
#define MOD 998244353 

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int k,x;
	cin>>k>>x;

	REP(i,max(x-k+1,(int)-1000000),x-1)
	{
		cout<<i<<" ";
	}
	REP(i,x,min((int)1e6,x+k-1))
	{
		cout<<i<<" ";
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5, mod = 1e9 + 7;
int cnt[256];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i){
        ++cnt[s[i]];
    }
    int app = 0;
    for (int i = 0; i < 256; ++i){
        if (cnt[i] == 2) ++app;
    }
    if (app == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string[] s = Console.ReadLine().Split(' ');
        double[] nums = new double[n];
        double value = 0;

        for (int i = 0; i < n; i++)
            nums[i] = double.Parse(s[i]);

        Array.Sort(nums);

        value = nums[0];

        for(int i = 1; i < n; i++){
            value = (value + nums[i]) / 2;
        }

        Console.WriteLine(value);
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

struct UnionFind{
	vector<int> rnk,par;

	UnionFind(int sz) : rnk(sz,0),par(sz){
		for(int i = 0;i < sz;i++) par[i] = i;
	}

	int find(int x){
		if(par[x] == x) return x;
		return par[x] = find(par[x]);
	}

	void unite(int x,int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(rnk[x] < rnk[y]) swap(x,y);
		par[y] = x;
		if(rnk[x] == rnk[y]) rnk[x]++;
	}
	
	bool same(int x,int y){
		return (find(x) == find(y));
	}
};

signed main(){
	int n,m;
	cin >> n >> m;
	UnionFind uf(n * 2);
	for(int i = 0;i < m;i++){
		int x,y,z;
		cin >> x >> y >> z; x--;y--;
		if(z % 2){
			uf.unite(x,y + n);
			uf.unite(x + n,y);
		}else{
			uf.unite(x,y);
			uf.unite(x + n,y + n);
		}
	}
	set<int> st;
	for(int i = 0;i < n * 2;i++) st.insert(uf.find(i));
	cout << st.size() / 2 << endl;
}

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

using namespace std;

main(){
    long long n , m;
    scanf("%lld %lld" , &n , &m);

    if((n < 2ll) && (m < 2ll))printf("1\n");
    else if(n == 1)printf("%lld\n" , m-2ll);
    else if(m == 1)printf("%lld\n" , n-2ll);
    else printf("%lld\n" , (n-2ll)*(m-2ll));

    return 0;
}


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

int n, k, q, x, a[100001], frek[100001];

int main (){
	cin >> n >> k >> q;
	for(int i=1;i<=n;i++){
		a[i]=k;
	}
	for(int i=1;i<=q;i++){
		cin >> x;
		frek[x]++;
	}
	for(int i=1;i<=n;i++){
		a[i]=k-(q-frek[i]);
	}
	for(int i=1;i<=n;i++){
		if(a[i]<=0) cout << "No" << endl;
		else cout << "Yes" <<endl;
	}
}




Measured memory_bytes: 1408
//Preparing Boxes

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    nvarep(n,a);
    vector<int>ans(n,0);
    int s=0;
    for(int i=n;i>0;i--){
        int c=0,j=1;
        for(;i*j<=n;j++){
            c+=ans[i*j-1];
        }
        if(c%2!=a[i-1])ans[i-1]++,s++;
    }
    cout<<s<<nnn;
    rep(i,0,n)if(ans[i]==1)cout<<i+1<<nnn;
    return 0;
}

Measured memory_bytes: 6324
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
#define ll long long
#define re register
#define pb push_back
#define fi first
#define se second
const int N=4e6+10;
const int mod7=1e9+7;
const int mod=1e9+7;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
void read(ll &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
int main()
{
    int n;
    read(n);
    printf("%d\n",n*n);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long int n,m;
  cin>>n>>m;
  vector<long int>arr(m);
  long int sum=0;
  for(int i=0;i<m;i++)
  {
    cin>>arr[i];
    sum+=arr[i];
  }
  if(sum>n) cout<<-1<<"\n";
  else 
    cout<<n-sum<<"\n";
}

Measured memory_bytes: 3712
import java.util.Arrays;
import java.util.Scanner;

/**
 * Gluttony
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            long K = sc.nextLong();

            long[] A = new long[N];
            long[] F = new long[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextLong();
            }
            for (int i = 0; i < N; i++) {
                F[i] = sc.nextLong();
            }

            long sum = Arrays.stream(A).sum();
            if (sum <= K) {
                System.out.println(0);
                return;
            }

            Arrays.sort(A);
            Arrays.sort(F);

            long min = 0;
            long max = 0;
            for (int i = 0; i < N; i++) {
                max = Math.max(max, A[i] * F[N - 1 - i]);
            }

            while (max - min > 1) {
                long mid = (min + max) / 2;

                long need = 0;
                for (int i = 0; i < N; i++) {
                    need += Math.max(0, A[i] - mid / F[N - 1 - i]);
                }

                if (need > K) {
                    min = mid;
                } else {
                    max = mid;
                }
            }

            System.out.println(max);
        }

    }

}


Measured memory_bytes: 104420
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

const int MOD = 998244353;
int mod(int n) {
    n %= MOD;
    if (n < 0) return n + MOD;
    else return n;
}   
void add(int &a, int b) {
    a = mod(a+b);
}   

const int N = 307;
int dp[N][N][N]; // i, j, ans


int link[N];
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    string s;
    int op;
    cin >> s >> op;
    int n = s.size();
    
    reverse(all(s));

    /*
    while (j < n) {
        if (i < n && a[i] == b[j]) {
            ++i;
            ++j;
        }   
        else if (b[j] == '1' && have) {
            ++j;
            --have;
        }   
        else if (i < n && a[i] == '1') {
            ++have;
            ++i;
            ++ans;
        }   
        else {
            return INF;
        }   
    }   
    */

    link[n] = n;
    for (int i = n - 1; i >= 0; --i) {
        if (s[i] == '0')
            link[i] = i;
        else
            link[i] = link[i+1];
    }   

    dp[0][0][0] = 1;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            for (int k = 0; k < N; ++k) {
                int x = dp[i][j][k];
                if (x == 0)
                    continue;

                int have = i - j;

                //b[j] = 0
                if (i < n && s[i] == '0') {
                    add(dp[i+1][j+1][k],x);
                }   
                else {
                    int to = link[i];
                    if (to < n) {
                        int ad = to - i;
                        add(dp[to+1][j+1][k+ad],x);
                    }
                }   

                //b[j]=1
                if (i < n && s[i] == '1') {
                    add(dp[i+1][j+1][k],x);
                }   
                else if (have) {
                    add(dp[i][j+1][k], x);
                }   
            }
        }               
    }   

    int ans = 0;
    for (int i = 0; i <= op && i < N; ++i)
        add(ans, dp[n][n][i]);
    cout << ans << endl;
}


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

int main() {
  int N;
  int count = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
      string s;
      cin >> s;
      if(s == "Y"){
          count++;
      }
  }
  
  if(count != 0){
      cout << "Four" << endl;
  }
  else{
      cout << "Three" << endl;
  }
  
}

Measured memory_bytes: 256
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

n = int(readline())
a = np.array(read().split(), np.int32)

b = np.zeros(10**6 + 10, np.int32)
cnt = 0

for x in a:
    if b[x] > 1:
        continue
    b[::x] += 1

for x in a:
    if b[x] == 1:
        cnt += 1

print(cnt)


Measured memory_bytes: 39620
#include <stdio.h>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define INF 100000010

using namespace std;

int main(void){
  int n,m;
  int a,b,c,d;
  int s,g,V,P;
  cin>>n;
  cin>>m;
  map<int,int> mp[n];
  for(int i=0;i<m;i++){
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    a--;
    b--;
    mp[a][b]=c;
    mp[b][a]=d;
  }
  scanf("%d,%d,%d,%d",&s,&g,&V,&P);
  s--;
  g--;
  int iki[n];
  int kaeri[n];
  for(int i=0;i<n;i++){
    iki[i]=INF;
    kaeri[i]=INF;
  }
  iki[s]=0;
  kaeri[g]=0;

  vector<int> next;
  vector<int> _next;
  next.push_back(s);
  for(int i=0;i<20;i++){
    _next.clear();
    for(int j=0;j<next.size();j++){
      int city=next[j];
      for(auto iter=mp[city].begin();iter!=mp[city].end();iter++){
        int city_next_to = iter->first;
        int cost = iter->second;
        if(iki[city_next_to]>iki[city]+cost){
          iki[city_next_to]=iki[city]+cost;
          _next.push_back(city_next_to);
        }
      }
    }
    next.clear();
    copy(_next.begin(),_next.end(),back_inserter(next));
  }

  next.clear();
  next.push_back(g);
  for(int i=0;i<20;i++){
    _next.clear();
    for(int j=0;j<next.size();j++){
      int city=next[j];
      for(auto iter=mp[city].begin();iter!=mp[city].end();iter++){
        int city_next_to = iter->first;
        int cost = iter->second;
        if(kaeri[city_next_to]>kaeri[city]+cost){
          kaeri[city_next_to]=kaeri[city]+cost;
          _next.push_back(city_next_to);
        }
      }
    }
    next.clear();
    copy(_next.begin(),_next.end(),back_inserter(next));
  }
  cout<<V-P-iki[g]-kaeri[s]<<endl;
  return 0;
}



Measured memory_bytes: 3204
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
string s;
int n, k;
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k >> s;
    int x = 0;
    F0R(i, n - 1)
    {
        if(s[i] == s[i + 1]) x++;
    }
    cout << min(x + 2 * k, n - 1);
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

int a[SIZE], ans[SIZE];

int main(){
  int N, K;

  cin >> N >> K;

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

  priority_queue<pair<int,int>> pq;

  for (int i=0; i<K; i++)
    pq.push({a[i], -i});

  int index = 0;
  for (int i=0; i<N-K; i++) {
    pq.push({a[i+K], -(i+K)});

    while(pq.size() && -pq.top().second < index) {
      pq.pop();
    }

    auto p = pq.top(); pq.pop();

    index = -p.second;
    ans[i] = p.first;
  }

  for (int i=0; i<N-K; i++)
    printf("%d", ans[i]);

  puts("");

  return 0;
}



Measured memory_bytes: 5624
n,k = map(int,input().split())
s = str(input())
ans = ""
for i in range(n):
  if(i==k-1):
    if(s[i]=="A"):
      ans+="a"
    elif(s[i]=="B"):
      ans+="b"
    else:
      ans+="c"
  else:
    ans+=s[i]
print(ans)

Measured memory_bytes: 3064
import Control.Monad
import Control.Applicative
import Data.List
import Debug.Trace

type Channel = (Int, Int)

main :: IO ()
main = do
  [n, p, q] <- getInts
  unless (n + p + q == 0)
    $ do
      ns <- replicateM n $ map tupleToMinutes <$>
            getChannel (p, q)
      let candidate = merge ns
      print $ maximum $ map (\(a, b) -> b - a) candidate
      main
      
getInts :: IO [Int]
getInts = map read . words <$> getLine

getChannel :: Channel -> IO [Channel]
getChannel (p, q) = do
  n <- readLn :: IO Int
  ns <- getInts
  let ns' = (p, p) : go ns ++ [(q, q)]
  return $ go' ns'
  where
    go :: [Int] -> [(Int, Int)]
    go [] = []
    go (a:b:z) = (a, b) : go z
    go' :: [(Int, Int)] -> [(Int, Int)]
    go' [x] = [x]
    go' (a:b:c) = (snd a, fst b) : (go' (b:c))

--tupleToMinutes = id
tupleToMinutes (a, b) = (toMinutes a, toMinutes b)

toMinutes :: Int -> Int
toMinutes n = (n `div` 100) * 60 + (n `mod` 100)

merge :: [[Channel]] -> [Channel]
merge = go . sort . concat
  where
    go :: [Channel] -> [Channel]
    go ls = let ls' = flatten (merge' ls) in
--              trace (show ls) $
              if ls' == ls then ls
              else go ls'
    merge' :: [Channel] -> [[Channel]]
    merge' = groupBy (\(a1, b1) (a2, _) ->
                    a1 <= a2 && a2 <= b1)
    flatten :: [[Channel]] -> [Channel]
    flatten = map (\ls -> (minimum (map fst ls),
                           maximum (map snd ls)))

Measured memory_bytes: 4116
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main():
    n = int(ipt())
    cp = [-1 for i in range(2*10**5+1)]
    dp = [0]*(n+1)
    dp[0] = 1
    for i in range(1,n+1):
        dp[i] += dp[i-1]
        c = int(ipt())
        pc = cp[c]
        if pc != -1 and pc != i-1:
            dp[i] += dp[pc]
        cp[c] = i
        dp[i] %= mod

    print(dp[-1])


    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 90312
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int N, K;
	cin >> N >> K;
	string res = "YES";
	if (N < 2 * K - 1) res = "NO";
	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 256
#define Z(V) for(v=360,m=g();--m;V+=sin(x*z))v-=x=g();V+=sin(v*z)
a;g(){scanf("%d",&a);a?a:exit(0);}main(m,v,x){for(;;){double s=0,t=0,z=.0175,e=.000001;Z(s);Z(t);puts(s>t+e?"1":s+e<t?"2":"0");}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;
void f(){
 LL ans = -1*INFINITY, sum= 0, temp = 0, add = 0;
 int n, k, alpha, m, beta, cycle;
 cin >> n >> k;
 vector<int> p(n+1);
 vector<int> c(n+1);
 p.at(0) = 0;
 c.at(0) = 0;
 forn(i, n){
 	cin >> p.at(i);
 }
 forn(i, n){
 	cin >> c.at(i);
 }
 forn(j, n){ 
   sum = 0;
   add = 0;
   alpha = 0;
   m = p.at(j);
   forn(i, n){
    	sum += c.at(m);
      if(m == j){
        cycle = i;
        break;
      }
      m = p.at(m);
   }
  if(k>cycle && sum>0){
    add = sum;
  //k = alpha * n + beta;  
    alpha = k / cycle;
    beta = k % cycle;
  }
  else if(k > cycle)
  {
    beta = cycle;
  }
  else
  { 
    beta = k;
  }
  if(beta == 0){
    beta = cycle;
    alpha--;
  }
  temp = 0;
  m = p.at(j);
  forn(i, beta){
    	temp += c.at(m);
      m = p.at(m);
      ans = max(ans, temp+alpha * add);
   }
  //cout << "start:" << j << " cycle:" <<cycle<<" beta:" << beta << " sum:" << sum<< " ans: "<< ans << endl;
 }
 cout << ans << endl;
}
   
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    
  f();
 return 0;
}

Measured memory_bytes: 3720
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

enum{N=200023};

struct sth{
	int a,b;
	bool operator<(const sth&e)const{
		return a!=e.a ? a<e.a: b>e.b;
	}
}d[N],d2[N];

priority_queue<int>pq;

int main(){
	int T = ci();
	while( T-- ){
		int n = ci();
		ll ans = 0;
		int tot = 0, tot2 = 0;
		rep(i,1,n){
			int k = ci(), l = ci(), r = ci();
			if( l<r ){
				d2[++tot2] = (sth){n-k,r-l};
				ans += l;
			}
			if( l>r ){
				d[++tot] = (sth){k,l-r};
				ans += r;
			}
			if( l==r ) ans+=l;
		}
		pq = priority_queue<int>();
		sort(d+1,d+tot+1);
		int j = 1;
		rep(i,1,tot){
			while( j<=tot && i>d[j].a ){
				if( pq.empty()==0 && d[j].b > -pq.top() ){
					ans += d[j].b+pq.top();
					pq.pop();
					pq.push(-d[j].b);
				}
				j++;
			}
			if( j<=tot ){
				ans += d[j].b;
				pq.push(-d[j].b);
				j++;
			}
		}
		pq = priority_queue<int>();
		tot = tot2;
		rep(i,1,tot) d[i] = d2[i];
		sort(d+1,d+tot+1);
		j = 1;
		rep(i,1,tot){
			while( j<=tot && i>d[j].a ){
				if( pq.empty()==0 && d[j].b > -pq.top() ){
					ans += d[j].b+pq.top();
					pq.pop();
					pq.push(-d[j].b);
				}
				j++;
			}
			if( j<=tot ){
				ans += d[j].b;
				pq.push(-d[j].b);
				j++;
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 4948
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;

int main() {
    int k;
    cin >> k;
    vector<int> data(32);
    data = {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};
    cout << data.at(k-1) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18
//#define mod 1000000007
#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

//cout<< fixed << setprecision(10)



int main(){

    fast
    int T;
    T=1;
    //cin>>T;
    while(T--){
    	ll a,b,v,w,t;
    	cin>>a>>v;
    	cin>>b>>w;
    	cin>>t;
    	ll x=abs(b-a);
    	
    	if(w>=v)
    	{
    		if(x==0)
    		{
    			cout<<"YES";
			}
			else
			{
				cout<<"NO";
			}
		}
		else
		{
			ll s=v-w;
			ll y=x/s;
			if(x%s==0)
			{
				if(t>=y)
				{
					cout<<"YES";
				}
				else
				{
					cout<<"NO";
				}
			}
			else
			{
				if(t>y)
				{
					cout<<"YES";
				}
				else
				{
					if(t>=y+1)
					{
						cout<<"YES";
					}
					else
					{
						cout<<"NO";
					}
				}
			}
			
		}
    	
    
    }

}

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

int main() {
	char n[3];  bool flag = false;
	for (int i = 0; i < 2; i++) {
		cin >> n[i];
		if (n[i] == '9') flag = true;
	}
	cout << (flag ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;

int main() 
{
    ll l,r;
    cin >> l >> r;
    if(r-l>=2019){
        cout << 0;
        return 0;
    }
    l = l % 2019;
    r = r % 2019;
    if(r <= l || l == 0 || r == 0){
        cout << 0;
    }else{
        int ans = 2020;
        for(ll i = l; i < r; i++){
            for(ll j = i+1; j <= r; j++){
                int t = (i * j) % 2019;
                ans = min(ans,t);
            }
        }
        cout<<ans;
    }
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T read(T)(){ return read.to!T; }
T[] read(T)(long n){ return n.iota.map!(_ => read!T).array; }
T[][] read(T)(long m, long n){ return m.iota.map!(_ => read!T(n)).array; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	
	int n = read.to!int;
	int m = read.to!int;
	
	long[] xs;
	foreach(i; 0 .. n) xs ~= read.to!long;
	
	int[long] xcnt;
	foreach(x; xs){
		if(x !in xcnt) xcnt[x] = 0;
		xcnt[x] += 1;
	}
	
	int[] as, bs; // a: 同じ数のペアの個数 b: 全個数
	as = new int[](m);
	bs = new int[](m);
	long[] ks = xcnt.keys;
	foreach(x; ks){
		int k = x % m;
		as[k] += xcnt[x] / 2;
		bs[k] += xcnt[x];
	}
	
	long ans;
	foreach(k; 0 .. m){
		if(m - k < k) continue;
		if(k == 0) ans += bs[k] / 2;
		else if(k + k == m) ans += bs[k] / 2;
		else{
			if(bs[k] >= bs[m - k]){
				ans += bs[m - k];
				ans += min((bs[k] - bs[m - k]) / 2, as[k]);
			}
			else{
				ans += bs[k];
				ans += min((bs[m - k] - bs[k]) / 2, as[m - k]);
			}
		}
	}
	
	ans.writeln;
	
}

Measured memory_bytes: 12732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<18,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    int ans=0;
    for(int i=1;i<=N;i++){
        if(i<=9){
            for(int j=1;j<=N;j++){
                string S=to_string(j);
                if(S[0]-'0'==i&&S[S.size()-1]-'0'==i) ans++;
            }
        }else{
            int ii=i;
            while(i>=10) i/=10;
            int a=i,b=ii%10;
            i=ii;
            
            if(b==0) continue;
            
            if(a==b) if(a<=N) ans++;
            
            if(b*10+a<=N) ans++;
            
            for(int j=b*10;j<=b*10+9;j++){
                if(j*10+a<=N) ans++;
            }
            
            for(int j=b*100;j<=b*100+99;j++){
                if(j*10+a<=N) ans++;
                else break;
            }
            
            for(int j=b*1000;j<=b*1000+999;j++){
                if(j*10+a<=N) ans++;
                else break;
            }
            
            for(int j=b*10000;j<=b*10000+9999;j++){
                if(j*10+a<=N) ans++;
                else break;
            }
        }
        
        //cout<<i<<" "<<ans<<endl;
    }
    
    cout<<ans<<endl;
}




Measured memory_bytes: 256
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    auto S = sread();
    if ('A' <= S[0] && S[0] <= 'Z')
    {
        writeln("A");
    }
    else
    {
        writeln("a");
    }
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll ar[200007],a,b, test, sum,t,x=0,p,q,y,i,j,k=0,l,cnt;
map<ll,ll>br;
string s,s1,s2;

int main()
{
    ll test;
    cin>>a;
   for(i=1;i<=a;i++)
   {
       cin>>ar[i];
       br[ar[i]]++;

   }
    for(i=1;i<=a;i++)
        if(br[ar[i]]>1)
    {
        cout<<"NO";
        return 0;
    }
    cout<<"YES"<<endl;


}


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

int main(){
    int l,r ;
    cin >> l >> r ;
    while (l > 2019)
    {
        l -= 2019 ;
        r -= 2019 ;
    }
    int ans = 2018 ;
    if (r >= 2019)
    {
        ans = 0 ;
    }else
    {
        for (int i = l; i < r; i++)
        {
            for (int j= i+1; j <= r; j++)
            {
                ans=min((i*j)%2019 , ans) ;
            }
            if (ans==0)
            {
                break ;
            }
            
        }
        
    }
    
    cout << ans <<endl;
    
}

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

using namespace std;

const int maxn = 1e5 + 3;

int n, two = 0, four = 0, twos;

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x; scanf("%d", &x);
        two += (x % 2 == 0); four += (x % 4 == 0);
        if (x % 2 == 0 && x % 4 != 0) twos++;
    }  
    if (four + twos / 2>= n / 2 || two == n) printf("Yes");
    else printf("No");
    return 0;
}

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


int main() {
int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  
  vector<int> vec(5);
  vec[0]=a;
  vec[1]=b;
  vec[2]=c;
  vec[3]=d;
  vec[4]=e;
  bool connect=true;
  for(int i=0;i<5;i++){
    for(int j=0;j<5;j++){
      if(i<j){
        if(vec[j]-vec[i]>k){
          connect=false;
        }
      }
    }
  }
   
  if(connect){cout<<"Yay!"<<endl;}
  else{cout<<":("<<endl;}
    
  
          

}


Measured memory_bytes: 256