akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
 
	ll x;
	cin >> x;
 
	ll a = 0, b = 0;
 
	bool f = false;
 
	for (int i = -1000; i < 1000; i++) {
		a = pow(i, 5);
		for (int j = -1000; j < 1000; j++) {
			b = pow(j, 5);
 
			if (a - b == x) {
				cout << i << " " << j << endl;
				f = true;
				break;
			}
		}
		if (f == true)break;
	}
 
	return 0;
}

Measured memory_bytes: 4116
#include<stdio.h>
#include<math.h>
int main()
{
	long long int l,n,i,min,d;
	scanf("%lld %lld",&n,&l);
	long long int a[n],s;
	for(i=0;i<n;i++)
	{
		a[i]=l+i;
	}
	if(l>=0)
	{
		min=l;
		printf("%lld\n",(n-1)*(n+2*l)/2);
	}
	else
	{
		min=fabs(a[0]);
		for(i=1;i<n;i++)
		{
			if(fabs(a[i])<min)
			{
				min=fabs(a[i]);
				d=a[i];
			}
		}
		s=(n*l)+(n*(n-1)/2)-d;
		printf("%lld\n",s);
	}
	return 0;
}





Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<math.h>
#define _USE_MATH_DEFINES
using namespace std;
int main(){
  double r,s,l;
  scanf("%lf", &r);;
  s = r*r*M_PI;
  l = 2*M_PI*r;
  printf("%f %f\n", s, l);
}


Measured memory_bytes: 3228
def main():
    N, M = map(int, input().split())
    d = {}
    for _ in range(M):
        u, v = map(int, input().split())
        if u in d:
            d[u].append(v)
        else:
            d[u] = [v]
    s, t = map(int, input().split())
    cur = set([s])
    ne1 = set()
    ne2 = set()
    ne3 = set()
    c = 0
    v3 = set()
    v1 = set()
    v2 = set()
    while len(v3) < N:
        for i in cur:
            if i not in d:
                continue
            for j in d[i]:
                if j not in v1:
                    ne1.add(j)
                    v1.add(j)
        if len(ne1) == 0:
            return -1
        for i in ne1:
            if i not in d:
                continue
            for j in d[i]:
                if j not in v2:
                    ne2.add(j)
                    v2.add(j)
        if len(ne2) == 0:
            return -1
        for i in ne2:
            if i not in d:
                continue
            for j in d[i]:
                if j not in v3:
                    ne3.add(j)
                    v3.add(j)
        if len(ne3) == 0:
            return -1
        c += 1
        if t in ne3:
            return c
        cur = ne3
        ne1 = set()
        ne2 = set()
        ne3 = set()
    return -1
print(main())


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

int main() {
    string S;
    cin >> S;
    int a = 0, b;
    b = S.size();
    if(S.at(0) != 'A' + 0){
        cout << "WA" << endl;
        return 0;
    }
    if (S.at(1) + 0 < 'a' + 0 || S.at(0) + 0 > 'z' + 0) {
        cout << "WA" << endl;
        return 0;
    }
    if (S.at(b - 1) + 0 < 'a' + 0 || S.at(b - 1) + 0 > 'z' + 0) {
        cout << "WA" << endl;
        return 0;
    }
    for (int i = 2; i < b - 1; i++){
        if (S.at(i) + 0 == 'A' + 2){
            a++;
            continue;
        } 
        if (S.at(i) + 0 < 'a' + 0 || S.at(i) + 0 > 'z' + 0) {
        cout << "WA" << endl;
        return 0;
        }
    }
    if (a == 1) {
        cout << "AC" << endl;
    }
    else {
        cout << "WA" << endl;
    }
}


Measured memory_bytes: 256
int main(){
    int t, h, m, s;
    
    scanf("%d", &t);
    
    h = t / 3600;
    t = t % 3600;
    m = t / 60;
    s = t % 60;
    
    printf("%d:%d:%d\n", h, m, s);
    
    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
int n,k;
LL a[Max],f[Max];
LL suma[Max],sumf[Max];
int lena=1,lenf=1;
bool cmp(LL a,LL b){
    return a>b;
}
LL fun()
{
    LL ans=1e12+5;
    for(int i=1;i<lenf;i++)
        sumf[i]=sumf[i-1]+abs(f[i])-abs(f[i-1]);

    for(int i=1;i<lena;i++)
        suma[i]=suma[i-1]+a[i]-a[i-1];

    for(int i=0;i<=k;i++)
    {
        if(i<lena && (k-i)<lenf){
            ans=min(ans,suma[i]*2+sumf[k-i]);
           //  printf("1: %lld %lld %lld\n",suma[i],sumf[k-i],ans);
            ans=min(ans,suma[i]+sumf[k-i]*2);
            // printf("2: %lld\n",ans);
        }
        if((k-i)<lena && i<lenf)
        {
            ans=min(ans,sumf[i]*2+suma[k-i]);
           //  printf("3: %lld %lld %lld \n",suma[k-i],sumf[i],ans);
            ans=min(ans,sumf[i]+suma[k-i]*2);
           // printf("4: %lld\n",ans);
        }
    }
    return ans;
}
int main()
{
    LL x;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%lld",&x);
        if(x<0)
            f[lenf++]=x;
        else
            a[lena++]=x;
    }
    sort(f+1,f+lenf,cmp);
    printf("%lld\n",fun());
    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Linq;
namespace arc094a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] read = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            int max = read.Max();
            int count = 0;
            int diff = 3*max - read[0] - read[1] -read[2];
            if(diff%2==0){
                count += diff/2;
            }else{
                count += (diff+3)/2;
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a;
    cin >> n;
    map<int, int> m;
    for(int i=0;i<n;i++){
        cin >> a;
        m[a] ++;
    }
    string ans = "Yes";
    if(m.size() > 3) ans = "No";
    else if (m.size() == 3){
        int x = 0;
        for (auto p : m){
            x ^= p.first;
            if(p.second != n/3)
                ans = "No";        
        }
        if(x != 0)
            ans = "No";
    }else if (m.size() == 2){
        for (auto p : m){
            if (p.first == 0){
                if (p.second != n/3)
                    ans = "No";
            }else{
                if (p.second != 2*n/3)
                    ans = "No";
            }
        }
    }else{
        if (m[0] != n)
            ans = "No";        
    }
    cout << ans << endl;
}

