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

static vector<int> adj[100005];
static int dis[100005];
static int leaf[100005];
static int p[100005];

void dfs(int u){
	for(int v : adj[u]){
		if(dis[v] == -1){
			dis[v] = dis[u] + 1;
			p[v] = u;
			dfs(v);
			leaf[u] = max(leaf[u],leaf[v]);
		}
	}
	if((int) adj[u].size() > 1) leaf[u]++;
}
int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, T, A;
	cin >> n >> T >> A;
	T--; A--;
	for(int i = 0;i < n-1;i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	
	
	fill(dis,dis+n,-1);
	dis[A] = 0;
	dfs(A);
	
	//for(int i = 0;i < n;i++){
	//	cout << leaf[i] << " ";
	//}

	
	int ovans = 0;
	long long x = T;
	while(true){
		int DChase = dis[x];
		int DRun = dis[T] - DChase;
		//cout << DChase << " " << DRun << "\n";
		if(DChase <= DRun){
			break;
		}
		
		int ans = DRun + leaf[x];
		ans += (DChase - DRun - 1);
		//cout << x << " " << ans << "\n";
		ovans = max(ans, ovans); 
		x = p[x];
	}
	cout << ovans << "\n";
}


Measured memory_bytes: 10752
#include <stdio.h>

int main(){
  int h,w;
  int i,j;

  while(1){
    scanf("%d %d",&h,&w);
    if(h==0 && w==0) break;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        if((i+j)%2==0) printf("#");
        else{printf(".");}
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 2036
x1,y1,x2,y2=map(int,input().split())
dx=x2-x1
dy=y2-y1
x3=x2+dy*(-1)
y3=y2+dx
dx=x3-x2
dy=y3-y2
x4=x3+dy*(-1)
y4=y3+dx
print(x3,y3,x4,y4)



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

using namespace std;
using ll = long long;

int main() {
    chrono::system_clock::time_point start;
    start = chrono::system_clock::now();

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

    const int INF = 1000000000;

    int d;
    cin >> d;
    vector<int> c(26);
    vector<vector<int>> s(d, vector<int>(26));
    for(int i = 0; i < 26; ++i) cin >> c[i];
    for(int j = 0; j < d; ++j)
        for(int i = 0; i < 26; ++i) cin >> s[j][i];

    int m;
    vector<int> t(d);
    vector<vector<int>> blank(d, vector<int>(26, 1));
    for(int j = 0; j < d; ++j) {
        for(int i = 0; i < 26; ++i) 
            if(j != 0) blank[j][i] = blank[j - 1][i] + 1;
        m = - INF;
        for(int i = 0; i < 26; ++i) {
            if(s[j][i] + c[i] * blank[j][i] > m) {
                t[j] = i;
                m = s[j][i] + c[i] * blank[j][i];
            }
        }
        blank[j][t[j]] = 0;
    }

    int d_, q, dt, diff = 0, m2;
    vector<int> t_ = t;
    vector<vector<int>> blank_ = blank;
    srand((unsigned int)time(NULL));
    while(chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - start).count() < 1900) {
        d_ = rand() % d;
        m2 = - INF;
        for(int i = 0; i < 26; ++i) {
            if(s[d_][i] > m2) {
                m2 = s[d_][i];
                q = i;
            }
        }
        // q = rand() % 26;

        diff = 0;

        diff -= s[d_][t_[d_]];
        diff += s[d_][q];

        if(d_ != 0) blank_[d_][t_[d_]] = blank_[d_ - 1][t_[d_]] + 1;
        else blank_[d_][t_[d_]] = 1;
        diff -= c[t_[d_]] * blank_[d_][t_[d_]];
        dt = d_ + 1;
        while(t_[dt] != t_[d_] && dt < d) {
            diff += c[t_[d_]] * blank_[dt][t_[d_]];
            blank_[dt][t_[d_]] = blank_[dt - 1][t_[d_]] + 1;
            diff -= c[t_[d_]] * blank_[dt][t_[d_]];
            dt++;
        }

        diff += c[q] * blank_[d_][q];
        blank_[d_][q] = 0;
        dt = d_ + 1;
        while(t_[dt] != q && dt < d) {
            diff += c[q] * blank_[dt][q];
            blank_[dt][q] = blank_[dt - 1][q] + 1;
            diff -= c[q] * blank_[dt][q];
            dt++;
        }

        t_[d_] = q;

        // printf("%d\n", diff);

        if(diff > 0) {
            t = t_;
            blank = blank_;
        } else {
            t_ = t;
            blank_ = blank;
        }
    }

    for(int j = 0; j < d; ++j) {
        printf("%d\n", t[j] + 1);
    }

    return 0;
}

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

#define range(i, l, r) for (int i = (int)l; i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = ((int)(r) - 1); i >= (int)l; --(i))

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int mod     = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(16); cerr << fixed << setprecision(16); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solver() {
  int N = input(), M = input(), Q = input();
  
  auto r = make_v(N + 1, N + 1, 0);
  range(i, 0, M) {
    int L = input(), R = input();
    r[L][R]++;
  }

  range(i, 1, N + 1) range(j, 1, N + 1) {
    r[i][j] += r[i - 1][j] + r[i][j - 1] - r[i - 1][j - 1];
  }

  auto f = [&](int sy, int ly, int sx, int lx) {
    return r[ly][lx] + r[sy][sx] - r[ly][sx] - r[sy][lx];
  };

  range(i, 0, Q) {
    int p = input(), q = input();
    
    cout << f(p - 1, N, 0, q) << endl;
  }
}

signed main(int argc, char *argv[]) {
  solver();
}



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

using namespace std;

int main()
{
  string pass;
  bool check = true;
  cin>>pass;

  int sizes = pass.size();
  if(sizes < 6){
    check = false;
  }
  else{
    bool nc = false;
    bool xc = false;
    bool Xc = false;
    for(char e : pass){
      if(65 <= e && e <= 90 && xc != true){
        xc = true;
      }
      else if(97 <= e && e <= 122 && Xc != true){
        Xc = true;
      }
      else if(48 <= e && e <= 57 && nc != true){
        nc = true;
      }

      if(xc == true && Xc == true && nc == true){
        break;
      }
    }
    if(xc != true || Xc != true || nc != true){
      check = false;
    }
  }

  if(check == false){
    cout<<"INVALID"<<endl;
  }
  else{
    cout<<"VALID"<<endl;
  }

  return 0;
}


Measured memory_bytes: 3188
S_dash = input()
T = input()

if len(S_dash) < len(T):
    print("UNRESTORABLE")
    exit()

else:
    res = "UNRESTORABLE"
    rev_S = S_dash[::-1]
    rev_T = T[::-1]
    for i in range(len(rev_S)-len(rev_T)+1):
        check = rev_S[i:i+len(rev_T)]
        t_ok = [False] * len(rev_T)
        for j, (c, t) in enumerate(zip(check, rev_T)):
            if c == t or c == "?":
                t_ok[j] = True
        if sum(t_ok) == len(t_ok):
            res = list(rev_S)
            for j,t in enumerate(rev_T):
                res[i+j] = t
            res = "".join(res[::-1])
            res = res.replace("?", "a")
            print(res)
            exit()

    print(res)
                

Measured memory_bytes: 62024
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
//typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int a,b;
	cin>>a>>b;
	if((a*b)%2==1){
		cout<<"Odd"<<endl;
	}
	else{
		cout<<"Even"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc132/tasks/abc132_b

#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define FORR(i, m, n) for (int(i) = (n); (i) >= (m); i--)
#define rep(...) _overload3(__VA_ARGS__, FOR, REP, )(__VA_ARGS__)
#define repr(...) _overload3(__VA_ARGS__, FORR, REPR, )(__VA_ARGS__)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main()
{
  int n, p[3], r = 0;
  cin >> n;

  cin >> p[0] >> p[1];
  REP(i, n - 2)
  {
    cin >> p[2];
    if ((p[1] < p[0] && p[2] < p[1]) || (p[1] < p[2] && p[0] < p[1]))
      r++;
    p[0] = p[1];
    p[1] = p[2];
  }

  cout << r << '\n';
  return 0;
}


Measured memory_bytes: 256
S=input()
A, B=map(int, [S[:2], S[2:]])
if 1<=A<=12 and 1<=B<=12:
  print("AMBIGUOUS")
else:
  if (A==0 or A>=13) and 1<=B<=12:
    print("YYMM")
  elif 1<=A<=12 and (B==0 or B>=13):
    print("MMYY")
  else:
    print("NA")

Measured memory_bytes: 3064
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;

int main() {
    int s;
    cin >> s;

    auto f = [](int n) {
        return n % 2 == 0 ? n / 2 : 3 * n + 1;
    };

    vector<int> v(1000, 0);

    v[s] = 1;
    for (int i = 1; i <= 1000000; ++i) {
        s = f(s);
        if (v[s]) {
            cout << i + 1 << endl;
            break;
        }
        v[s] = 1;
    }

    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>

using namespace std;

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

	int a, b, c;

	cin >> a >> b >> c;

	cout << min(a + b, min(a + c, b + c)) << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#include <queue>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      bfs;
  bfs.emplace(0, 0);
  vector<pair<int, int>> mark(N, {-1, -1});
  mark[0] = {0, 0};
  while (!bfs.empty()) {
    int step = bfs.top().first;
    int room = bfs.top().second;
    bfs.pop();
    if (mark[room].first < step) continue;
    for (auto nv : G[room]) {
      if (mark[nv].first == -1 || (step + 1) < mark[nv].first) {
        mark[nv] = {step + 1, room + 1};
        bfs.emplace(step + 1, nv);
      }
    }
  }

  rep(i, N) {
    if (mark[i].second == -1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for (int i = 1; i < N; ++i) {
    cout << mark[i].second << endl;
  }
  return 0;
}


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

std::vector<int> g[100000];
long long dp[2][100000];
long long mo=1000000000+7;

void dfs(int cur,int par){
  dp[0][cur]=1;
  dp[1][cur]=1;
  for(int dst:g[cur]){
    if(dst==par)continue;
    dfs(dst,cur);
    dp[0][cur]=dp[0][cur]*(dp[0][dst]+dp[1][dst])%mo;
    dp[1][cur]=dp[1][cur]*dp[0][dst]%mo;
  }
  return;
}

int main(){
  int N;
  std::cin>>N;
  if(N==1){
    std::cout<<2<<std::endl;
    return 0;
  }
  for(int i=0;i<N-1;++i){
    int x,y;
    std::cin>>x>>y;
    --x;
    --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for(int i=0;i<2;++i){	  
    for(int j=0;j<100000;++j){
      dp[i][j]=0;
    }
  }
  dfs(0,-1);
  std::cout<<(dp[0][0]+dp[1][0])%mo<<std::endl;
  
  return 0;
}



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

int main() {
    int N ;
    int a = 0,w = 0,tl = 0,r = 0;
	cin >> N;
    for(int i = 0;i < N;i++){
        string S;
        cin >> S;
        if(S.compare("AC") == 0){
            a++;
        }else if(S.compare("TLE") == 0){
            tl++;
        }else if(S.compare("WA") == 0){
            w++;
        }else{
            r++;
        }
    }
    printf("AC x %d\n",a);
    printf("WA x %d\n",w);
    printf("TLE x %d\n",tl);
    printf("RE x %d\n",r);
	return 0;                     
}

Measured memory_bytes: 3720
#include<iostream>
#include<string>
#include<vector>
#include <math.h>

#define LL long long
#define MOD 1000000007
#define rep(i,n) for(int i = 0;i < (n);i++)

using namespace std;

int main() {

    int N;
    string S;
    cin >> N >> S;

    int cnt[3] = {0};
    
    rep(i,N){
        if(S[i] == 'R') cnt[0]++;
        if(S[i] == 'G') cnt[1]++;
        if(S[i] == 'B') cnt[2]++;
    }

    LL ans = 1;
    rep(i,3)ans *= cnt[i]; 

     rep(i,N){
         for(int j = i+1;j < N;j++){
            int k = 2 * j - i;
            if(S[i] == S[j]) continue;
            if(S[j] == S[k]) continue;
            if(S[k] == S[i]) continue;
            if(k < N) ans--;
         }
     }
     cout << ans <<endl;

	return 0;
}








Measured memory_bytes: 3632
n = int(input())
a = [int(i) for i in input().split(" ")]
flag = 0
for i in a:
    if i%2 == 0:
        if i%3 != 0 and i%5 != 0:
            flag = 1
            break
if flag == 0:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 2940
main = do
    [l,r] <- map read . words <$> getLine :: IO [Int]
    print $ minimum $ [(a `mod` 2019) * (b `mod` 2019) `mod` 2019|  a <- [l,l+1..min r (l+2019)], b <- [a+1,a+2..min r (l+2019)]]

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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;


const int SIZE = 110;
ll n, m;
string s[SIZE],t[SIZE];
ll ans1[SIZE], ans2[SIZE];

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    cin >> m;
    for(int i = 0; i < m; i++){
        cin >> t[i];
    }

    for(int i = 0; i < n; i++){
        if(s[i] == "0") continue;
        ++ans1[i];
        for(int j = i+1; j < n; j++){
            if(s[i] == s[j]){
                ++ans1[i];
                s[j] = "0";
            }
        }
    }

    for(int i = 0; i < m; i++){
        if(t[i] == "0") continue;
        ++ans2[i];
        for(int j = i+1; j < m; j++){
            if(t[i] == t[j]){
                ++ans2[i];
                t[j] = "0";
            }
        }
    }

    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(s[i] == t[j]){
                ans1[i] -= ans2[j];
                break;
            }
        }
        ans = max(ans, ans1[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      long[] a = new long[3*n+1];
      for(int i = 1;i <= 3*n;i++)a[i]=sc.nextLong();
      Arrays.sort(a);
      long sum = 0;
      for(int i = n+1;i <= 3*n;i+=2)sum+=a[i];
      System.out.println(sum);
    }
}


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

using namespace std;
#define eps = (1e-10);
//点
struct Point{
    double x,y;
    Point(double _x=0,double _y=0):x(_x),y(_y){}
    Point operator + (Point p){return Point(x+p.x,y+p.y);}
    Point operator - (Point p){return Point(x-p.x,y-p.y);}
    Point operator * (double a){return Point(a*x,a*y);}
    Point operator / (double a){return Point(x/a,y/a);}
    double norm(){return x*x+y*y;}//模的平方
    double ABS() {return sqrt(norm());}//模
};
//线段
struct Segment{
    Point p1,p2;
};
//点积
double dot(Point a,Point b){
    return a.x*b.x+a.y*b.y;
}
//叉积
double cross(Point a,Point b){
    return a.x*b.y-a.y*b.x;
}
bool Intersect(Segment A ,Segment B){
    if(max(B.p1.x,B.p2.x)<min(A.p1.x,A.p2.x)) return 0;
    if(max(B.p1.y,B.p2.y)<min(A.p1.y,A.p2.y)) return 0;
    if(max(A.p1.y,A.p2.y)<min(B.p1.y,B.p2.y)) return 0;
    if(max(A.p1.x,A.p2.x)<min(B.p1.x,B.p2.x)) return 0;
    if(cross(A.p1-B.p1,A.p2-B.p1)*cross(A.p1-B.p2,A.p2-B.p2)>0) return 0;
    if(cross(B.p1-A.p1,B.p2-A.p1)*cross(B.p1-A.p2,B.p2-A.p2)>0) return 0;
    return 1;
}
int main(){
    int q;
    scanf("%d",&q);
    while(q--){
        Segment A,B;
        scanf("%lf %lf %lf %lf",&A.p1.x,&A.p1.y,&A.p2.x,&A.p2.y);
        scanf("%lf %lf %lf %lf",&B.p1.x,&B.p1.y,&B.p2.x,&B.p2.y);
        if(Intersect(A,B)){
            puts("1");
        }else{
            puts("0");
        }
    }
    return 0;
}


Measured memory_bytes: 3228
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var A = G();
		int N = A[0], K = A[1];
		A = G();
		var cnt = new Dictionary<int, int>();
		foreach (var a in A)
		{
			if (!cnt.ContainsKey(a)) cnt[a] = 1;
			else cnt[a]++;
		}
		var k = cnt.Values.ToList();
		k.Sort();
		var c = 0;
		for (var i = 0; i < k.Count - K; i++) c += k[i];
		Console.WriteLine(c);
	}
}


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

using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ul, ul> P;

const int INF = 1e9;
const int MOD =1e9+7;
const ll LINF = 1e18;

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

    if(abs(A - B) % 2){
        cout << "IMPOSSIBLE" << endl;
    }else{
        cout << (A + B) / 2 << endl;
    }
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int a,b,c;
    cin>>a>>b>>c;
    (a==b&&b==c)?Yes:No;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

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

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

using namespace std;

const int N = 1e5 + 5;
int ans[N] , k;
vector<pair<int , int> > adj[N];

void dfs (int node , int par , int col) {
    int nxt = 1;
    for (auto &c : adj[node]) {
        if (c.first == par) continue;
        nxt += nxt == col;
        k = max(k , nxt);
        ans[c.second] = nxt;
        dfs(c.first , node , nxt);
        nxt++;
    }
}

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

    int n;
    cin >> n;

    for (int i = 0 ;i < n - 1 ;i++) {
        int u , v;
        cin >> u >> v;
        adj[u].push_back({v , i});
        adj[v].push_back({u , i});
    }

    dfs(1 , 1 , -1);

    cout << k << '\n';
    for (int i = 0 ;i < n - 1 ;i++)
        cout << ans[i] << '\n';
}

Measured memory_bytes: 12492
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  int n; cin >> n;
  vector<int> a(n);
  vector<int> x(n);
  vector<int> y(n);
  map<int, int> mx;
  map<int, int> my;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    x[i] = i+1 + a[i];
    y[i] = i+1 - a[i];
    mx[x[i]]++;
    my[y[i]]++;
  }
  sort(all(x));
  sort(all(y));
  long long cnt = 0;
  for(int i=0; i<n; i++) {
    cnt += my[x[i]];
  }
  cout << cnt << endl;


  return 0;
}

