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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
int h1,h2,m1,m2,k;
cin>>h1>>m1>>h2>>m2>>k;
int st = (h1)*60 + (m1);
int end = (h2)*60+m2;
cout<<end-st-k<<"\n";
}



Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 998244353
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, D[101010];
int cnt[101010];

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%d", D + i);
	int maxD = 0;
	if (D[0] != 0) {
		puts("0");
		return 0;
	}
	for (int i = 0; i < N; ++i) maxD = max(maxD, D[i]);
	for (int i = 0; i < N; ++i) ++cnt[D[i]];
	if (cnt[0] != 1) {
		puts("0");
		return 0;
	}
	i64 ret = 1;
	for (int i = 1; i <= maxD; ++i) {
		for (int j = 0; j < cnt[i]; ++j) ret = ret * cnt[i - 1] % MOD;
	}
	printf("%lld\n", ret);

	return 0;
}


Measured memory_bytes: 1656
#include <stdio.h>
#include <iostream>
#include <fstream>

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

void solve() {
    int L; cin >> L;
    printf("%lf\n", (L / 3.0) * (L / 3.0) * (L / 3.0));
}

int main() {

#ifdef DEV
    std::ifstream in("Maximum Volume.input");
    cin.rdbuf(in.rdbuf());

    int t; cin >> t;
    for (int x = 1; x <= t; ++x) {
        solve();
    }
#else
    solve();
#endif

    return 0;
}


Measured memory_bytes: 3692
import numpy as np

a, b, x = list(map(int, input().split()))
v = a * a * b

if v/2 <= x:
    print(np.arctan(2*(v-x)/(a**3))*(180/np.pi))
else:
    print((np.pi/2 - np.arctan((2*x)/(a*b*b)))*(180/np.pi))


Measured memory_bytes: 12424
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

import math

def calc_num_of_sockets(plug, tap):
    return math.ceil((tap-1)/(plug-1))

def main():
    plug, tap = map(int, input().split())
    print(calc_num_of_sockets(plug, tap))

if __name__ == "__main__":
    try:
        assert calc_num_of_sockets(4, 10) == 3
        assert calc_num_of_sockets(8, 9) == 2
        assert calc_num_of_sockets(8, 8) == 1
    except:
        import traceback
        traceback.print_exc()
        exit()
    main()


Measured memory_bytes: 3188
N=int(input())
S=input()
s=0
s+=S.count('R')*S.count('G')*S.count('B')
for i in range(N):
  for j in range(i+1,N):
    k=2*j-i
    if k<N and S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
      s-=1
print(s)

Measured memory_bytes: 68076
X, Y = map(int, input().split())

S = 0

if X == 1:
    S += 300000
elif X == 2:
    S += 200000
elif X == 3:
    S += 100000

if Y == 1:
    S += 300000
elif Y == 2:
    S += 200000
elif Y == 3:
    S += 100000

if S == 600000:
    S += 400000

print(S)

Measured memory_bytes: 3060
N = int(input())
s = input()
t = input()
if s == t:
    print(N)
    exit(0)
ans = 2*N
for k in range(1,N+1):
    if s[k:] == t[:-k]:
        ans = min(ans,2*N-len(s[k:]))
print(ans)


Measured memory_bytes: 61864
#include<stdio.h>
int main(void){
  long long n,a[100001],i,b,c,d;
  scanf("%lld",&n);
  c=0;
  d=0;
  for(i=0;i<n;i++){
    scanf("%lld",&a[i]);
    if(a[i]==0){
    printf("0\n");
    d=1;
    }
  }
  b=1;
  if(d==0){
  for(i=0;i<n;i++){
    // b*=a[i];
    // printf("%lld\n",b);
    if(a[i]<=1000000000000000000/b){
      b*=a[i];
    }else{
      c=1;
      printf("-1\n");
      break;
    }
  }
  if(c==0){
    printf("%lld\n",b);
  }
  }
  return 0;
}


Measured memory_bytes: 2512
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
const double EPS = 1e-9;
#define INF (1LL<<60)
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);  
  //問題文を読む時間をケチらない！！
  //未定義動作に気を付ける！！
  //DPや二分探索の範囲に気をつける！！

  int h,w,a,b;
  cin >> h >> w >> a >> b;

  int ans = h*w - a*w;
  ans = ans/w * (w-b);

  cout <<  ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