Measured memory_bytes: 3840
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        va: [usize; n],
        vb: [usize; n]
    }
    let mut ans = vec![];
    ans.push(va.iter().map(|&x| x & 1).sum::<usize>() * n + vb.iter().map(|&x| x & 1).sum::<usize>() * n);
    for d in 1..29 {
        let t = va.iter().map(|&x| x >> d & 1).sum::<usize>() * n + vb.iter().map(|&x| x >> d & 1).sum::<usize>() * n;
        let mut va2 = va.iter().map(|&x| x & (1 << d) - 1).collect::<Vec<usize>>();
        let mut vb2 = vb.iter().map(|&x| x & (1 << d) - 1).collect::<Vec<usize>>();
        va2.sort();
        vb2.sort();
        let mut c = 0;
        let mut ia = 0;
        let mut ib = n;
        while ia < n && va2[ia] + vb2[n - 1] < 1 << d {
            ia += 1;
        }
        while ia < n {
            while ib > 0 && va2[ia] + vb2[ib - 1] >= 1 << d {
                ib -= 1;
            }
            if ib == 0 {
                c += (n - ia) * n;
                break;
            }
            c += n - ib;
            ib += 1;
            ia += 1;
        }
        ans.push(t + c);
    }
    let mut x = 0;
    for i in 0..29 {
        x |= (ans[i] & 1) << i;
    }
    println!("{}", x);
}


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

using namespace std;

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

#define INF 2<<29
#define F first
#define S second

int main(){
  int n,a,b;
  scanf("%d %d %d",&n,&a,&b);
  
  if((b-1-a)%2==1) printf("Alice\n");
  else printf("Borys\n");
  
  return (0);
}


Measured memory_bytes: 256
#include <iostream>

class CStack
{
public:
    CStack()
    {
        topIndex = 0;
    }
    ~CStack(){;}
    
    void push(char charactor)
    {
        if(topIndex < 100)  /* スタック可能数を超えてpushした場合、なにもしない */
        {
            stack[topIndex] = charactor;
            ++topIndex;
        }
    }
    char pop(void)
    {
        if(topIndex > 0)
        {
            --topIndex;
            return stack[topIndex];
        }
        return '\0';
    }
    char top(void)
    {
        return stack[topIndex-1];
    }
    bool enpty(void)
    {
        if(topIndex == 0)
        {
            return true;
        }
        return false;
    }
    
private:
    int topIndex;
    char stack[100];
};

/* 括弧の左右が対になっているか */
bool isMatchLeftRight(char left, char right)
{
    if((left == '(') && (right == ')'))
    {
        return true;
    }
    if((left == '[') && (right == ']'))
    {
        return true;
    }
    return false;
}

/* 1行がバランスしているか */
bool isBalance(char* line)
{
    bool result = true;
    CStack cStack;      /* スタック生成 */
    
    for(int index=0; index<100; ++index)
    {
        /* 行の最後か */
        if(line[index]=='.')
        {
            break;
        }
        
        if((line[index]=='(') || (line[index]=='['))
        {
            cStack.push(line[index]);    /* 左括弧をpush */
        }
        else
        {
            if((line[index]==')') || (line[index]==']'))
            {
                if(isMatchLeftRight(cStack.top(), line[index]))
                {
                    cStack.pop();        /* 直前の左括弧をpop */
                }
                else
                {
                    result = false;
                    break;
                }
            }
        }
    }
    
    if((result==true) && (cStack.enpty()))
    {
        result = true;
    }
    else
    {
        result = false;
    }
    return result;
}

