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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}


ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * x % mod;
            x = x * x % mod;
            n >>= 1;
    }
    return res;
}

void solve() {
    int N;
    cin >> N;
    vector<int> A(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    const ll mod = 998244353;
    vector<vector<ll>> dp(N + 1, vector<ll>(300 * 300 + 1));
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 300 * 300 + 1; j++) {
            dp[i + 1][j] += 2 * dp[i][j];
            dp[i + 1][j] %= mod;
            if (j + A[i] < 300 * 300 + 1) {
                dp[i + 1][j + A[i]] += dp[i][j];
                dp[i + 1][j + A[i]] %= mod;
            }
        }
    }


    vector<vector<ll>> dp2(N + 1, vector<ll>(300 * 300 + 1));
    dp2[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 300 * 300 + 1; j++) {
            dp2[i + 1][j] += dp2[i][j];
            dp2[i + 1][j] %= mod;
            if (j + A[i] < 300 * 300 + 1) {
                dp2[i + 1][j + A[i]] += dp2[i][j];
                dp2[i + 1][j + A[i]] %= mod;
            }
        }
    }


    ll ans = 0;
    for (int j = 0; j <= sum; j++) {
        if (j * 2 >= sum) {
            ans += dp[N][j];
            ans %= mod;
        }
    }

    ans *= 3;
    ans %= mod;

    if (sum % 2 == 0) {
        ans += 3 * mod - dp2[N][sum / 2] * 3;
        ans %= mod;
    }

    cout << (mod_pow(3, N, mod) + mod - ans) % mod << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

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

int main() {
	int a=0,b=0;
	cin >>a>>b;
	double a1=a, b1=b;
	printf("%d %d %.5lf\n",a/b,a%b,a1/b1);
	return 0;
}


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

using cap_type = int;
using cost_type = int;

struct edge {
    int to, rev;
    cap_type cap;
    cost_type cost;
    edge(int t, int c, int ct, int r) : to(t), rev(r), cap(c), cost(ct) {}
};
using graph = vector<vector<edge>>;

void add_edge(graph& g, int from, int to, cap_type cap, cost_type cost) {
    g[from].emplace_back(to, cap, cost, g[to].size());
    g[to].emplace_back(from, 0, -cost, g[from].size() - 1);
}

cost_type min_cost_flow(graph& g, int s, int t, cap_type f) {
    static_assert(!is_floating_point<cap_type>::value, "");
    using P = pair<cost_type, int>;
    const auto inf = numeric_limits<cost_type>::max() / 2;
    cost_type res = 0;
    vector<cost_type> h(g.size()), dist(g.size());
    vector<int> prevv(g.size()), preve(g.size());
    while(f > 0) {
        priority_queue<P, vector<P>, greater<>> que;
        fill(std::begin(dist), std::end(dist), inf);
        dist[s] = 0;
        que.emplace(dist[s], s);
        while(!que.empty()) {
            const auto cur_d = que.top().first;
            const int v = que.top().second;
            que.pop();
            if(dist[v] < cur_d) continue;
            for(int i = 0; i < (int)g[v].size(); ++i) {
                auto& e = g[v][i];
                if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
                    dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
                    prevv[e.to] = v;
                    preve[e.to] = i;
                    que.emplace(dist[e.to], e.to);
                }
            }
        }
        if(dist[t] == inf) return -1;
        for(int v = 0; v < (int)g.size(); ++v) {
            h[v] += dist[v];
        }

        auto d = f;
        for(int v = t; v != s; v = prevv[v]) {
            d = min(d, g[prevv[v]][preve[v]].cap);
        }
        f -= d;
        res += d * h[t];
        for(int v = t; v != s; v = prevv[v]) {
            auto& e = g[prevv[v]][preve[v]];
            e.cap -= d;
            g[v][e.rev].cap += d;
        }
    }
    return res;
}

int main() {
    int V, E, F; cin >> V >> E >> F;
    graph g(V);
    for(int i = 0; i < E; ++i) {
        int u, v, c, d; cin >> u >> v >> c >> d;
        add_edge(g, u, v, c , d);
    }

    cout << min_cost_flow(g, 0, V - 1, F) << endl;
}