int main(){

	int n;
	long long int mod = 1000000000 + 7;
	cin >> n;
	vector<int> a(n);
	vector<int> t(n);
	for(int i=0; i<n; i++) cin >> a[i];
	for(int i=0; i<n; i++) cin >> t[i];

	if( a[n-1] != t[0] ){
		cout << 0 << endl;
		return 0;
	}

	int h = 0;
	vector<int> q(n, 0);
	vector<bool> qa(n, false);
	for(int i=0; i<n; i++){
		if( h < a[i] ){
			h = a[i];
			q[i] = 1;
			qa[i] = true;
		}else if( h == a[i] ){
			q[i] = a[i];
		}else{
			cout << 0 << endl;
			return 0;
		}
	}
	
	// for(int i=0; i<n; i++) cout << q[i] << " ";
	// cout << endl;

	h = 0;
	vector<int> q2(n, 0);
	vector<bool> q2a(n, false);
	for(int i=n-1; i>=0; i--){
		if( h < t[i] ){
			h = t[i];
			q2[i] = 1;
			q2a[i] = true;
		}else if( h == t[i] ){
			q2[i] = t[i];
		}else{
			cout << 0 << endl;
			return 0;
		}
	}

	vector<int> tmp(n, 0);

	for(int i=0; i<n; i++){
		if( qa[i] && q2a[i] && a[i] != t[i] ){
			cout << 0 << endl;
			return 0;
		}else if( qa[i] && a[i] > t[i] ){
			cout << 0 << endl;
			return 0;
		}else if( q2a[i] && a[i] < t[i] ){
			cout << 0 << endl;
			return 0;
		}
		tmp[i] = min(q[i], q2[i]);
	}

	// for(int i=0; i<n; i++) cout << q[i] << " ";
	// cout << endl;

	long long int ans = 1;
	for(int i=0; i<n; i++){
		tmp[i] = tmp[i] % mod;
		ans = (ans % mod * tmp[i] % mod)%mod;
	}
	ans %= mod;

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 2176
#include<stdio.h>
#include<string.h>
int main()
{
 char S[100];

 scanf("%s",S);
int count=0;
 for(int i=0;i<strlen(S);i++)
 {
  if(S[i]!=S[strlen(S)-1-i])
	  count++;

 }


 printf("%d\n",count/2);

	return 0;}


Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
//#define _CRTDBG_MAP_ALLOC
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const ll LINF = 9187201950435737471;
const ll nLINF = -9187201950435737472;
const int INF = 2139062143;
const int nINF = -2139062144;
const ull ULINF = numeric_limits<ull>::max();
const int MAXN = 2e4 + 15;
const ll MOD = 1e9  ;
const double EPS = 1e-9;
const double PI = acos(-1);
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rnd(seed);

#define all(_v) _v.begin(), _v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define sqr(_v) (_v * _v)
#define vi vector <int>
#define vii vector <pair <int, int> >
#define eb emplace_back
#define pb push_back


inline void IO() {
#if(DEBUG_LEVEL > 0)
    freopen("../input.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
}

template <typename T>
istream& operator >> (istream& in, vector<T>& a) {
    for (auto& i : a)
        in >> i;
    return in;
}

template <typename T>
ostream& operator << (ostream& out, const vector<T>& a) {
    for (auto& i : a) {
        out << i << " ";
    }
    return out;
}

template <typename T, typename D>
istream& operator >> (istream& in, pair<T, D>& a) {
    in >> a.first >> a.second;
    return in;
}

template <typename T, typename D>
ostream& operator << (ostream& out, const pair<T, D>& a) {
    out << a.first << " " << a.second;
    return out;
}

inline void solve() {
    cout << setprecision(8) << fixed;
    int n, k;
    cin >> n >> k;
    vector <double> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] = (1 + a[i]) / 2.0;
    }
    double ans = 0, nowsum = 0;
    for (int i = 0; i < k; ++i) {
        nowsum += a[i];
    }
    ans = nowsum;
    for (int i = k; i < n; ++i) {
        nowsum += a[i];
        nowsum -= a[i - k];
        ans = max(ans, nowsum);
    }
    cout << ans;
}