// EOF


Measured memory_bytes: 31240
def cal(a,b):
    return a[0]*b[1]-a[1]*b[0]

c=1

while 1:
    N=int(input())
    if N==0:
        break
    p=[tuple(map(int, input().split())) for _ in range(N)]
    input()
    S=0
    for i in range(N):
        S += cal(p[i],p[i-1])
    S=abs(S/2)
    print("{} {}".format(c,S))
    c+=1


Measured memory_bytes: 5620
n, Y = [int(s) for s in input().split(' ')]
 
for x in range(n, -1, -1):
    if Y < x*10000 or n < x:
        continue
    
    for y in range(n-x, -1, -1):
        if Y < x*10000+y*5000 or n < x+y:
            continue
        if (Y-x*10000-y*5000) % 1000 != 0:
            continue
            
        z = int((Y-x*10000-y*5000)/1000)
        if n == x+y+z:
            print('{} {} {}'.format(x, y, z))
            exit()
            
print('-1 -1 -1')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define initdp(a, b)  for (int i = 0; i <= a; i++)   for (int j = 0; j <= b; j++) dp[i][j] = -1;
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define ll long long
#define pll pair<ll, ll>
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 1000005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
using namespace std;



int a,b,c,d,n,m;
bool vis[1002][1002];
char mat[1002][1002];

