akhauriyash/Code-Regression huggingface dataset:
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut a = vec![0i32; n + 2];
    for i in 1..n + 1 {
        a[i] = itr.next().unwrap().parse().unwrap();
    }

    let mut s = vec![0i32; n + 1];
    let mut t = vec![0i32; n + 1];
    for i in 0..n + 1 {
        s[i] = (a[i + 1] - a[i]).abs();
    }
    for i in 0..n {
        t[i] = (a[i + 2] - a[i]).abs();
    }
    let sum = s.iter().sum::<i32>();
    let mut out = Vec::new();
    for i in 0..n {
        writeln!(out, "{}", sum - s[i] - s[i + 1] + t[i]).ok();
    }
    stdout().write_all(&out).unwrap();
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x(x % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

int main() {
    int p;
    cin >> p;
    mod = p;
    vector<int> a(p);
    rep(i, p) cin >> a[i];
    vector<mint> b(p);

    combination c(p - 1);
    rep(i, p) {
        if (a[i]) {
            // add (1 - (x-i)^(p-1))
            b[0] += 1;
            mint pw = 1;
            for (int j = p - 1; j >= 0; j--) {
                b[j] -= pw * c(p - 1, j);
                pw *= -i;
            }
        }
    }

    rep(i, p) cout << b[i].x % mod << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
#include <utility>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp make_pair

int n, m, vis[128];
vector<pair<int, int> > g[128];

int main() {
    for (;;) {
        scanf("%d", &n);
        if (n == 0) return 0;
        rep (i, n) g[i].clear();
        scanf("%d", &m);
        rep (i, m) {
            int a, b, c;
            scanf("%d,%d,%d", &a, &b, &c);
            g[a].push_back(mp(-(c/100-1), b));
            g[b].push_back(mp(-(c/100-1), a));
        }
        memset(vis, 0, sizeof(vis));
        priority_queue<pair<int, int> > q;
        q.push(mp(0, 0));
        int ans = 0;
        while (!q.empty()) {
            const pair<int, int> vv(q.top());
            q.pop();
            const int x = vv.second;
            if (vis[x]) continue;
            vis[x] = 1;
            ans += -vv.first;
            rep (i, g[x].size()) q.push(g[x][i]);
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void){

  int x,y;

  while(1){
    scanf("%d%d",&x,&y);
    if(x==0&&y==0)
      break;
    if(x<y){
    printf("%d %d\n",x,y);
    }else{
      printf("%d %d\n",y,x);
    }
  }


  return 0;
}

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

const int N = 5005;
int a[N];
bitset<N> pref[N], suf[N];
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k; cin >> n >> k;
	long long sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	if (sum < k) return cout << n << '\n', 0;
	pref[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		pref[i] = pref[i - 1];
		if (a[i] <= k) {
			 pref[i]|= pref[i - 1] << a[i];
		}
	}
	suf[n + 1][0] = 1;
	for (int i = n; i >= 1; i--) {
		suf[i] = suf[i + 1];
		if (a[i] <= k) {
			suf[i] |= suf[i + 1] << a[i];
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		auto cur = pref[i - 1];
		for (int j = i + 1; j <= n; j++) {
			cur |= cur << a[j];
		}
		bool ok = false;
		for (int j = max(0, k - a[i]); j < k; j++) {
			ok |= cur[j];
		}
		ans += ok;
	}
	cout << n - ans << '\n';
    return 0;
}

Measured memory_bytes: 9860
Module Module1
    Sub main()
        Dim user2 As List(Of String) = New List(Of String)(Split(Console.ReadLine(), " "))

        Dim total(2) As Long

        For i = 1 To CLng(user2(0)) - 1
            total(0) += i
        Next
        For i = 1 To CLng(user2(1)) - 1
            total(1) += i
        Next

        Console.WriteLine(total.Sum)
        
    End Sub
end module

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

int main(){
  string s,t="AKIHABARA"; cin>>s;
  int n=s.size(), i=0, j=0;
  
  while(i<9){
    if(j<n && t[i]==s[j]){++i; ++j;}
    else if(t[i]=='A')++i;
    else break;
  }

  if(i==9 && j==n)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//end

int n; ll x[101000],y[101000];

bool que(ll n,ll r){
   if(n<0||r<0||n<r)return 0;
   rep(k,0,63)if(((n>>k&1)==0)&&(r>>k&1))return 0;
   return 1;
}
bool col(ll a,ll b){
   bool res=0;
   rep(i,0,n)res^=que(a-x[i]+b-y[i],a-x[i]);
   return res;
}

int main(){
   scanf("%d",&n);
   rep(i,0,n)scanf("%lld%lld",&x[i],&y[i]);
   ll c=INF,res=0;
   rrep(k,62,-1){
      ll nxt=res+(1LL<<k);
      if(col(c-nxt,nxt))res=nxt;
   } printf("%lld\n",c-res);
   return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////
struct UnionFind {
	vector<int>par;
	vector<int>rank;

	UnionFind(int N) :par(N),rank(N) {
		for (int i = 0; i < N; ++i) {
			par[i] = i;
			rank[i] = 0;
		}
	}

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

	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)return;//各木について木の高さ(rank)を記憶しておく
		if (rank[x] < rank[y]) {
			//併合の際に二つの木のrankが異なればrankの小さいものから大きいものへ辺を張る
			par[rx] = ry;
		}
		else {
			par[ry] = rx;
			if (rank[rx] == rank[ry])rank[rx]++;
		}
	}

	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
int main() {
	int n, q; cin >> n >> q;
	UnionFind tree(n+1);
	REP(i, q) {
		int c,x,y; cin >> c;
		if (c == 0) {
			cin >> x >> y;
			tree.unite(x, y);
		}
		else {
			cin >> x >> y;
			if (tree.same(x, y))cout << 1 << endl;
			else cout << 0 << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3160
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

def resolve():
    s,=pin()
    a=set()
    for i in range(10**7):
        if s in a:
            print(i+1)
            break
        else:a.add(s)
        
        if s%2:s=s*3+1
        else:s//=2
        
        

#%%submit!    
resolve()


Measured memory_bytes: 38256
#include <stdio.h>

int main(void)
{
    double a, b;

    while (scanf("%lf %lf", &a, &b) != EOF){
        if (a < 35.5 && b < 71){
            printf("AAA\n");
        }
        else if (a < 37.5 && b < 77){
            printf("AA\n");
        }
        else if (a < 40 && b < 83){
            printf("A\n");
        }
        else if (a < 43 && b < 89){
            printf("B\n");
        }
        else if (a < 50 && b < 105){
            printf("C\n");
        }
        else if (a < 55 && b < 116){
            printf("D\n");
        }
        else if (a < 70 && b < 148){
            printf("E\n");
        }
        else {
            printf("NA\n");
        }
    }

    return (0);
}

Measured memory_bytes: 608
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String[] nk = sc.nextLine().split(" ");

		int N = Integer.parseInt(nk[0]);
		int K = Integer.parseInt(nk[1]);

		List<Integer> h = new ArrayList<>();
		for(int i=0;i<N;i++) {
			h.add(sc.nextInt());
		}

		Collections.sort(h);
		int min = Integer.MAX_VALUE;

		for(int i=0;i<=(N-K);i++) {
			if(min > (h.get(i+K-1) - h.get(i))) {
				min = (h.get(i+K-1) - h.get(i));
			}
		}

		System.out.println(min);
	}
}


Measured memory_bytes: 60948
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,N; cin>>H>>N;
  vector<int> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  int sum=0;
  
  for (int i=0; i<N; i++){
    sum += A[i];
  }
  
  if (sum >= H) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 640
#include <stdio.h>

typedef unsigned char uchar;

#define HASHSIZ 543217
typedef struct { unsigned s; char x, v; } HASH;
HASH hash[HASHSIZ+3], *hashend = hash+HASHSIZ;

int lookup(unsigned s, int x)
{
	long long t = ((long long)x << 32) + s;
	HASH *hp = hash + (int)(t % HASHSIZ);
	while (hp->s) {
		if (hp->s == s && hp->x == x) return hp->v;
		if (++hp == hashend) hp = hash;
	}
	return 0;
}

void insert(unsigned s, int x, char v)
{
	long long t = ((long long)x << 32) + s;
	HASH *hp = hash + (int)(t % HASHSIZ);
	while (hp->s) {
		if (hp->s == s && hp->x == x) { hp->v = v; break; }
		if (++hp == hashend) hp = hash;
	}
	hp->s = s, hp->x = x, hp->v = v;
}

#define QMAX 50000
typedef struct { unsigned s; char x, v; } T;
T s[QMAX+3]; int top, end;
int hi[9] = {2,3,2,3,4,3,2,3,2};
int to[9][4] = {{1,3},{0,2,4},{1,5},{0,4,6},{1,3,5,7},{2,4,8},{3,7},{4,6,8},{5,7}};

void toArray(char *nine, unsigned s, int x)
{
	int i;
	
	for (i = 8; i >= 0; i--) {
		if (i == x) nine[i] = 0;
		else nine[i] = s & 0xf, s >>= 4;
	}
}

unsigned swap(char *nine, int zero, int nx)
{
	int i;
	unsigned res;
	
	res = 0;
	for (i = 0; i < 9; i++) {
		if      (i == zero) res <<= 4, res |= nine[nx];
		else if (i != nx)   res <<= 4, res |= nine[i];
	}
	return res;
}

#define MAGIC 20

int main()
{
	int i, x, nx, v, nv, t;
	unsigned a, na;
	unsigned gs; int gx;	// goal
	char nine[9];
	
	gs = 0; for (i = 0; i < 9; i++) {
		scanf("%d", &t);
		if (t == 0) gx = i;
		else gs <<= 4, gs |= t;
	}
	s[0].s = 0x12345678, s[0].x = 8;
	s[1].x = -1;
	top = 0, end = 2;
	insert(s[0].s, s[0].x, 0);
	v = 0;
	while (top != end) {
		a = s[top].s, x = s[top].x;
		if (++top == QMAX) top = 0; 
		if (x < 0) {
			if (v == MAGIC) break;
			v++;
			s[end].x = -1; if (++end == QMAX) end = 0;
			continue;
		}
		if (x == gx && a == gs) goto done;
		if (lookup(a, x) < v) continue;

		toArray(nine, a, x);
		for (i = 0; i < hi[x]; i++) {
			nx = to[x][i];
			na = swap(nine, x, nx), nv = v+1;
			t = lookup(na, nx);
			if (!t || nv < t) {
				s[end].s = na, s[end].x = nx;
				if (++end == QMAX) end = 0;
				insert(na, nx, nv);
			}
		}
	}

	s[0].s = gs, s[0].x = gx, s[1].x = -1;
	top = 0, end = 2;
	v = 0;
	while (top != end) {
		a = s[top].s, x = s[top].x;
		if (++top == QMAX) top = 0; 
		if (x < 0) {
			v++;
			s[end].x = -1; if (++end == QMAX) end = 0;
			continue;
		}
		if ((t = lookup(a, x)) > 0) { v += t; break; }

		toArray(nine, a, x);
		for (i = 0; i < hi[x]; i++) {
			nx = to[x][i];
			na = swap(nine, x, nx), nv = v+1;
			t = lookup(na, nx);
			if (!t || nv < t) {
				s[end].s = na, s[end].x = nx;
				if (++end == QMAX) end = 0;
			}
		}
	}
done:
	printf("%d\n", v);
	return 0;
}



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

int main(){
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> sum(n+1, 0);
  rep(i, n){
    int add = 0;
    if(i > 0 && s.at(i) == 'C' && s.at(i-1) == 'A') add++;
    sum.at(i+1) = sum.at(i) + add;
  }
  rep(_q, q){
    int l, r;
    cin >> l >> r;
    cout << sum.at(r) - sum.at(l) << endl;
  }
  return 0;
}

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REP_REV(i,a,b) for (int i = a; i >= b; i--)
#define what_is(x) cerr << #x << " is " << x << endl;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<ll> vl;
typedef pair<ll, ll> pl;

void solve() {
	string n;
	cin >> n;
	int sum = 0;
	REP(i, 0, n.size() - 1) {
		int num = n[i] - '0';
		sum += num;
	}
	if (sum % 9 == 0) cout << "Yes";
	else cout << "No";
	/*
	int n;
	cin >> n;
	int highest = 7;
	int noHighest = 3;
	int bessie = 7, elsie = 7, mildred = 7;
	int ans = 0;
	bool bessieOn = true, elsieOn = true, mildredOn = true;
	vector<tuple<int, string, int>> records;
	REP(i, 0, n - 1) {
		int day, change;
		string name;
		cin >> day >> name >> change;
		tuple<int, string, int> record = tie(day, name, change);
		records.push_back(record);
	}
	sort(records.begin(), records.end());
	REP(i, 0, n - 1) {
		int currNoHighest = 0;
		int high = highest;
		if (get<1>(records[i]) == "Bessie") bessie += get<2>(records[i]);
		if (get<1>(records[i]) == "Mildred") mildred += get<2>(records[i]);
		if (get<1>(records[i]) == "Elsie") elsie += get<2>(records[i]);
		highest = max(bessie, max(elsie, mildred));

		bool bessieOnNext = bessie == highest;
		bool elsieOnNext = elsie == highest;
		bool mildredOnNext = mildred == highest;
		if (bessieOn != bessieOnNext || elsieOn != elsieOnNext || mildredOn != mildredOnNext) {
			ans++;
		}
		bessieOn = bessieOnNext;
		elsieOn = elsieOnNext;
		mildredOn = mildredOnNext;
	}

	cout << ans;*/
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	//freopen("measurement.in", "r", stdin);
	//freopen("measurement.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//ll t;
	//cin >> t;
	//while (t--) {
	solve();
	//}
	return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file

Measured memory_bytes: 3332
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
ll s[100005];
ll t[100005];

int main() {
  ios::sync_with_stdio(false);
  int A, B, Q;
  cin >> A >> B >> Q;
  for (int i=0; i<A; i++) {
    cin >> s[i];
  }
  for (int i=0; i<B; i++) {
    cin >> t[i];
  }
  for (int i=0; i<Q; i++) {
    ll x;
    cin >> x;
    ll *p = lower_bound(s, s+A, x);
    ll *q = lower_bound(t, t+B, x);
    ll p0 = (p == s+A) ? s[A-1] : *p;
    ll q0 = (q == t+B) ? t[B-1] : *q;
    ll p1 = (p == s) ? s[0] : p[-1];
    ll q1 = (q == t) ? t[0] : q[-1];
    ll ret = min({
        abs(x-p0) + abs(p0-q0),
        abs(x-p0) + abs(p0-q1),
        abs(x-p1) + abs(p1-q0),
        abs(x-p1) + abs(p1-q1),
        abs(x-q0) + abs(q0-p0),
        abs(x-q0) + abs(q0-p1),
        abs(x-q1) + abs(q1-p0),
        abs(x-q1) + abs(q1-p1)});
    cout << ret << endl;
  }
}

Measured memory_bytes: 2944
dnum = gets.to_i
output = []
for i in 0..dnum-1
    n,k = gets.split(" ").map(&:to_i)
    x = []
    x << gets.split(" ").map(&:to_i)
    xd = []
    for i in 0..n-2
        xd << x[0][i+1] - x[0][i]
    end
    xd.sort!
    sum = 0
    if k > n
        k = n
    end
    for i in 0..xd.length-k
        sum += xd[i]
    end
    output << sum
end
for i in 0..output.length-1
    print("#{output[i]}\n")
end

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


int main() {
	string s, t;
	cin >> s >> t;
	vector<int> rs(26, -1);
	vector<int> rt(26, -1);
	for (int i = 0; i < s.size(); i++)
	{
		int a = s[i] - 'a';
		int b = t[i] - 'a';

		if (rs[a] != -1 || rt[b] != -1) {
			if (rs[a] != b || rt[b] != a) {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			rs[a] = b;
			rt[b] = a;
		}
	}

	cout << "Yes" << endl;
}


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;

    double an1=6*m;

    double an2=.5*(60*h+m);
//    cout<<an1<<" "<<an2<<endl;
    double an=abs(an1-an2);
    if(360-an<an)
        an=360-an;
//            cout<<an<<endl;
    an=(an*PI)/180;
    double d=a*a+b*b-2*a*b*cos(an);
    d=sqrt(d);
    cout<<prec(10)<<d;

}


Measured memory_bytes: 4120
alp = list("abcdefghijklmnopqrstuvwxyz")
text = str()

while True:
    
    try:

        num = str(input().lower())
        
    except EOFError:
        break
    
    text += num

text = list(text)
for i in alp:
    x = text.count(i)
    print(f"{i} : {x}")


Measured memory_bytes: 5572
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using lint = long long;
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
int sup=1000005;
signed main(){
  int n;cin>>n;
  vector<int> a(sup,0);
  vector<int> memo(a);
  rep(i,n){
      int x;cin>>x;
      a[x]+=1;
  }
  rep1(i,sup-1){
      if(a[i]>=1){
          int cur=1;
          while(i*cur<sup){
              memo[i*cur]+=2;
              ++cur;
          }
      }
  }
  int res=0;
  rep(i,sup){
      if(a[i]==1&&memo[i]==2){
          ++res;
      }
  }
  cout<<res<<"\n";
  return 0;
}

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

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

  int p=0,w=0,g=0,y=0;

  for(int count = 1;count <= n;count++){
  	  string s;
  	  cin >> s;
  	  
  	  if(s == "P"){
  	  	  p = 1;
  	  }else if(s == "W"){
  	  	  w = 1;
  	  }else if(s == "Y"){
  	  	  y = 1;
  	  }else if(s == "G"){
  	  	  g = 1;
  	  }
  }
  
  if(p + w + g + y == 4){
  	  cout << "Four" << endl;
  }else if(p + w + g + y == 3){
  	  cout << "Three" << endl;
  }

}



Measured memory_bytes: 256
N = int(input())
tmp = []
for i in range(N+1):
    if i%2 != 0:
        tmp.append(i)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
ans = []
for j in range(len(tmp)):
    ans.append(make_divisors(tmp[j]))
count = 0
for k in range(len(ans)):
    if len(ans[k]) == 8:
        count += 1
print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a,b,ab,x,y;
    cin >> a >> b >> ab >> x >> y;
    int answer = INT32_MAX;
    int tmp = 0;
    for(int i=0;i < 200001;i+=2){
        tmp = 0;
        tmp += i*ab;
        tmp += max(0,x-i/2)*a;
        tmp += max(0,y-i/2)*b;
        answer = min(answer,tmp);
    }
    
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

char s[10];

int main()
{
	scanf("%s",s);
	int n=strlen(s);
	for(int i=0;i<n-1;++i)
	{
		if(s[i]=='A'&&s[i+1]=='C') 
		{
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

// dp[i][j][s]: i番目でjより大きい数を選べ，和がsのとき，最終的にsにできる個数
int dp[10][21][156];

int N, K, S;
int rec(int index, int x, int s){
    if(index == K){return s == S;}
    if(dp[index][x][s] != -1){return dp[index][x][s];}

    int res = 0;
    FOR(i, x+1, N+1){
        if(s + i <= S){
            res += rec(index+1, i, s+i);
        }
    }

    return dp[index][x][s] = res;
}

int main(){
    while(std::cin >> N >> K >> S, N || K || S){
        std::fill(dp[0][0], dp[0][0]+10*21*156, -1);
        std::cout << rec(0, 0, 0) << std::endl;
    }
}

Measured memory_bytes: 1284
N, M, K = map(int, input().split())


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


uf = UnionFind(N)

edge1 = []
edge2 = []

for _ in range(M):
    a, b = map(int, input().split())
    edge1.append((a - 1, b - 1))

for _ in range(K):
    a, b = map(int, input().split())
    edge2.append((a - 1, b - 1))

for a, b in edge1:
    uf.union(a, b)

res = [uf.size(i) - 1 for i in range(0, N)]

for a, b in edge1:
    res[a] -= 1
    res[b] -= 1

for a, b in edge2:
    if uf.same(a, b):
        res[a] -= 1
        res[b] -= 1

print(' '.join(map(str, res)))


Measured memory_bytes: 41788
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int n,x,y,b,p,i,c,d,e,z;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x>>y>>b>>p;
		if(b>=5 && p>=2){
			z=x*b+y*p;
			z=z*8/10;
		}
		else{
			c=b;
			d=p;
			if(b<5) c=5;
			if(p<2) d=2;
			z=x*b+y*p;
			e=x*c+y*d;
			e=e*8/10;
			if(e<z){
			 z=e;
			}
		}
		cout<<z<<endl;
	}
	
	return 0;
}




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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    set<int> s;
    for(int i=0; i<N; i++){
        cin >> d[i];
        s.insert(d[i]);
    }
    cout << s.size() << endl;
}

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

int main() {
  int n;
  int vec[MAX_ARRAY_SIZE];

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  for (int i = 0; i < n; i++) {
    cout << vec[n - i - 1];
    if (i != n - 1)
      cout << " ";
    else
      cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3080
import java.io.BufferedReader
import kotlin.math.max

fun main() {
    val br = System.`in`.bufferedReader()
    val n = br.readInt()
    val s = br.readLine()
    var redCt = 0
    var whiteCt = 0
    for (c in s) {
        if (c == 'R') {
            redCt++
        }
    }
    var best = redCt
    for (x in 0 until n) {
        if (s[x] == 'W') {
            whiteCt++
        } else {
            redCt--
        }
        best = best.coerceAtMost(max(redCt, whiteCt))
    }

    print(best)
}

private const val SPACE_INT = ' '.toInt()
private const val ZERO_INT = '0'.toInt()
private const val NL_INT = '\n'.toInt()

private fun BufferedReader.readInt(): Int {
    var ret = read()
    while (ret <= SPACE_INT) {
        ret = read()
    }
    val neg = ret == '-'.toInt()
    if (neg) {
        ret = read()
    }
    ret -= ZERO_INT
    var read = read()
    while (read >= ZERO_INT) {
        ret *= 10
        ret += read - ZERO_INT
        read = read()
    }

    while (read <= SPACE_INT && read != -1 && read != NL_INT) {
        mark(1)
        read = read()
    }
    if (read > SPACE_INT) {
        reset()
    }
    return if (neg) -ret else ret
}

Measured memory_bytes: 37972
while True:
    n = int(input())
    if n >= 1:
        x = 1000 - n
        a = x%500
        b = a%100
        c = b%50
        d = c%10
        e = d%5
        y = x//500 + a//100 + b//50 + c//10 + d//5 +e//1
        print(y)
    if n == 0:
        break



Measured memory_bytes: 5592
module Main where

  import           Control.Monad
  import           Data.List
  import           Data.Ord
  import           Data.List.Split
  import           Data.Array.IO
  import qualified Data.Vector.Unboxed as V
  
  main :: IO ()
  main = do
    as <- sort <$> replicateM 5 readLn :: IO [Int]
    d <- readLn :: IO Int
    if f as (head as) d then putStrLn "Yay!" else putStrLn ":("
  
  f [a] m d = a - m <= d
  f (a:b:cs) m d = a - m <= d && f (b:cs) m d
  

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

int main(){
	int64_t n; cin >> n;
  	int64_t p=n;
  	int mod=2;
  	vector<int> A(int(sqrt(n)+2),0);
    int m=0;
  	int ans =0;
  	int counter=1;
  	for(int i=2;i< int(sqrt(n)+2);i++ ){
    	while(p%i==0){
        	A[i]++;
          	if(A[i] == counter){
            	A[i]-=counter;
              	counter++;
              	ans++;
            }
          	p/=i;
        }
      	counter = 1;
      	
    }
  	if(p!=1){
    	ans++;
    }
  	cout << ans << endl;
}



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

template<class T>
using least_queue = priority_queue<T, vector<T>, greater<T>>;

ULL gcd(ULL a, ULL b) { return b ? gcd(b, a % b) : a; }

int main() {
	UL N; cin >> N;
	UL PB[5002] = {}; rep(i, N) cin >> PB[i + 1];
	N += 2;
	UL ans2 = 500000;
	rep(s, 3 + 1)rep(t, 3 + 1) {
		UL P[5002];
		rep(i, N) P[i] = PB[i];
		P[0] = s; P[N - 1] = t;
		UL ans = 0;
		for (UL i = 1; i < N; i += 2) {
			UL t = min(P[i - 1], P[i]);
			P[i - 1] -= t; P[i] -= t;
			ans += t + t;
			if (i != N - 1) {
				P[i + 1] = max(P[i + 1], P[i]) - P[i];
				ans += P[i] + P[i];
				P[i] = 0;
			}
			else { ans += P[i]; P[i] = 0; }
		}
		ans += P[0];
		for (UL i = 2; i < N; i += 2) {
			if (i == N - 1) ans += P[i];
			else ans += P[i] + P[i];
		}
		ans -= (s + t);
		ans2 = min(ans, ans2);
	}
	cout << ans2 << endl;
	return 0;
}



Measured memory_bytes: 3124
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List
import Data.Maybe
import Data.Ord
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM

readInt = fst . fromJust . BS.readInt

readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

main = do
  [n, m, c] <- getIntList
  bs <- getIntList
  as <- replicateM n getIntList
  print $ length $ filter (> 0) $ map ((+) c . sum . zipWith (*) bs) as


Measured memory_bytes: 3884
#include <iostream>
#include <vector>

int main(int argc, char *argv[]) {
  int h, n;
  std::cin >> h >> n;
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    std::cin >> a;
    sum += a;
  }

  std::cout << (h <= sum ? "Yes" : "No") << std::endl;
}


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

int main() {
    ll n;
    string s;
    
    std::cin >> n;
    std::cin >> s;
    
    if(n%2==1){
        std::cout << "No" << std::endl;
    
        return 0;
    }
    for (int i = 0; i < n/2; i++) {
        if(s[i] != s[i+n/2]){
            std::cout << "No" << std::endl;
        
            return 0;
        }
    }
    std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    X, K, D = map(int, input().split())
    X = abs(X)

    answer = int()
    if X > 0:
        if X >= D*K:
            answer = X-D*K
        else:
            if (X//D)%2 == K%2:
                answer = X%D
            else:
                answer = D-X%D
    elif X == 0:
        if D%2 == 0:
            answer = 0
        else:
            answer = D
    print(answer)

if __name__ == "__main__":
    main()



Measured memory_bytes: 9232
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

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

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; }

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

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

    int n, l;
    int a[100005];

    cin >> n >> l;
    rep(i, n) cin >> a[i];

    rep(i, n - 1) {
        if (a[i] + a[i + 1] >= l) {
            cout << "Possible" << endl;
            rep(j, i) {
                cout << j + 1 << endl;
            }
            for (int j = n - 2; j >= i; j--) {
                cout << j + 1 << endl;
            }
            return 0;
        }
    }
    cout << "Impossible" << endl;

    return 0;
}


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

#define YES(condition) if(condition) cout << "YES" << endl; else cout << "NO" << endl
#define Yes(condition) if(condition) cout << "Yes" << endl; else cout << "No" << endl
#define POSS(condition) if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl
#define Poss(condition) if(condition)cout << "Possible" << endl; else cout << "Impossible" << endl
#define First(condition) if(condition)cout << "First" << endl; else cout << "Second" << endl
#define negative(condition, num) if(condition)cout << -1 << endl; else cout << num << endl
long power(long base, long exponent, long mod){ if(exponent % 2){ return power(base, exponent - 1, mod) * base % mod; }else if(exponent){ long root_ans = power(base, exponent / 2, mod); return root_ans * root_ans % mod; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
int main(){
    int H, W, K;
    cin >> H >> W >> K;
    string space[H + 2];
    space[0].resize(W + 2, '#');
    space[H + 1].resize(W + 2, '#');
    position start = {0, 0};
    for(int i = 1; i <= H; i++){
        cin >> space[i];
        space[i] = "#" + space[i] + "#";
        for(int j = 1; j <= W; j++){
            if(space[i][j] == 'S'){
                start = {i, j};
            }
        }
    }
    queue<pair<int, position>> pathes;
    pathes.push({0, start});
    while(!pathes.empty()){
        for(int i = 0; i < 4; i++){
            if(space[pathes.front().second.y + move_pattern[i].y][pathes.front().second.x + move_pattern[i].x] == '.' && pathes.front().first < K){
                space[pathes.front().second.y + move_pattern[i].y][pathes.front().second.x + move_pattern[i].x] = 'S';
                pathes.push({pathes.front().first + 1, {pathes.front().second.y + move_pattern[i].y, pathes.front().second.x + move_pattern[i].x}});
            }
        }
        pathes.pop();
    }
    int ans = 1e9;
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            if(space[i][j] == 'S'){
                ans = min(ans, min({i - 1, j - 1, H - i, W - j}));
            }
        }
    }
    cout << (ans + K - 1) / K + 1 << endl;
}


Measured memory_bytes: 1536
n=int(input())
a=list(map(int,input().split()))

babies=[(a,i) for i,a in enumerate(a)]
babies.sort(reverse=True)

dp=[[0]*(n+1) for i in range(n+1)]#左、右から何人いるか? 家庭菜園
ans=0
for l in range(n):
    for r in range(n):
        if l+r==n:
            ans=max(ans,dp[l][r])
            break
        activeness,ind=babies[r+l]
        dp[l+1][r]=max(dp[r+1][r],dp[l][r]+abs(ind-l)*activeness)
        dp[l][r+1]=max(dp[l][r+1],dp[l][r]+abs(ind-(n-1-r))*activeness)

print(ans)


Measured memory_bytes: 106208
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    string s,t;
    cin>>s>>t;
    int n = s.size();
    int m = t.size();
    int ans = 1e9;
    for(int i=0;i<n;i++){
        int ret = 0;
        if(i + m - 1 >= n)break;
        for(int j=0;j<m;j++){
            if(s[i+j]!=t[j])ret++;
        }
        chmin(ans,ret);
    }
    cout << ans << endl;
    
}   

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = Console.ReadLine();

			int sum = input.Select(c => int.Parse(c.ToString())).Sum();

			long num = long.Parse(input);

			Console.WriteLine(num % sum == 0 ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 11220
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e5 + 7;
int lst[Max];

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (min(b, d) - max(a, c) >= 0) cout << min(b, d) - max(a, c);
	else cout << 0;
}

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

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

  // Aに移す量
   int D = A -B; 
  
  // 容器２の残りの量
  int Ans = C- D;
  if ( Ans < 0 ) {
    Ans = 0;
  }
  
  //結果出力
  cout << Ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    for(int i=0;i<3000;i++){
        cin>>a>>b;
        if(a==0&&b==0){
            return 0;
        }
        if(a>b){
            swap(a,b);
        }
        cout<<a<<" "<<b<<endl;
    }
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T & ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T & ref, const T value) {
    if (ref < value) ref = value;
}

int main() {
    int n;
    cin >> n;
    vector<ll> vs(n);
    rep(i, n) {
        cin >> vs[i];
    }
    multiset<int> colors;
    colors.insert(vs[0]);
    for (int i = 1; i < n; i++) {
        auto item = vs[i];
        auto it = colors.lower_bound(item);
        if (it == colors.begin()) {
            colors.insert(item);
        }
        else {
            it--;
            colors.erase(it);
            colors.insert(item);
        }
    }
    cout << colors.size() << endl;
    return 0;
}



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

#define EPS 1e-7

#define ENSYURITU 3.1415926535897932384626433832795028841

int main(void) {
    int n;
    int i,j,k;
    int count,max;
    int loopmax;
    double x[300],y[300];
    double cx,cy;
    while(scanf("%d",&n)==1 && n!=0) {
        for(i=0;i<n;i++)scanf("%lf%lf",&x[i],&y[i]);
        max=0;
        loopmax=500000/n;
        for(k=0;k<n;k++) {
            for(i=0;i<loopmax;i++) {
                cx=x[k]+cos(2*ENSYURITU*i/loopmax);
                cy=y[k]+sin(2*ENSYURITU*i/loopmax);
                count=0;
                for(j=0;j<n;j++) {
                    if((x[j]-cx)*(x[j]-cx)+(y[j]-cy)*(y[j]-cy)<1+EPS)count++;
                }
                if(count>max)max=count;
                if(max==n)break;
            }
        }
        printf("%d\n",max);
    }
    return 0;
}



Measured memory_bytes: 2120
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,a,b,L,ans;
vector<ll> v;
int main(void){
    cin>>n>>m;
    cin>>L;
    b=L;
    for(int i=1;i<m;i++){
        cin>>a;
        v.push_back(a-b);
        if(i==m-1)v.push_back(L+(n-a));
        b=a;
    }
    sort(v.begin(),v.end());
    for(int i=0;i<m-1;i++){
        //cout<<v[i]<<endl;
        ans+=v[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3444
$S=<STDIN>;chomp $S;

$L=length($S);

if($L % 2==0) {
	$r=$L/2;
	$i=int($L/2);$j=1;
	$c=substr($S,$i,1);
	while ( $r<$L && substr($S, $i-$j,1) eq $c && substr($S,$i+$j-1,1) eq $c ) {
		$j+=1;
		$r+=1;
	}
} else {
	$r=($L+1)/2;
	$i=int($L/2);$j=1;
	$c=substr($S,$i,1);
	while ( $r<$L && substr($S, $i-$j,1) eq $c && substr($S,$i+$j,1) eq $c ) {
		$j+=1;
		$r+=1;
	}
}
print $r;



Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)

int main()
{
  ll n;
  cin >> n;
  vector<ll> num(n);
  for(ll i = 1;i <= n;i++)
  {
    num[i-1] = i;
  }
  ll sum = 0;
  for(int i = 0;i < n;i++)
  {
    if(num[i]%3 != 0 &&num[i]%5 != 0)
    {
      sum += num[i];
    }
  }
  cout << sum << endl;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define Graph vector<vector<int>>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }


void func(long long A, long long B, long long C, long long K){

}

int main(){

    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    
    if(A>=K){
        cout << K << endl;
    }

    else if(A<K&&A+B>=K){
        cout << A << endl;
    }

    else{
        cout << A-(K-A-B) << endl;
    }
    return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <climits> 

long gcd(long a, long b)
{
    if(b<a){
        std::swap(a,b);
    }
    if(b%a==0){
        return a;
    }else{
        return gcd(a,b%a);
    }
}

std::vector<long> result;
long natural(long N)
{
    long testnum=std::sqrt(N);
    if((testnum+1)*(testnum+1)<=N){
        testnum++;
    }
    for(long i=2; i<=testnum; i++){
        if(N%i==0){
            result.push_back(i);
            while(N%i==0){
                N=N/i;
            }
        }
    }
    if(N>testnum){
        result.push_back(testnum);
    }
    result.push_back(1);
    return result.size();
}

int main()
{
    long A,B;
    std::cin >> A >> B;
    std::cout << natural(gcd(A,B));
    return 0;
}

Measured memory_bytes: 256
/* ****Ragnar7 _Lawliet_**** */
/* First, solve the problem.Then write the code. */
#include<bits/stdc++.h>
#define ll          long long
#define ld 			long double
#define hell        1000000007
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen ("input.txt","r",stdin);
	// freopen ("output.txt","w",stdout);
	#endif
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		ll n;
		cin>>n;
		ll ans = 0;
		ll x,prev=0;
		for(ll i=0;i<n;i++)
		{
			cin>>x;
			if(x<prev)
			{
				ans+=(prev-x);
				continue;
			}
			prev=x;
		}
		cout<<ans;
		
	}

	
	time
	return 0;
}

Measured memory_bytes: 3648