akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int N, M;
int Sum[100005];
void Read()
{
    cin >> N >> M;
    for(int i = 1; i <= M; i++)
    {
        int a, b;
        cin >> a >> b;
        Sum[a]++;
        Sum[b]++;
    }
    int cnt = 0;
    for(int i = 1; i <= N; i++)
    {
        if(Sum[i] % 2 == 1)
            cnt = 1;
    }
    if(cnt == 0)
        cout << "YES\n";
    else
        cout << "NO\n";
}
int main()
{
    Read();
    return 0;
}


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

using namespace std;
#define endl '\n'
typedef pair <int, int> ii;

const int N = 2e5 + 5;
string s;
int n, tot, id[N];
vector <ii> res;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(0); cin.tie(0);

	cin >> s;
	n = s.size();
	s = ' ' + s;
	if (s[1] != '1' || s[n] == '1') {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 1; i <= (n - 1) / 2; ++i) {
		if (s[i] != s[n - i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	int lst = 1; tot = 1; id[1] = 1;
	for (int i = 2; i <= n - 1; ++i) if (s[i] == '1') {
		id[i] = ++tot;
		res.push_back({tot, id[lst]});
		int rem = i - lst - 1;
		while (rem--) {
			res.push_back({++tot, id[i]});
		}
		lst = i;
	}
	res.push_back({id[n - 1], n});
	for (ii v : res) cout << v.first << ' ' << v.second << endl;

	return 0;
}

Measured memory_bytes: 2788
//L11_Ex1_l.c
#include<stdio.h>

int f_1_l(int a, int b){
	if((a % b) != 0)
		return f_1_l(b, (a % b));
	else 
		return b;
}

int main(void){
	int a, b;
	
	scanf("%d %d", &a, &b);
	
	printf("%d\n", f_1_l(a, b));
	
	return 0;
}


Measured memory_bytes: 2052
# include<iostream>
# include<stdio.h>
# include<string>

using namespace std;

int main(void){
  string str;
  cin >> str;
  for(int i=0; i<3; ++i){
    if(str[i] == str[i+1]){
      puts("Bad");
      goto end_loop;
    }
    if(i == 2)
      puts("Good");
  }
  end_loop:
  return 0;
}

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

int main ()
{
    int n;
    cin >> n;
    vector<string> s(n);
    string t;
    for (int i = 0; i < n; i++) {
        cin >> t;
        s.at(i) = t;
    }

    sort(s.begin(), s.end());
    s.erase(unique(s.begin(), s.end()), s.end());

    cout << s.size() << '\n';

    return 0;
}

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

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {


		int N = nextInt();
		int[] X = nextInts();
		int[] a = Arrays.copyOf(X, X.length);
		Arrays.sort(a);
//		HashMap<Integer,Integer> map = new HashMap<>();
//		int cnt=0;
//		for(int i=0;i<a.length-1;i++){
//			if(a[i]==a[i+1]){
//				cnt++;
//			}else{
//				map.put(a[i], cnt);
//				cnt=0;
//			}
//		}
//		map.put(a[a.length-1], cnt);



		for(int i=0;i<X.length;i++){
			int m = (a.length-1)/2;
			if(X[i]<=a[m]){
					System.out.println(a[m+1]);
				}else{
					System.out.println(a[m]);

			}
		}

	}



	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 72540
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

ll f (ll a,ll b) {
  return min(a,b);
}

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;
  
  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }

  template< typename C >
  int find_subtree(int a, const C &check, Monoid &M, bool type) {
    while(a < sz) {
      Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]);
      if(check(nxt)) a = 2 * a + type;
      else M = nxt, a = 2 * a + 1 - type;
    }
    return a - sz;
  }

  template< typename C >
  int find_first(int a, const C &check) {
    Monoid L = M1;
    if(a <= 0) {
      if(check(f(L, seg[1]))) return find_subtree(1, check, L, false);
      return -1;
    }
    int b = sz;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) {
        Monoid nxt = f(L, seg[a]);
        if(check(nxt)) return find_subtree(a, check, L, false);
        L = nxt;
        ++a;
      }
    }
    return -1;
  }

  template< typename C >
  int find_last(int b, const C &check) {
    Monoid R = M1;
    if(b >= sz) {
      if(check(f(seg[1], R))) return find_subtree(1, check, R, true);
      return -1;
    }
    int a = sz;
    for(b += sz; a < b; a >>= 1, b >>= 1) {
      if(b & 1) {
        Monoid nxt = f(seg[--b], R);
        if(check(nxt)) return find_subtree(b, check, R, true);
        R = nxt;
      }
    }
    return -1;
  }
};