bool valid(int i,int j) {
    return i>=1 && j>=1 && i<=n && j<=m;
}

int dr[] = {0,0,1,-1};
int dc[] = {-1,1,0,0};


 
void test_case() {

  
 
    cin>>n>>m;

    cin>>a>>b;
    cin>>c>>d;

    fo(i,1,n) {
        fo(j,1,m) {
            cin>>mat[i][j];
        }
    }

    deque<pair< pii, int> >dq;
    dq.push_front(mpr(mpr(a,b),0));

    while(!dq.empty()) {
        pair<pii, int> temp = dq.front();
        dq.pop_front();

        pii pos = temp.first;

       // cout<<pos.first<<pos.second<<endl;


        if(pos.first == c && pos.second == d) {
            cout<<temp.second<<endl;
            return;
        }

        if(vis[pos.first][pos.second] == 1) continue;

        vis[pos.first][pos.second] = 1;

        for(int i=0; i<4; i++) {
            int x = pos.first + dr[i];
            int y = pos.second + dc[i];
            if(valid(x,y) && mat[x][y] == '.' && vis[x][y] == 0 ) {
                dq.push_front(mpr(mpr(x,y), temp.second));
            }
        }  

        for(int i=-2; i<=2; i++) {
            for(int j=-2; j<=2; j++) {
                int x = pos.first + i;
                int y = pos.second + j;
                if(pos.first == 3 && pos.second == 3) {
                // cout<<x<<" "<<y<<endl;
            }
                if(valid(x,y) && mat[x][y] == '.' && vis[x][y] == 0) {
                    // cout<<x<<" "<<y<<" hwcijkckw";
                    dq.push_back(mpr(mpr(x,y), temp.second+1));
                }
            }
        }


    }

    cout<<-1<<endl;

}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);
    int t = 1;
   //  cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 6152
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 
 