Measured memory_bytes: 3160
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (h, w) = get!(usize, usize);
    let aa: Vec<Vec<char>> = (0..h)
        .map(|_| util::line().chars().collect::<Vec<_>>())
        .collect();

    let n = aa.iter()
        .map(|v| v.iter().filter(|&&c| c == '#').count())
        .sum::<usize>();

    let mut stack = vec![(0, 0, 1)];

    while let Some((y, x, c)) = stack.pop() {
        if y == h - 1 && x == w - 1 && c == n {
            println!("Possible");
            return;
        }

        if y < h && x < w && aa[y][x] == '#' {
            stack.push((y + 1, x, c + 1));
            stack.push((y, x + 1, c + 1));
        }
    }

    println!("Impossible");
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

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

int main(){
	int n,m;
	cin>>n>>m;

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

	cout<<sum<<endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
 int N;
 cin>>N;
 vector<int>A(N);
 vector<int>B(N);
 vector<pair<int,int>>P;
 for(int i=0;i<N;i++){
   cin>>A[i]>>B[i];
   P.push_back(make_pair(B[i],A[i]));
 }
 sort(P.begin(),P.end());
 int64_t sum=0;
for(int i=0;i<N;i++){
  sum+=P[i].second;
  if(sum>P[i].first){cout<<"No"<<endl;return 0;}
}
cout<<"Yes"<<endl;
 return 0;
}

Measured memory_bytes: 6824
import math
N = int(input())

dvs = []
pair = []
digit = []

for i in range(1, int(N**0.5)+1):
  if N % i == 0:
    pair.append([i, N/i])
    
#for i in range(len(dvs)//2+1):
#  pair.append([dvs[i], dvs[-(i+1)]])

for i in range(len(pair)):
  digitA = int(math.log10(pair[i][0])) + 1
  digitB = int(math.log10(pair[i][1])) + 1
  digit.append(max(digitA, digitB))

ans = min(digit)
print(ans)

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

	private static int[] face = new int[6];

	public static void action(char action){
		int intTemp;
		switch(action){
		case 'W':
			intTemp = face[0];
			face[0] = face[2];
			face[2] = face[5];
			face[5] = face[3];
			face[3] = intTemp;
			break;
		case 'E':
			intTemp = face[0];
			face[0] = face[3];
			face[3] = face[5];
			face[5] = face[2];
			face[2] = intTemp;
			break;
		case 'N':
			intTemp = face[0];
			face[0] = face[1];
			face[1] = face[5];
			face[5] = face[4];
			face[4] = intTemp;
			break;
		case 'S':
			intTemp = face[0];
			face[0] = face[4];
			face[4] = face[5];
			face[5] = face[1];
			face[1] = intTemp;
			break;
		default :
			break;
		}
	}
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		for(int i = 0; i < 6; i++){
			face[i] = scan.nextInt();
		}
		String strAction;
		char charAction;
		strAction = scan.next();
		for(int i = 0; i < strAction.length(); i++){
			charAction = strAction.charAt(i);
			action(charAction);
		}
		System.out.println(face[0]);
		scan.close();
	}
}