int main(void)
{
    for(;;)
    {
        std::string sLine(100, '\0');
        getline(std::cin, sLine);   /* 1行取得 */
        
        if(sLine.size()>100) /* 100文字を超えていたら終了 */
        {
            break;
        }
        if(sLine[0]=='.')    /* データセットの最後なら処理終了 */
        {
            break;
        }
        
        /* 苦肉の策 */
        char line[100] = {'\0'};
        for(int index=0; index<sLine.size(); ++index)
        {
            line[index] = sLine[index];
        }

        /* 1行がバランスしているかチェック */
        bool result = true;
        result = isBalance(line);
        
        /* 1行の結果を出力 */
        if(result == true)
        {
            std::cout << "yes" << std::endl;
        }
        else
        {
            std::cout << "no" << std::endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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 ll INF = 1e9;
const ll MOD = 1e9 + 7;


//keyより大きいxの個数
int GreaterThan_X(vector<int> &v, int key){
    return distance(upper_bound(all(v), key), v.end());
}

//keyより小さいxの個数
int LessThan_X(vector<int> &v, int key){
    return distance(v.begin(), lower_bound(all(v), key));
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    sort(all(a));
    sort(all(b));
    sort(all(c));

    ll ans = 0;
    rep(i, n){
        ll x = GreaterThan_X(c, b[i]);
        ll y = LessThan_X(a, b[i]);
        ans += x * y;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1536
from scipy.sparse.csgraph import floyd_warshall
n,m,l = list(map(lambda x:int(x),input().split()))
d = [[float('inf') for i in range(n)] for j in range(n)]
for i in range(n):
    d[i][i] = 0
for i in range(m):
    a,b,c = list(map(lambda x:int(x),input().split()))
    if c <= l:
        d[a-1][b-1] = c
        d[b-1][a-1] = c

d = floyd_warshall(d)

dd = [[float('inf') for i in range(n)] for j in range(n)]
for i in range(n):
    for j in range(n):
        if d[i][j] <= l:
            dd[i][j] = 1

dd = floyd_warshall(dd)
q = int(input())
for i in range(q):
    s,t = input().split()
    s = int(s)-1
    t = int(t)-1
    if dd[s][t] == float('inf'):
        print(-1)
    else:
        print(int(dd[s][t]-1))

Measured memory_bytes: 19764
import sys
from collections import defaultdict
import queue

n = int(sys.stdin.readline())

graph = defaultdict(list)

X, Y = [[] for i in range(n)], [[] for i in range(n)]
atX, atY = defaultdict(list), defaultdict(list)

for i in range(n):
	a, b = map(int, sys.stdin.readline().split())
	a -= 1; b-= 1
	X[i] = a; Y[i] = b
	atX[X[i]].append(i)
	atY[Y[i]].append(i)

visX = set(); visY = set()
found = [False]*n

ans = n*(-1)
for root in range(n):
	if found[root]: continue
	usedX, usedY = set(), set()

	que = queue.Queue()
	que.put(root)
	found[root] = True
	usedX.add(X[root])
	usedY.add(Y[root])

	while not que.empty():
		cur = que.get()
		toVisit = []
		if X[cur] not in visX:
			visX.add(X[cur])
			for ele in atX[X[cur]]:
				toVisit.append(ele)
		if Y[cur] not in visY:
			visY.add(Y[cur])
			for ele in atY[Y[cur]]:
				toVisit.append(ele)

		for ele in toVisit:
			if found[ele]: continue
			found[ele] = True
			usedX.add(X[ele])
			usedY.add(Y[ele])
			que.put(ele)
	ans += len(usedX)*len(usedY)
print(ans)

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

int main(){
    ll X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
    vector<ll> P(A), Q(B), R(C);
    for(int i = 0; i < A; i++) cin >> P[i];
    for(int i = 0; i < B; i++) cin >> Q[i];
    for(int i = 0; i < C; i++) cin >> R[i];
    ll SUM = 0;
    sort(P.rbegin(), P.rend());
    sort(Q.rbegin(), Q.rend());
    sort(R.rbegin(), R.rend());

    for(int i = 0; i < X; i++) SUM += P[i];
    for(int i = 0; i < Y; i++) SUM += Q[i];
    int ic = 0;


    while((R[ic] > P[X-1] && X > 0) ||( R[ic] > Q[Y-1] && Y > 0)){
        SUM += R[ic]; ic++;
        
        if(Y <= 0){
            SUM -= P[X-1]; X--;
        }
        else if(X <= 0){
            SUM -= Q[Y-1];Y--;
        }
        else{
            if(P[X-1] < Q[Y-1]) {
                SUM -= P[X-1]; X--;
            }
            else {
                SUM -= Q[Y-1];Y--;
            }
        }
        if(ic == C) break;
    }
    cout << SUM << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
 #include <math.h>
 using namespace std;
 
 int main(){
    int N;

    cin >> N;

    if(N==7 |N==5 |N==3)    
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
 }
 


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

int main()
{
  int a, b;
  cin >> a >> b;
  if (a > 0 and b > 0)
  {
    printf("Positive");
  }
  else if (a < 0 and  b < 0)
  {
    if ((b - a + 1) % 2 == 0)
    {
      printf("Positive");
    }
    else
    {
      printf("Negative");
    }
  }
  else
  {
    printf("Zero");
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 110000
typedef long long ll;
	ll n,s,a[N],p[N],ans;
	ll l,r;
bool check(){
	return a[l]<=s&&s<=a[r];
}
int main(){
	scanf("%lld%lld",&n,&s);
	for(ll i=1;i<=n;i++){
		scanf("%lld%lld",&a[i],&p[i]);
	}
	l=1; r=n;
	while(a[l]<=s&&s<=a[r]){
		ans+=a[r]-a[l];
		if(p[l]>=p[r])while(p[l]>=p[r]&&a[l]<=s&&s<=a[r])p[l]+=p[r],r--;
		else while(p[l]<p[r]&&a[l]<=s&&s<=a[r])p[r]+=p[l],l++;
	}
	if(a[l]>=s)ans+=a[r]-s;
	else if(a[r]<=s)ans+=s-a[l];
	printf("%lld\n",ans);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 998244353;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	int x; cin >> x;
	int ans=(x*360/gcd(360,x))/x;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
import sys
 
A, B=map(int,input().split())
 
if B==1:
  print(0)
  sys.exit()

if A >= B:
  print(1)
  sys.exit()

B -= A  
A -= 1
 
Cnt = 1
Flag = 0
while Flag == 0:
  B -= A
  Cnt += 1
  if B > 0:
    continue
  else:
    Flag = 1
    break
 
 
print(Cnt)

Measured memory_bytes: 3064
// atcoder/abc176/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int h, w;
  pair<int, int> src, dst;
  while (cin >> h >> w >> src >> dst) {
    --src.first;
    --src.second;
    --dst.first;
    --dst.second;

    const int N = 1e3 + 5;
    static char g[N][N];
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        cin >> g[i][j];
      }
    }

    const int inf = 1 << 29;
    static int cost[N][N];
    fill(&cost[0][0], &cost[N - 1][N - 1] + 1, inf);

    deque<pair<int, int>> q;
    cost[src.first][src.second] = 0;
    q.push_back(src);

    while (q.size()) {
      auto curr = q.front();
      q.pop_front();
      if (curr == dst) break;
      for (int i = -2; i <= +2; ++i) {
        for (int j = -2; j <= +2; ++j) {
          int ni = curr.first + i;
          int nj = curr.second + j;
          unless (0 <= ni && ni < h) continue;
          unless (0 <= nj && nj < w) continue;
          if (g[ni][nj] == '#') continue;

          int x;
          if (abs(i) + abs(j) == 1) {
            x = 0;
          } else {
            x = 1;
          }
          if (cost[ni][nj] > cost[curr.first][curr.second] + x) {
            cost[ni][nj] = cost[curr.first][curr.second] + x;
            if (x) {
              q.push_back({ni, nj});
            } else {
              q.push_front({ni, nj});
            }
          }
        }
      }
    }

    cout << (cost[dst.first][dst.second] == inf ? -1 : cost[dst.first][dst.second]) << endl;
  }

  return 0;
}


Measured memory_bytes: 8608
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }

char s[N];
int n,a[N],id[4],ch[4],num[4],b[N];
int pre[N],nxt[N];
void del(int x) { pre[nxt[x]]=pre[x],nxt[pre[x]]=nxt[x]; }
int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	scanf ("%s",s+1);
	int len=strlen (s+1);
	for (int i=1; i<=len; i++)
	{
		int x=s[i]-'A'+1;
		if (x!=a[n]) a[++n]=x;
	}
	for (int i=1; i<=n; i++)
		++num[a[i]];
	for (int i=1; i<=3; i++)
		b[i]=num[i];
	sort (num+1,num+3+1);
	if (!num[1]) return 0;
	for (int j=1; j<=3; j++)
		for (int i=1; i<=3; i++)
			if (num[i]==b[j]) { id[i]=j,ch[j]=i,num[i]=-1; break; }
	for (int i=1; i<=n; i++)
		a[i]=ch[a[i]];
	for (int i=1; i<=n+1; i++)
		pre[i]=i-1,nxt[i]=i+1;
	nxt[0]=1;
	sort (b+1,b+3+1);
	for (int i=nxt[0]; i<=n; i=nxt[i])
	{
		if (b[2]==b[3]) break;
		if (a[i]==3&&a[pre[i]]!=a[nxt[i]]) del(i),--b[3];
	}
	for (int i=nxt[0]; i<=n; i=nxt[i])
	{
		if (b[2]==b[3]) break;
		if ((a[i]==1&&a[nxt[i]]==3)||(a[i]==3&&a[nxt[i]]==3))
			if (a[pre[i]]!=a[nxt[nxt[i]]]) del(i),del(nxt[i]),i=nxt[i],--b[1],--b[3];
	}
	for (int i=nxt[0]; i<=n; i=nxt[i])
	{
		if (b[1]==b[2]) break;
		if ((a[i]==2&&a[nxt[i]]==3)||(a[i]==3&&a[nxt[i]]==2))
			if (a[pre[i]]!=a[nxt[nxt[i]]]) del(i),del(nxt[i]),i=nxt[i],--b[2],--b[3];
	}
	for (int i=nxt[0]; i<=n; i=nxt[i])
		putchar(id[a[i]]+'A'-1);


    return 0;
}


Measured memory_bytes: 15872
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	  	Scanner scanner = new Scanner(System.in);
	  	boolean J = true;
	  	int i,j;
	  	
	  	while(J) {
	  		
		  	int  h = scanner.nextInt();			//入力
		  	int  w = scanner.nextInt();
		  	
		  	if( h == 0 && w == 0 )
		  		break;
	  		
		  	for(i = 1; i <= h ; i ++){
		  		for(j = 1; j <= w ; j++){
		  			if(j == w) {
		  				if( (i + j) % 2 == 0)
		  					System.out.println("#");
		  				else
		  					System.out.println(".");
		  			}
		  			else{
		  				if( (i + j) % 2 == 0)
		  					System.out.print("#");
		  				else
		  					System.out.print(".");
		  			}
		  		}
		  	}
		  	System.out.print("\n");
		  	
  		}
        scanner.close();
  }
}


Measured memory_bytes: 34792
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
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; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

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

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct edge{
  int to;
  ll cost;
};
vector<edge> G[max_n];
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
ll d[max_n];
void solve(int k){
  rep(i,0,max_n){
    d[i] = INF;
  }
  d[k] = 0;
  priority_queue<int> que;
  que.push(k);
  while(que.size()){
    int x=que.top();  que.pop();
    for(auto e : G[x]){
      if(d[e.to]>d[x] + e.cost){
        d[e.to] = d[x] + e.cost;
        que.push(e.to);
      }
    }
  }
}
int main(){
  int n;  cin >> n;
  rep(i,0,n-1){
    int x,y;  ll z;
    cin >> x>>y>>z;
    --x;  --y;
    G[x].pb((edge){y, z});
    G[y].pb((edge){x, z});
  }
  int q,k;
  cin >>q>>k;
  k--;
  solve(k);
  rep(i,0,q){
    int x,y;  cin >> x >> y;
    --x;  --y;
    cout << d[x]+d[y] << endl;
  }
  return 0;
}


Measured memory_bytes: 11632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        String r;
        switch (s) {
            case "Sunny":
                r = "Cloudy";
                break;
            case "Cloudy":
                r = "Rainy";
                break;
            default:
                r = "Sunny";
                break;
        }
        System.out.println(r);
    }
}