#define PI 3.14159265
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
 
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};
 
//const int mod = 998244353;
 
struct dsu{
	int parent[N];
	int cont;
	void make_set(int n){
		for(int i = 1; i <= n; i++)
			parent[i] = i;
		cont = n;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a);
		b = find_set(b);
		if(a != b){
			parent[b] = a;
			cont--;
		}
	}
};
 


int main()
{
	ll n; cin>> n;
	if(n % 2)
		cout<<0;
	else{
		ll ans = 0, d = 10;
		while(d <= n){
			ans += n/d;
			d *= 5;
		}
		cout<<ans;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<string>
using namespace std;
#include <stdio.h>
#include <limits.h>
#include "bits/stdc++.h"
int A = 0;
int B = 0;
int X = 0;
string str("NO");
int main() {
	cin >> A >> B >> X;
	if (A + B >= X) {
		if (A <= X) {
			str = "YES";

		}
	}
	cout << str;
	return 0;
}


Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(long long int i = 0; i < (n); i++)


int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}


int GCD(int a,int b){
  int r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


int LCM(int a,int b){
  int c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


int Factorial(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  string a,b;
  int k=0;//どこからがbの範囲か調べる
  bool flag=false;
  vector<string> v;
  cin>>a>>b;
  if(a.size()<b.size()){
    cout<<"UNRESTORABLE"<<endl;
    return 0;
    
    
    
  }else if(a.size()==b.size()){
    flag=true;
    rep(i,a.size()){
      if(a[i]==b[i] || a[i]=='?'){
      }else{
        flag=false;
      }
    }
    if(flag){
      cout<<b<<endl;
      return 0;
    }else{
      cout<<"UNRESTORABLE"<<endl;
      return 0;
    }
    
    
    
  }else if(a.size()>b.size()){
    flag=false;
    rep(i,a.size()-b.size()+1){
      bool can=true;
      for(int j=0;j<b.size();j++){
        
        if(a[i+j]==b[j] || a[i+j]=='?'){
          if(j==0){
            k=i;
          }
        }else{
          can=false;
        }
      }
      if(can){//出力処理
        flag=true;
        string d=a;
        int c=a.size();//値を変えるから保存
        string s;
        rep(i,c-b.size()+1){
          if(i==k){
            s+=b;
            d=d.erase(i,b.size()-1);
            k=-1;
          }else if(d[i]=='?'){
            s+='a';
          }else{
            s+=d[i];
          }
        }
        v.push_back(s);
      }
    }
    
  }
  if(flag){
    sort(v.begin(),v.end());
    cout<<v[0]<<endl;
  }else{
    cout<<"UNRESTORABLE"<<endl;
  }
  
  
  
}




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

int n;
long long int d[16][16];

long long int dp[1 << 15][15];

const long long int INF = 10000000000;

long long int rec(int s,int v){

    if(dp[s][v] >= 0){
        return dp[s][v];
    }

    if(s == (1 << n) -1 && v == 0){
        return dp[s][v] = 0;
    }

    long long int res = INF;

    for(int u=0; u<n; u++){
        if(!(s >> u & 1)){
            //?¬????u????§??????????
            res = min(res, rec(s | 1 << u ,u) + d[v][u]);
        }
    }

    return dp[s][v] = res;

}

int main() {

    int e;

    cin >> n >> e;

    int s,t,dd;

    for(int i=0;i<=15;i++){
        for(int j=0;j<=15;j++){
            d[i][j] = INF;
        }
    }

    for(int i=0; i<e; i++){
        scanf(" %d %d %d",&s,&t,&dd);
        d[s][t] = dd;
    }

    for(int i=0;i < (1<<15) ; i++){
        for(int j=0;j<15;j++){
            dp[i][j] = -1;
        }
    }

    long long int ans = rec(0,0);

    if(ans==INF){
        ans = -1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7036
N=int(input())
d = dict()
for i in range(N):
    wd = input()
    if wd in d:
        d[wd] +=1
    else:
        d[wd] = 1
r=sorted(d.items(),key=lambda x:-x[1])
res = []
for it in r:
    if it[1]==r[0][1]:
        res .append(it[0])
res = sorted(res)
for it in res:
    print(it)

Measured memory_bytes: 47324
#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 h,w;
  cin >> h >> w;

  queue<P> q;
  vector<int> dx = {-1, 0, 1, 0};
  vector<int> dy = { 0, 1, 0,-1};
  //vector<vector<vector<P>>> to(h,vector<P>(w,vector<P>(0));
  //vector<vector<P>> to[100005][100005];
  P to[h][w][4];

  vector<string> a(h);
  rep(i,h){
    cin >> a[i];
    rep(j,w){
      if(a[i][j]=='#'){
        q.push(make_pair(i,j));
      }
      rep(k,4){
        if(i+dy[k]>=0&&i+dy[k]<h&&j+dx[k]>=0&&j+dx[k]<w){
          to[i][j][k] = make_pair(i+dy[k],j+dx[k]);
        }
        else{
          to[i][j][k] = make_pair(-1,-1);
        }
      }
    }
  }

  vector<vector<int>> dist(h,vector<int>(w,0));
  while(!q.empty()){
    P v = q.front();
    q.pop();
    int yv = v.first;
    int xv = v.second;
    for(auto p : to[yv][xv]){
      int yu = p.first;
      int xu = p.second;
      if(xu==-1||yu==-1) continue;
      if(a[yu][xu]=='#') continue;
      a[yu][xu] = '#';
      dist[yu][xu] = dist[yv][xv] + 1;
      q.push(make_pair(yu,xu));
    }
  }

  int ans = 0;
  rep(i,h) rep(j,w){
    if(ans<dist[i][j]) ans = dist[i][j];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 44688
n,k=map(int,input().split())
h=list(map(int,input().split()))

dp=[float("inf")]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])

for i in range(2,n):
    for j in range(1,min(i,k)+1):
        dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))

print(dp[-1])

Measured memory_bytes: 55008
import sys
from operator import itemgetter

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def iif(n): return [int(input()) for _ in range(n)]
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    mod = 1000000007
    
    A, B = mi()
    
    A -= 1
    if A % 2 == 1:
        # 偶数個
        if (A // 2) % 2 == 1:
            A = 0
        # 奇数個
        else:
            A = 1
    else:
        if ((A-1) // 2) % 2 == 1:
            A = 0 ^ A
        else:
            A = 1 ^ A

    if B % 2 == 1:
        if (B // 2) % 2 == 1:
            B = 0
        else:
            B = 1
    else:
        if ((B-1) // 2) % 2 == 1:
            B = 0 ^ B
        else:
            B = 1 ^ B

    print(A ^ B)

    return

main()


Measured memory_bytes: 9224
c[1100000];main(i,j,n){for(i=2;i*i<1e6;++i)for(j=i;!c[i]&&j<1e6;c[j+=i]=1);for(j=0;~scanf("%d",&n);j=!printf("%d\n",j))for(i=n;i>1;j+=!c[i--]);}

Measured memory_bytes: 0
N,A,B,C = map(int,input().split())

bumboos = [int(input()) for _ in range(N)]

INF = 10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a,b,c) > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a+bumboos[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b+bumboos[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c+bumboos[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0,0,0,0))


"""
1, 2, 3, 4, 5, 6  7, 8
A  A  A  A  A  A  A  A
B  B  B  B  B  B  B  B
C  C  C  C  C  C  C  C
X  X  X  X  X  X  X  X

example
5 100 90 80
98
40
30
21
80

1. dfs(0,0,0,0)
  ret0 = dfs(1,0,0,0) + 10
  ret1 = dfs(1,98,0,0) + 10 <- will be chosen
  ret2 = dfs(1,0,98,0) + 10
  ret3 = dfs(1,0,0,98) + 10

2. dfs(1,98,0,0)
  ret0 = dfs(2,98,0,0) + 10
  ret1 = dfs(2,138,0,0) + 10
  ret2 = dfs(2,98,40,0) + 10 <- will be chosen
  ret3 = dfs(2,98,0,40) + 10

3. dfs(2,98,40,0)
  ret0 = dfs(3,98,40,0) + 10
  ret1 = dfs(3,128,40,0) + 10
  ret2 = dfs(3,98,70,0) + 10 <- will be chosen
  ret3 = dfs(3,98,40,30) + 10

4. dfs(3,98,70,0)
  ret0 = dfs(4,98,70,0) + 10
  ret1 = dfs(4,119,70,0) + 10
  ret2 = dfs(4,98,91,0) + 10 <- will be chosen
  ret3 = dfs(4,98,70,21) + 10

5. dfs(4,98,91,0)
  ret0 = dfs(5,98,91,0) + 10
  ret1 = dfs(5,178,91,0) + 10
  ret2 = dfs(5,98,171,0) + 10
  ret3 = dfs(5,98,91,80) + 10 <- will be chosen

6. dfs(5,98,91,80)
  return abs(98 - 100) + abs(91 - 90) + abs(80 - 80) - 30 if min(98,91,80) > 0 else INF
equals
  return 2 + 1 + 0 - 30
equals
  return -27

then,

5. dfs(4,98,91,0)
  ret3 = -27 + 10
  it returns -17

4. dfs(3,98,70,0)
  ret2 = -17 + 10
  it returns -7

3. dfs(2,98,40,0)
  ret2 = -7 + 10
  it returns 3

2. dfs(1,98,0,0)
  ret2 = 3 + 10
  it returns 13

1. dfs(0,0,0,0)
  ret1 = 13 + 10
  it returns 23

therefore, the answer is 23.
"""


Measured memory_bytes: 3064
/*

Author : AllKilled
Date   : 201911037

Contest: AtCoder Grand Contest 040.
Problem: Task A.
Result :

*/
#include<bits/stdc++.h>
using namespace std;

typedef long long LL;

const LL MAXN = 1e6+7;

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

struct Node{
    LL l, r;
};
vector<Node> g;
vector<Node> f;
LL n, ans, dp[MAXN];

void process(){
    for(int i = 0; i < n; ++i){
        if(i){
            LL l = max(f[i-1].l, g[i].l);
            LL r = min(f[i-1].r, g[i].r);
            f[i] = {l, r};
        }
        else f[0] = g[i];
        dp[i] = max(0ll, f[i].r - f[i].l + 1);
    }
    f.push_back({0ll, (LL)1e12});
    for(int i = n - 1; i > 0; --i){
        if(i < n - 1){
            LL l = max(f[i-1].l, f[i+1].l);
            LL r = min(f[i-1].r, f[i+1].r);
            ans = max(ans, max(0ll, r-l+1) + max(0ll, g[i].r - g[i].l + 1));
        }
        LL l = max(f[i+1].l, g[i].l);
        LL r = min(f[i+1].r, g[i].r);
        f[i] = {l, r};
        ans = max(ans, dp[i-1] + max(0ll, r - l + 1));
        //cout<<i<<" "<<dp[i-1]<<" "<<l<<" "<<r<<" "<<ans << endl;
    }
    f.pop_back();
}

int main()
{
    cin >> n;
    g.resize(n); f.resize(n);
    for(int i = 0; i < n; ++i) {
        cin >> g[i].l >> g[i].r;
        ans = max(ans, g[i].r - g[i].l + 1);
    }
    sort(g.begin(), g.end(), [](Node a, Node b){
        return a.l < b.l || (a.l == b.l && a.r < b.r);
    });
    process();
    sort(g.begin(), g.end(), [](Node a, Node b){
        LL l = a.r - a.l + 1, r = b.r - b.l + 1;
        return (l > r) || (l == r && (a.l < b.l || (a.l == b.l && a.r < b.r))) ;
    });
    process();

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


Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int main(){
	long long n, k;
	cin >> n >> k;

	if(k == 0){
		cout << n * n << endl;
		return 0;
	}

	long long ans = 0;
	range(i,k + 1,n + 1){
		ans += n / i * (i - k);
		ans += max<long long>(n % i + 1 - k, 0);
	}
	cout << ans << endl;
}


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

#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))

using namespace std;

using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;

const ll MOD = 1e9+7;

int main(){
string s;
int q;
string order;
int a;
int b;
string p;
cin>>s>>q;
REP(i,q){
    cin>>order;
    if(order=="reverse"){
    cin>>a>>b;
    p=s.substr(a,b-a+1);
    reverse(p.begin(),p.end());
    s=s.replace(a,b-a+1,p);
    }
    if(order=="replace"){
    cin>>a>>b>>p;
    s=s.replace(a,b-a+1,p);
    }
    if(order=="print"){
    cin>>a>>b;
    p=s.substr(a,b-a+1);
    cout<<p<<endl;
    }
}
}


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

int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    cout << fixed << setprecision(10) << sqrt(a*a + b*b - 2*a*b*cos(M_PI*(60*h-11*m)/360)) << endl;
}

Measured memory_bytes: 4236
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF 1e18
ll MOD = 1e9+7;
ll a[403];
ll n,K;
ll dp[3003][3003];
//T 
//dp[i][j] - number of ways for making prefix i with last number as j
int main(){
	int n;cin>>n;
	string s;cin>>s;
	dp[1][1] = 1;
	for(int len=2;len<=n;len++){
		vector<ll> pref(len+1);
		for(int i=2;i<=len;i++){
			pref[i] = pref[i-1] + dp[len-1][i-1];
			pref[i]%= MOD;
		}
		for(int b=1;b<=len;b++){//the number i am considering on the len psn
			int L,R;
			if(s[len-2]=='<') L = 1,R = b-1;
			else L = b,R = len-1;
			// from L to R -- I have to add in dp[len][b] -- direct prefix_sum application
			dp[len][b] = (pref[R+1] - pref[L] + MOD);
			dp[len][b] %= MOD;
			// for(int a=1;a<=(len-1);a++){//num on len-1 posn
			// 	int real_a = (a>=b)?a+1:a;
			// 	assert(real_a!=b);
			// 	if((real_a<b) != (s[len-2]=='<')) continue;
			// 	// cout<<"?";
			// 	dp[len][b] += dp[len-1][a];
			// 	dp[len][b] %= MOD;
			// }
			// cout<<len<<" "<<b<<" "<<dp[len][b]<<endl;
		} 
	}
	ll ans=0;
	for(int a=1;a<=n;a++) {ans+=dp[n][a];ans%= MOD;}
	cout<<ans<<endl;
}

Measured memory_bytes: 49776
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n;
    cin >> n;
    vector<ll> mae(n);
    vector<ll> naka(n);
    vector<ll> usi(n);
    ll ans = 0;
    priority_queue<ll, vector<ll>, greater<ll>> maeq;
    priority_queue<ll> usiq;
    for (int i = 0; i < n; i++) {
        cin >> mae[i];
        ans += mae[i];
        maeq.push(mae[i]);
    }
    for (int i = 0; i < n; i++) {
        cin >> naka[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> usi[i];
        ans -= usi[i];
        usiq.push(usi[i]);
    }
    vector<ll> mans(n + 1);
    vector<ll> usins(n + 1);
    priority_queue<ll> zanq;
    for (int i = 0; i < n; i++) {
        mans[i + 1] = mans[i];
        if (naka[i] > maeq.top()) {
            mans[i + 1] += naka[i] - maeq.top();
            maeq.pop();
            maeq.push(naka[i]);
        }
    }
    for (int i = n-1; i > -1; i--) {
        usins[i] = usins[i+1];
        if (naka[i] < usiq.top()) {
            usins[i] +=  usiq.top() - naka[i];
            usiq.pop();
            usiq.push(naka[i]);
        }
    }
    ll zans = 0;
    for (int i = 0; i < n + 1; i++) {
        zans = max(zans, mans[i] + usins[i]);
    }
    cout << zans + ans << endl;
}

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

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

typedef long long int64;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(n*a, b) << endl;

  return 0;
}


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

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if((a==b && b == c) || (a != b && a != c && c!= b))
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long a[1005]={1},b[1000]={1,2};
int main(){
int n;
cin >> n;
if (n==1)
{
cout << 1 << endl;
return 0;
}
for (int i=2;i<=100;i++) {
b[i]=b[i-1]*2;
}
for (int i=1;i<=100;i++) if (b[i]<=n&&b[i+1]>n) {
cout << b[i] << endl;
return 0;
}
} 

Measured memory_bytes: 256
import copy
N = int(input())
H = list(map(int,input().split()))
ans = 'Yes'
H2 = H.copy()
for n in range(N):
    H2[n] -= 1
H3 = [H2[0]]
for n in range(1,N):
    if H3[-1] <= H2[n]:
        H3.append(H2[n])
    elif H3[-1] <= H[n]:
        H3.append(H[n])
    else:
        ans = 'No'
        break
print(ans)

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

int main(){
    int N,M;
    cin >>N>>M;
    int A[N];
    int sum = 0;
    for(int i=0;i<N;i++){
        cin >>A[i];
        sum += A[i];
    }
    int count = 0;
    int  S = sum/(4*M);
    if(S*(4*M) == sum){
        for(int i=0;i<N;i++){
        if(A[i] >=S) count ++;
        }
        if(count >= M) cout <<"Yes"<<endl;
        else cout <<"No"<<endl;
    }
    else{
        for(int i=0;i<N;i++){
        if(A[i] > S) count ++;
        }
        if(count >= M) cout <<"Yes"<<endl;
        else cout <<"No"<<endl;
    }

}

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

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

    vector<int> x(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }

    vector<int> res(N);
    for (int i = 0; i < N; i++) {
        res[i] = x[i] - X;
    }

    sort(res.begin(), res.end());
    reverse(res.begin(), res.end());
    if (N == 1) {
        cout << abs(x[0] - X) << endl;;
    }
    else {
        int ans = 0;
        for (int i = 0; i < N - 1; i++) {
            int r = res[i] % res[i + 1];
            while (r != 0) {
                res[i] = res[i + 1];
                res[i + 1] = r;
                r = res[i] % res[i + 1];
            }
            ans = res[i + 1];
        }
        cout << abs(ans) << endl;
    }
}

Measured memory_bytes: 1024
import sys
import math
from collections import deque
import bisect

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    S = SI()
    T = SI()
    if set(S) | set(T) != set(S):
        print(-1)
        exit()
    s2i = {}

    for i, s in enumerate(S):
        if s in s2i:
            s2i[s].append(i)
        else:
            s2i[s] = [i]

    now = 0
    digit = -1
    for t in T:
        target = bisect.bisect_right(s2i[t], digit)
        if target == len(s2i[t]):
            digit = s2i[t][0]
            now += 1
        else:
            digit = s2i[t][target]

    print(now * len(S) + digit + 1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9844
import sys
input = sys.stdin.readline
def main():
    N = int( input())
    X = []
    for _ in range(N):
        x, l = map( int, input().split())
        X.append((x+l, x-l))
    X.sort()
    ans = 1
    now = X[0][0]
    for i in range(1,N):
        b, a = X[i]
        if now <= a:
            now = b
            ans += 1
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 17008
def daydream():
	S = input()
	flag = False
	divide = ['dreamer', 'dream', 'eraser', 'erase']
	while True:
		if len(S) == 0:
			flag = True
			break
		for d in divide:
			if S.endswith(d):
				S = S[:-len(d)]
				break
		else:
			break
	if flag:
		print('YES')
	else:
		print('NO')

daydream()

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

int main(){
	long long a,b,c;
	cin >> a >> b >> c;
	if(c-a-b < 0){
		cout << "No" << endl;
	}else if(4*a*b < (c-a-b)*(c-a-b)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <atcoder/math>
#include <cstdio>

using namespace std;
using namespace atcoder;

int main() {
    int t;
    scanf("%d", &t);
    for (int i = 0; i < t; i++) {
        long long n, m, a, b;
        scanf("%lld %lld %lld %lld", &n, &m, &a, &b);
        printf("%lld\n", floor_sum(n, m, a, b));
    }
    return 0;
}


Measured memory_bytes: 1712