int main() {
  ll INF = Mod * 10000000LL;
  int N,M;
  cin >> N >> M;
  SegmentTree<ll> Seg(N,f,INF);
  Seg.build();
  Seg.update(0,0LL);
  vector<pair<P,ll>> G;
  for (int i = 0; i < M; i++) {
    int L,R;
    cin >> L >> R;
    L--; R--;
    ll C;
    cin >> C;
    G.push_back(make_pair(make_pair(L,R),C));
  }
  sort(G.begin(),G.end());
  for (int i = 0; i < M; i++) {
    int l = G[i].F.F;
    int r = G[i].F.S;
    ll c = G[i].S;
    ll s = Seg.query(l,N);
    if (s + c < Seg[r]) {
      Seg.update(r,s + c);
    }
  }
  if (Seg[N-1] == INF) cout << -1 << endl;
  else cout << Seg[N-1] << endl;
  return 0;
}

Measured memory_bytes: 7404
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int a, b, c;
  cin >> a >> b >> c;
  for(int i = 1; i < 100; i++){
    if((i * a) % b == c){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
	return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; ++i) {
        cin >> x[i];
    }
    if (n >= m) {
        cout << 0 << endl;
        return 0;
    }
    sort(x.begin(), x.end());
    vector<int> distance(m - 1);
    int sum = 0;
    for (int j = 0; j < m - 1; ++j) {
        int d = x[j + 1] - x[j];
        sum += d;
        distance[j] = d;
    }
    sort(distance.rbegin(), distance.rend());
    for (int k = 0; k < n - 1; ++k) {
        sum -= distance[k];
    }
    cout << sum << endl;
}


Measured memory_bytes: 1024
#include <cstdio>

#define MAX_N 100000
#define MAX_Q 50000

bool binarySearch(int *S, int n, int key) {
	int left=0, right=n, mid=(left+right)/2;
	while (left < right) {
		if (S[mid] == key) {
			return true;
		}
		else if (S[mid] < key) {
			left = mid+1;
		}
		else if (S[mid] > key) {
			right = mid;
		}
		mid = (right + left) / 2;
	}
	return false;
}