Measured memory_bytes: 21588
#include <iostream>
#include <map>
#define db(x) cout << "> " << #x << ": " << x << endl;

using namespace std;

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

	int n,m;
	cin>>n>>m;

	int arr[n+1];
	for(int i=1;i<n+1;++i)
		cin>>arr[i];
	arr[0]=0;

	map<int,int> cnt;
	int sum=0;
	for(int i=1;i<=n;++i){
		sum+=arr[i];
		sum%=m;
		++cnt[sum];
	}
	++cnt[0];

	long long ans=0;
	for(auto it=cnt.begin();it!=cnt.end();++it)
		ans+=(long long)(it->second)*(long long)(it->second-1)/2LL;
	cout<<ans<<endl;

	return 0;
}


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

// フェルマーの小定理より、素数Mに対しa^(-1)はa^(M - 2)と合同であることを使う。
const ll MOD = 1000000007;

ll pow(ll x, ll n) {
    ll ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x % MOD;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}

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

  if (!( ((2 * X - Y) >= 0) && ((2 * Y - X) >= 0) && ((2 * X - Y) % 3 == 0) && ((2 * Y - X) % 3 == 0))) {
    cout << 0 << endl;
    return 0;
  }

  int a = (2 * X - Y) / 3, b = (2 * Y - X) / 3;

  ll bunshi = 1, bunbo1 = 1, bunbo2 = 1;
  for(int i = 1; i <= a + b; i++) {
    bunshi *= i;
    bunshi %= MOD;
  }
  for(int i = 1; i <= a; i++) {
    bunbo1 *= i;
    bunbo1 %= MOD;
  }
  bunbo1 = pow(bunbo1, MOD - 2);

  for(int i = 1; i <= b; i++) {
    bunbo2 *= i;
    bunbo2 %= MOD;
  }
  bunbo2 = pow(bunbo2, MOD - 2);

  ll ans;
  ans = bunshi * bunbo1;
  ans %= MOD;
  ans *= bunbo2;
  ans %= MOD;

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