Measured memory_bytes: 17328
#include<stdio.h>
#include<stdlib.h>
int main() {
	int N;
	int man = 0, dis = 0;
	scanf("%d", &N);
	int *T = (int *)malloc(sizeof(int)*N);
	int *X = (int *)malloc(sizeof(int)*N);
	int *Y = (int *)malloc(sizeof(int)*N);
	T[0] = 0, X[0] = 0, Y[0] = 0;
	for (int i = 1; i < N+1; i++)
	{
		scanf("%d%d%d", &T[i], &X[i], &Y[i]);
	}
	for (int i = 1; i < N+1; i++)
	{
		man = abs(X[i] - X[i - 1]) + abs(Y[i] - Y[i - 1]);
		dis = T[i] - T[i - 1];
		//man = 4;
		//dis = 5;
		if (man > dis || (dis - man >= 0 && (dis - man) % 2 == 1))
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
	char ch=getchar();int f=0;
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') {f=f*10+(ch^48);ch=getchar();}
	return f;
}
long long k,a[55];
int main()
{
	cin>>k;
	if(k==0)
	cout<<"2\n0 0";
	else if(k==1)
	cout<<"3\n1 0 3";
	else if(k<=50)
	{

		cout<<k<<endl;
		for(int i=1;i<=k;i++)
  cout<<k<<" ";
	}
	else
	{
		long long x=k/50;
		for(int i=1;i<=50;i++)
		a[i]=49+x;
		k%=50;
		cout<<"50"<<endl;
		for(int i=1;i<=k;i++)
		{
			a[i]+=50;
			for(int j=1;j<=50;j++)
			{
				if(j!=i)
				{
					a[j]--;
				}
			}
		}
		for(int i=1;i<=50;i++)
		cout<<a[i]<<" ";
	}
}


Measured memory_bytes: 256
from sys import setrecursionlimit

setrecursionlimit(1000000)


def art_points(n, m, G):
    def dfs(cur, prev):
        nonlocal t
        prenum[cur] = lowest[cur] = t
        t += 1
        visited[cur] = True

        for ne in G[cur]:
            if not visited[ne]:
                parent[ne] = cur
                dfs(ne, cur)
                lowest[cur] = min(lowest[cur], lowest[ne])
            elif ne != prev:
                lowest[cur] = min(lowest[cur], prenum[ne])

    t = 1
    prenum = [0] * n
    parent = [0] * n
    lowest = [0] * n
    visited = [False] * n
    dfs(0, -1)

    ap = set()
    np = 0
    for i, p in zip(range(1, n), parent[1:]):
        if p == 0:
            np += 1
        elif prenum[p] <= lowest[i]:
            ap.add(p)
    if np > 1:
        ap.add(0)
    return ap


def main():
    n, m = [int(x) for x in input().split()]
    G = [[] for _ in range(n)]
    for _ in range(m):
        s, t = [int(x) for x in input().split()]
        G[s].append(t)
        G[t].append(s)
    for p in sorted(art_points(n, m, G)):
        print(p)


main()



Measured memory_bytes: 21664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
 
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(200010);


int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    sort(A.rbegin(), A.rend());
    mint ma=0;
    rep(i,N){
        ma += mint(A[i])*comb(N-1-i, K-1);
    }
    reverse(A.begin(), A.end());
    mint mi=0;
    rep(i,N){
        mi += mint(A[i])*comb(N-1-i, K-1);
    }
    cout << (ma-mi) << endl;
}


Measured memory_bytes: 7156
#include<bits/stdc++.h>
using namespace std;
string ss[110];
int main(){
    int n,l;
    cin >> n >>l;
    for(int i=0;i<n;i++){
        cin >> ss[i];
    }
    sort(ss,ss+n);
    for(int i=0;i<n;i++){
        cout << ss[i];
    }
    cout << endl;
    return 0;
}

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