signed main() {
    IO();
    int t = 1;
   // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int k,s,x,y,z;
    int cnt=0;
    cin>>k>>s;
    for(int x=0; x<=k; x++){
        for(int y=0; y<=k; y++){
            if(s-x-y<=k && s-x-y>=0){
                cnt++;
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < (ll) b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= (ll) b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const ll MAX= 5e5+6;
const ll inf =1e12;



int main(){
	fastio;
	string s;
	cin>>s;
	ll ans=0,c=1;
	f(i,0,s.size()){
		if(s[i]=='D') ans++;
		else if(i<sz(s)-1 && s[i]=='P' && s[i+1]=='D') ans++;
		else if(s[i]=='?'){
			s[i]='D';
		}
	}
	cout<<s<<endl;
}


 

Measured memory_bytes: 3744
#include <bits/stdc++.h> 
using namespace std;
int main() {
  int N;
  cin >> N;
  int count = 0;
  string S;
  cin >> S;
  
  for (int i = 0; i < N-1; i++) {
    if (S.at(i) == S.at(i+1)) {
      count++;
    }
    else {
      continue;
    }
  }
  
  cout << N - count << endl;

  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <string.h>
#include <algorithm>
#define INF (1<<30)
#define P pair<int,int>
using namespace std;

void dfs(int n, vector<vector<P>>& G, vector<int>& dist) {
	for (P p : G[n]) {
		int next = p.first, cost = p.second;
		if (dist[next] == INF) {
			dist[next] = dist[n] + cost;
			dfs(next, G, dist);
		}
	}
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n; cin >> n;
	int u, v;
	vector<vector<P>> G(n);
	vector<int> dist(n,INF),dist_u(n,INF),dist_v(n,INF);
	for (int i = 0; i < n - 1; i++) {
		int s, t, w; cin >> s >> t >> w;
		G[s].emplace_back(make_pair(t, w));
		G[t].emplace_back(make_pair(s, w));
	}

	dist[0] = 0;
	dfs(0, G, dist);
	auto maxIt = max_element(dist.begin(), dist.end());
	u = distance(dist.begin(), maxIt);

	dist_u[u] = 0;
	dfs(u, G, dist_u);
	maxIt = max_element(dist_u.begin(), dist_u.end());
	v = distance(dist_u.begin(), maxIt);

	dist_v[v] = 0;
	dfs(v, G, dist_v);
	for (int i = 0; i < n; i++) {
		cout << max(dist_u[i], dist_v[i]) << endl;
	}
}

Measured memory_bytes: 4100
#include<cstdio>
#include<algorithm>
using namespace std;
int map[26],map1[4];
char s[200];
int n,m;
int main()
{
	int i,j,k;
	int num1=0,num2=0,num3=0,num0=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%s",s+1);
		for(j=1;j<=m;j++)
			(map[s[j]-'a']+=1)%=4;
	}
	for(i=0;i<26;i++)
		map1[map[i]]++;
	if(m&1&&n&1)num1=1;
	if(m&1)
		num2+=(n>>1);
	if(n&1)
		num2+=(m>>1);
	num0=(n>>1)*(m>>1);
	if(map1[1]>num1){
		printf("No\n");
		return 0;
	}
	num1-=map1[1];
	if(map1[2]>num2){
		printf("No\n");
		return 0;
	}
	num2-=map1[2];
	if(map1[3]>min(num1,num2)){
		printf("No\n");
		return 0;
	}
	num1-=map1[3];num2-=map1[3];
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin >> s;
	int n = s.size();
	string t = "";
	REP(i,n/2) t += "hi";
	cout << (s==t ? "Yes\n" : "No\n");
	return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

//Carden Lantern
public class Main{

	static class E implements Comparable<E>{
		public int s;
		public int t;
		public int x;
		public E(int s, int t, int x) {
			this.s = s;
			this.t = t;
			this.x = x;
		}
		public int compareTo(E o) {
			return x-o.x;
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int m = sc.nextInt();
			PriorityQueue<E> q = new PriorityQueue<E>();
			for(int i=0;i<m;i++){
				String[] s = sc.next().split(",");
				q.add(new E(Integer.parseInt(s[0]), Integer.parseInt(s[1]), Integer.parseInt(s[2])/100-1));
			}
			UnionFind union = new UnionFind(n);
			int c = 0;
			while(union.num>1){
				E e = q.poll();
				if(!union.find(e.s, e.t)){
					union.union(e.s, e.t);
					c+=e.x;
				}
			}
			System.out.println(c);
		}
	}
	
	static class UnionFind {
		final int[] tree;
		int num;
		public UnionFind(int n) {
			this.tree = new int[n];
			Arrays.fill(tree, -1);
			num=n;
		}

		// merge the set contains x and the set contains y
		void union(int x, int y) {
			x = root(x);
			y = root(y);
			if(x != y) {
				if(tree[x] < tree[y]) {
					x ^= y; y ^= x; x^= y;
				}
				tree[x] += tree[y];
				tree[y] = x;
				num--;
			}
		}
		// decide if x and y belong to the same set
		boolean find(int x, int y) {
			return root(x) == root(y);
		}
		int root(int x) {
			return tree[x] < 0 ? x : (tree[x] = root(tree[x]));
		}
		// return size of the set contains x
		int size(int x) {
			return -tree[root(x)];
		}
		// return the number of sets
		int getNum() {
			return num;
		}
	}
}

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

int main(){
    int n, f = 0;
    string s;
    cin >> n;
    for ( int i = 0; i < n; i++)
    {
       cin >> s;
       if(s == "Y"){
           f = 1;
       }
    }
    if(f == 1) 
        cout << "Four" << endl;
    else
    {
        cout << "Three" << endl;
    }
    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2);
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------------------

int main(void) {
  int n, m, c;
  cin >> n >> m >> c;
  arr(b,m);
  int ans=0;
  rep(i,n){
    int tmp=c;
    rep(i,m){
      int a; cin >> a;
      tmp+= a*b[i];
    }
    if(tmp>0) ans++;
  }

  prt(ans);

}


Measured memory_bytes: 256
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;

typedef long long ll;

#define pb push_back
#define mp make_pair
#define x first
#define y second

const ll inf=2147483647;

//

ll read()
{
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}

void print(ll x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(ll i=sz-1; i>=0; i--)putchar('0'+a[i]);
}

ll n;
ll a[11111],b[11111];
ll sa,sb;

int main(){
	n=read();
	for(ll i=1;i<=n;i++){
		a[i]=read();
		sa+=a[i];
	}
	for(ll i=1;i<=n;i++) b[i]=read(),sb+=b[i];
	
	if(sa>sb){
		puts("No");
		return 0;
	}
	
	ll xx=sb-sa;
	ll n1=0,n2=0;
	for(ll i=1;i<=n;i++){
		while(a[i]<b[i]) a[i]+=2,n1++;
		while(b[i]<a[i]) b[i]++,n2++;
	}
	if((xx-n2)!=2*(xx-n1) || n1>xx || n2>xx){
		puts("No");
	}
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, n, b, c;
  in(n);
  a = 0;
  string s;
  rep2(i, 1, n + 1){
    c = 1;
    b = i;
    while(b / 10 > 0){
      b = b / 10;
      c++;
    }
    if(c % 2 == 1)
      a++;
  }
  out(a);
  memi;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
typedef pair<ll, ll> p;
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; }
const long long mod = 1e9 + 7;
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);

int main() {

	string S;
	cin >> S;

	ll ans = 0;

	rep(i, 3) {
		if (S[i] == 'R') {
			ans = 1;
		}
	}

	rep(i,2){
		if (S[i] == 'R' && S[i + 1] == 'R')
			ans++;
	}

	cout << ans;

	return 0;
}


ll gcd(ll a, ll b) {
	if (a % b == 0)return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

Measured memory_bytes: 3624
using System;
using System.Text;

namespace _010_CircumscribedCircleofaTriangle
{
	class Program
	{
		static void Main ( string[] args )
		{
			int dataSetCount = int.Parse ((Console.ReadLine ()));
			StringBuilder output = new StringBuilder (dataSetCount * 5 * 3);

			for (int lp = 0; lp < dataSetCount; lp++)
			{
				decimal[] points = Array.ConvertAll (Console.ReadLine ().Split (' '), decimal.Parse);

				Vector2 vertex1 = new Vector2 (points[0], points[1]);
				Vector2 vertex2 = new Vector2 (points[2], points[3]);
				Vector2 vertex3 = new Vector2 (points[4], points[5]);

				Vector2 middlePoint1 = (vertex1 + vertex2) / 2;
				Vector2 distance1 = new Vector2 (vertex1.Y - vertex2.Y, vertex2.X - vertex1.X);

				Vector2 middlePoint2 = (vertex2 + vertex3) / 2;
				Vector2 distance2 = new Vector2 (vertex2.Y - vertex3.Y, vertex3.X - vertex2.X);

				Vector2 circlePoint = Vector2.CrossPoint (middlePoint1, middlePoint1 + distance1, middlePoint2, middlePoint2 + distance2);

				decimal radius = Vector2.Sqrt ((circlePoint - vertex1).Length ());

				output.AppendFormat ("{0:0.000} {1:0.000} {2:0.000}", circlePoint.X, circlePoint.Y, radius);
				output.AppendLine ();
			}

			Console.Write (output);
		}
	}

	class Vector2
	{
		public Vector2 ( decimal x, decimal y )
		{
			this.X = x;
			this.Y = y;
		}

		public decimal X { private set; get; }
		public decimal Y { private set; get; }

		public static Vector2 operator + ( Vector2 ob1, Vector2 ob2 )
		{
			return new Vector2 (ob1.X + ob2.X, ob1.Y + ob2.Y);
		}
		public static Vector2 operator - ( Vector2 ob1, Vector2 ob2 )
		{
			return new Vector2 (ob1.X - ob2.X, ob1.Y - ob2.Y);
		}
		public static Vector2 operator * ( Vector2 ob, decimal scalar )
		{
			return new Vector2 (ob.X * scalar, ob.Y * scalar);
		}
		public static Vector2 operator / ( Vector2 ob, decimal scalar )
		{
			return new Vector2 (ob.X / scalar, ob.Y / scalar);
		}
		public static decimal Sqrt ( decimal number )
		{
			return new decimal (Math.Sqrt (decimal.ToDouble (number)));
		}
		public decimal Length ()
		{
			return X * X + Y * Y;
		}
		public static decimal CrossProduct ( Vector2 line1, Vector2 line2 )
		{
			return line1.X * line2.Y - line1.Y * line2.X;
		}
		public static Vector2 CrossPoint ( Vector2 line1Point1, Vector2 line1Point2, Vector2 line2Point1, Vector2 line2Point2 )
		{
			Vector2 vectorA = line1Point2 - line1Point1;
			Vector2 vectorB = line2Point2 - line2Point1;

			decimal distance = CrossProduct (vectorB, vectorA);

			return line1Point1 + vectorA * CrossProduct (vectorB, line2Point2 - line1Point1) / distance;
		}
	}
}

Measured memory_bytes: 9364
h, w, k = map(int, input().split())
x = [[0] * w for _ in range(h)]
cnt = 1
for i in range(h):
    s = input()
    for j in range(w):
        if s[j] == '#':
            x[i][j] = cnt
            cnt += 1
for i in range(h):
    for j in range(1, w):
        if x[i][j] == 0:
            x[i][j] = x[i][j - 1]
for i in range(h):
    for j in range(2, w + 1):
        if x[i][-j] == 0:
            x[i][-j] = x[i][-j + 1]
for i in range(w):
    for j in range(1, h):
        if x[j][i] == 0:
            x[j][i] = x[j - 1][i]
for i in range(w):
    for j in range(2, h + 1):
        if x[-j][i] == 0:
            x[-j][i] = x[-j + 1][i]
for i in range(h):
    print(*x[i])


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

using namespace std;

int n, k;
string s;

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

    cin >> n >> k;
    cin >> s;

    if(s[k - 1] <= 90)
        s[k - 1] += 32;

    cout << s;

    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var w, h, n int
	fmt.Scan(&w, &h, &n)

	arr := make([][]int, h)
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			arr[i] = append(arr[i], 1)
		}
	}
	ans := 0
	for i := n - 1; i >= 0; i-- {
		var xi, yi, a int
		fmt.Scan(&xi, &yi, &a)

		for y := 0; y < h; y++ {
			for x := 0; x < w; x++ {
				if (a == 1 && x < xi) ||
					(a == 2 && x >= xi) ||
					(a == 3 && y < yi) ||
					(a == 4 && y >= yi) {
					arr[y][x] = 0
				}
				if i == 0 {
					ans += arr[y][x]
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  if(a == 1) a = 14;
  if(b == 1) b = 14;
  if(a > b) cout << "Alice" << endl;
  else if(a == b) cout << "Draw" << endl;
  else cout << "Bob" << endl;
}


Measured memory_bytes: 256
//I solved it before. If I had enough time I wouldn't have submitted old codes.
//If you forbid I won't do this in the upcoming contests
#include <iostream>
#include <vector>
#include <cmath>
#include <set>
#include <queue>
#include <map>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <algorithm>
#include <limits.h>
#include <bits/stdc++.h>
#define fw(x) freopen("x.txt","w",stdout)
#define For(i,a,b,c) for(int i = a;i < b;i+=c)
#define REP(i,n) for(int i = 0;i < n;++i)
#define REP1(i,n) for(int i = 1; i<=n;i++)
#define mem(a,s) memset(a,s,sizeof a)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define pf printf
#define sc scanf
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define vii vector<int>
#define vll vector<ll>
#define vss vector<string>
#define debug(x)  cout<<#x"="<<(x)<<endl
#define pb push_back


using namespace std;


// moves

//int dx[]= {0,0,1,-1};/*4 side move*/
//int dy[]= {-1,1,0,0};/*4 side move*/
//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/
//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/
//int dx[]={1,1,2,2,-1,-1,-2,-2};/*knight move*/
//int dy[]={2,-2,1,-1,2,-2,1,-1};/*knight move*/


//big_mod

//ll bigmod(ll a,ll b,ll m)
//{if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a)% m;return x;}
//ll BigMod(ll B,ll P,ll M){ ll R=1%M; while(P>0) {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;} /// (B^P)%M

//ll getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1ll;}
//ll setBit1(ll num, int idx) {return num or (1ll<<idx);}
//ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
//ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}

const int mod = 1000000007;
ll qpow(ll n,ll k)
{
    ll ans=1;
    assert(k>=0);
    n%=mod;
    while(k>0)
    {
        if(k&1)
            ans=(ans*n)%mod;
        n=(n*n)%mod;
        k>>=1;
    }
    return ans%mod;
}
int ar[100009][3];
int sum[100009][3];
void run(int i, int pre, int n){
    if(i>=n) return;
    int sum1=0, sum2=0, sum3=0;
    if(pre!=0){
        if(sum[i+1][0] == -1 ) run(i+1, 0, n);
        sum1 = ar[i][pre] + sum[i+1][0];
    }
    if(pre!=1){
        if(sum[i+1][1] == -1 ) run(i+1, 1, n);
        sum2 = ar[i][pre] + sum[i+1][1];
    }
    if(pre!=2){
        if(sum[i+1][2] == -1 ) run(i+1, 2, n);
        sum3 = ar[i][pre] + sum[i+1][2];
    }
    sum[i][pre] = max(sum1, max(sum2, sum3));
}
int main()
{
    fast;
    int n, a, b, c;
    cin>>n;
    REP1(i, n){
        cin>>a>>b>>c;
        sum[i][0]= -1;
        sum[i][1]= -1;
        sum[i][2]= -1;
        ar[i][0] = a;
        ar[i][1] = b;
        ar[i][2] = c;
    }
    sum[n][0] = ar[n][0];
    sum[n][1] = ar[n][1];
    sum[n][2] = ar[n][2];
    run(1, 0, n);
    run(1, 1, n);
    run(1, 2, n);
    cout<< max(sum[1][0], max(sum[1][1], sum[1][2]) ) <<'\n';
    return 0;
}

Measured memory_bytes: 15316
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}


int main(){
    int N; cin >> N;
    long long a[100010];
    for (int i = 1; i <= N; i++){
        cin >> a[i];
    }
    long long L[100010],R[100010];
    L[0] = 0; R[N+1] = 0;
    L[1] = a[1]; R[N] = a[N];
    for (int i = 2; i <= N; i++){
        L[i] = GCD(L[i-1],a[i]);
    }
    for (int i = N-1; i >= 1; i--){
        R[i] = GCD(R[i+1],a[i]);
    }
    long long mx = 0;
    for (int i = 1; i <= N; i++){
        long long tmp = GCD(R[i+1],L[i-1]);
        mx = max(mx,tmp);
    }
    cout << mx << endl;
}

Measured memory_bytes: 2560
# -*- coding:utf-8 -*-

def solve():
    N, Q = list(map(int, input().split()))
    S = input()

    dp = [0]*(N)
    dp[0] = 0
    for i in range(0, N-1):
        if S[i]=="A" and S[i+1]=="C":
            dp[i+1] = dp[i] + 1
        else:
            dp[i+1] = dp[i]
    
    for i in range(Q):
        l, r = list(map(int, input().split()))
        print(dp[r-1] - dp[l-1])
    


if __name__ == "__main__":
    solve()


Measured memory_bytes: 6188
from typing import List


def solve(index: int, elements: List[int], target_value: int) -> bool:
    if target_value < 0:
        return False
    elif 0 == target_value:
        return True
    elif len(elements) == index:
        return False

    return solve(index + 1, elements, target_value - elements[index]) or solve(index + 1, elements, target_value)


if __name__ == "__main__":
    _ = int(input())
    elements = list(map(lambda x: int(x), input().split()))
    min_elem = min(elements)
    sum_elem = sum(elements)
    _ = int(input())
    m_list = list(map(lambda x: int(x), input().split()))

    for m in m_list:
        if m < min_elem or sum_elem < m:
            print("no")
        else:
            if solve(0, elements, m):
                print("yes")
            else:
                print("no")



Measured memory_bytes: 7232
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<functional>
#include<algorithm>
using namespace std;
#define int long long

signed main() {
	int k;
	cin >> k;
	int a = k / 50;
	int m = k % 50;
		cout << 50 << endl;
		int s = a + 49;
		if (m == 0) {
			for (int i = 0; i < 50; i++) {
				if (i)cout << ' ';
				cout << s;
			}
			cout << endl;
		}
		else {
			for (int i = m; i < 50; i++) {
				if (i!=m)cout << ' ';
				cout << s - m ;
			}
			for (int i = 0; i < m; i++) {
			cout << ' ';
				cout << s + 50 - m + 1;
			}
			cout << endl;
		}
		cout << endl;
	}

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

string x;

int main(){
  cin >> x;
  int n = x.size();
  int cnt = 0;
  rep(i, n){
    if(x.at(i) == 'S'){
      cnt++;
    }else if(x.at(i) == 'T' && cnt > 0){
      cnt--;
    }
  }
  cout << cnt * 2 << endl;
  /*
  rep(i, cnt) cerr << 'T';
  rep(i, cnt) cerr << 'S';
  cout << endl;
  */
  return 0;
}


Measured memory_bytes: 640
import java.util.*;
import java.io.*;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static FastReader sc = new FastReader();
    static final double E = 0.000000001;
    static final long MOD = (long) (1e9 + 7);
    static final long MAX = (long)1e9 ;

    public static void main(String[] args) throws IOException {
        int n = sc.nextInt();
        int k = sc.nextInt();
        int res = 0;
        while(n-- > 0)
        {
            if(sc.nextInt() >= k)
                res++;
        }
        System.out.println(res);

    }


}


Measured memory_bytes: 33224
a,b,n = map(int,input().split())
ans = 0
if b > n :
    x = n
    ans = (a*x)//b - a*(x//b)
elif b == n :
    x = n-1
    ans = (a*x)//b - a*(x//b)
else:
    x = b-1
    ans = (a*x)//b - a*(x//b)
print(ans)

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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

const int MAXN = 1e5;
int n, a[MAXN + 5];

int main() {
    read(n);
    for (int i = 1; i <= n; ++i) read(a[i]);
    sort(a + 1, a + n + 1, greater<int>());
    for (int i = 1; i <= n; ++i)
        if (i + 1 > a[i + 1]) {//找到以原点为左下角的最大正方形，其右上方顶点为 (i, i) 
            int j = 0;
            for (; a[j + i + 1] == i; ++j);
            if (((a[i] - i) & 1) || (j & 1)) puts("First");
            else puts("Second");
            break;
        }
    return 0;
}

Measured memory_bytes: 4020
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,K = MI()
    A=LI()
    B=LI()
    A.sort()
    B.sort(reverse=True)

    def is_ok(x,K):
        for i,a in enumerate(A):
            t = x//B[i]
            K -= max(0,a-t)
        return K>=0

    ok = 10**12+2
    ng = -1
    while ok-ng > 1:
        mid = (ok+ng)//2
        if is_ok(mid,K):
            ok = mid
        else:
            ng = mid
        
    print(ok)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 108164
import sys
import numpy as np

n = int(sys.stdin.readline().rstrip())
txy = np.array(sys.stdin.read().split(), dtype=np.int64).reshape(n, 3)
t, x, y = np.concatenate((np.array([[0, 0, 0]]), txy), axis=0).T

def main():
    dt = t[1:] - t[:-1]
    dd = np.absolute(x[1:] - x[:-1]) + np.absolute(y[1:] - y[:-1])
    ans = 'Yes' if np.all((dt >= dd) & (dt & 1 == dd & 1)) else 'No'
    print(ans) 

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 34276
from itertools import combinations

n, m, x = list(map(int, input().split()))
c = []
a = []

# c, aにデータを用意
for i in range(n):
    tmp = list(map(int, input().split()))
    c.append(tmp[0])
    a.append([])
    
    for j in range(1, m + 1):
        a[i].append(tmp[j])

money_min = -1
comb = []
# 組み合わせを用意
for l in range(n):
    tmp = combinations(range(n), l + 1)
    for i in tmp:
        comb.append(i)
    
# 組み合わせごとに考える
for el in comb:
    ables = []
    money = 0        
    scores = []

    # scoreに0をいれる
    for i in range(m):
        scores.append(0)

    # 組み合わせを足し合わせる
    for n in el:
        money += c[n] # 金
        for i in range(m):
            scores[i] += a[n][i] # 習得度

    # 判定
    for i in range(m):
        ables.append(scores[i] >= x)

    # 良ければ金額更新
    if all(ables):
        money_min = money if money_min < 0 or money_min > money else money_min

print(money_min)

Measured memory_bytes: 9260
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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


	int N;
	int A[100000], B[100000], C[100000];
	cin >> N;

	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];
	rep(i, N) cin >> C[i];

	sort(A, A + N);
	sort(B, B + N);
	sort(C, C + N);

	ll are[100000][3] = {};
	rep(i, N) are[i][0] = 1;

	int j = 0;
	rep(i, N) {
		are[i][1] = j;
		while (B[i] > A[j] && j < N) {
			are[i][1]++;
			j++;
		}
	}

	j = 0;
	rep(i, N) {
		if (i != 0) are[i][2] = are[i - 1][2];
		while (C[i] > B[j] && j < N) {
			are[i][2] += are[j][1];
			j++;
		}
	}

	ll kotae = 0;
	rep(i, N) {
		kotae += are[i][2];
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1005;
ll a[200000];
ll kkk(ll a,ll b)
{
    ll re=1;
    while(b)
    {
        if(b&1)
        {
            re=re*a%mod;
        }
        b>>=1;
        a=a*a%mod;
    }
    return re;
}
int main(){
    ll n,k,z;
    scanf("%lld%lld",&n,&k);
    ll mii=1e12;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);

    }
    for(int i=1;i<=n-k+1;i++)
    {
        mii=min(a[i+k-1]-a[i]+min(abs(a[i]),abs(a[i+k-1])),mii);
    }
    printf("%lld\n",mii);
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = 1e12;
const ll N =(32005); // TODO : change value as per problem
const ll MOD = 1e9+7;
bool dp[N][N];
bool dp2[N][N];
ll get(ll x){
	return x + 16000ll + 1ll;
}

void solve(){
	string s;
	cin >> s;
	int x,y;
	cin >> x >> y;
	int idx=sz(s);
	int wow = 0;
	for(int i =0;i < sz(s);i++){
		if(s[i] == 'T') {idx = i;break;}
		wow++;
	}
	vll a,b;
	bool ok = false;
	ll c = 0;
	for(int i = idx+1;i<sz(s);i++){
		// cout << s[i] << " " << ok<< endl;
		if(s[i] == 'T'){
			if(ok) a.pb(c);
			else b.pb(c);
			ok ^= true;
			c = 0;
		}
		else{
			c++;
		}
	}
	if(c != 0){
			if(ok) a.pb(c);
			else b.pb(c);
	}
	ll n = sz(a);
	ll m = sz(b);
	
	dp[0][get(wow)] = true;
	
	int sum = 8000;
	
	for(int i =1;i<=n;i++){
		for(int j = -sum;j<=sum;j++){
			dp[i][get(j)] |= dp[i-1][get(j+a[i-1])];
			 dp[i][get(j)] |= dp[i-1][get(j-a[i-1])];
		}
	}
	dp2[0][get(0)] = true;
	for(int i =1;i<=m;i++){
		for(int j = -sum;j<=sum;j++){
			assert(get(j + b[i-1]) < N); 
			assert(get(j - b[i-1]) >= 0); 
			if(get(j-b[i-1]) <0 ){
				cout << j << endl;
			}
			dp2[i][get(j)] |= dp2[i-1][get(j+b[i-1])];
			dp2[i][get(j)] |= dp2[i-1][get(j-b[i-1])];
		}
	}

	if(dp[n][get(x)] && dp2[m][get(y)])
		cout << "Yes\n";
	else 
		cout << "No\n";
}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}


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


int main(){
	string s;
//	int how[27]={};
	cin >> s;
	
	int answer = 0;
	int I=0,J=s.size()-1;
	while(1) {
		if(s[I] == s[J]){
			I++;
			J--;
		}else if(s[I] == 'x'){
			answer++;
			I++;
		}else if(s[J] == 'x'){
			answer ++;
			J--;
		}else if(s[I] != s[J]){
			cout << "-1" << endl;
			return 0;
		}
		if(I>=J){break;}
	}
	cout << answer << endl;
	/*
	
	
	
	
	for(int i=0;i<s.size();i++){
		if(s[i] != 'x'){
			how[s[i] - 'a']++;
		}
	}
	bool c = false;
	for(int i=0;i<=26;i++){
		if(how[i]%2 != 0){
			c= true;
			break;
		}
	}
	
	string str={};
	for(int i=0;i<s.size();i++){
		if(s[i] != 'x'){
			str += s[i];
		}
	}
	
	for(int i=0;i<str.size()/2;i++){
		if(str[i] != str[str.size()-i-1]){
			cout << "-1" << endl;
			return 0;
		}
	}
	
	char mannnaka = str[str.size()/2];
	int nannkaidetekuru=0;
	for(int i=0;i<str.size()/2;i++){
		if(str[i] == mannnaka){
			nannkaidetekuru ++;
		}
	}
	int I=0,J=0;
	for(int i=0;i<s.size();i++){
		if(s[i] == mannnaka){
			if(nannkaidetekuru != 0){
				nannkaidetekuru --;
			}else{
				I = J = i;
				break;
			}
		}
	}
	int answer = 0;
//	I--;
//	J++;
	
	if(c){
		int i=1;
		while(1){
			if(s[I+i] == mannnaka){
				J = I+i;
				break;
			}
		}
	}
	while(1){
		I--;
		J++;
		if(s[I] == s[J]){
		}else if(s[I] == 'x'){
			answer ++;
			J--;
		}else if(s[J] == 'x'){
			answer ++;
			I++;
		}
		if(I<0 || J>=s.size()){break;}
	}
	
	answer += (I+1);
	answer += (s.size()-J-1);
	
	cout << answer << endl;
	*/
	return 0;
}


Measured memory_bytes: 512
import java.util.*;

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

    int n = scan.nextInt();
    //int k = scan.nextInt();
    if (n == 0) {
      	System.out.println(0);
    	return;
    }
    int[][] act = new int[n][3];
    int[] dp1 = new int[n];
    int[] dp2 = new int[n];
    int[] dp3 = new int[n];

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 3; j++) {
        act[i][j] = scan.nextInt();
      }      
    }
    scan.close();

    Arrays.fill(dp1, Integer.MIN_VALUE);
    Arrays.fill(dp2, Integer.MIN_VALUE);
    Arrays.fill(dp3, Integer.MIN_VALUE);
    dp1[0] = act[0][0];
    dp2[0] = act[0][1];
    dp3[0] = act[0][2];

	for (int i = 1; i < n; i++) {
      dp1[i] = Math.max(dp2[i-1], dp3[i-1]) + act[i][0];
	  dp2[i] = Math.max(dp1[i-1], dp3[i-1]) + act[i][1];
      dp3[i] = Math.max(dp1[i-1], dp2[i-1]) + act[i][2];
    }

                                      
    System.out.println(max(dp1[n-1], dp2[n-1], dp3[n-1]));
  }
                                      
  private static int max(int a, int b, int c) {
  	return Math.max(a, Math.max(b,c));
  }
}