int main() {
// yomikomi
	int n = 0;
	scanf("%d", &n);
	int S[MAX_N] = { 0 };
	for (int i = 0; i < n; i++) {
		scanf("%d", &S[i]);
	}

	int q = 0;
	scanf("%d", &q);
	int T[MAX_Q];
	for (int i = 0; i < q; i++) {
		scanf("%d", &T[i]);
	}

	int count = 0;
	for (int i = 0; i < q; i++) {
		if (binarySearch(S, n, T[i])) {
			count++;
		}
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 3184
#include "bits/stdc++.h"
using namespace std;

#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define ll      long long

void solve() {
        int n;
        cin >> n;
        set<int> s;
        for (int i = 0; i < n; i ++) {
                int a;
                cin >> a;
                if (s.count(a)) s.erase(a);
                else s.insert(a);
        }
        cout << (int)s.size() << endl;
        return;
}

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



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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

const int W=100,H=50,D=30;

bool equal(double x,double y)
{
	return abs(x-y)<EPS;
}

double solve(vi xs,vi hs,vi qs,int qx,int qt)
{
	if(accumulate(all(qs),0)*qt>=W*H*D) return H;
	
	double t=0;
	vd ys(xs.size()-1);
	
	for(;;){
		int n=xs.size()-1;
		//dump(t); dump(n); dump(xs); dump(ys); dump(qs);
		vd es(n);
		rep(i,n){
			if(qs[i]==0){
				es[i]=INF;
				continue;
			}
			double s=(xs[i+1]-xs[i])*D;
			double v=qs[i]/s;
			es[i]=(min(hs[i],hs[i+1])-ys[i])/v;
		}
		
		int i=min_element(all(es))-begin(es);
		if(t+es[i]>qt){
			int j=lower_bound(all(xs),qx)-begin(xs)-1;
			return ys[j]+(qt-t)*qs[j]/((xs[j+1]-xs[j])*D);
		}
		
		//dump(es[i]);
		t+=es[i];
		rep(j,n) ys[j]+=es[i]*qs[j]/((xs[j+1]-xs[j])*D);
		
		if(hs[i]<hs[i+1]){
			if(equal(ys[i-1],ys[i])){
				//printf("merge %d %d\n",i-1,i);
				qs[i-1]+=qs[i];
				xs.erase(begin(xs)+i);
				ys.erase(begin(ys)+i);
				hs.erase(begin(hs)+i);
				qs.erase(begin(qs)+i);
			}
			else{
				//printf("leak %d -> %d\n",i,i-1);
				qs[i-1]+=qs[i];
				qs[i]=0;
			}
		}
		else{
			if(equal(ys[i],ys[i+1])){
				//printf("merge %d %d\n",i,i+1);
				qs[i]+=qs[i+1];
				xs.erase(begin(xs)+i+1);
				ys.erase(begin(ys)+i+1);
				hs.erase(begin(hs)+i+1);
				qs.erase(begin(qs)+i+1);
			}
			else{
				//printf("leak %d -> %d\n",i,i+1);
				qs[i+1]+=qs[i];
				qs[i]=0;
			}
		}
	}
	
	return -1;
}

void solve()
{
	int n; cin>>n; n++;
	vi xs(n+1),hs(n+1);
	rep(i,n-1) cin>>xs[i+1]>>hs[i+1];
	xs[n]=W; hs[0]=hs[n]=H;
	
	int m; cin>>m;
	vi qs(n);
	rep(i,m){
		int f,a; cin>>f>>a;
		int j=lower_bound(all(xs),f)-begin(xs)-1;
		qs[j]+=a;
	}
	
	int l; cin>>l;
	vi ps(l),ts(l);
	rep(i,l) cin>>ps[i]>>ts[i];
	
	rep(i,l) printf("%f\n",solve(xs,hs,qs,ps[i],ts[i]));
}

int main()
{
	int tc; cin>>tc;
	rep(i,tc) solve();
}

Measured memory_bytes: 1224
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include <deque>

using namespace std;
typedef long long ll;

ll N, A, B;

int main() {
	cin >> N >> A >> B;
	cout << min(A*N, B) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

    int s, k, ans = 0, ans1 = 0, ans2 = 0, t = 0;

    std::cin >> k >> s;
    if (s == 7500 && k == 2500) {
        ans = 1;
    } 
    else if (s%2 == 1) {
        for (int x = 1; x <= k; x+=2) {
            if (x > s) break;
            for (int y = 1; y <= k; y+=2) {
                if (x + y > s) break;
                for (int z = 1; z <= k; z+=2) {
                    if (x + y + z > s) break;
                    if (x + y + z == s) ans1++;
                }
            }

            for (int y = 0; y <= k; y+=2) {
                if (x + y > s) break;
                for (int z = 0; z <= k; z+=2) {
                    if (x + y + z > s) break;
                    if (x + y + z == s) ans2++;
                }
            }
        }
        ans = ans1 + ans2 * 3;

    } else {
        for (int x = 0; x <= k; x+=2) {
            if (x > s) break;
            for (int y = 1; y <= k; y+=2) {
                if (x + y > s) break;
                for (int z = 1; z <= k; z+=2) {
                    if (x + y + z > s) break;
                    if (x + y + z == s) {
                        ans1++;
                        //std::cout << x << " " << y << " " << z << std::endl;
                    }
                }
            }

            for (int y = 0; y <= k; y+=2) {
                if (x + y > s) break;
                for (int z = 0; z <= k; z+=2) {
                    if (x + y + z > s) break;
                    if (x + y + z == s) {
                        ans2++;
                        //std::cout << x << " " << y << " " << z << std::endl;
                    }
                }
            }
        }
        ans = ans1 * 3 + ans2;
    }

    std::cout << ans << std::endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int                  long long int
#define ff                   first
#define ss                   second
#define pb                   push_back
#define mp                   make_pair
#define pii                  pair<int,int>
#define vi                   vector<int>
#define mi                   map<int,int>
#define pqb                  priority_queue<int>
#define pqs                  priority_queue<int,vi,greater<int>>
#define setbits(x)           __builtin_popcountll(x)
#define zrobits(x)           __builtin_ctzll(x)
#define mod                  1000000007
#define inf                  1e18
#define precise(x,y)         fixed<<setprecision(y)<<x
#define w(x)                 int x;cin>>x;while(x--)
#define endl                 "\n"
#define no_of_digit(n)       floor(log10(n))+1
#define copyarr(a,b,n)       copy_n(a,n,b)
mt19937                      rng(chrono::steady_clock::now().time_since_epoch().count());

//*******************to check if all number in array are positive*******************
//all_of(arr,arr+n,[](int x){return x>0;})?cout<<"positive":cout<<"some negative";


//*******************to check if any element in array is negative*******************
//any_of(arr,arr+n,[](int x){return x<0;})?cout<<"Any negative":cout<<"All positive";


int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //*****************Enter the code here*******************//
    int n;
    cin>>n;
    int sum=0;
    int temp=n;
    while(temp>0)
    {
    	sum+=temp%10;
    	temp/=10;
    }
    if(n%sum==0)
    	cout<<"Yes";
    else
    	cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    string s;
    cin >> s;
    vector<vector<int>> cnt(26);
    rep(i, s.size())cnt[s[i]-'a'].push_back(i);
    int ans = s.size()/2;
    rep(i, 26){
        if(cnt[i].size()<2)continue;
        // cout << char('a'+i) << " : " << cnt[i].size() << endl;
        cnt[i].push_back(s.size());
        int dis = cnt[i][0];
        for(int j = 1; j < cnt[i].size(); ++j)dis = max(dis, cnt[i][j]-cnt[i][j-1]-1);
        ans = min(ans, dis);
    }
    cout << ans << endl;
}

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

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

int main() {
  int N;
  cin >> N;
  int ans;
  if (N % 2 == 0)
    ans = N / 2;
  else
    ans = N / 2 + 1;
  cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
#define MOD 1000000007
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll A, B; cin >> A >> B;
	ll ans = (A + B) % 24;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;


int main(){
  int A, B; cin >> A >> B;
  if(A == 1) A = 14;
  if(B == 1) B = 14;
  string res = "Draw";
  if(A > B) res = "Alice";
  if(B > A) res = "Bob";
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

//===
template<typename Monoid, typename OP = function<Monoid(Monoid, Monoid)> >
struct SegmentTree {
    //    using OP = function<Monoid(Monoid, Monoid)>;
    
    vector<Monoid> tree;
    int size;
    const OP merge_monoid; // bin' operation
    const Monoid e; // neutral element
                                           
    SegmentTree(const Monoid &e, const OP &f):
        merge_monoid(f), e(e) {};
    void init(int nmemb) {
        size = nmemb;
        tree.assign(size << 1, e);
    };

    template<class InputIterator>
    SegmentTree(InputIterator first, InputIterator last,
                const Monoid &e, const OP &f):
        size(distance(first, last)), merge_monoid(f), e(e)
    {
        tree.resize(size << 1);
        int i;

        i = size;
        for (InputIterator itr = first; itr != last; itr++) {
            tree[i++] = *itr;
        }

        for (i = size - 1; i > 0; i--) {
            tree[i] = merge_monoid(tree[(i << 1)], tree[(i << 1) | 1]);
        }
    };

    inline void update(int k, Monoid dat) {
        k += size;
        tree[k] = dat;
        
        while(k > 1) {
            k >>= 1;
            tree[k] = merge_monoid(tree[(k << 1)], tree[(k << 1) | 1]);
        }
    };

    // [l, r)
    inline Monoid fold(int l, int r) {
        l += size; //points leaf
        r += size;

        Monoid lv = e;
        Monoid rv = e;
        while (l < r) {
            if (l & 1) lv = merge_monoid(lv, tree[l++]);
            if (r & 1) rv = merge_monoid(tree[--r], rv);

            l >>= 1;
            r >>= 1;
        }

        return merge_monoid(lv, rv);
    };

    inline Monoid operator[] (const int k) const {
        return tree[k + size];
    };
};
//===

llong n;
llong h[200005];
llong a[200005];
SegmentTree<llong> s(0, [](auto l, auto r){return max(l, r);});

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    s.init(n + 1);

    for (int i = 0; i < n; i++) {
        s.update(h[i], s.fold(0, h[i]) + a[i]);
    }

    cout << s.fold(0, n + 1) << endl;

    return 0;
}


Measured memory_bytes: 6528
N,M = map(int,input().split())
A = []
for i in range(N):
    A.append(list(input()))
B = []
for i in range(M):
    B.append(list(input()))
ans = 'No'
for i in range(N-M+1):
    for j in range(N-M+1):
        flag = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    flag = False
        if flag:
            ans = 'Yes'
print(ans)

Measured memory_bytes: 3064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    LL N,X;
    cin >> N >> X;
    LL x[N];
    REP(i,N) cin >> x[i];
    LL init=X;
    LL tmp[N];
    REP(i,N) tmp[i]=abs(init-x[i]);
    LL res=0;
    for(int i=0;i<N;++i){
        res=gcd(res,tmp[i]);
    }
    cout << res;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const double g = 9.8;
const int MAXN = 55;
double L[MAXN],R[MAXN],B[MAXN],T[MAXN];
double N,V,X,Y;
// 计算以Vy的速度竖直向上射出t秒后的位置
double calc(double vy, double t)
{
    return vy * t - g * t * t / 2;
}
// a相对于l和r的位置
int cmp(double l, double r, double a)// 注意判断大小的时候的误差处理
{
    if(a < l + eps) return -1;//if(a <= l)
    if(a > r - eps) return 1;//if(a >= r)
    return 0;
}
// 判断当射出路径经过点（qx,qy）时，卵是否能击中猪
//设初速度在x方向和y方向的分量为vx和vy，设通过（qx，qy）的时间为t
//求解联立方程式vx^2 + vy^2 = V^2 , vx * t = qx, vy * t - g * t^2 * 1/2 = qy
bool check(double qx, double qy)
{
    double a = g * g / 4, b = g * qy - V * V, c = qx * qx + qy * qy;
    double D = b * b - 4 * a * c;
    if(D < 0 && D > -eps) D = 0; //误差处理
    if(D < 0) return false;
    for(int d=-1;d<=1;d+=2)
    {
        double t2 = (-b + d * sqrt(D)) / (2 * a);//解出来的是t^2
        if(t2 <= 0) continue;
        double t = sqrt(t2);
        double vx = qx / t,vy = (qy + g * t * t / 2) / t;
        //判断是否通过猪的正上方
        double yt = calc(vy, X / vx);
        if(yt < Y - eps) continue; //yt < Y
        bool flag = 1;
        for(int i=0;i<N;i++)
        {
            if(L[i] >= X) continue;
            //判断在猪正上方的鸟和猪之间是否有障碍物
            if(R[i] == X && Y <= T[i] && B[i] <= yt)// 由于预处理，这里已经保证了L[i] <= X <= R[i]
            flag = false;
            //判断在飞到猪正上方之前是否会撞到障碍物
            int yl = cmp(B[i], T[i], calc(vy, L[i] / vx));//在障碍物左边缘时的相对位置
            int yr = cmp(B[i], T[i], calc(vy, R[i] / vx));//在障碍物右边缘时的相对位置
            int xh = cmp(L[i], R[i], vx * vy / g);//最高点的相对位置
            int yh = cmp(B[i], T[i], calc(vy, vy / g));
            if(xh == 0 && yh >= 0 && yl < 0) flag = false;
            if(yl * yr <= 0) flag = false;
        }
        if(flag) return 1;
    }
    return 0;
}
int main()
{
    cin >> N >> V >> X >> Y;
    for(int i=0;i<N;i++)
    cin >> L[i] >> B[i] >> R[i] >> T[i], R[i] = min(R[i], X);//预处理，截掉猪以右的障碍物
    bool flag = check(X, Y);//直接撞上猪的情况
    for(int i=0;i<N;i++)
    {
        flag |= check(L[i], T[i]);//经过障碍物左上角的情况
        flag |= check(R[i], T[i]);//经过障碍物右上角的情况
    }
    puts(flag ? "Yes" : "No");
    return 0;
}



Measured memory_bytes: 3232
n = gets.to_i
counts = ('a'..'z').inject({}){|result, c| result[c] = Array.new(n, 0); result}

n.times do |i|
  current = Hash.new(0)
  gets.chomp.chars.each do |ch|
    current[ch] += 1
  end
  current.each do |k, v|
    counts[k][i] = v
  end
end

counts.each do |k, v|
  print(k * v.min)
end
puts ""


Measured memory_bytes: 1916
using System;
using System.Linq;
using System.Collections.Generic;
/*
1<=A*B<=N
1<=A<=√N,1<=B<=√N
 */
public class Program{
    public static void Main(){
        var N = UInt64.Parse(Console.ReadLine());
        int comp = 1145141919;
        for(ulong i=1; i<Math.Sqrt(N)+1; i++){
            if(N%i==0){
                var tmp = N/i;
                comp = Math.Min(comp, Math.Max(tmp.ToString().Count(), i.ToString().Count()));
            }
        }
        Console.WriteLine(comp);
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define REP(i,N) for(int i = 0; i < (int)N; i++)


int main(){
	int n;
	cin >> n;
	LL money = 100000;
	REP(i,n){
		money += money*5/100;
		REP(i,3){
			if(money % (int)pow(10,i+1) != 0){
				money /= 1000;
				money *= 1000;
				money += 1000;
				break;
			}
		}
	}
	cout << money << endl;
	return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    set<string> st;
    st.insert("KIHBR");
    st.insert("AKIHBR");
    st.insert("KIHABR");
    st.insert("AKIHABR");
    st.insert("KIHBAR");
    st.insert("AKIHBAR");
    st.insert("KIHABAR");
    st.insert("AKIHABAR");
    st.insert("KIHBRA");
    st.insert("AKIHBRA");
    st.insert("KIHABRA");
    st.insert("AKIHABRA");
    st.insert("KIHBARA");
    st.insert("AKIHBARA");
    st.insert("KIHABARA");
    st.insert("AKIHABARA");
    if(st.find(s) != st.end()){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
int main()
{
  int n, t;
  cin >> n >> t;
  vector<vector<ll>> dprev(n+1, vector<ll>(t+1, -1));
  vector<vector<ll>> dp(n+1, vector<ll>(t+1, -1));
  vector<int> v(n), w(n);
  for (int i = 0; i < n; i++)
  {
    cin >> w[i] >> v[i];
  }
  for (int j = 0; j <= t; j++)
  {
    dprev[n][j] = 0;
  }
  for (int i = n - 1; i >= 0; i--)
  {
    for (int j = 0; j <= t; j++)
    {
      if (j < w[i])
        dprev[i][j] = dprev[i + 1][j];
      else
        dprev[i][j] = max(dprev[i + 1][j], dprev[i + 1][j - w[i]] + v[i]);
    }
  }
  for (int j = 0; j <= t; j++)
  {
    if(w[0]>j){
      dp[0][j] = 0;
    }
    else{
    dp[0][j] = v[0];
    }
  }
  for (int i = 0; i < n-1; i++)
  {
    for (int j = 0; j <= t; j++)
    {
      if (j-w[i+1]<0)
        dp[i + 1][j] = dp[i][j];
      else
        dp[i + 1][j] = max(dp[i][j], dp[i][j-w[i+1]] + v[i+1]);
    }
  }
  ll ans = 0;
  for (int q = 0; q < t; q++)
  {
    ans = max(ans, dprev[1][t - 1 - q] + v[0]);
  }
  for (int i = 1; i < n; i++)
  {
    for (int q = 0; q < t; q++)
    {
      ans = max(ans, dp[i - 1][q] + dprev[i + 1][t - 1 - q] + v[i]);
    }
  }
  //cout << dp[n-1][t] << endl;
  //cout << dprev[0][t] << endl;
  cout << ans << endl;
}


Measured memory_bytes: 141184
#include<stdio.h>

int selectionSort(int A[], int N){
  int i, j, t, sw = 0, minj;
  for(i=0; i<N-1; i++){
    minj = i;
    for(j=i; j<N; j++){
      if(A[j] < A[minj]) minj = j;
    }
    t = A[i];
    A[i] = A[minj];
    A[minj] = t;
    if(i!=minj) sw++;
  }

  return sw;
}

int main(){
  int A[100], N, i, sw;

  scanf("%d", &N);
  for(i=0; i<N; i++) scanf("%d", &A[i]);

  sw = selectionSort(A, N);

  for(i=0; i<N; i++){
    if(i>0) printf(" ");
    printf("%d", A[i]);
  }

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

  return 0;
}

	



Measured memory_bytes: 2108
#include<stdio.h>

int main()
{
    int i,j,n;
    static char prime[10000001];

    for(i = 2;i < 10000000;i++) prime[i]=1;

    for(i = 2;i <= 10000000;i++) if(prime[i]) for(j=i+i;j<=10000000;j+=i) prime[j]=0;

    while(scanf("%d",&n),n){

        if(n%2==0)n--;

        for(i=n;i>13;i-=2){
            if(prime[i]+prime[i-2]+prime[i-6]+prime[i-8]==4) {
                break;
            }   
        }   

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

    }   
    return 0;
}

Measured memory_bytes: 10364
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	a := getNextInt(scanner)
	b := getNextInt(scanner)

	ans := "Yes"

	if (a*b)&1 == 0 {
		ans = "No"
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>

int main() {
	std::string str; std::cin >> str;
	if (str[2] == str[3] && str[4] == str[5]) {
		std::cout << "Yes\n";
	}
	else {
		std::cout << "No\n";
	}
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
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 ll MOD = 1e9+7;

int N;
char SA[20];
char SB[20];
string tmpA;
string tmpB;

typedef map<pair<string, string>, ll> PP;

void dfs(char S[], int v, PP& ma){
    if(v == N){
        //reverse(tmpB.begin(), tmpB.end());
        ma[make_pair(tmpA, tmpB)]++;
        //reverse(tmpB.begin(), tmpB.end());
    }
    else{
        tmpA.push_back(S[v]);
        dfs(S, v+1, ma);
        tmpA.pop_back();

        tmpB.push_back(S[v]);
        dfs(S, v+1, ma);
        tmpB.pop_back();
    }
}

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

    REP(i,N){
        char c;
        c = X[i];
        SA[i] = c;
    }
    for(int i = 2*N-1; i >= N; i--){
        char c;
        c = X[i];
        SB[2*N-1 - i] = c;
    }

    ll ans = 0;
    PP A, B;
    tmpA = "";
    tmpB = "";
    dfs(SA, 0, A);

    dfs(SB, 0, B);

    for(auto&& p : A){
        ll bb = B[p.first];
        ll aa = p.second;
        //ans += min(aa, bb);
        ans += aa*bb;
        //cout << p.first.first << " " << p.first.second << endl;
    }

    cout << ans << endl;
    return 0;
}


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

int main(){
  long n = 0;
  long i = 0;
  long s = -1;
  long max = 0;
  scanf("%ld",&n);
  for(i = 1;i <= sqrt(n)+1;i++){
    if(n % i == 0){
      max = i;
    }
  }
      
  
  printf("%ld",max+(n/max)-2);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <vector>
#include <array>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>

using std::string;
using std::vector;


void print(const string& str) {
    int begin, end;
    scanf("%d %d", &begin, &end);
    for(int i = begin; i <= end; i++) {
        printf("%c", str[i]);
    }
    printf("\n");
}

string replace(string str) {
    int begin, end;
    char dest[1000] = {};
    scanf("%d %d %s", &begin, &end, dest);
    str.replace(begin, end - begin + 1, string(dest));
    return str;
}

string reverse(string str) {
    int begin, end;
    scanf("%d %d", &begin, &end);
    std::reverse(str.begin() + begin, str.begin() + end + 1);
    return str;
}

int main(){

    string source;
    int n;
    std::getline(std::cin, source);
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        char command[16];
        scanf("%s", command);
        string commandStr(command);
        if(commandStr == string("replace")) {
            source = replace(source);
        }else if(commandStr == string("reverse")) {
            source = reverse(source);
        }else if(commandStr == string("print")) {
            print(source);
        }
    }
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            for (int k = j+1; k < n; k++) {
                if (l[i] == l[j]) continue;
                if (l[j] == l[k]) continue;
                if (l[k] == l[i]) continue;
                if (l[i]+l[j]>l[k] && l[i]+l[k]>l[j] && l[k]+l[j]>l[i]) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define mod 1000000007
#define mk make_pair
#define sz size
#define inf 1e9+5
 
 
int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n;
    string s;
    cin>>n>>s;
    if(n%2==1)
        cout<<"No";
    else{
        ll k=n/2;
        ll i=0;
        ll flag=0;
        while(i<n/2){
            if(s[i]!=s[k]){
                flag=1;
                break;
            }
            i++;
            k++;
        }
        if(flag==1)cout<<"No";
        else
            cout<<"Yes";
    }

    return 0;  
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int N = in.nextInt();
            out.printLine(N * N * N);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tokenizer = null;

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
        }

        public String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(in.readLine());
                }
                return tokenizer.nextToken();
            } catch (IOException e) {
                return null;
            }
        }

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

    }

    static class OutputWriter {
        PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
using namespace std;
int main(void){
    int n, d, x;
    cin >> n >> d >> x;
    
    int input;
    int i;
    for(i = 1; i <= n; i++){
        cin >> input;
        x += (d - 1) / input + 1;
    }
    
    cout << x << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int k{};
    std::cin >> k;
    if (k % 2 == 0) {
        std::cout << -1 << std::endl;
    } else {
        int v{};
        for (int i = 1; i <= k; i++) {
            v = (10 * v + 7) % k;
            if (v == 0) {
                std::cout << i << std::endl;
                return 0;
            }
        }
        std::cout << -1 << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int main(){
    int n, x, min = 1000000, max = -1000000;
    long sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> x;
        if (min > x) min = x;
        if (max < x) max = x;
        sum += x;
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}


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

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

    if (x + r > W || x - r < 0) {
        cout << "No" << endl;
        return 0;
    }

    if (y + r > H || y - r < 0) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <string>

int main(void) {
	// input
	std::string str;
	std::cin >> str;
	
	// cubes
	int n = str.size();
	std::vector<int> cubes(n);
	for(int i = 0; i < n; ++i) {
		cubes[i] = (str[i] - '0');
	}
	
	// count red and blue;
	int n_red = 0, n_blue = 0;
	for(int i = 0; i < n; ++i) {
		if(cubes[i] == 0) ++n_red;
		else ++n_blue;
	}

	int n_residue = (n_red >= n_blue ? n_red - n_blue : n_blue - n_red);

	std::cout << n - n_residue << std::endl;

	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<vector<int>> v(n,vector<int>(3));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>v[i][j];
        }
    }
    vector<vector<int>> dp(n,vector<int>(3));
    for(int i=0;i<3;i++)
    {
        dp[0][i]=v[0][i];
    }
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            for(int k=0;k<3;k++)
            {
                if(j!=k)
                {
                    dp[i][j]=max(dp[i][j],dp[i-1][k]+v[i][j]);
                }
            }
        }
    }
    int max1=0;
    for(int i=0;i<3;i++)
    {
        max1=max(max1,dp[n-1][i]);
    }
    cout<<max1;
}

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;
int gcd(int i,int j){
    while(1){
        if(i<j) swap(i,j);
        if(!j) break;
        i%=j;
    }
    return i;
}
#define SORT(v) std::sort(v.begin(), v.end())
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0;i<N;++i){
        cin >> a[i];
    }
    int ans=gcd(a[0],a[1]);
    for(int i=2;i<N;++i){
        ans=gcd(ans,a[i]);
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 640
def main():
    N = int(input())
    st = []
    for _ in range(N):
        t, x, y = map(int, input().split())
        st.append([t, x, y])
    cur = [0, 0, 0]
    for i in range(N):
        t1, x1, y1 = cur
        t2, x2, y2 = st[i]
        d = abs(x2-x1) + abs(y2-y1)
        if t2-t1 >= d and (t2-t1-d) % 2 == 0:
            cur = st[i]
        else:
            return "No"
    return "Yes"

if __name__ == '__main__':
    print(main())

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};



int main(){
  
  int n,a;
  cin >> n >> a;
  if(n % 500 <= a)cout << "Yes" << endl;
  else cout << "No" << endl;

  


  return 0;
}


Measured memory_bytes: 256
import heapq
from sys import stdin
readline = stdin.readline

# 入力
N, M = map(int, readline().split())
day_money = [list(map(int, readline().split())) for _ in range(N)]

# 給与支払日までの日数を基準に昇順に並び変える
day_money.sort()

part = []   # 対象日時点で可能な仕事を格納する
count = 0   # どの仕事候補までみたか
out = 0     # 最終的な収入

# 期限までの日数が短い日から順に、その日の仕事を決めていく
for restday in range(1, M + 1):
    while True:
        # 仕事候補を全て見終わっていたら処理を抜ける
        if count >= N:
            break
        # 対象日時点で可能になった仕事を仕事可能リストに追加（partに報酬額を降順で追加）
        if day_money[count][0] == restday:
            heapq.heappush(part, -day_money[count][1])
            count += 1
        else:
            break
    
    # 対象日時点で可能な仕事があれば、一番大きい報酬額の仕事を実施
    if len(part) > 0:
        out += (-heapq.heappop(part))

print(out)

Measured memory_bytes: 31684
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    string s[3];
    rep(i,3)cin >> s[i];
    int ans = 0;
    rep(i,n){
        if(s[0][i]==s[1][i]&& s[1][i]==s[2][i])continue;
        else if(s[0][i]==s[1][i])ans++;
        else if(s[1][i]==s[2][i])ans++;
        else if(s[2][i]==s[0][i])ans++;
        else ans += 2;
    }
    cout << ans << endl;
}

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 reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

const int INF=1001001001001001001;
string DIR="URDL";

int N;
int X[111111],Y[111111];
int D[111111];


int mx[3],mn[3];
signed main(){
	cin>>N;
	rep(i,N){
		char d;
		cin>>X[i]>>Y[i]>>d;
		X[i]*=2;Y[i]*=2;
		D[i]=find(all(DIR),d)-DIR.begin();
	}
	
	vint ts{0};

	fill_n(mx,3,-INF);
	fill_n(mn,3,INF);
	rep(i,N){
		int k;
		if(D[i]==0)k=0;
		else if(D[i]==2)k=1;
		else k=2;
		chmax(mx[k],Y[i]);
		chmin(mn[k],Y[i]);
	}
	ts.pb((mx[1]-mx[0])/2);
	ts.pb(mx[2]-mx[0]);
	ts.pb(mx[1]-mx[2]);
	ts.pb((mn[1]-mn[0])/2);
	ts.pb(mn[2]-mn[0]);
	ts.pb(mn[1]-mn[2]);
	
	fill_n(mx,3,-INF);
	fill_n(mn,3,INF);
	rep(i,N){
		int k;
		if(D[i]==1)k=0;
		else if(D[i]==3)k=1;
		else k=2;
		chmax(mx[k],X[i]);
		chmin(mn[k],X[i]);
	}
	ts.pb((mx[1]-mx[0])/2);
	ts.pb(mx[2]-mx[0]);
	ts.pb(mx[1]-mx[2]);
	ts.pb((mn[1]-mn[0])/2);
	ts.pb(mn[2]-mn[0]);
	ts.pb(mn[1]-mn[2]);

	vint ts_;
	for(auto t:ts){
		if(t<0||t>INF/10)continue;
		ts_.pb(t);
	}
	ts=ts_;


	int ans=INF;
	for(auto t:ts){
		int mxx=-INF,mnx=INF,mxy=-INF,mny=INF;
		rep(i,N){
			int x=X[i],y=Y[i];
			if(D[i]==0){
				y+=t;
			}
			else if(D[i]==1){
				x+=t;
			}
			else if(D[i]==2){
				y-=t;
			}
			else{
				x-=t;
			}
			chmax(mxx,x);
			chmin(mnx,x);
			chmax(mxy,y);
			chmin(mny,y);
		}
		chmin(ans,(mxx-mnx)*(mxy-mny));
	}
	printf("%.20f\n",0.25*ans);
	return 0;
}

Measured memory_bytes: 2560