Measured memory_bytes: 3608
#include<stdio.h>
#include<set>
#include<algorithm>
using namespace std;

set<int> st;

int main(){
	int n,t;
	int ans=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&t);
		set<int>::iterator it=st.find(t);
		if(*it!=t){
			ans++;
			st.insert(t);
			continue;
		}else if(*it==t){
			ans--;
			st.erase(t);
		}
	}
	printf("%d",ans);
	
}

Measured memory_bytes: 4864
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define repp(i,n,s) for (int i= (int)(n); i >= (int)(s); i--)
#define mp make_pair
ll mod = 1000000007;
ll mod2 = 998244353;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    if (n>=30){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int a[100000];

int main(){
	int n;
	scanf("%d",&n);
	int m;
	for(int i = 0;i < n;i++){
		scanf("%d",&m);
		a[m]++;       //把读取到的数的前后数都加1，最后那个数的值最大，答案就是多少
		a[m-1]++;
		a[m+1]++;
	}	
	int max = 0;
	for(int i = 0;i < 100000;i++){
		if(a[i] > max) max = a[i];
	}		
	printf("%d\n",max);
	
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,k,a,ans;
  ans = 0;
  cin >> n >> m;
  vector<int> f(m+1,0);
  for(int i = 0;i < n;i++){
    cin >> k;
    for(int j = 0;j < k;j++){
      cin >> a;
      f[a]++;
    }
  }
  for(int i = 1;i <= m;i++){
    if(f[i] == n)ans++;
  }
  cout << ans << endl;
}
    


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

struct Town {
  int x;
  int y;
  int idx;
};
struct Entry {
  int cost;
  int idx;
};
const int INF = INT_MAX - 1;
using Visited = bitset<100100>;
int main() {
  int N;
  cin >> N;
  vector<Town> towns(N);
  for(int i = 0; i < N; ++i) {
    cin >> towns[i].x >> towns[i].y;
    towns[i].idx = i;
  }
  vector<vector<Entry>> edges(N);
  sort(towns.begin(), towns.end(), [](const auto& a, const auto& b) { return a.x < b.x; });
  for(int i = 0; i < N - 1; ++i) {
    auto& c = towns[i];
    auto& n = towns[i + 1];
    edges[c.idx].push_back({abs(c.x - n.x), n.idx});
    edges[n.idx].push_back({abs(c.x - n.x), c.idx});
  }
  sort(towns.begin(), towns.end(), [](const auto& a, const auto& b) { return a.y < b.y; });
  for(int i = 0; i < N - 1; ++i) {
    auto& c = towns[i];
    auto& n = towns[i + 1];
    edges[c.idx].push_back({abs(c.y - n.y), n.idx});
    edges[n.idx].push_back({abs(c.y - n.y), c.idx});
  }
  auto compare = [](const auto& a, const auto& b) { return a.cost > b.cost; };
  priority_queue<Entry, vector<Entry>, decltype(compare)> qs(compare);
  qs.push({0, 0});
  long long ans = 0;
  Visited visited;
  while(!qs.empty()) {
    auto q = qs.top();
    qs.pop();
    if(visited.test(q.idx)) {
      continue;
    }
    visited.set(q.idx);
    ans += q.cost;
    for(auto n : edges[q.idx]) {
      qs.push(n);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11636
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

// vector 操作  vector<int> data(10,5) 5が10個　data(10) 要素数10
// v.size(), v.empty(), v.insert(itr,値), v.erase(itr) (first,last),
// sort(itr), find(all(x),値),reverse(itr),accumulate(itr,0) 積算,
//v.swap
// stringも同じ itrがただの数字になる
// s.substr(n,m)n番目以降m文字取り出す　erase(n,m)も  s.find
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

// map 操作  map<string,int> mp キー=string 値=int型  pair< , >型
// 代入:mp["abc"]=123  mp.erase(キー)
// itr = mp.begin()のとき　itr->first = key, itr->second = val
// mp.find(key) itrを返す
typedef pair<int,int> P;  //q(p.first,p.second)で定義できる？

// lcm( , ) gcd( , ) 最大公約数　最小公倍数
//if(cin.eof()) break; 入力数が決まってないとき
//ifstream  whilwee(ifs>>data)

// 浮動小数点
// cout << fixed; 以下と組fみ合わせで小数点以下n桁
// cout << setprecision(n) << 値; n桁表記
// defaultfloat
int main (){
    ll int k;
    ll int n;
    cin >> k >> n;
    velli a(k);
    REP(i,n){
        cin >> a[i];
    }
    ll int ans ;

    ll int maxsa = 0;
    REP(i,n-1){
        if(a[i+1]-a[i]>maxsa){
            maxsa = a[i+1]-a[i];
        }
    }
    if(a[0]+k-a[n-1]>maxsa) maxsa = a[0]+k-a[n-1];

    ans = k - maxsa;
    cout << ans;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  ll sum = 0;
  
  rep(i, N){
   rep(j, N){
    rep(k, N){
      sum += gcd(gcd(i,j),k);
    }
   }
  }
  
  cout << sum << endl;
  return 0;
}




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

bool judge(int a){
  for(int i = 2; i<a; i++) {
	if(a % i == 0) return false;
  }
  return true;
}
    

int main(){
  int X;
  cin >> X;
  
  while(!judge(X)) X ++;
  cout <<X;
}

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

using namespace std;

int main(){

    string s;
    cin >> s;

    vector<int> out = {};
    for(int i=0; i<s.length(); ++i){
        //cout << "i=" << i << " s[i]=" << s[i] << endl;
        //cout << (s[i]=='0') << endl;
        if(s[i]=='0') out.push_back(0);
        else if(s[i]=='1') out.push_back(1);
        else if(s[i]=='B' && out.size()>0) out.pop_back();
        //for(int j=0; j<out.size(); ++j){
        //    cout << out[j];
        //}
    }
    //cout << out.size();
    for(int j=0; j<out.size(); ++j){
        cout << out[j];
    }

    return 0;

}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#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++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int,int>> P(M);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    P[i] = {a, b};
  }

  sort(P.begin(), P.end(), [](pii a, pii b){
    if (a.second == b.second) {
      return a.first < b.first;
    } else {
      return a.second < b.second;
    }
  });

  int ret = 0, f = 0;
  for (int i = 0; i < M; i++) {
    if (f <= P[i].first) {
      f = P[i].second;
      ret++;
    } 
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int inf = 99999999;
int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i = 0; i < n; i++){
    cin >> p[i];
  }

  vector<int> min(n);
  fill(min.begin(),min.end(),inf);

  min[0]=p[0];

  for(int i = 1; i < n; i++){
    if(min[i-1] < p[i]){
      min[i]=min[i-1];
    }else{
      min[i]=p[i];
    }
  }
  ll ans = 0;
  for(int i = 0 ; i < n; i++){
    if(min[i]==p[i]){
      ans++;
    }
  }

  cout << ans << endl;


}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<map>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
template<typename T>
T rabs(T x)
{
	return x>0?x:-x;
}
int n;
int main()
{
	int nowx=0;
	int nowy=0;
	int nowt=0;
	read(n);
	while(n--)
	{
		int a,b,c;
		read(c);
		read(a);
		read(b);
		if(rabs(a-nowx)+rabs(b-nowy)>c-nowt || ((rabs(a-nowx)+rabs(b-nowy))&1)!=((c-nowt)&1))
		{
			printf("No\n");
			return 0;
		}
		nowx=a;
		nowy=b;
		nowt=c;
	}
	printf("Yes\n");
	return 0;
}

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

using namespace std;
using ll=long long;

#define PRI(n) cout << n <<endl;
#define PRI2(n, m) cout << n << " " << m << endl;
#define PRI3(n, m, o) cout << n << " " << m<< " " << o << endl;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REPInv(i, n)  for(int i = n-1; i >= 0; --i)

#define FOR(i, t, n)  for(int i = t; i <= (int)n; ++i)
#define FORInv(i, t, n)  for(int i = t; i >= (int)n; --i)

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll MOD = 1e9 + 7;

bool isPrime(ll x) {
    if (x == 0)return 0;
    if (x == 1)return 0;
    if (x == 2)return 1;
    if (x % 2 == 0)return 0;
    FOR(i, 3, x - 1) {
        if (x % i == 0)return 0;
    }
    return 1;
}

ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll nCr(int n, int r) {
    vector<ll> C(r + 1);
    C[0] = 1;
    FOR(i, 1, n) FORInv (j, min(i, r), 1)C[j] = (C[j] + C[j - 1]) % MOD;
    return C[r];
}

struct edge {
    int to, cost;
    bool flag = false;
};
ll N, M;
string S;
vector<edge> X[100010];
bool B[100010];
int D[100010];

int main() {
    cin >> S;
    int g = 0, p = 0;
    REP(i, S.length())if (S[i] == 'p')p++;
    PRI(floor(S.length()/2)-p);
    return 0;

}

Measured memory_bytes: 2816
def readinput():
    n=int(input())
    h=list(map(int,input().split()))
    return n,h

def main(n,h):
    hr=list(reversed(h))
    for i in range(n-1):
        if hr[i]<hr[i+1]:
            if hr[i+1]-hr[i]>1:
                return 'No'
            else:
                hr[i+1]-=1
    return 'Yes'

if __name__=='__main__':
    n,h=readinput()
    ans=main(n,h)
    print(ans)


Measured memory_bytes: 20720
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using lli = long long int;

int main(){
  lli h, n;
  std::cin >> h >> n;
  vector<lli> a(n), b(n);
  for (int i = 0; i < n; i++) {
    std::cin >> a[i] >> b[i];
  }
  lli dp[h + 10];
  for (int i = 0; i <= h; i++) dp[i] = 1e9;
  dp[0] = 0;
  for (int i = 1; i <= h; i++) {
    for (int j = 0; j < n; j++) {
      if(i - a[j] >= 0){
        dp[i] = std::min(dp[i], dp[i - a[j]] + b[j]);
      }else{
        dp[i] = std::min(dp[i], b[j]);
      }
    }
  }
  std::cout << dp[h] << std::endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en,h) for(int i=st; i<=en; i+=h)
#define eb emplace_back
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,ans,p,q;
string s;

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

  cin>>n>>m>>q; int a[n]; fill(a,a+n,m-q);
  rep(i,q){
    cin>>p; a[p-1]++;
  }
  for (int i = 0; i < n; i++)cout<<(a[i]>=1?"Yes":"No")<<'\n';
}

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

long long N, W;
long long w[105], v[105];
long long dp[105][100005];

// dp[i][j] = min weight from 0 to i with value j

long long rec(long long d, long long val)
{
    if (d == -1)
    {
        if (val == 0)
            return 0;
        return LLONG_MAX;
    }

    if (val < 0)
        return LLONG_MAX;

    if (dp[d][val] != -1)
        return dp[d][val];

    long long val1 = rec(d - 1, val - v[d]);
    if (val1 <= LLONG_MAX - w[d])
        val1 += w[d];
    long long val2 = rec(d - 1, val);
    dp[d][val] = min(val1, val2);

    return dp[d][val];
}

int main()
{
    cin >> N >> W;
    long long max_val = 0;
    for (long long i = 0; i < N; i++)
    {
        cin >> w[i] >> v[i];
        max_val += v[i];
    }

    for (long long i = 0; i < N; i++)
        for (long long j = 0; j <= max_val; j++)
            dp[i][j] = -1;

    // for (long long i = 0; i <= max_val; i++)
    //     rec(N - 1, i);

    long long ans = 0;
    for (long long i = max_val; i >= 0; i--)
    {
        // cout << i << " " << dp[N - 1][i] << endl;
        rec(N - 1, i);
        if (dp[N - 1][i] <= W && ans < max_val)
        {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 80128
#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)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int nil = -1;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int n;
vector<int> to[200010];
vector<int> ans;

void dfs(int c, int p = -1) {
  for (int v : to[c]) {
    if (v == p) continue;
    ans[v] += ans[c];
    dfs(v, c);
  }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin >> n >> q;
    rep (i, n - 1) {
      int a, b;
      cin >> a >> b;
      a--; b--;
      to[a].push_back(b);
      to[b].push_back(a);
    }
    ans.resize(n);
    rep (i, q) {
      int p, x;
      cin >> p >> x;
      ans[p - 1] += x;
    }
    dfs(0);
    rep (i, n) {
      if (i < n - 1) {
        cout << ans[i] << " ";
      } else {
        cout << ans[i] << endl;
      }
    }

    return 0;
}


Measured memory_bytes: 23552
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
long long a[100000];
signed main()
{
	int n;
	long long x, total = 0;
	scanf("%d%lld", &n, &x);	
	for(int i = 0; i < n; scanf("%lld", &a[i++])){}
	for(int i = 1; i < n; ++i)
	{
		if(a[i - 1] + a[i] > x)
		{
			total += min(a[i], a[i - 1] + a[i] - x);
			a[i] -= min(a[i], a[i - 1] + a[i] - x);
		}
		if(a[i - 1] + a[i] > x)
		{
			total += a[i - 1] + a[i] - x;
			a[i - 1] -= a[i - 1] + a[i] - x;
		}
	}
	printf("%lld\n", total);
}

Measured memory_bytes: 1024
s = input()
indices = {}

for i in range(len(s)):
    if s[i] in indices:
        indices[s[i]].append(i)
    else:
        indices[s[i]] = [-1, i]

minres = 1000

for key, value in indices.items():
    if len(value) > 1:
        dist = [value[i+1]-value[i] - 1 for i in range(len(value) - 1)]
    else:
        dist = [value[0]]

    res = max(max(dist), len(s)-value[-1]-1)
    if res < minres:
        minres = res

print(minres)

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

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

int main(void){
    int n,m;
    cin>>n>>m;
    vector<int> c(m+1);
    rep(i,1,m+1)cin>>c[i];
    vector<int> dp(n+1);
    rep(i,1,n+1)dp[i]=INF;
    dp[0]=0;
    rep(i,1,m+1){
        for(int j=0;j+c[i]<=n;j++){
            dp[j+c[i]]=min(dp[j+c[i]],dp[j]+1);
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 3192
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int N, A, B;
    scanf("%d", &N);
    if(N == 1){
        printf("Hello World\n");
    }
    scanf("%d", &A);
    scanf("%d", &B);
    if(N == 2){
        printf("%d", A + B);
    }

}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <ctime>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define mp(a, b) make_pair(a, b)

using namespace std;

typedef long long LL;
typedef double D;
const int N = 500010;
struct W{ D t; LL v;} q[N];
D t[N];
LL v[N];
int main()
{
	int n, l;
	scanf("%d%d", &n, &l);
	Rep(i, n) scanf("%lf%lld", &t[i], &v[i]);
	
	int he = 1, ta = 0;
	LL sv = 0; D st = 0;
	Rep(i, n) {
		q[++ ta].t = t[i], q[ta].v = v[i];
		st = (st * sv + t[i] * v[i]) / (sv + v[i]), sv += v[i];
		while (he <= ta && sv - q[he].v >= l) {
			st = (st * sv - q[he].t * q[he].v) / (sv - q[he].v);
			sv -= q[he].v, he ++;
		}
		if (sv > l) st = (st * sv - q[he].t * (sv - l)) / l, q[he].v -= sv - l, sv = l;
		printf("%.7lf\n", st);
		
		while (he <= ta - 1 && q[ta - 1].t > q[ta].t) {
			q[ta - 1].t = (q[ta - 1].t * q[ta - 1].v + q[ta].t * q[ta].v) / (q[ta - 1].v + q[ta].v);
			q[ta - 1].v += q[ta].v, ta --;
		}
	}
	
	return 0;
}


Measured memory_bytes: 24576
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
	int c=0;
		int n,d;
		cin>>n>>d;
		for(int i=0;i<n;i++)
		{
			double x,y,p;
			cin>>x>>y;
			p=pow(x,2)+pow(y,2);
			p=pow(p,0.5);
			if(p<=d)
			c++;
		}
		cout<<c;
		
	}
}

Measured memory_bytes: 4392
#include<stdio.h>

int main(){
	int a, b;
	
	scanf("%d %d", &a, &b);
	
	if(a > b){
		printf("a > b\n");
	}else if(a < b){
		printf("a < b\n");
	}else{
		printf("a == b\n");
	}
	
	return 0;
}


Measured memory_bytes: 2124
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
	int m = Integer.parseInt(sc.next());
	int l = Integer.parseInt(sc.next());
	int r = Integer.parseInt(sc.next());
	for(int i = 1; i<m; i++) {
	    int tmpL = Integer.parseInt(sc.next());
	    int tmpR = Integer.parseInt(sc.next());
	    if(l<tmpL) l=tmpL;
	    if(tmpR<r) r= tmpR;
	}
	System.out.println(Math.max(r-l+1,0));

    }
}

Measured memory_bytes: 49288