Measured memory_bytes: 98700
N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = sum([a for a in A if a > 0])
B = [a if a <= 0 else 0 for a in A]

s = sum(B[:K])
s_max = s
c = sum([1 for a in A[:K] if a <= 0])
c_max = c
for i in range(N-K):
  s += B[i+K] - B[i]
  s_max = max(s_max, s)
  c += (A[i+K]<=0) - (A[i]<=0)
  c_max = max(c_max, c)

if c_max == K:
  print(ans)
  quit()

B = [a if a > 0 else 0 for a in A]
s = sum(B[:K])
s_min = s
for i in range(N-K):
  s += B[i+K] - B[i]
  s_min = min(s_min, s)

print(max(ans+s_max, ans-s_min))

Measured memory_bytes: 14736
#include <stdio.h>
#include <stdlib.h>
#define N 100001
#define MAX 100001
 
int A[MAX];
 
int partition(int p, int r){
  int x,i,j,kari;
  x = A[r];
  i = p - 1;
  for(j=p; j<r; j++){
    if(A[j] <= x){
      i++;
      kari = A[i];
      A[i] = A[j];
      A[j] = kari;
    }
  }
    kari = A[i+1];
    A[i+1] = A[r];
    A[r] = kari;
   
  return i+1;
}
 
int main(){
  int i,num,base;
  scanf("%d",&num);
  for(i=0; i<num; i++) scanf("%d",&A[i]);
  base = partition(0,num-1);
 
  for(i=0; i<num; i++){
    if(i == base) printf("[");
    printf("%d",A[i]);
    if(i == base) printf("]");
    if(i!=num-1) printf(" ");
  }
  printf("\n");
 
  return 0;
 
}

Measured memory_bytes: 992
#C
import numpy as np
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
G = 0
lists = np.zeros(N)
for i in range(M):
    A, B = list(map(int, input().split()))
    if H[A-1] < H[B-1]:
        lists[A-1] = 1
    elif H[A-1] == H[B-1]:
        lists[A-1] = 1
        lists[B-1] = 1
    else:
        lists[B-1] = 1
for i in range(N):
    if lists[i] == 0:
        G += 1
print(G)

Measured memory_bytes: 38300
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;

const long long MOD = 1000000007;


int main() {
  long long A, B, N;
  cin >> A >> B >> N;

  if( N >= B){
    cout << A - (A+(B-1))/B << endl;
  }else{
    cout << floor(A*N/B) - A*floor(N/B) << endl;
  }

}

Measured memory_bytes: 3720