akhauriyash/Code-Regression huggingface dataset:
void main()
{
    long[] tmp = rdRow;
    long n = tmp[0], k = tmp[1];
    long[] a = rdRow;

    long g = a[0];
    long amax = a[0];
    foreach (x; a)
    {
        if (x == k)
        {
            "POSSIBLE".writeln;
            return;
        }
        g = gcd(g, x);
        amax = max(amax, x);
    }

    bool ok = k <= amax;
    if (ok) ok = (amax - k) % g == 0;

    writeln(ok ? "POSSIBLE" : "IMPOSSIBLE");
}

T rdElem(T = long)()
{
    //import std.stdio : readln;
    //import std.string : chomp;
    //import std.conv : to;

    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;

dchar[] rdDchar()
{
    //import std.conv : to;

    return rdStr.to!(dchar[]);
}

T[] rdRow(T = long)()
{
    //import std.stdio : readln;
    //import std.array : split;
    //import std.conv : to;

    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    //import std.stdio : write, writeln;

    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 4300
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

int main(){
    while(1){
        string s;
        getline(cin, s);
        if(s == ".") return 0;

        stack<char> st;
        int n = s.size();

        bool valid = true;
        for(int i=0; i<n; i++){
            if(s[i] == '(' || s[i] == '['){
                st.emplace(s[i]);
            }

            if(s[i] == ')'){
                if(st.size() && st.top() == '('){
                    st.pop();
                }
                else{
                    valid = false;
                }
            }
            else if(s[i] == ']'){
                if(st.size() && st.top() == '['){
                    st.pop();
                }
                else{
                    valid = false;
                }
            }
        }

        if(valid && !st.size()){
            cout << "yes" << endl;
        }
        else{
            cout << "no" << endl;
        }
    }
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
 
#define reset(X) memset(X, 0, sizeof(X))
//#define int long long
typedef long long ll;
#define pb push_back
#define se second
#define fi first
#define endl '\n'
#define all(X) X.begin(),X.end()
 
const int INF=2e18;
const int mod=1e9+7;
const int mod2=998244353;
 
 
 
#define readn(a) int a;cin>>a;
#define readv(a,n) vector<int> a(n);for(int i=0;i<n;i++)cin>>a[i];
#define reada(a,n,m) int a[n][m];for(int i=0;i<n;i++)for(int j=0;j<m;j++) cin>>a[i][j];
 
 
 
typedef vector<int> vi;
typedef pair<int, int> pii;
int pow(int a, int b, int mod)
{
    int prod=1;
    int mult=a;
    while(b!=0)
    {
        if(b%2)
        {
            prod*=mult;
            prod%=mod;
        }
        mult*=mult;
        mult%=mod;
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int mod)
{
    return pow(q, mod-2, mod);
}


const int MAXN=2e3+10;
bitset<MAXN*MAXN> arr[2] ;
signed main()
{
 
  
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE 
    if (fopen("INPUT.txt", "r")) {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
//---------------------------------------------------------------------------------------------------
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(all(a));
    arr[0].set(0);
    int prev=0, next=1;
    for(int i=1;i<=n;i++)
    {
        arr[next]=arr[prev]|(arr[prev]<<(a[i-1]));
        swap(prev, next);
    }
    int k=accumulate(all(a), (int)0);
    
    pair<int, int> best={INF, -1};
    for(int i=(k+1)/2;i<MAXN*MAXN;i++)
    {
        if(arr[prev][i]!=0)
        best=min(best, {i-k/2, i});
    }
    cout<<best.se<<endl;
}

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

using namespace std;

#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,n) FOR(i,0,n)

int main() {
	string str;
	cin >> str;
	
	cout << str.substr(0, 4) << " " << str.substr(4, 8) << endl;
	return 0;
}

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    lli a,b,c,d;
    lli x1,y1,x2,y2;
    cin2(x1,y1);
    cin2(x2,y2);
    if (x1 < x2) {
        a = x1;
        b = y1;
        c = x2;
        d = y2;
    }
    else if (x1 > x2){
        a = x2;
        b = y2;
        c = x1;
        d = y1;
    }
    else {
        if (y1 >= y2) {
            a = x1;
            b = y1;
            c = x2;
            d = y2;
        }
        else {
            a = x2;
            b = y2;
            c = x1;
            d = y1;
        }

    }

    if (b <= c) {
        cout << 0 << endl;
    }
    else if (b <= d) {
        cout << b - c << endl;
    }
    else {
        cout << d - c << endl;
    }

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define N 317
using namespace std;

//?????±?????????317
int a[N];//?????±????????????
int b[100489];//????????????
signed main(){
    int K=1;
    K<<=31;
    K--;
    fill(a,a+N,K);
    fill(b,b+100489,K);
    int c,d;scanf("%d%d",&c,&d);
    for(int e=0;e<d;e++){
	int f,g,h;scanf("%d%d%d",&f,&g,&h);
	if(f==0){
	    b[g]=h;
	    int MIN=INT_MAX;
	    for(int i=g/N*N;i<(g/N+1)*N;i++){
		MIN=min(MIN,b[i]);
		}
	    a[g/N]=MIN;	
	    }
	else{
	    h++;
	    int MIN=INT_MAX;
	    //????????????????????¨???
	    for(int i=g;i<h&&i<(g/N+1)*N;i++){MIN=min(MIN,b[i]);}
	    //????????????????????¨???
	    for(int i=h/N*N;i<h;i++){
		if(i<g)continue;
		MIN=min(MIN,b[i]);
		}
	    //?????±??????
	    for(int i=g/N+1;i<h/N;i++)MIN=min(MIN,a[i]);
	    printf("%d\n",MIN);
	    }    
	}
    }

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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int A,P;
cin>>A>>P;
cout<<int((A*3+P)/2)<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
import math

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()	
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n, k = rli()
	A = list(math.log(x) for x in rli())
	prev, score = 1, 1
	for i, a in enumerate(A):
		prev = score
		score += a 
		if i >= k:
			score -= A[i-k]
			if score > prev:
				print("Yes")
			else:
				print("No")
	stdout.close()

if __name__ == "__main__":
	main()

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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector <int> x(n);
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    int ans=1e9;
    for(int p=1;p<=100;p++){
        int hp=0;
        for(int i=0;i<n;i++){
            hp+=pow(x[i]-p, 2);
        }
        ans=min(ans, hp);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <vector>


using namespace std;

int N, A, B, C;
vector<int> l;

int dfs(int cur, int a, int b, int c) {
	if (cur == N) {
		if (a == 0 || b == 0 || c == 0) return numeric_limits<int>::max()/16;
		else return abs(a - A) + abs(b - B) + abs(c - C) - 30;
	}
	int ret0, ret1, ret2, ret3;
	ret0 = dfs(cur + 1, a, b, c);
	ret1 = dfs(cur + 1, a + l[cur], b, c) + 10;
	ret2 = dfs(cur + 1, a, b + l[cur], c) + 10;
	ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10;

	return min({ ret0, ret1, ret2, ret3 });
}

int main() {
	int i;
	cin >> N >> A >> B >> C;

	for (i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		l.push_back(tmp);
	}

	cout << dfs(0, 0, 0, 0) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;int a[500001],i,j,n;
main(){
	for(i=2;i<500001;i++){
		if(i%7==1||i%7==6){
			for(j=2;j<=sqrt(i);j++){
				if(a[j]==1&&i%j==0){
					a[i]=0;goto E;
				}
			}
			a[i]=1;
		E:;
		} 
	}
	while(true){
		cin>>n;
		if(n<2){break;}printf("%d:",n);
		for(i=2;i<=n;i++){
			if(a[i]==1&&n%i==0){printf(" %d", i);}
		}
		cout<<endl;
	}
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    string s;
    cin >> s;
    deque<int> dq;
    rep (i, s.size()) {
        if (s[i] == 'B' && !dq.empty()) {
            dq.pop_back();
        }
        if (s[i] == '0') dq.push_back(0);
        else if (s[i] == '1') dq.push_back(1);
    }
    while (!dq.empty()) {
        int x = dq.front();
        cout << x;
        dq.pop_front();
    }
    cout << endl;
    
    return 0;
}



Measured memory_bytes: 256
def solve(Mi,i):
	if Mi == 0: return True
	if i < n and A[i] <= Mi <= sum(A[i:]):
		r1 = solve(Mi-A[i],i+1)
		if r1: return r1
		r2 = solve(Mi,i+1)
		if r2: return r2
n = input()
A = sorted(map(int,raw_input().split()))
q = input()
M = map(int,raw_input().split())
for Mi in M:
	print "yes" if solve(Mi,0) else "no"

Measured memory_bytes: 4232
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  ll x;
  cin >> n >> x;
  vector<ll> a(n);
  REP(i,n) cin >> a[i];
  ll cnt = 0;
  if(a[0]>x){
    cnt = a[0] - x;
    a[0] = x;
  }
  REP(i,n-1){
    if(a[i]+a[i+1]>x){
      ll sub = a[i]+a[i+1]-x;
      cnt += sub;
      a[i+1] -= sub;
    }
  }
  cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N,A,B;
    cin >> N >> A >> B;
    ll ans = 0;
    ans += N / (A + B) * A;
    N %= (A + B);
    ans += min(A, N);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	

using namespace std;

int main() {
	long long N, M;
	cin >> N >> M;
	long long maxL = 0;
	long long minR = 10000000;
	for (long long i = 0; i < M; ++i) {
		long long l, r;
		cin >> l >> r;
		maxL = max(maxL, l);
		minR = min(minR, r);
	}
	cout << max(minR - maxL + 1, 0ll) << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <limits>
#include <set>
#include <map>
 
int main()
{
    int n{}, k{};
    std::cin >> n >> k;
    std::vector<int> nums(n + 1);
    int64_t total{};
    for (int64_t i = k; i <= n + 1; i++) {
        const auto min = i * (i - 1) / 2;
        const auto max = min + (n - i + 1) * i;
        total = (total + max - min + 1) % 1000000007LL; 
    }
    std::cout << total << std::endl;
    return 0;
}

Measured memory_bytes: 4048
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define F first
#define S
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  ll x;
  cin>>x;
  ll ans=x/11;
  x=x%11;
  ans*=2;
  if(x>=6){
    ans++;
    x-=6;
  }
  if(x)
    ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(ll x, ll y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

int main()
{
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll ans = B-A+1;
    ll cdiv = B/C - (A-1)/C;
    ll ddiv = B/D - (A-1)/D;
    ll cddiv = B/lcm(C, D) - (A-1)/lcm(C, D);
    ans -= cdiv + ddiv - cddiv; 

    cout << ans << endl;
}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int N, M;
  cin >> N >> M;
  map<int, int> ma;
  rep(i, N) {
    int a; cin >> a;
    ma[a]++;
  }
  rep(i, M) {
    int b, c; cin >> b >> c;
    vector<int> zeros;
    each(m, ma) {
      if (m.first >= c) break;
      int cnt = min(m.second, b);
      m.second -= cnt;
      b -= cnt;
      ma[c] += cnt;
      if (m.second == 0) zeros.push_back(m.first);
      if (b == 0) break;
    }
    each(v, zeros) {
      ma.erase(v);
    }
  }
  i64 ans = 0;
  each(v, ma) {
    ans += (i64) v.first * v.second;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 5632
from collections import Counter as ct
N=int(input())
Q=[int(i) for i in input().split()]
Qdict=ct(Q)
M=int(input())
R=[int(i) for i in input().split()]
Rdict=ct(R)
YES=all([Qdict[d]>=num for d,num in Rdict.items()])
print("NYOE S"[YES::2])

Measured memory_bytes: 56920
#define R for(i=0;i++<n;)
#define S(s) int s;scanf("%d",&s);
#define P(x) R printf("%d%c",x[i-1],i<n?32:10);
main(i){S(n)int a[n],b[n];R a[i-1]=b[n-i]=i*n;R{S(p)a[--p]+=i,b[p]+=i;}P(a)P(b)}

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

int main() {
	string w;
	bool check;
	int cnt[26] = { };
	cin >> w;
	for (auto x : w) {
		cnt[x % 26]++;
	}
	for (int i = 0; i < 26; i++) {
		if (cnt[i] % 2) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pr(a) cout << (a) << endl
typedef long long ll;
typedef pair<int,int> P;
const int MAX=100001;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int ord[MAX], low[MAX];
vector<int> G[MAX];
void dfs(int u, int pre, int &c, vector<int> &A){
  ord[u] = low[u] = c++;

  int deg=0;
  bool ok=false;
  for(int i=0;i<G[u].size();i++){
    int v = G[u][i];
    if(v != pre){
      if(ord[v] == -1){
        dfs(v,u,c,A);
        low[u] = min(low[u],low[v]);
        deg++;
        if(ord[u] <= low[v]) ok = true;
      }
      else low[u] = min(low[u],ord[v]);
    }
  }
  if(pre == -1 && deg >= 2 || pre != -1 && ok) A.push_back(u);
}

void articulation(int n, vector<int> &A){
  A.clear();
  int c = 0;
  fill(ord,ord+n,-1);
  for(int i=0;i<n;i++) if(ord[i] == -1) dfs(i,-1,c,A);
}

int main() {
  int n,m;
  cin >> n >> m;
  rep(i,m) {
    int x,y;
    cin >> x >> y;
    G[x].pb(y);
    G[y].pb(x);
  }
  vector<int> ans;
  articulation(n,ans);
  sort(all(ans));
  rep(i,ans.size()) pr(ans[i]);
  return 0;
}


Measured memory_bytes: 5068
local s = io.stdin:read("*l")
local t = {}

for i=1,#s do
	if s:sub(i,i) ~= "B" then
		table.insert(t, s:sub(i,i))
	elseif #t ~= 0 then
		table.remove(t)
	end
end

print(table.concat(t))

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

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

    int k,x;
    cin >> k >> x;

    if(k * 500 >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

int n,m,k;
vector<int> vis;
void dfs(Graph &G,int x,int y){
    vis[x]=y;
    for(auto v:G[x]){
        if(vis[v]!=-1)continue;
        dfs(G,v,y);
    }
}

int main(){
    cin>>n>>m>>k;
    Graph g(n);
    //O(m)
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    Graph h(n);
    //O(k)
    rep(i,k){
        int c,d;
        cin>>c>>d;
        c--;d--;
        h[c].push_back(d);
        h[d].push_back(c);
    }
    //O(n)
    vis.assign(n,-1);
    int j=0;
    rep(i,n){
        if(vis[i]!=-1)continue;
        dfs(g,i,j);
        ++j;
    }
    //O(n)
    vector<int> cnt(n);
    rep(i,n){
        cnt[vis[i]]++;
    }
    vector<int> NoConnect(n,0);
    rep(i,n){
        if(h[i].size()==0)continue;
        for(auto v:h[i]){
            if(vis[i]!=vis[v]){
                NoConnect[v]++;
            }
        }
    }
    rep(i,n){
        int ans=cnt[vis[i]]-1;
        ans=ans-g[i].size()-h[i].size()+NoConnect[i];
        cout<<ans<<endl;
    }

    
}

Measured memory_bytes: 15744
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

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


int main(){
		ll n;
		ll k;
		cin >> n >> k;
		vector<ll>a(n);
		rep(i, n) {
			cin >> a[i];
		}
		rep(i, n - k) {
			if (a[i] < a[i + k]) {
				cout << "Yes"<<endl;
			}
			else {
				cout << "No"<<endl;
			}
		}
	
}
	



Measured memory_bytes: 4836
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    
    vector<ll> sum(N + 1, 0);
    rep(i, N) sum[i + 1] = sum[i] + A[i];
    
    ll ans = INF;
    for (int y = 2; y <= N - 2; ++y) {
        vector<int> x(2, 0), z(2, 0);
        x[1] = (int)(upper_bound(ALL(sum), sum[y] / 2) - sum.begin());
        if (x[1] == 1) x[0] = x[1];
        else x[0] = x[1] - 1;
        z[1] = (int)(upper_bound(ALL(sum), sum[y] + (sum[N] - sum[y]) / 2) - sum.begin());
        if (z[1] == y + 1) z[0] = z[1];
        else z[0] = z[1] - 1;
        rep(i, 2) rep(j, 2) {
            ll MAX = max({sum[x[i]] - sum[0], sum[y] - sum[x[i]], sum[z[j]] - sum[y], sum[N] - sum[z[j]]});
            ll MIN = min({sum[x[i]] - sum[0], sum[y] - sum[x[i]], sum[z[j]] - sum[y], sum[N] - sum[z[j]]});
            ans = min(ans, MAX - MIN);
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 6408
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;

    cin >> n;

    vector<int> a(n), as(n);

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

    sort(as.begin(), as.end());

    for (int i = 0; i < n; i++)
    {
        if (*as.rbegin() == a[i])
        {
            cout << as[n - 2] << endl;
        }
        else
        {
            cout << *as.rbegin() << endl;
        }
    }
}

Measured memory_bytes: 3200
import java.util.Scanner;
 public class Main {
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        int a = sc.nextInt();
        int b = sc.nextInt();
 
        String relation;
 
        if(a > b){
            relation = ">";
        }else if(a < b){
            relation = "<";
        }else{
            relation = "==";
        }
        System.out.printf("a %s b\n", relation);
    }
}


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

using namespace std;

bool check_dim(int D, int L, int R, const string &T, const string &S, int s) {
    const int N = T.size();
    // keep current winning interval for aoki
    int x = 1, y = D;
    // process moves in reverse
    for (int i = N - 1; x <= y && i >= 0; --i) {
        if (T[i] == L) { // aoki can make the interval larger
            y = min(D, y + 1);
        } else if (T[i] == R) {
            x = max(1, x - 1);
        }
        if (S[i] == L) { // takashi can make it smaller
            ++x;
        } else if (S[i] == R) {
            --y;
        }
    }
    return x <= s && s <= y;
}

int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    int H, W, N, sr, sc;
    cin >> H >> W >> N >> sr >> sc;
    string S, T;
    cin >> S >> T;

    constexpr int L = 0, R = 1, U = 2, D = 3;
    map<char, int> m{{'L', L}, {'R', R}, {'U', U}, {'D', D}};
    for (int i = 0; i < N; ++i) {
        S[i] = m[S[i]];
        T[i] = m[T[i]];
    }
    
    if (!check_dim(W, L, R, T, S, sc)
        || !check_dim(H, U, D, T, S, sr)) {
        cout << "NO\n";
        return 0;
    }    
    cout << "YES\n";

    return 0;
}

Measured memory_bytes: 920
#include<bits/stdc++.h>
#define fr(i1,m) for(int i1=0;i1<m;i1++)
using namespace std;

int main()
{
  string a,b,c;
  while(cin>>a>>b>>c)
  {
      long l,t,r;
      l=a.size();
      t=b.size();
      r=c.size();
      if(a[l-1]==b[0]&&b[t-1]==c[0])
      {
          cout<<"YES\n";
      }
      else
        cout<<"NO\n";
  }
    return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    for(int i = 1; i < n; i++){
        int cnt = 0;
        for(char c = 'a'; c <= 'z'; c++){
            bool r = false, l = false;
            for(int j = 0; j < i; j++){
                if(s[j] == c) r = true;
            }
            for(int j = i; j < n; j++){
                if(s[j] == c) l = true;
            }
            if(r && l) cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int c[100001];
ll d[100001];
int w = 41;
void calc(ll x){
	for(int i = 1; i <= w; i++){
		if(x % 2 == 1)c[i] += 1;
		x /= 2;
	}
}

int main(){
	ll n, k;
	cin>>n>>k;
	vector<ll> vec(n, 0);
	for(int i = 0; i < n; ++i){
		cin>>vec[i];
	}
	for(auto x : vec)calc(x);
	for(int i = 1; i <= w; ++i){
		int pos = c[i];
		int neg = n - c[i];
		if(neg > pos)d[i] = 1;
		else d[i] = 0;
	}
	ll ans = 0;
	for(ll i = w; i >= 1; i--){
		ll cnt = (d[i] << (i - 1));
		if(ans + cnt <= k)ans = ans + cnt;
	}
	ll sum = 0;
	for(int i = 0; i < n; ++i)sum += (ans ^ vec[i]);
	cout<<sum<<endl;	
	return 0;
}



Measured memory_bytes: 1024
import numpy as np
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

#print(A)
#print(B)
#print(C)
#print(sum(B))

testA = A + [0]
testB = [0] + A
#print(testA)
#print(testB)
#print((np.array(testA) - np.array(testB)))
#print(list(((np.array(testA) - np.array(testB)) == 1))[1:])
#print(np.array(A)[((np.array(testA) - np.array(testB)) == 1)[1:]])
#print(np.array(C)[np.array(A)[((np.array(testA) - np.array(testB)) == 1)[1:]]-1])

print(sum(B) + sum(np.array(C)[np.array(A)[((np.array(testA) - np.array(testB)) == 1)[1:]]-1]))

Measured memory_bytes: 12508
#include<bits/stdc++.h>
#define itn int
#define REP(i,n) for(int i=0;i<(n);i++)
#define IREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(n);i++)
#define REPEACH(itr,k) for(auto&& itr : k)
#define MOD 1000000007

using namespace std;
typedef long long ll;

const ll INF = 1LL<<60;
typedef pair<double,int> P;

vector<bool> memo(50,false);
vector<vector<int>> v(5000,vector<int>());
bool soudayo[50][50];
void saiki(int i){
  memo[i]=true;
  REP(j,v[i].size()){
    if(!memo[v[i][j]]&&soudayo[i][v[i][j]]==false){
      saiki(v[i][j]);
    }
  }
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  REP(i,m){
    cin >> a[i] >> b[i];
    a[i]--;b[i]--;
    v[a[i]].push_back(b[i]);
    v[b[i]].push_back(a[i]);
  }
  int ans=0;
  REP(i,m){
    soudayo[a[i]][b[i]]=true;
    soudayo[b[i]][a[i]]=true;
    REP(j,n){
      memo[j]=false;
    }
    saiki(0);
    bool bridge=false;
    REP(j,n){
      if(memo[j]==false){
        bridge=true;
        continue;
      }
    }
    if(bridge==true){
      ans++;
    }
    soudayo[a[i]][b[i]]=false;
    soudayo[b[i]][a[i]]=false;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
int main(void){
  int a,b;

  scanf("%d %d\n",&a,&b);
  int d = a / b;
  int r = a % b;
  double f = (double)a / b;

  printf("%d %d %f\n",d,r,f);
  return 0;
}


Measured memory_bytes: 2124
#include <iostream>
using namespace std;
int main() {
    int n, k; cin >> n >> k;
    long long ans = 0;
    for (int a = 1; a <= n; a++) {
        int b = ((k - a)% k + k)%k;
        if (2 * b % k == 0) {
            ans += (long long)((a+n)/k - a/k) * ((a+n)/k - a/k);
        }
    }
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

const int NN = 510;
int n, m, q;
int sum[NN][NN];

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

    cin >> n >> m >> q;
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        sum[l][r]++;
    }
    for (int i = 1; i < NN; i++) {
        int pf = 0;
        for (int j = 1; j < NN; j++) {
            pf += sum[i][j];
            sum[i][j] = pf + sum[i-1][j];
        }
    }

    for (int i = 0; i < q; i++) {
        int a, b;
        cin >> a >> b;
        cout << sum[NN-1][b] - sum[a-1][b] << '\n';
    }
    return 0;
}

Measured memory_bytes: 1920
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a,b=mi()
if b%2==1:
  print("No")
  sys.exit()
if 2*a<=b<=4*a:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9620
#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 (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007
#define INF 1000000000
#define EPS 0.0000000001
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    string s;
    cin>>s;
    int mmm=s[5]-'0';
    mmm=mmm*10+(s[6]-'0');
    int ddd=s[8]-'0';
    ddd=ddd*10+(s[9]-'0');
    if(mmm<=4&&ddd<=30){
        cout<<"Heisei";
    }
    else{
        cout<<"TBD";
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  int X;
  cin >> X;
  if (X >= 30) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>

using namespace std;

int dp[4001][4001];

void solve()
{
	string a, b;
	while (cin >> a)
	{
		cin >> b;
		memset(dp, 0, sizeof(dp));
		int ans = 0;
		for (int i = 0; i < a.size(); ++i)
		{
			for (int j = 0; j < b.size(); ++j)
			{
				if (a[i] == b[j])
				{
					dp[i + 1][j + 1] = dp[i][j] + 1;
					ans = max(ans, dp[i + 1][j + 1]);
				}
				else
				{
					dp[i + 1][j + 1] = 0;
				}
			}
		}
		cout << ans << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 63748
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
//-0.4620981203755741
int main(){
    int a,b,m;
    std::cin >> a>>b>>m;
    VEC(int,aa,a);
    VEC(int,bb,b);
    std::vector<int> ans;
    rep(i,m){
        int x,y,z;
        std::cin >> x>>y>>z;
        x--;y--;
        ans.pb(aa[x]+bb[y]-z);
    }
    sort(all(aa));
    sort(all(bb));
    ans.pb(aa[0]+bb[0]);
    sort(all(ans));
    std::cout << ans[0] << std::endl;
}

Measured memory_bytes: 1660
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;


int main(void){
    int N;
    cin >> N;

    int F[100][15];
    int P[100][15];
    int ans;
    ans = -(1<<30);

    for(int i=0;i<N;i++){
        for(int j=0;j<10;j++){
            cin >> F[i][j];
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<11;j++){
            cin >> P[i][j];
        }
    }

    for(int i=1;i<(1<<10);i++){
        int sum=0;
        for(int j=0;j<N;j++){
            int c = 0;
            for(int k=0;k<10;k++){
                if((i>>k)&1 && F[j][k]){
                    c++;
                }
            }
            sum = sum + P[j][c];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	ll n;
	cin >> n;
	
	int ans = 100000;
	for(ll i = 1;i*i <= n;i++)
	{
		if(n % i == 0)
		{
			int kou = 0,zen = 0;
			ll tmp = i;
			while(tmp)
			{
				zen++;
				tmp /= 10;
			}
			tmp = n / i;
			while(tmp)
			{
				kou++;
				tmp /= 10;
			}
			ans = min(max(zen,kou),ans);
		}
	}
	
	cout << ans << endl;
				
			
			
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,i,x,y;                            
int main(){	
    cin>>a>>b;
    x=min(a,b);
    y=max(a,b);
    for(i=1;i<=x;i++)
    	if(y*i%x==0) break;
	cout<<y*i;
	return 0;
}

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

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

using ll = long long;
using P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

int main() {
    ll K;
    cin>>K;
    ll ans = 0;
    ll m = 0;
    vector<bool> done(K,false);
    while(true){
        m = (m*10+7)%K;
        ans++;
        if(m==0) {
            cout<<ans<<endl;
            break;
        }
        if(done[m]){
            cout<<-1<<endl;
            break;
        }
        done[m]=true;
    }
}

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

#define INF 1234567890
#define ll long long

ll Y, X;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> Y >> X;
	if (Y == 1 || X == 1) cout << 1;
	else if (Y%2==0 || X%2==0) cout << Y*X/2;
	else cout << Y*X/2+1;
	return 0;
}

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

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

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

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

vector<bool> sosu(1e7+10, true);
void eratos(){
    sosu[1]=false;
    for(int i=2; i<=sqrt(1e7); i++){
        if(sosu[i]){
            for(int j=2; i*j<=1e7; j++){
                sosu[i*j]=false;
            }
        }
    }
}

int main(){
    int n; cin>>n;
    eratos();

    int ans=0;
    for(int i=2; i<=1e7-2; i++){
        if(sosu[i] && i <= n){
            if(sosu[i+2]) ans++;
        }
    }
    cout << ans*2 << endl;
}


Measured memory_bytes: 3968
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan =new Scanner(System.in);
    		
    		int k=Integer.parseInt(scan.next());
    		System.out.print((k/2)*(k-k/2));
   
     
    }
    }
// end 

Measured memory_bytes: 21844
n, m = map(int, input().split())
l_max = 1
r_min = 10 ** 5
for i in range(m):
    l, r = map(int, input().split())
    l_max = max(l, l_max)
    r_min = min(r, r_min)

print(max(0, r_min - l_max + 1))





Measured memory_bytes: 9016
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();

		if (c[0] == c[1] && c[1]== c[2]) System.out.println("Yes");
		else if (c[1] == c[2] && c[2]== c[3]) System.out.println("Yes");
		else System.out.println("No");
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	string s,t;
	cin >> s >> t;
	int c = 0;
	int ans = 0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j+i<n;j++)
		{
			//cout<<s[i+j]<<':'<<t[j]<<endl;
			//cout<<c<<endl;
			if(s[i+j]==t[j])
			{
				c++;

			}
			else
			{
				
				break;
			}
			
		}
		ans = max(ans , c);
				c=0;
		
	}
	cout<<2*n-ans<<endl;
	return 0;
}

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

using namespace std;

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

const int MAX_N = (int)1e5 + 5;

vector<int> G[MAX_N];

int dp[MAX_N];

int dfs(int v){
	if (dp[v] != -1){
		return dp[v];
	} // end if

	int res = 0;
	rep (i, (int)G[v].size()){
		int u = G[v][i];
		res = max(res, dfs(u) + 1);
	} // end rep
	return dp[v] = res;
}

int main()
{
	rep (i, MAX_N) G[i].clear();
	memset(dp, -1, sizeof(dp));

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int N, M; cin >> N >> M;
	rep (i, M){
		int x, y; cin >> x >> y;
		--x, --y;
		G[x].push_back(y);
	} // end rep

	int res = 0;
	rep (i, N){
		res = max(res, dfs(i));
	} // end rep

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define ll long long
#define res register ll
using namespace std;
ll n,num,m;
ll a[101010];
ll f[101010],sum[101010];
inline ll read()
{
  ll X=0,w=0;
  char ch=0;
  while(!isdigit(ch))
  {
    w|=ch=='-';
    ch=getchar();
  }
  while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
  return w?-X:X;
}
void work(ll x,ll base)
{
  if (x<a[1])
  {
    sum[x]+=base;
    return;
  }
  ll l=1,r=n;
  ll total;
  while (l<=r)
  {
    ll mid=(l+r)/2;
    if (a[mid]<=x)
    {
      total=mid;
      l=mid+1;
    }
    else r=mid-1;
  }
  f[total]+=base*(x/a[total]);
  x=x%a[total];
  if (x) work(x,base);
}
int main()
{
  n=read(),m=read();
  num=1;
  a[1]=n;
  ll x;
  for (res i=1; i<=m; ++i)
  {
    x=read();
    while (x<=a[num] && num)
      --num;
    ++num;
    a[num]=x;
  }
  m=n;
  n=num;
  f[n]=1;
  for (res i=n-1; i>=1; --i)
  {
    f[i]+=f[i+1]*(a[i+1]/a[i]);
    work(a[i+1]%a[i],f[i+1]);
  }
  for (res i=a[1]; i>=1; --i)
    sum[i]+=sum[i+1];
  for (res i=1; i<=a[1]; ++i)
    sum[i]+=f[1];
  for (res i=1; i<=m; ++i)
    printf("%lld\n",sum[i]);
  return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 22000;
const int M = 1e6+5;
const int INF = 0x3f3f3f3f;

int main()
{     
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if((a == b && a != c) || (a == c && a != b) || (b == c && b != a)) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,a[100010],f[100010];

main()
{
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    f[1]=abs(a[0]-a[1]);
    for(int i=2;i<n;i++) f[i]=min(f[i-1]+abs(a[i]-a[i-1]),f[i-2]+abs(a[i]-a[i-2]));
    cout<<f[n-1];
}

Measured memory_bytes: 1792
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    if (b%a==0) {
      System.out.println(a+b);
    }
    else {
      System.out.println(b-a);
    }
  }
}

Measured memory_bytes: 23380
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    int n,m,x,c=0,b=0;
    cin>>n>>m>>x;
    vec a(m);
    rep(i,m){
        cin>>a[i];
        if(a[i]<x) c++;
        else b++;
    }
    cout<<min(c,b)<<endl;
}

Measured memory_bytes: 256