int main() {
    int a, b;
    
    cin >> a >> b;
    if (a > b) {
        cout << "a > b" << endl;
    } else if (a < b) {
        cout << "a < b" << endl;
    } else {
        cout << "a == b" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int H,W;
  cin>>H>>W;
  int A[500][500];
  for (int i(0);i<H;i++){
    for (int j(0);j<W;j++){
      int a;
      cin>>a;
      A[i][j] = (a%2);
    }
  }
  int ans_cnt(0);
  vector<tuple<int,int,int,int>> ans;
  for (int i(0);i<H;i++){
    if (i % 2 == 0){
      for (int j(0);j<W;j++){
        if (A[i][j] == 1){
          if (j != W - 1){
            A[i][j+1]++;
            ans.push_back(make_tuple(i,j,i,j+1));
            ans_cnt++;
          }else if (i != H-1){
            A[i+1][W-1]++;
            ans.push_back(make_tuple(i,j,i+1,W-1));
            ans_cnt++;
          }
        }
      }
    }else{
      for (int j(W-1);j>=0;j--){
        if (A[i][j] == 1){
          if (j != 0){
            A[i][j-1]++;
            ans.push_back(make_tuple(i,j,i,j-1));
            ans_cnt++;
          }else if (i != H-1){
            A[i+1][0]++;
            ans.push_back(make_tuple(i,j,i+1,0));
            ans_cnt++;
          }
        }
      }
    }
  }
  cout << ans_cnt << endl;
  for (int i(0);i<ans_cnt;i++){
    cout << get<0>(ans[i]) + 1<< " " << get<1>(ans[i])+1<<" " << get<2>(ans[i])+1 <<" "<< get<3>(ans[i])+1 << endl;
  }
  return 0;
}



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

int main(){
     int m,f,l, total;
    char grade;
    while(true){
       
        cin >> m >>f >>l;
        total = m+f;
        if (m==-1 && f ==-1) break;
        if (m ==-1 || f ==-1){
            grade = 'F';
        }else if(total>=80){
            grade = 'A';
        }else if(total>=65 && total <80 ){
            grade = 'B';
        }else if(total>=50 && total <65 ){
            grade = 'C';
        }else if(total>=30 && total <50 ){
            grade = 'D';
            if(l>=50){
                grade = 'C';
            }
        }else if(total <30 ){
            grade = 'F';
        }
        cout << grade <<endl;
    }

}




Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
using namespace std;

const int N = 100;
int bit[N+10];

int sum(int i){
	int s = 0;
	while(i > 0){
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(int i, int x){
	while(i <= N){
		bit[i] += x;
		i += i & -i;
	}
}

vector<int> compress(vector<int> v){
	map<int, int> mp;
	for(int i=0;i<v.size();i++)mp[v[i]] = 0;

	int id = 1;
	for(map<int,int>::iterator it=mp.begin(); it != mp.end(); it++){
		it->second = id++;
	}

	for(int i=0;i<v.size();i++)v[i] = mp[v[i]];

	return v;
}


int main(){
	int n;
	while(cin >> n && n){
		memset(bit, 0, sizeof(bit));

		vector<int> v(n);
		for(int i=0;i<n;i++)cin >> v[i];

		v = compress(v);

		int ans = 0;
		for(int i=n-1;i>=0;i--){
			ans += sum(v[i] - 1);
			add(v[i], 1);
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var inpu1 = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var t = inpu1[0];
        var go = inpu1[1];
        var heis = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var min = 9999999999999d;
        var result = -1;
        for(var i = 0; i < num; i++)
        {
            var dif = Abs(t - heis[i] * 0.006 - go);
            if (dif < min)
            {
                min = dif;
                result = i+1;
            }
        }
        WriteLine(result);
    }
}


Measured memory_bytes: 13076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n,m;
	cin>>n>>m;
	map<ll,ll>a;
	for(ll i=0;i<n;i++){
		ll now;
		cin>>now;
		now*=-1;
		a[now]++;
	}
	for(ll i=0;i<m;i++){
		ll x,y;
		cin>>x>>y;
		y*=-1;
		a[y]+=x;
	}
	ll cnt=0,ans=0;
	for(auto itr=a.begin();itr!=a.end();itr++){
		ll num=itr->first;
		ll val=itr->second;
		if(cnt+val<=n){
			ans+=val*num;
			cnt+=val;
		}
		else{
			ans+=num*(n-cnt);
			break;
		}
	}
	cout <<-1*ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  if(n == 0){
    cout << 0 << endl;
    return 0;
  }
  stack<int> ans;
  while(n != 0){
    int na = abs(n);
    if(na % 2 == 0){
      ans.push(0);
    }else{
      ans.push(1);
      n--;
    }
    n /= -2;
  }
  while(!ans.empty()){
    cout << ans.top();
    ans.pop();
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3604
IDENTIFICATION DIVISION.
       PROGRAM-ID. ATCODER.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  INDATA PIC X(100).
       01  VARN PIC 9(03).
       01  VARM PIC 9(03).
       PROCEDURE DIVISION.
           ACCEPT INDATA

           UNSTRING INDATA
           DELIMITED BY SPACE
           INTO VARN VARM.
         IF VARN = VARM THEN
                 DISPLAY "Yes"
         ELSE
                 DISPLAY "No"
         END-IF

       STOP RUN.


Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
                    
                    
int main(){
    int H1, M1, H2, M2, K, ans;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    ans = (H2 * 60 + M2) - (H1 * 60 + M1) - K;

    cout << ans << endl;

    return 0;

            
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define maxC 10000
using namespace std;
int dp[maxC][maxC];

int lcs(string s1, string s2,int m, int n)
{
    for(int i=0; i<=m; i++){
        for(int j=0; j<=n; j++){
            if(i==0 || j==0){
                dp[i][j] = 0;
            }
            else if(s1[i-1]==s2[j-1])
                dp[i][j] = 1 + dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
        }
    }
    return dp[m][n];
}

void print_lcs(string s1, string s2, int length,int m, int n)
{
    char ans[length+1];
    ans[length] = '\0';
    int i=m, j=n;
    while(i>0 && j>0){
        if(s1[i-1]==s2[j-1]){
            ans[length-1] = s1[i-1];
            i--;
            j--;
            length--;
        }
        else if (dp[i-1][j] > dp[i][j-1])
            i--;
        else
            j--;
    }
    cout <<ans << endl;
}

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

    string s1,s2;
    cin >> s1 >> s2;

    int m = s1.length();
    int n = s2.length();
    int length = lcs(s1,s2,m,n);
    //cout<<"Length of the longest common subsequence: "<<length<<endl;
    print_lcs(s1,s2,length,m,n);
    return 0;
}




Measured memory_bytes: 50912
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    n = int(input())
    a, b = map(int, input().split())
    P = list(map(int, input().split()))
    L = [0, 0, 0]
    for i in range(n):
        if P[i] <= a:
            L[0] += 1
        elif a+1 <= P[i] <= b:
            L[1] += 1
        else:
            L[2] += 1
    print(min(L))


resolve()

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int n;
string s;
int sum[3];
int a;
int main(){
	cin >>n;
	for(int i=0;i<n;i++){
		sum[0]=sum[1]=sum[2]=0;
		for(int k=0;k<2;k++){
			cin >>s;
			a=1;
			for(int j=0;j<s.size();j++){
				if(s[j]=='m'){
					sum[k]+=a*1000;
					a=1;	
				}else if(s[j]=='c'){
					sum[k]+=a*100;
					a=1;
				}else if(s[j]=='x'){
					sum[k]+=a*10;
					a=1;
				}else if(s[j]=='i'){
					sum[k]+=a;
					a=1;
				}else if(s[j]>='2'&&s[j]<='9'){
					a=s[j]-'0';
				}
			}
		}
		sum[2]=sum[0]+sum[1];
		while(sum[2]!=0){
			if(sum[2]/1000>0){
				if(sum[2]/1000>1)cout<<sum[2]/1000;
				cout <<'m';
				sum[2]=sum[2]%1000;
			}else if(sum[2]/100>0){
				if(sum[2]/100>1)cout<<sum[2]/100;
				cout <<'c';
				sum[2]=sum[2]%100;
			}else if(sum[2]/10>0){
				if(sum[2]/10>1)cout<<sum[2]/10;
				cout <<'x';
				sum[2]=sum[2]%10;
			}else if(sum[2]>0){
				if(sum[2]>1)cout<<sum[2];
				cout <<'i';
				sum[2]=0;
			}
		}
		cout <<endl;
	}
}

Measured memory_bytes: 3096
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n = int(input())
edge = [[] for i in range(n)]
for i in range(n-1):
    x,y = map(int,input().split())
    edge[x-1].append(y-1)
    edge[y-1].append(x-1)
mod = 10**9+7
p = -1
le = -1
for i in range(n):
    if len(edge[i]) > le:
        p = i
#c[i]:iの子の集合
c = [[] for i in range(n)]
def ch(x,y):
    for e in edge[x]:
        if e == y:
            continue
        c[x].append(e)
        ch(e,x)
ch(p,-1)

#dp[i][k]:iを親とする木の場合の数.kが0ならiは黒,1なら白
dp = [[-1,-1] for i in range(n)]

#dp[x][0]を求める
def bla(x):
    if dp[x][0] != -1:
        return dp[x][0]
    res = 1
    for e in c[x]:
        res = res*whi(e)%mod
    dp[x][0] = res
    return res

#dp[x][1]を求める
def whi(x):
    if dp[x][1] != -1:
        return dp[x][1]
    res = 1
    for e in c[x]:
        res = ( (bla(e)+whi(e))%mod )*res%mod
    dp[x][1] = res
    return res
print((bla(p)+whi(p))%mod)

Measured memory_bytes: 96748
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=2010,O=1000000007;
inline int fpow(int x,int n){
	int a=1;
	for(;n;n>>=1,x=(lint)x*x%O){
		if(n&1){
			a=(lint)a*x%O;
		}
	}
	return a;
}
int f[N];
inline int Main(){
	int n=ni,k=ni;
	memset(f,0,sizeof(f));
	f[0]=1;
	for(int i=1;i<n;i++){
		for(int j=i;j>0;j--){
			f[j]=(f[j+1]+f[j-1])%O;
		}
		f[0]=f[1];
	}
	return (lint)f[n-k]*fpow(2,max(n-k-1,0))%O;
}
int main(){
	printf("%d\n",Main());
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    final int N=sc.nextInt();
    int[] a={1,2,3,4,5,6,7,8,9};
    int counter=0;
    boolean flg=false;
    for(int i=counter;i<9;i++){
      for(int j=0;j<9;j++){
        if(a[i]*a[j]==N){
          flg=true;
        }
      }
    }
    if(flg){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22740
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define INF 1e9
using ll = std::int64_t;

template <class T>bool chmax(T &a, const T &b);
template <class T>bool chmin(T &a, const T &b);
//最大公約数
std::int64_t gcd(std::int64_t a, std::int64_t b);
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb);
//ラングレス圧縮
std::vector<std::pair<char, std::int64_t>> rle(std::string str);
//素数判定
bool is_prime(std::int64_t n);
// 約数の列挙
std::vector<std::int64_t> divisor(std::int64_t n);
// 素因数分解
std::map<std::int64_t,std::int64_t> prime_factor(std::int64_t n);

//10^9 + 7
#define yojo 1000000007
#define MAX_NUM 200001

void Main()
{
  int n;
  string s;
  cin >> n;
  cin >> s;

  vector<pair<char, int64_t>> tmp = rle(s);

  std::cout << tmp.size() << std::endl;

  return;
}

int main()
{
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

template <class T> bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}

template <class T> bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return true;
  }
  return false;
}

//最大公約数
std::int64_t gcd(std::int64_t a, std::int64_t b)
{
  // a >= b && b != 0
  std::int64_t c;
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}

//最大公約数安全版
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb)
{
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0)
  {
    return -1;
  }
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}

//ラングレス圧縮
std::vector<std::pair<char, std::int64_t>> rle(std::string str)
{
  std::vector<std::pair<char, std::int64_t>> data;
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++)
  {
    if (i == str.size())
    {
      data.push_back(make_pair(str[i - 1], count));
      break;
    }
    else if (now != str[i])
    {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return data;
}

//素数判定
bool is_prime(std::int64_t n)
{
  for (std::int64_t i = 0; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      return false;
    }
  }
  
  return n != 1;
}

//約数の列挙
std::vector<std::int64_t> divisor(std::int64_t n)
{
  std::vector<std::int64_t> res;
  for (int i = 0; i < n; i++)
  {
    if(n % i == 0){
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  return res;
}

// 素因数分解
std::map<std::int64_t, std::int64_t> prime_factor(std::int64_t n)
{
  std::map<std::int64_t, std::int64_t> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      ++res[i];
      n /= i;
    }
  }

  if (n != 1)
  {
    res[n] = 1;
  }
  
  return res;
}

Measured memory_bytes: 2628
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;

int main(void) {
	int N, R;
	while (cin >> N >> R, N) {
		if (N == 1){
			cout << 1 << endl;
			continue;
		}
		
		stack<int> yama;
		for (int i = 1; i <= N; i++) {
			yama.push(i);
		}

		for (int i = 0; i < R; i++) {
			stack<int> p;
			stack<int> c;
			int begin, size;
			cin >> begin >> size;

			for (int j = 0; j < begin - 1; j++) {
				p.push( yama.top() );
				yama.pop();
			}
			for (int j = 0; j < size; j++) {
				c.push ( yama.top() );
				yama.pop();
			}

			while (!p.empty()) {
				yama.push( p.top() );
				p.pop();
			}
			while (!c.empty()) {
				yama.push( c.top() );
				c.pop();
			}
		}

		cout << yama.top() << endl;
	}

	return 0;
}

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

int main(void){
  int n, T;
  cin >> n >> T;
  int t[n];
  for(int i = 0; i < n; i++) cin >> t[i];
  long long ans = 0;
  for(int i = 0; i < n - 1; i++){
    ans += min(T, (t[i + 1] - t[i]));
  }
  ans += T;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
using namespace std;
 
int main(){
  char IN[4];
  for(int i=0;i!=4;i++){
  	scanf("%s", &IN[i]);
  }
  if(IN[0]==IN[1]&&IN[1]==IN[2]){
  	printf("%s\n", "Yes");
  }else if(IN[1]==IN[2]&&IN[2]==IN[3]){
  	printf("%s\n", "Yes");
  }else{
  	printf("%s\n", "No");
  }
return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  vector<int>A(N);
  bool jud = true;
  for (int i=0; i<N; i++) cin >> A[i];
  for (int i=0; i<N; i++){
    if (A[i]%2==0){
      if (A[i]%3==0 || A[i]%5==0){   
      }
      else{
        jud = false;
      }
    }
  }
  if (jud == false){
    cout << "DENIED" << endl;
  }
  else{
    cout << "APPROVED" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;

typedef pair <int, int> pii;

int main()
{

	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//long long n, A[1000000000];
	//ll n, m, q;
	ll x[1000];
	cin >> a;
	cin >> b;
	for (int i = 0; i < a; i++)
	{
		cin >> x[i];
	}
	for (int i = 0; i < a; i++)
	{
		if (x[i]<b-x[i])
		{
			c += 2 * x[i];
		}
		else
		{
			c += 2 * (b-x[i]);

		}
	}
	
	cout << c << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//accumulate(x, x + a, 0);
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}



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

int main()
{
    int H, W;
    cin >> H >> W;

    if ((W == 1) || (H == 1))
    {
        cout << 1;
        return 0;
    }

    long ans = 0;
    for (int i = 0; i < H; i++)
    {
        if (i % 2 == 0)
        {
            ans += (W + 1) / 2;
        }
        else
        {
            ans += W / 2;
        }
    }

    cout << ans;
}


Measured memory_bytes: 256
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;lli p=1ll,r=0ll,res=0ll;
    cin>>s;
    int n=s.length();
    int f[2019]={0};
    f[0]=1;
    for(int i=n-1;i>=0;--i)
    {
        r=(r+(s[i]-'0')*p)%2019;
        p=(p*10)%2019;
        res+=f[r]++;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
int main(void){
 
    int A,B,C,X,Y;
    
    cin >> A >> B >> C >> X >> Y;
    
    int ans = 0;


    if( A + B <= 2*C){ //ABピザで買うと得しない場合。
        
        ans = A * X + B * Y;
        
    }else{ //ABピザで買うと得する場合
    
        if( X > Y ){ //Aピザの方がたくさん必要。
            
            if( A > 2*C){
                
                ans = C * 2 * Y + C * 2 * (X - Y);
                
            }else{
               
                ans = C * 2 * Y + A  * (X - Y);
                
            }
            
        }else{
    
            if( B  > 2*C){
                
                ans = C * 2 * X + C * 2 * (Y - X);
                
            }else{
               
                ans = C * 2 * X + B  * (Y - X);
                
            }
    
        }
    }
   
   cout << ans << endl;
    
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		sc.close();

if (a <= 999) {
System.out.println("ABC");
} else {
System.out.println("ABD");
}

}
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

ll myPow(ll n)
{
    ll ret = 1;
    rep(i, n) ret *= 2;
    return ret;
}

void Main()
{
    ll n = in(), m = in();
    ll sum = 100 * (n - m) + 1900 * m;
    ll ans = sum * myPow(m);
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
#define trace3(x, y, z) cerr << #x << ": " << x << ", " << #y < ": " << y << ", " << #z << ": " << z << endl;
#define all(v) v.begin(), v.end()

bool is_pal(string &s, int l, int r) {
	while(l < r) {
		if(s[l] != s[r]) {
			return 0;
		}
		l++;
		r--;
	}
	return 1;
}

int main() {
	string s;
	cin >> s;
	int n = s.length();
	s.insert(s.begin(), 1, '@');
	if(is_pal(s, 1, n) && is_pal(s, 1, (n - 1) / 2) && is_pal(s, (n + 3) / 2, n)) {
		cout << "Yes";
	}
	else cout << "No";
	cout << endl;
}

Measured memory_bytes: 256
n = int(input())
red = [list(map(int,input().split())) for _ in range(n)]
blue = [list(map(int,input().split())) for _ in range(n)]

red_s = sorted(red,key=lambda x:x[1],reverse=True)
blue_s = sorted(blue)

pair = 0
for bx,by in blue_s:
  for i,(rx,ry) in enumerate(red_s):    
    if rx<bx and ry<by:
      pair +=1
      red_s.pop(i)
      break

print(pair)      

Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

using namespace std;


int main() {
	int N;
	cin >> N;
	int Seven = 0;
	while (Seven <= N) {
		if ((N - Seven) % 4 == 0) {
			cout << "Yes" << endl;
			return 0;
		}
		Seven += 7;
	}
	cout << "No" << endl;
	return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

VLL G[100000];
int t_cost[100000];
int a_cost[100000];

void t_dfs(int now, int cost) {
    t_cost[now] = cost;
    REP(i, G[now].size()) {
        if(t_cost[G[now][i]] == -1 && cost < a_cost[G[now][i]]) {
            t_dfs(G[now][i], cost+1);
        }
    }
}

void a_dfs(int now, int cost) {
    a_cost[now] = cost;
    REP(i, G[now].size()) {
        if(a_cost[G[now][i]] == -1) {
            a_dfs(G[now][i], cost+1);
        }
    }
}

void solve(long long N, long long u, long long v, std::vector<long long> A, std::vector<long long> B){
    fill(t_cost, t_cost+N, -1);
    fill(a_cost, a_cost+N, -1);

    REP(i, N-1) {
        G[A[i]-1].PB(B[i]-1);
        G[B[i]-1].PB(A[i]-1);
    }

    a_dfs(v-1, 0);
    t_dfs(u-1, 0);

    int max_cost = -INF;
    REP(i, N) {
        if(t_cost[i] != -1 && max_cost < a_cost[i]) {
            max_cost = a_cost[i];
        }
    }

    cout << (max_cost - 1) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long u;
    scanf("%lld",&u);
    long long v;
    scanf("%lld",&v);
    std::vector<long long> A(N-1);
    std::vector<long long> B(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, u, v, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 12032
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Ld r;
    cin >> r;
    cout << r * 2 * pi << endl;

    return 0;
}


Measured memory_bytes: 3812
import sys
n = int(input())
li = [[0,0,0]]
for _ in range(n):
    li.append(list(map(int,input().split())))
# print(li) [[3, 1, 2], [6, 1, 1]]
for i,l in enumerate(li):
    if i == 0:
        continue
    bef = li[i-1]
    diff = l[1]+l[2]-bef[1]-bef[2]
    if diff <= l[0]-bef[0] and  (diff - (l[0]-bef[0]))%2 == 0:
        continue
    else:
        print('No')
        sys.exit()
else:
    print('Yes')

Measured memory_bytes: 60376
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		int x = scanner.nextInt();
		
		int y = scanner.nextInt();
		
		System.out.print(x * y);
		System.out.print(" ");
		System.out.println(2 * x + 2 * y);
		
		scanner.close();
		
	}

}


Measured memory_bytes: 26160
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  ll n,k,x,y,sum=0;
  cin>>n>>k>>x>>y;
  if(n>k){
    rep(i,0,k){
      sum+=x;
    }
    rep(i,0,n-k){
      sum+=y;
    }
  }else{
    rep(i,0,n){
      sum+=x;
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define REP(i, start, end) for (int(i) = (start); (i) < (end); (i)++)

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

  int sum = 0, min = 1001, tmp;
  REP(i, 0, N) {
    cin >> tmp;
    sum += tmp;
    if (min > tmp) min = tmp;
  }

  cout << (X - sum) / min + N;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) ((x).begin()),((x).end())
#define int ll
using pii = pair <int, int>;
#define INF 0x7f7f7f7f7f7f7f7f
const bool debug = false;

int32_t main()
{
    int n, m;
    cin >> n >> m;
    cout << (n*(n-1)/2)+(m*(m-1)/2);
}

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

int main(){
    int k,x; cin >>k >> x;
    int g = k*500;
    if(g>=x) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
//==========================================
// ABC141c
//
// 2019/09/15
//==========================================

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main(int argc, char* argv[])
{
  long n, k, q;
  cin >> n >> k >> q;
  vector<long> a(n);
  for(long i=0; i<q; ++i) 
  {
    long temp;
    cin >> temp;
    a[temp-1]++;
  }

  for(long i=0; i<n; ++i)
  {
    if(k - (q - a[i]) > 0) cout << "Yes" << endl;
    else cout <<"No" << endl;
  }


  return 0;
}

Measured memory_bytes: 1408